Class: GuitarProParser::Song
- Inherits:
-
Object
- Object
- GuitarProParser::Song
- Includes:
- GuitarProHelper
- Defined in:
- lib/guitar_pro_parser/song.rb
Overview
This class represents the content of Guitar Pro file. It can be initialized by path to .gp file. Then it will automatically parse its data. Or it can be just instantiated with default values of the attributes.
Constant Summary
Constants included from GuitarProHelper
GuitarProHelper::BEND_TYPES, GuitarProHelper::BEND_VIBRATO_TYPES, GuitarProHelper::CHORD_TONALITIES, GuitarProHelper::CHORD_TYPES, GuitarProHelper::DURATIONS, GuitarProHelper::FINGERS, GuitarProHelper::GRACE_NOTE_DURATIONS, GuitarProHelper::GRACE_NOTE_TRANSITION_TYPES, GuitarProHelper::HARMONIC_TYPES, GuitarProHelper::MAP_SLIDE_TYPES_GP4, GuitarProHelper::MAP_SLIDE_TYPES_GP5, GuitarProHelper::MUSICAL_DIRECTIONS, GuitarProHelper::NINE_ELEVEN_THIRTEEN, GuitarProHelper::NOTES, GuitarProHelper::NOTE_DYNAMICS, GuitarProHelper::NOTE_TYPES, GuitarProHelper::REST_TYPES, GuitarProHelper::SLIDE_TYPES, GuitarProHelper::STRING_EFFECTS, GuitarProHelper::STROKE_DIRECTIONS, GuitarProHelper::STROKE_EFFECT_SPEEDS, GuitarProHelper::TREMOLO_PICKING_SPEEDS, GuitarProHelper::TRILL_PERIODS, GuitarProHelper::TRIPLET_FEEL, GuitarProHelper::VERSIONS, GuitarProHelper::VOICES
Instance Attribute Summary collapse
-
#album ⇒ Object
Song information.
-
#artist ⇒ Object
Song information.
-
#bars_settings ⇒ Object
Array of settings of bars.
-
#bpm ⇒ Object
Tempo as beats per minute.
-
#channels ⇒ Object
Table of midi channels.
-
#composer ⇒ Object
Song information.
-
#copyright ⇒ Object
Song information.
-
#equalizer ⇒ Object
Array of equalizer settings.
-
#instructions ⇒ Object
Song information.
-
#key ⇒ Object
Key (signature) at the beginning of the piece.
-
#lyricist ⇒ Object
Song information.
-
#lyrics ⇒ Object
Lyrics represented as array of hashes with 5 elements (for lyrics lines from 1 to 5).
-
#lyrics_track ⇒ Object
Associated track for the lyrics (>= 4.0 only).
-
#master_reverb ⇒ Object
Selected master reverb setting (in Score information, value from 0 to 60) (>= 5.0 only) TODO: Represent as names.
-
#master_volume ⇒ Object
Master volume (value from 0 - 200, default is 100) (>= 5.0 only).
-
#musical_directions ⇒ Object
(Hash) Musical directions definitions.
-
#notices ⇒ Object
Array of notices.
-
#octave ⇒ Object
Octave.
-
#page_setup ⇒ Object
(PageSetup) Data about page setup such as paddings, width, height, etc.
-
#subtitle ⇒ Object
Song information.
-
#tempo ⇒ Object
(String) Tempo text.
-
#title ⇒ Object
Song information.
-
#tracks ⇒ Object
Array of tracks.
-
#transcriber ⇒ Object
Song information.
-
#triplet_feel ⇒ Object
(Boolean) Shuffle rhythm feel.
-
#version ⇒ Object
Guitar Pro version.
Instance Method Summary collapse
- #add_bar_settings ⇒ Object
- #add_track ⇒ Object
-
#initialize(file_path = nil, headers_only = false) ⇒ Song
constructor
Initializes new Song instance.
Methods included from GuitarProHelper
Constructor Details
#initialize(file_path = nil, headers_only = false) ⇒ Song
Initializes new Song instance. Parameters: (String) file_path
Path to file to read. If is not specified default song instance will be created. (Boolean) headers_only
Read only headers information from file if true (much faster than reading every note)
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/guitar_pro_parser/song.rb', line 106 def initialize(file_path = nil, headers_only = false) @version = 5.1 @title = '' @title = '' @subtitle = '' @artist = '' @album = '' @lyricist = '' @composer = '' @copyright = '' @transcriber = '' @instructions = '' @notices = '' @triplet_feel = :no_triplet_feel @lyrics_track = 0 @lyrics = [] @master_volume = 100 @equalizer = Array.new(11, 0) @page_setup = PageSetup.new @tempo = 'Moderate' @bpm = 120 @key = 1 @octave = 0 @channels = [] @musical_directions = Hash[GuitarProHelper::MUSICAL_DIRECTIONS.collect { |elem| [elem, nil] }] @master_reverb = 0 @bars_settings = [] @tracks = [] # Read data from file if it is specified Reader.new(self, file_path, headers_only) unless file_path.nil? end |
Instance Attribute Details
#album ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def album @album end |
#artist ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def artist @artist end |
#bars_settings ⇒ Object
Array of settings of bars. Doesn’t represent bars as containers for notes (look at Bar class for it)
97 98 99 |
# File 'lib/guitar_pro_parser/song.rb', line 97 def @bars_settings end |
#bpm ⇒ Object
Tempo as beats per minute
63 64 65 |
# File 'lib/guitar_pro_parser/song.rb', line 63 def bpm @bpm end |
#channels ⇒ Object
Table of midi channels. There are 4 ports and 16 channels, the channels are stored in this order: port1/channel1 - port1/channel2 … port1/channel16 - port2/channel1 … in array with the format:
[[1,2,...16], [1,2,...16], [1,2,...16], [1,2,...16]]
84 85 86 |
# File 'lib/guitar_pro_parser/song.rb', line 84 def channels @channels end |
#composer ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def composer @composer end |
#copyright ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def copyright @copyright end |
#equalizer ⇒ Object
Array of equalizer settings. Each one is represented as number of increments of .1dB the volume for
-
32Hz band is lowered
-
60Hz band is lowered
-
125Hz band is lowered
-
250Hz band is lowered
-
500Hz band is lowered
-
1KHz band is lowered
-
2KHz band is lowered
-
4KHz band is lowered
-
8KHz band is lowered
-
16KHz band is lowered
-
overall volume is lowered (gain)
54 55 56 |
# File 'lib/guitar_pro_parser/song.rb', line 54 def equalizer @equalizer end |
#instructions ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def instructions @instructions end |
#key ⇒ Object
Key (signature) at the beginning of the piece. It is encoded as:
-
…
-
-1: F (b)
-
0: C
-
1: G (#)
-
2: D (##)
-
…
TODO: convert digit to something readable
74 75 76 |
# File 'lib/guitar_pro_parser/song.rb', line 74 def key @key end |
#lyricist ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def lyricist @lyricist end |
#lyrics ⇒ Object
Lyrics represented as array of hashes with 5 elements (for lyrics lines from 1 to 5). Each line has lyrics’ text and number of bar where it starts
{text: "Some text", bar: 1}
(>= 4.0 only)
36 37 38 |
# File 'lib/guitar_pro_parser/song.rb', line 36 def lyrics @lyrics end |
#lyrics_track ⇒ Object
Associated track for the lyrics (>= 4.0 only)
29 30 31 |
# File 'lib/guitar_pro_parser/song.rb', line 29 def lyrics_track @lyrics_track end |
#master_reverb ⇒ Object
Selected master reverb setting (in Score information, value from 0 to 60) (>= 5.0 only) TODO: Represent as names
94 95 96 |
# File 'lib/guitar_pro_parser/song.rb', line 94 def master_reverb @master_reverb end |
#master_volume ⇒ Object
Master volume (value from 0 - 200, default is 100) (>= 5.0 only)
39 40 41 |
# File 'lib/guitar_pro_parser/song.rb', line 39 def master_volume @master_volume end |
#musical_directions ⇒ Object
(Hash) Musical directions definitions. Each symbol is represented as the bar number at which it is placed. If the symbol is not presented its value is nil. There is full list of supported symbols in GuitarProHelper::MUSICAL_DIRECTIONS array (>= 5.0 only)
90 91 92 |
# File 'lib/guitar_pro_parser/song.rb', line 90 def musical_directions @musical_directions end |
#notices ⇒ Object
Array of notices
21 22 23 |
# File 'lib/guitar_pro_parser/song.rb', line 21 def notices @notices end |
#octave ⇒ Object
Octave. Default value is 0. It becomes 8 if the sheet is to be played one octave higher (8va).
78 79 80 |
# File 'lib/guitar_pro_parser/song.rb', line 78 def octave @octave end |
#page_setup ⇒ Object
(PageSetup) Data about page setup such as paddings, width, height, etc. (>= 5.0 only)
57 58 59 |
# File 'lib/guitar_pro_parser/song.rb', line 57 def page_setup @page_setup end |
#subtitle ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def subtitle @subtitle end |
#tempo ⇒ Object
(String) Tempo text
60 61 62 |
# File 'lib/guitar_pro_parser/song.rb', line 60 def tempo @tempo end |
#title ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def title @title end |
#tracks ⇒ Object
Array of tracks
100 101 102 |
# File 'lib/guitar_pro_parser/song.rb', line 100 def tracks @tracks end |
#transcriber ⇒ Object
Song information
17 18 19 |
# File 'lib/guitar_pro_parser/song.rb', line 17 def transcriber @transcriber end |
#triplet_feel ⇒ Object
(Boolean) Shuffle rhythm feel. < 5.0 only. In version 5 of the format it is true when there is at least 1 bar with triplet feel.
26 27 28 |
# File 'lib/guitar_pro_parser/song.rb', line 26 def triplet_feel @triplet_feel end |
#version ⇒ Object
Guitar Pro version
14 15 16 |
# File 'lib/guitar_pro_parser/song.rb', line 14 def version @version end |
Instance Method Details
#add_bar_settings ⇒ Object
139 140 141 142 |
# File 'lib/guitar_pro_parser/song.rb', line 139 def @bars_settings << BarSettings.new @bars_settings.last end |