lib/beats/audio_engine.rb
# Composites the sample data for each of the pattern's tracks, and returns the overflow sample data
# from tracks whose last sound trigger extends past the end of the pattern. This overflow can be
# used by the next pattern to avoid sounds cutting off when the pattern changes.
Composites the sample data for each of the pattern's tracks, and returns the overflow sample data
from tracks whose last sound trigger extends past the end of the pattern. This overflow can be
used by the next pattern to avoid sounds cutting off when the pattern changes.
Composites the sample data for each of the pattern ' s tracks and returns the overflow sample data from tracks whose last sound trigger extends past the end of the pattern . This overflow can be used by the next pattern to avoid sounds cutting off when the pattern changes .
def generate_pattern_sample_data(pattern, incoming_overflow)
      if @composited_pattern_cache[pattern].nil?
        primary_sample_data, overflow_sample_data = composite_pattern_tracks(pattern)
        @composited_pattern_cache[pattern] = {primary: primary_sample_data.dup, overflow: overflow_sample_data.dup}
      else
        primary_sample_data = @composited_pattern_cache[pattern][:primary].dup
        overflow_sample_data = @composited_pattern_cache[pattern][:overflow].dup
      end
      primary_sample_data, overflow_sample_data = handle_incoming_overflow(pattern,
                                                                           incoming_overflow,
                                                                           primary_sample_data,
                                                                           overflow_sample_data)
      primary_sample_data = AudioUtils.scale(primary_sample_data, @kit.num_channels, @song.total_tracks)
      {primary: primary_sample_data, overflow: overflow_sample_data}
    end
def generate_pattern_sample_data ( pattern , incoming_overflow ) if @composited_pattern_cache [ pattern ] . nil? primary_sample_data , overflow_sample_data = composite_pattern_tracks ( pattern ) @composited_pattern_cache [ pattern ] = { primary : primary_sample_data . dup , overflow : overflow_sample_data . dup } else primary_sample_data = @composited_pattern_cache [ pattern ] [ :primary ] . dup overflow_sample_data = @composited_pattern_cache [ pattern ] [ :overflow ] . dup end primary_sample_data , overflow_sample_data = handle_incoming_overflow ( pattern , incoming_overflow , primary_sample_data , overflow_sample_data ) primary_sample_data = AudioUtils . scale ( primary_sample_data , @kit . num_channels , @song . total_tracks ) { primary : primary_sample_data , overflow : overflow_sample_data } end
Composites the sample data for each of the pattern's tracks, and returns the overflow sample data
from tracks whose last sound trigger extends past the end of the pattern.
Composites the sample data for each of the pattern ' s tracks and returns the overflow sample data from tracks whose last sound trigger extends past the end of the pattern .
# Unless cached, composite each track's sample data. # Composite overflow from the previous pattern onto this pattern, to prevent sounds from cutting off.
pattern
incoming_overflow