module ZXUtils::MusicBox::SongCommands
MusicBox
SongCommands
¶ ↑
Commands for a Song
.
For the other available commands see: MultitrackCommands
and TrackConfigCommands
.
Public Instance Methods
Creates a chord with the given name
as a symbol or a string. Provide args
for the MusicBox::Chord.new
.
See MusicBox::Chord
.
# File lib/zxutils/music_box/song.rb, line 105 def chord(name, *args) @chords[name.to_sym] = Chord.new(*args) end
Creates an envelope with the given name
as a symbol or a string. Provide args
for the MusicBox::Envelope.new
.
See MusicBox::Envelope
.
# File lib/zxutils/music_box/song.rb, line 91 def envelope(name, *args) @envelopes[name.to_sym] = Envelope.new(*args) end
Imports a MusicBox::Chord
instance with the given name
as a symbol or a string.
# File lib/zxutils/music_box/song.rb, line 110 def import_chord(name, chord) raise ArgumentError unless chord.is_a?(Chord) @chords[name.to_sym] = chord end
Imports a MusicBox::Envelope
instance with the given name
as a symbol or a string.
# File lib/zxutils/music_box/song.rb, line 96 def import_envelope(name, envelope) raise ArgumentError unless envelope.is_a?(Envelope) @envelopes[name.to_sym] = envelope end
Imports a MusicBox::Instrument
class with the given name
as a symbol or a string.
# File lib/zxutils/music_box/song.rb, line 62 def import_instrument(name, track) raise ArgumentError unless track.is_a?(Class) and track.ancestors.include?(Instrument) @instruments[name.to_sym] = track end
Imports a MusicBox::Mask
instance with the given name
as a symbol or a string.
# File lib/zxutils/music_box/song.rb, line 124 def import_mask(name, mask) raise ArgumentError unless mask.is_a?(Mask) @masks[name.to_sym] = mask end
Imports a MusicBox::Multitrack
class with the given name
as a symbol or a string.
# File lib/zxutils/music_box/song.rb, line 82 def import_multitrack(name, multitrack) raise ArgumentError unless multitrack.is_a?(Class) and multitrack.ancestors.include?(Multitrack) @multitracks[name.to_sym] = multitrack end
Imports a MusicBox::Track
class with the given name
as a symbol or a string.
# File lib/zxutils/music_box/song.rb, line 43 def import_track(name, track) raise ArgumentError unless track.is_a?(Class) and track.ancestors.include?(Track) @tracks[name.to_sym] = track end
Creates an instrument with the given name
as a symbol or a string.
Give a block of code containing instrument commands. See MusicBox::Instrument
.
# File lib/zxutils/music_box/song.rb, line 51 def instrument(name, &block) first_octave_note_ = @first_octave_note tempo_ = @tempo @instruments[name.to_sym] = Class.new do |klass| include Instrument tempo(tempo_) klass.module_eval(&block) end end
Creates a mask with the given name
as a symbol or a string. Provide args
for the MusicBox::Mask.new
.
See MusicBox::Mask
.
# File lib/zxutils/music_box/song.rb, line 119 def mask(name, *args) @masks[name.to_sym] = Mask.new(*args) end
Creates a multi-track with the given name
as a symbol or a string.
Give a block of code containing multi-track commands. See MusicBox::Multitrack
.
# File lib/zxutils/music_box/song.rb, line 70 def multitrack(name, &block) first_octave_note_ = @first_octave_note tempo_ = @tempo @multitracks[name.to_sym] = Class.new do |klass| include Multitrack first_octave_note(first_octave_note_) tempo(tempo_) klass.module_eval(&block) end end
Creates a track with the given name
as a symbol or a string.
Give a block of code containing track commands. See MusicBox::Track
.
# File lib/zxutils/music_box/song.rb, line 31 def track(name, &block) first_octave_note_ = @first_octave_note tempo_ = @tempo @tracks[name.to_sym] = Class.new do |klass| include Track first_octave_note(first_octave_note_) tempo(tempo_) klass.module_eval(&block) end end