From help-request at octave dot org Thu Dec 23 03:53:36 2004 Subject: Re: Audio i/o From: edA-qa mort-ora-y To: Jose Colmenares CC: help at octave dot org Date: Thu, 23 Dec 2004 10:55:03 +0100 Jose Colmenares wrote: > I want to play, using my soundcard, a certain signal. > I could generate the signal, and play it using the > playsound command. Nevertheless, how do I put the > vector in the correcto format? I've searched the web, Do you need to play them from directly within Octave? If not, then here is a solution. If yes, then well, use the same advice and simply call the "system" function. ;) If you are generating waveforms it is probably fairly convenient for you to use floating point samples. These samples should be in the range [-1,1] as that is what a typical sound-card, and the playing system are expecting. Your vector is a normal Octave vector (one-row) in time offset order t(1) is first sample, t(2) is second, ... Once you have a vector you need to write it to a file. You can do this with a command like: fwrite( handle, data, "float" ) The "float" instructs it to write in the float format, which should be 32-bit floating point. Now, for Linux: Once you have a file you can play it using the program "sox" and "esdcat". esdcat is installed on most new Linux installs, sox may need to be additionally installed. RUn this command: sox -t raw -l -f -r 44100 filename -c 1 -s -w -t raw - | esdcat -r 44100 -m This converts your RAW file forward into something esdcat can use, and then it plays it. Replace 44100 with the appropriate byte rate. The docs on sox/esdcat explain the rest of the options. Now, for Windows: Well, from the command line I don't know what to do, but maybe esdcat is also ported... otherwise open your file in something like CoolEdit and let it play it. -- edA-qa mort-ora-y Idea Architect http://disemia.com/ ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------