Corey Richardson wrote:
Hello Tutors,

I'm working on a small script that compresses a file, sends it through
the telephone, and then receives and decompresses the file on the other
end. The compression is the easy part. The transmission is the hard
part. If anyone has worked with sound before, what do you recommend?

Sorry, do I understand you correctly?

You want to compress an arbitrary file, convert that compressed data into some sort of sound, play the sound through the telephone, record it at the other end, decompress it, and get the original file back again?

This is certainly possible -- it's how modems work. But it's a lot of work, and it's reinventing the wheel in the biggest way. Good luck!

Normally, people transmit files using the highest level protocol they can:

application sends data via HTTP (etc)
... which is built on top of TCP
... which is built on top of IP
... which is built on top of the link layer
... which is built on top of the physical hardware layer

If I've understood you correctly, you want to write your own equivalent of TCP/IP, using only some sort of library link layer to deal with the hardware. That is, you don't want to care about voltages, but you do want to send data to the speaker and receive data from microphones. Yes?

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

and this may entertain, and help:
http://www.joelonsoftware.com/articles/LeakyAbstractions.html


Of course this can be done -- otherwise we wouldn't have the Internet! But my guess is that doing this in pure Python will be so slow it will 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...

* Your compressed file is a bunch of bytes. You need to come up with
  a scheme for encoding that to sound. This needs to be reversible
  and designed to work on low-fidelity systems (phone networks).
  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".

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

* 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.

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

I don't really want to use the wave module because it looks like too
much work.

Pardon me while I chortle :)



--
Steven

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to