module ZXUtils::MusicBox::Track

MusicBox Track ↑

A track consists of the ZXUtils::AYMusic commands.

To create a custom track you need to include the Track module in your class representing the given music track.

class MusicTrack1
    include ZXUtils::MusicBox::Track
    #... track commands follow
end

Such a track can be included with the MusicBox::SongCommands.import_track command of the Song.

Alternatively use MusicBox::SongCommands.track command to define tracks directly in the Song.

Commands ↑

For the list of available commands see TrackCommands and CommonInstrumentCommands.

Constants

Marker

Instances of this ruby struct are values of the markers hash. The properties present are:

  • name

    A marker's name.

  • offset

    A marker's position in the code.

Attributes

code[R]

A compiled track's body as a binary string.

markers[R]

A hash containging the Marker instances as values and their names as keys.

max_recursion_depth[R]

A maximal recursion depth this track reaches at some point. This must not exceed ZXUtils::AYMusic::TRACK_STACK_DEPTH.

resolver[R]

A resolver used by the compilation process.

Public Class Methods

new(resolver) click to toggle source

Instances of the derived classes are being created internally by the MusicBox::Song compilation process.

# File lib/zxutils/music_box/track.rb, line 691
def initialize(resolver)
        @resolver = resolver
        @markers = ROHash.new
        @ticks_counter = 0
        @max_recursion_depth = 0
        @rational_counter = Rational(0,1)
        @code = ''
        @last_pause_delay = Rational(0,1)
        @last_pause_ticks = 0
        @last_pause_range = 0...0
        self.class.instance_variable_get('@commands'.freeze).each { |c| self << c }
end

Public Instance Methods

bytesize() click to toggle source

Returns the size in bytes of the track's compiled body.

# File lib/zxutils/music_box/track.rb, line 710
def bytesize
        code.bytesize
end
ticks_counter(counter=0) click to toggle source

Adds a track's tick counter value to the given counter and returns it.

# File lib/zxutils/music_box/track.rb, line 705
def ticks_counter(counter=0)
        @ticks_counter && (@ticks_counter + counter)
end