[Tutor] How can Python use the head phone jack?

alan.gauld@bt.com alan.gauld@bt.com
Thu, 23 May 2002 13:20:17 +0100


> OK, what I'm really asking is, is there anyway for Python to 
> convert data into two different sounds (e.g. a high sound for 
> "1" and a low sound for "0") and send it out to the 
> speaker/audio/headphone jack? 

Yes but its platform dependant.
But Python does have sound functions and PyGame has quite 
sophisticated support based, I believe, on DirectX on Windows

> rid of or use those old audio tapes and then I thought it'd 
> be really cool to make Python use the ausio tapes for 
> storage, like the Commodore 64. 

Hmm, That wasn't even cool on the C64! :-)
Its a very slow and inefficient way to store data.
You ae limited by the frequencies of sound you use and the 
length of time needed to register the tines on the tape. 
Thus you can't get much more than about 300 BITS per second.
You then have to do all the error handling stuff(checksums, 
parity etc to make it even half reliable(hah!) so your 
storage works out about 30 bytes per second. For a C90 
cassette thats 90 x 60 x 30 = 160Kbytes

But of course you have two sides so its only 80K per side...
You can improve it using compression of course but do you 
really want to go there?!

Alan G.