[Tutor] Python + Sound

Alan Gauld alan.gauld at btinternet.com
Sat Feb 12 10:56:49 CET 2011


"Steven D'Aprano" <steve at pearwood.info> wrote

> I suggest you read up on how much work is needed to get reliable 
> data transport:
>
> http://en.wikipedia.org/wiki/TCP/IP_model
> http://www.howstuffworks.com/modem.htm
> http://en.wikipedia.org/wiki/Modem


He probably doesn't need all of that since its only for education
but he will need session setup/tear down as a minimum.

> But my guess is that doing this in pure Python will be so slow it 
> will

Python won't be the limit. The fastest you can swend pure digital
(without multiplexing) using audio is about 600 bits per second.
Thats less than 80 bytes per second. Python can handle that easily.

> be almost faster for you to copy the file onto a USB stick and 
> hand-deliver it to the other end. But if you insist...

Ah, the days of sneakerNet I remember it well :-)

>   The obvious way is to have one tone represent a one-bit, and 
> another
>   *very different* tone represent a two-bit. See also "frequency
>   modulation" and "amplitude modulation".

The other ways are to use more tones and encode groupss of digits.
Thats how faster modems work. And you can mess with the phasing
to send multiple groups simulateouslty. But for various technical
reasons the upper limit is around 64kb/s.

And dont forget the phone system can only transmit frequencies
between 300 and 3400Hz reliably. (100-4000Hz less reliably - not all
carriers support it)

> * Because of noise on the line, you need a scheme for error 
> correction.
>   Google for "Error correcting codes" for more information.

If you choose a realistic speed and stick with pure binary - say 100 
bps
error correction shouldn't be a big issue for short messages - say 
less
than a kilobyte.

> * The sender and receiver need a way to notify each other that they
>   are ready to start transmitting data. This is called a handshake.
>   Otherwise, you risk losing data from the ends of the transmission.

Yes, session set up and tear down is unavoidable.
The equivalent of saying "over", "roger" and "over and out" in radio
comms...

And the other big issue will be how to make the call in the first
place. I assume you plan on doing that bit manually? Otherwise
you are into a whole new can of worms!!

> You described this as "a small script" -- it might be so far, but by 
> the time you finish it will be huge.

It will be pretty big I suspect.

>> I don't really want to use the wave module because it looks like 
>> too
>> much work.
>
> Pardon me while I chortle :)

Yep, me too. You need all the help you can get! The work without
it will be much bigger!

It really will be much easier if you use a modem, at least for the
first attempt.

HTH,

Alan G. 




More information about the Tutor mailing list