Send sound to serial object / 56k modem
Hi,
First post. I'll try to do my best.
Max and a 56k voice modem are talking together pretty well in data mode.
Now I'd like to send 8 bits PCM files to the modem but I can't find which sound object can be accepted by the serial object..
Can someone help me ?
Thanx. yra.
Hello again,
Maybe I'm talking to myself but this might help someone, one day.
When the modem is in record mode it sends something to the serial object which sounds like ascii code (and which reacts to my voice on the phone). I don't get how to translate it into sound but I'm still trying.
To be continued..
Ok.
With the record mode I don't receive ascii code but audio bytes I guess.
When I don't talk to the phone, silence is like this :
127, 127, 128, 127, 127, 128, 127, 128, 128
And when I start talking :
96, 97, 107, 129, 136, 151, 149, 139, 146, 107, 115, 120, 141, 120, 134
What should I do with this ?
I can produce some modulations with [sig~] but can't really recognize my voice.. Problem of frequency ?
Any idea ?
Try subtracting 127, divide by 128 and stuff bytes in a buffer using peek~, incrementing index. You should get a recognizable waweform. Then use groove~ to play the buffer at proper sample rate (it should be around 8000Hz).
That's it ! It works very fine. peek~ is THE solution. Thanks a lot !
I think I have managed the frequency aspect in a dirty way but it works.
Now I'm working on the opposite way : how to send audio to the modem...
It doesn't work with a [snapshot~], going from the float number *127 +127.
Maybe I should go through a buffer too.
Yes, you should peek~ (in read mode) one sample over 6, supposing your DSP runs at 48000 and the modem sample rate is 8000Hz. Make sure your audio has no spectral content over 4000, otherwise you will get aliasing.
Scale to [0..255] and send to serial. There is a flow-control protocol to handle at this point (stuffing bytes faster than the modem can handle will overrun it). Refer to "Voice modem command set". If the modem uses CTS flow-control, you may be in trouble with Cycling's serial object. Jasch's comport is an alternative.
I have a conexant chipset which deals pretty well with overflow. I just have to terminate audio transmission before hanging up, otherwise serial object crashes.
Here is a way to send audio to the serial object for a conexant 56k V.92 modem (works with files which are already in PCM 8bits 8000Hz, same format selected on modem parameters, didn't try other possbilities).
Thanks again Mister Bernier, I was on a wrong way, couldn't manage without your help !
Hello yra,
I'm for days looking for a solution to my problem. I found this topic (https://cycling74.com/forums/send-sound-to-serial-object-56k-modem) and I think you have the solution.
I'm trying to play a sound over the modem. It works pretty well in the first 10 seconds. After 10 seconds, the sound "skip" and then crashes (mute). I think the modem begins overflow. My file has about 300kb, mono, u-law, 8000 sample rate, 8bits. My modem has a Conexant chipset (CX93010), USB.
Can you share how do you do it? Follows the code I'm trying.
InputStream stream = new InputStream(new File("C:\Greeting3.wav"));
boolean eof = false;
while(!eof)
{
byte[] b;
b = new byte[512];
int input = stream.read(b);
if(input > 0) {
//outputStream.write(b, 0, input);
}
if(input == -1){
eof = true;
}
}
stream.close();