Hello list. I'm trying to put together an AFSK modem in Python, and I have most 
of the code worked out. The last remaining issue will be generating the actual 
audio signal. Unfortunately, I have never written any kind of audio code before 
in any language, so I don't really know what I am doing.

I did find some code that generated a single or DTMF tone, but it only worked 
if you let it fill the whole buffer with samples, less than that and it would 
get distorted at the end. That, and it didn't allow the frequency to be changed 
mid-run. I will need to generate sinusoidal tones of arbitrary length, shifting 
frequency as often as once every 8 milliseconds.

The function should be something like this:

def makesamples(frequency,length,phase):
        samples=[]
        for t in range(length):
                # ???
        return samples

Then, calling it:

# ...
for sample in makesamples(1200,40,phase):
        soundcard.write(chr(sample & 0x00FF) + chr(sample & 0xFF00 >> 8))
# ...

The code calling the function would probably have to figure out the phase for 
the next call based on the length of the output.

For what it's worth, this will be running on an x86-64 Linux machine, using the 
ossaudiodev module to access the soundcard. Anyone think they can help?

-Joe
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to