lib/beats/kit_builder.rb
# Raised when trying to load a sound file which can't be found at the path specified
Raised when trying to load a sound file which can't be found at the path specified
Raised when trying to load a sound file which can ' t be found at the path specified
def build_kit
      filenames_to_buffers = {}
      @labels_to_filenames.values.uniq.each do |filename|
        filenames_to_buffers[filename] = load_sample_buffer(filename)
      end
      num_channels = filenames_to_buffers.values.map(&:channels).max || 1
      canonical_format = WaveFile::Format.new(num_channels, SAMPLE_FORMAT, SAMPLE_RATE)
      filenames_to_buffers.values.each {|buffer| buffer.convert!(canonical_format) }
      labels_to_buffers = {}
      @labels_to_filenames.each do |label, filename|
        labels_to_buffers[label] = filenames_to_buffers[filename].samples
      end
      labels_to_buffers[Kit::PLACEHOLDER_TRACK_NAME] = []
      Kit.new(labels_to_buffers, num_channels, BITS_PER_SAMPLE)
    end
def build_kit filenames_to_buffers = { } @labels_to_filenames . values . uniq . each do | filename | filenames_to_buffers [ filename ] = load_sample_buffer ( filename ) end num_channels = filenames_to_buffers . values . map ( & :channels ) . max || 1 canonical_format = WaveFile :: Format . new ( num_channels , SAMPLE_FORMAT , SAMPLE_RATE ) filenames_to_buffers . values . each { | buffer | buffer . convert! ( canonical_format ) } labels_to_buffers = { } @labels_to_filenames . each do | label , filename | labels_to_buffers [ label ] = filenames_to_buffers [ filename ] . samples end labels_to_buffers [ Kit :: PLACEHOLDER_TRACK_NAME ] = [ ] Kit . new ( labels_to_buffers , num_channels , BITS_PER_SAMPLE ) end
Raised when trying to load a sound file which can't be found at the path specified
Raised when trying to load a sound file which can ' t be found at the path specified
# Load each sample buffer # Convert each buffer to the same sample format