module ZXUtils::MusicBox::TrackCommands

MusicBox TrackCommands

Track commands for playing notes, setting instruments and yielding to other tracks.

For the other available track commands see: TrackConfigCommands, CommonInstrumentCommands.

Public Instance Methods

ei()
i(instrument_name)
Alias for: set_instrument
pch(*args)
Alias for: play_chord
play note_name, octave, *pause_lengths click to toggle source
note_name octave, *pause_lengths

To play notes on the use one of the commands:

note_name  corresponding note
a          A
a!         A#
b_         Bb
b          B
c          C
c!         C#
d_         Db
d          D
d!         D#
e_         Eb
e          E
f          F
f!         F#
g_         Gb
g          G
g!         G#
a_         Ab
octave

A number: 0 to 7.

pause_lenghs

Optional one or more pause lengths as integers, see CommonInstrumentCommands.pause.

E.g. to play a middle C# Half note:

c! 4, 2
NOTE

To set the octave boundary please consult TrackConfigCommands.first_octave_note. By default an octave starts from A.

In the case if you set:

first_octave_note :c

The middle C# will be at:

c! 5, 2
# File lib/zxutils/music_box/track.rb, line 591
def play(note_name, octave, *pause_lengths)
        @commands << NoteCommand.new(note_name, octave, @first_octave_note)
        pause(*pause_lengths) unless pause_lengths.empty?
end
play_chord note_name, octave, ticks=1, ... click to toggle source
pch note_name, octave, ticks=1, ...

Plays a chord. At least two different notes should be specified.

# File lib/zxutils/music_box/track.rb, line 605
def play_chord(*args)
        @commands << NoteChordCommand.new(@first_octave_note, *args)
        @commands.length
end
Also aliased as: pch
set_empty_instrument click to toggle source
ei

Turns off any instrument previously set up with TrackCommands.set_instrument on the current channel. The current instrument won't be immediately stopped until the next note is being played on this channel.

# File lib/zxutils/music_box/track.rb, line 634
def set_empty_instrument
        set_instrument(nil)
end
Also aliased as: ei
set_instrument instrument_name click to toggle source
i instrument_name

Sets an instrument for the current channel.

instrument_name

A symbol or string with the instrument name to set.

To turn off an instrument, set another one or use TrackCommands.set_empty_instrument. The previous instrument won't be immediately stopped until the next note is being played on this channel.

# File lib/zxutils/music_box/track.rb, line 621
def set_instrument(instrument_name)
        @commands << InstrumentCommand.new(instrument_name)
        @commands.length
end
Also aliased as: i
sub(track_name)
Alias for: sub_track
sub_track track_name click to toggle source
sub track_name

Yields execution of the track to another sub-track with the given track_name as a symbol or string. When the track execution is finished, the yielding track will resume execution.

# File lib/zxutils/music_box/track.rb, line 644
def sub_track(track_name)
        @commands << SubTrackCommand.new(track_name)
        @commands.length
end
Also aliased as: sub