-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGuitarPro5Track.php
More file actions
67 lines (54 loc) · 1.87 KB
/
Copy pathGuitarPro5Track.php
File metadata and controls
67 lines (54 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare(strict_types=1);
/*
* This file is part of the PhpTabs package.
*
* Copyright (c) landrok at github.com/landrok
*
* For the full copyright and license information, please see
* <https://github.com/stdtabs/phptabs/blob/master/LICENSE>.
*/
namespace PhpTabs\Reader\GuitarPro\Helper;
use PhpTabs\Music\Lyric;
use PhpTabs\Music\Song;
use PhpTabs\Music\TabString;
use PhpTabs\Music\Track;
final class GuitarPro5Track extends AbstractReader
{
/**
* Read track informations
*
* @param array<\PhpTabs\Music\Channel> $channels
*/
public function readTrack(Song $song, array $channels, Lyric $lyrics): Track
{
$this->reader->readUnsignedByte();
if ($song->countTracks() === 0 || $this->reader->getVersionIndex() === 0) {
$this->reader->skip();
}
$track = new Track();
$track->setLyrics($lyrics);
$track->setName($this->reader->readStringByte(40));
$stringCount = $this->reader->readInt();
for ($i = 0; $i < 7; $i++) {
$tuning = $this->reader->readInt();
if ($stringCount > $i) {
$string = new TabString();
$string->setNumber($i + 1);
$string->setValue($tuning);
$track->addString($string);
}
}
$this->reader->readInt();
$this->reader->factory('GuitarProChannel')->readChannel($song, $track, $channels);
$this->reader->readInt();
$track->setOffset($this->reader->readInt());
$this->reader->factory('GuitarProColor')->readColor($track->getColor());
$this->reader->skip($this->reader->getVersionIndex() > 0 ? 49 : 44);
if ($this->reader->getVersionIndex() > 0) {
$this->reader->readStringByteSizeOfInteger();
$this->reader->readStringByteSizeOfInteger();
}
return $track;
}
}