Method: Beats::Kit#get_sample_data
- Defined in:
- lib/beats/kit.rb
#get_sample_data(label) ⇒ Object
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 Fixnums between -32768 and 32767. Otherwise, this will be an Array of Fixnums 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 Fixnums:
get_sample_data("bass")
# => [154, 7023, 8132, 2622, -132, 34, ..., -6702]
# If @num_channels is 2, a Array of Fixnums 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.
35 36 37 38 39 40 41 |
# File 'lib/beats/kit.rb', line 35 def get_sample_data(label) unless @items.has_key?(label) raise LabelNotFoundError, "Kit doesn't contain sound '#{label}'." end @items[label] end |