stdtabs / phptabs Goto Github PK
View Code? Open in Web Editor NEWA 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
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
With small tweaks is getting along pretty well.
http://fretsolo.com/index.php?play3=]/Amon-Amarth/Amon_Amarth-Gods_Of_War_Arise.gp5&track=0
Thx.
This Class is useful, If it can render direct to images is wonderful
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
*
for ($i = 1; $i <= $stringCount; $i++) {
$strings[] = new TabString($i, 0);
}
return $strings;
}
may i know what exactly is TabString? thank you
Related to #7 (comment), some more recent versions of Guitar Pro file formats should be supported.
Hi. I try to use the library to get info about midi files.
How I can get duration of file?
For example, the duration of this file is 5:52
I saw the tutorial https://phptabs.readthedocs.io/en/latest/examples/ex.calculate-measure-and-beat-durations-in-seconds.html but it something strange for me. Because the resulted duration so small, or so big when I tried summarize all beats/voices.
Sorry, I'm not a musician)
I have good idea, I love it. But may be your didn't parse capo fret data from gp file, I hop you add it
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.
Music in 6/8. I tried to plus all notes length but it alway # with 2880 length of measure
Please view full json on: https://jsoneditoronline.org/?id=ad299386fc7b439f888296e64eec3145
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
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
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
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.
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
The KeySignature never seem to get set with mid files.
If always returns key signature: 0
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
{
"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 ?
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.