Coder Social home page Coder Social logo

stdtabs / phptabs Goto Github PK

View Code? Open in Web Editor NEW
40.0 4.0 8.0 1.46 MB

A PHP library for reading, writing and rendering guitar tablatures and MIDI files

Home Page: https://phptabs.readthedocs.io/

License: GNU Lesser General Public License v2.1

PHP 100.00%
guitar-tablature guitar-pro midi-parser tablature music chords guitar

phptabs's People

Contributors

landrok avatar motniemtin avatar peter279k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

phptabs's Issues

Class 'PhpTabs\Reader\Midi\TabString' not found

Hi, i get the above error when trying to parse Midi file via
$tab = new PhpTabs(public_path("midi/".$filename));
error is at
stdtabs\phptabs\src\PhpTabs\Reader\Midi\MidiReader.php

  • Create percussion strings
    *

    • @param int $stringCount
    • @return array
      */
      private function createPercussionStrings($stringCount)
      {
      $strings = array();

    for ($i = 1; $i <= $stringCount; $i++) {
    $strings[] = new TabString($i, 0);
    }

    return $strings;
    }

may i know what exactly is TabString? thank you

Tab from scratch

First of all, thank you for your Library! Very nice job, mate!!

I'm working on a proprietary tablature format and I'd like to convert it to phptabs format, in order to export to midi and gp5. I already mapped some of the structures like Channel, Note, Voice, Measure but the save function is still throwing errors. I'm probably missing something. So I'd like to ask if you have a minimal example of a tablature written from scratch. That would be very useful!

Thanks again.

Regards,
Chrystian.

Check Tab parsed successfully

Hi Landrok,
let me wish you a happy new year first! May it be as productive as the last one. :)

Quick question from my side:
I'm updating my website to use the current version 1.0.4 of PhpTabs. In former versions it was possible to check if an gp5-file has been parsed successfully by checking:

$tablature = new PhpTabs("file.gp5");
if ($tablature->hasError()) { ... }

In the current version this method does not exist anymore. Which way is intended to check if a file has been parsed succussfully?

Best regards,
MrChros

Error when convert gp5 to midi

Fatal error: Uncaught TypeError: Argument 1 passed to PhpTabs\Writer\Midi\MidiWriter::__construct() must be an instance of PhpTabs\Model\Song, instance of PhpTabs\Music\Song given, called in /src/PhpTabs/Component/Writer.php on line 60 and defined in /src/PhpTabs/Writer/Midi/MidiWriter.php:37 Stack trace: #0 /src/PhpTabs/Component/Writer.php(60): PhpTabs\Writer\Midi\MidiWriter->__construct(Object(PhpTabs\Music\Song)) #1 /src/PhpTabs/Component/Tablature.php(212): PhpTabs\Component\Writer->build('midi') #2 /src/PhpTabs/PhpTabs.php(138): PhpTabs\Component\Tablature->convert('midi') #3 /index.php(8): PhpTabs\PhpTabs->__call('conver in /src/PhpTabs/Writer/Midi/MidiWriter.php on line 37

New error when convert to midi file, and i can't open your midi when success in some files(on Windows Media)

Fatal error: Uncaught TypeError: Argument 1 passed to PhpTabs\Writer\Midi\MidiSequenceParser::applyStaticDuration() must be an instance of PhpTabs\Music\Tempo, string given, called in /phptabs-master/src/PhpTabs/Writer/Midi/MidiSequenceParser.php on line 598 and defined in /phptabs-master/src/PhpTabs/Writer/Midi/MidiSequenceParser.php:616 Stack trace: #0 /phptabs-master/src/PhpTabs/Writer/Midi/MidiSequenceParser.php(598): PhpTabs\Writer\Midi\MidiSequenceParser->applyStaticDuration('tempo', 60, 480) #1 /phptabs-master/src/PhpTabs/Writer/Midi/MidiSequenceParser.php(562): PhpTabs\Writer\Midi\MidiSequenceParser->applyDurationEffects(Object(PhpTabs\Music\Note), Object(PhpTabs\Music\Tempo), 480) #2 /phptabs-master/src/PhpTabs/Writer/Midi/MidiSequenceParser.php(262): PhpTabs\Writer\Midi\MidiSequenceParser->getRealNoteDuration(Object(PhpTabs\Writer\Midi\Midi in /phptabs-master/src/PhpTabs/Writer/Midi/MidiSequenceParser.php on line 616

