Alf P. Steinbach wrote: > Just as a contribution, since someone hinted that I haven't really > contributed much to the Python community. > > The [simple_sound] code will probably go into my ch 3 at <url: > http://tinyurl.com/programmingbookP3>, but sans sine wave generation since > I haven't yet discussed trig functions, and maybe /with/ changes suggested > by you?
> def _append_as_big_endian_int16_to( a, i ): > if i < 0: > i = i + 65536 > assert( 0 <= i < 65536 ) > a.append( i // 256 ) > a.append( i % 256 ) > data = array.array( "B" ) # B -> unsigned bytes. Do you know that array.array() supports 16 bit signed integers? There's even a byteswap() method to deal with endianess. > Utility class that may be used to capture output (an instance of this or > any other file like class can be passed as "filename" to > simple_sound.Writer): > > <code> > class BytesCollector: Are you reinventing io.BytesIO() here? Peter -- http://mail.python.org/mailman/listinfo/python-list