stream wav over udp

Hi!

I am wondering if anyone has experience of streaming csound output over udp?
I've tried socksend a little, but I need to be able to stream wav, not the inherent csound audio format (what format is that anyway?) and I dont know how to do that.
Any ideas?

Regards,
Anders

Probably not...

I'm afraid that you're probably facing a rather fundamental problem there. I was going to suggest sending the data to stdout, and piping it to something like 'netcat' (in Linux -- probably some equivalent in Windows), but I did some investigating first. (:-/)

The problem is that formats like WAV and AIFF are all chunked (R)IFF-style files, which begin with a header giving the overall size of the file. As a result, the data has to be written non-linearly. A dummy header is written first, then all the audio, and as a last step the program goes back to write the header properly (by repositioning in the file). Consequently you can't really stream the data through a pipe: any repositioning just closes the pipe (at least on Linux). In fact, the result seems to be that no data gets actually sent at all!

If you use the '-h' flag to Csound, to suppress headers, it will pipe fine, but it's no longer a WAV file then! (The Csound 'format' BTW is just a stream of values at the sample rate, presumably in either float or double depending on the Csound version.)

Don't know what your actual needs are, but I don't think WAV is ever suitable for streaming. I'd guess you should investigate some way of converting the raw output from Csound into a streaming format. 'sox' will do that sort of thing in batch mode; not sure if it will 'live stream' too.

Thanks for the reply! I

Thanks for the reply!
I think I can manage without wav as long as it is 16 bit PCM, so I'll try sending to stdout and pipe it to a fifo and then netcat to the receiver.
We'll see how it works...

Regards,
Anders

I have further investigated

I have further investigated the streaming properties, and tried to find out what format is actually sent by socksend.
By doing

instr 1

a1 oscil 8000, 220, 1
socksend a1, "127.0.0.1",12345, 182

endin

f1 0 65536 10 1

;ins strt dur

i1 0 4

e

and using

netcat -u -l 12345 > csound_dump.dat

to dump the output, I get a binary file to import into octave/matlab for analysis.

In octave I do

fid=fopen("csound_dump.dat");
L=fread(fid, Inf, "double");
fclose(fid);

figure(1)
plot(L(1:5000))

The "double" precision seem to be the most correct one, because I do get values out that have the same maximum amplitude as set in csound (8000 in this case), but there is some sort of modulation which is rather strange...
I have a graph of the first few thousand samples here: https://docs.google.com/leaf?id=0B9VJWAIGT4HFOGE0NmM4YjYtZmJhNy00NTU4LWI...

Solved (I think)

The culprit was the socksend packet size.
When changed to 128 (i.e. 2^7) things are smooth as a baby's butt!

So I can stream from csound via socksend, receive as double and write to a sound buffer as raw 16-bit integer and play it as if it was wav.

Yay!

Thanks for the feedback!!

Regards,
/Anders

buy zithromax ed drugs cialis online buy viagra uk generic cialis generic viagra cheap generic viagra viagra online staxyn ed pills Canadian pharmacy viagra Canadian pharmacy avanafil cialis uk pharmacy uk z-pack z pak kamagra uk z-pak viagra uk zpak zpack z pack