phptabs itterating tru partiture

Hi, Looking at the phptabs, lot's of work on this project, and well coded and done.

I am looking at the methods, and I cannot figure it out how do I walk trough a partiture, I am trying to generate guitar tabs, eventually vextab file to be played in vextab player.
Thank you.

can't change instrument tuning

when i try the following, it just changes the strings

$filename = '/GuitDaEMOns/CIID-Heaven&Hell-BibleBlack-Full2exp.mid';

$tab = new PhpTabs($filename);

foreach ($tab->getTracks() as $itrack => $track) {
    if ($track->getStrings()[0]->getValue() !== 0)
    {
        $tuning = [36,41,46,51,55,60,65];
        $count = $track->countStrings();
        $diff = $count - count($tuning) + 1;
        $j = 0;
        for ($i = $count - 1; $i >= 0; $i--)
         {
            $tabString = $track->getStrings()[$j];
            $tabString->setValue($tuning[$i]);
            $j++;
         }
    }
}
file_put_contents($filename.'.gp5', $tab->getTablature()->toGuitarPro5());
echo $tab->getTablature()->toAscii();

the strings change tuning but the notes don't change, the frets stay the same

Reading Midi Files

Hi, I'm trying to update the names for some midi files as when I import them into my DAW, they show a standard name and it's tough to know what is what.

I'm doing this:

<?php

require_once 'vendor/autoload.php';

use PhpTabs\PhpTabs;

$file = $argv[1];
$mid = new PhpTabs($file);
echo $mid->getName() . PHP_EOL;

--

Each time the getName() is blank. If I use a gp* file, it seems to work fine (for example: https://gprotab.net/en/tabs/the-eagles/hotel-california works).

Here's an example of it not working for a Midi file: https://www.midiworld.com/download/3290 (Enter Sandman).

Thanks,
Hans

I have problem to convert measure length to seconds. please help!

  {
    "header": {
      "number": 1,
      "start": 960,
      "length": 3840,
      "timeSignature": {
        "numerator": 4,
        "denominator": {
          "value": 4,
          "dotted": false,
          "doubleDotted": false,
          "divisionType": {
            "enters": 1,
            "times": 1
          }
        }
      },
      "tempo": 120,
      "marker": null,
      "repeatOpen": false,
      "repeatAlternative": 0,
      "repeatClose": 0,
      "tripletFeel": 1
    }
  }

What time spend for this measure ?, how to calculate ?

Render option for single measures only

I have recently tried the render function to ASCII format. It work very well, but I did not see an option to render only a single measure or a range of measures of a single track.

In order to enable such a feature I wrote an external function:

function PhpTabs_Render_Single_Measure(\PhpTabs\PhpTabs $tab_source, $track_number, $measure_number)
{
	// Create new Tablature, Track and copy Track name
	$tablature 	= new PhpTabs();
	$track 		= new Track();
	$track->setName($tab_source->getTrack($track_number)->getName());
	$tablature->addTrack($track);

	// Copy Strings
	$strings = $tab_source->getTrack($track_number)->getStrings();
	for($i=0;$i<count($strings);$i++) {
		$s = new TabString();
		$s->copyFrom($strings[$i]);
		$track->addString($s);
	}

	// Copy Measure Header according to $measure_number
	$mh = new MeasureHeader();
	$mh->copyFrom($tab_source->getMeasureHeader($measure_number));
	$mh->setNumber(1);
	$tablature->addMeasureHeader($mh);

	// Copy Measure according to $measure_number
	$m = new Measure($mh);
	$m->copyFrom($tab_source->getTrack($track_number)->getMeasure($measure_number));
	$track->addMeasure($m);

	
	$render_output = $tablature->getRenderer('ascii')->render(0);
	while($render_output[0] == chr(13) || $render_output[0] == chr(10))
	{
		$render_output = ltrim($render_output, chr(10));
		$render_output = ltrim($render_output, chr(13));
	}

	$output = "Measure " . ($measure_number + 1);
	$output.= " (" . $mh->getTimeSignature()->getNumerator() . "/" . $mh->getTimeSignature()->getDenominator()->getValue() . "):";
	$output.= "\n";
	$output.= $render_output;

	return $output;
}

I"m sure there is a better/easier way to do that. But for the time being, this function works and could easily be extended to render a range of measures.

For future version, I suggest to add this feature to the renderer. :)

Best,

MrChros

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.