def make_buffer_from_bit_pattern(pattern, on_freq, off_freq):
 last_bit = pattern[(-1)]
 output_buffer = []
 offset = 0
 for i in range(len(pattern)):
  bit = pattern[i]
  if (i < (len(pattern) - 1)):
   next_bit = pattern[(i + 1)]
  else:
   next_bit = pattern[0]
  freq = (on_freq if (bit == '1') else off_freq)
  tone = quietnet.tone(freq, DATASIZE, offset=offset)
  output_buffer += quietnet.envelope(tone, left=(last_bit == '0'), right=(next_bit == '0'))
  offset += DATASIZE
  last_bit = bit
 return quietnet.pack_buffer(output_buffer)

def make_buffer_from_bit_pattern ( pattern , on_freq , off_freq ) : last_bit = pattern [ ( - 1 ) ] output_buffer = [ ] offset = 0 for i in range ( len ( pattern ) ) : bit = pattern [ i ] if ( i < ( len ( pattern ) - 1 ) ) : next_bit = pattern [ ( i + 1 ) ] else : next_bit = pattern [ 0 ] freq = ( on_freq if ( bit == '1' ) else off_freq ) tone = quietnet . tone ( freq , DATASIZE , offset = offset ) output_buffer += quietnet . envelope ( tone , left = ( last_bit == '0' ) , right = ( next_bit == '0' ) ) offset += DATASIZE last_bit = bit return quietnet . pack_buffer ( output_buffer )
takes a pattern and returns an audio buffer that encodes that pattern .