python - How do hex escapes correlate with audio in PyAudio? -


i'm playing around pyaudio in attempt make microtonal music, can't seem off ground. found bit of code on using core audio in-program: http://code.activestate.com/recipes/578301-platform-independent-1khz-pure-audio-sinewave-gene/ , i've made small adjustments:

import time import pyaudio  # open stream stream=pyaudio.pyaudio().open(format=pyaudio.paint8,channels=1,rate=24000,output=true)  # amount of time wave played in seconds length = 1  # generate 1khz signal @ speakers/headphone output # sine wave, 8 bit depth start = time.clock() while time.clock() - start <= length:     stream.write("\x00\x30\x5a\x76\x7f\x76\x5a\x30\x00\xd0\xa6\x8a\x80\x8a\xa6\xd0")  # close open _channel(s)_ stream.close() pyaudio.pyaudio().terminate() 

from understand, hex escapes raw audio being sent audio output. i've put them hex converter , graphed values. looks sin wave, i'm still no closer intuitive understanding of what's going on. eventual goal write function can output given frequency in series of hex escapes written stream. how many samples contained within 1 bytestring , values represent (ie. values express crest, trough, , resting state of sine wave @ full volume)?


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -