You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: kit_builder.rb
    path of file: ./repos/beats/lib/beats
    
    the code of the file until where you have to start completion: module Beats
  class KitBuilder
    # Raised when trying to load a sound file which can't be found at the path specified
    class SoundFileNotFoundError < RuntimeError; end

    # Raised when trying to load a sound file which either isn't actually a sound file, or
    # is in an unsupported format.
    class InvalidSoundFormatError < RuntimeError; end

    BITS_PER_SAMPLE = 16
    SAMPLE_FORMAT = "pcm_#{BITS_PER_SAMPLE}".to_sym
    SAMPLE_RATE = 44100

    def initialize(base_path)
      @base_path = base_path
      @labels_to_filenames = {}
      @composite_replacements = {}
    end

    def add_item(label, filenames)
      if filenames.is_a?(Array)
        if filenames.empty?
 
    
    def build_kit
      # Load each sample buffer
      filenames_to_buffers = {}
      @labels_to_filenames.values.uniq.each do |filename|
        filenames_to_buffers[filename] = load_sample_buffer(filename)
      end

      # Convert each buffer to the same sample format
      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