class Beats::Kit
Constants
- PLACEHOLDER_TRACK_NAME
Attributes
bits_per_sample[R]
labels[R]
num_channels[R]
Public Class Methods
new(items, num_channels, bits_per_sample)
click to toggle source
# File lib/beats/kit.rb, line 7 def initialize(items, num_channels, bits_per_sample) @items = items @labels = @items.keys.freeze @num_channels = num_channels @bits_per_sample = bits_per_sample end
Public Instance Methods
get_sample_data(label)
click to toggle source
Returns the sample data for a sound contained in the Kit
. If the all sounds in the kit are mono, then this will be a flat Array of Integers between -32768 and 32767. Otherwise, this will be an Array of Integers pairs between -32768 and 32767.
label - The name of the sound to get sample data for. If the sound was defined in
the Kit section of a song file, this will generally be a descriptive label such as "bass" or "snare". If defined in a track but not the kit, it will generally be a file name such as "my_sounds/hihat/hi_hat.wav".
Examples
# If @num_channels is 1, a flat Array of Integers: get_sample_data("bass") # => [154, 7023, 8132, 2622, -132, 34, ..., -6702] # If @num_channels is 2, a Array of Integers pairs: get_sample_data("snare") # => [[57, 1265], [-452, 10543], [-2531, 12643], [-6372, 11653], ..., [5482, 25673]]
Returns the sample data Array for the sound bound to label.
# File lib/beats/kit.rb, line 36 def get_sample_data(label) unless @items.has_key?(label) raise LabelNotFoundError, "Kit doesn't contain sound '#{label}'." end @items[label] end