help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sound


From: Jonathan King
Subject: Re: Sound
Date: Thu, 6 Jul 2000 13:47:23 -0500 (CDT)

On Thu, 6 Jul 2000, B?rge Strand wrote:

> Is there a sound function available for Octave? I'm planning to set my
> computer up as an S/PDIF signal generator for some audio hardware
> development.
> 
> Until now I've been converting vectors to .wav files which were burnt
> on CDs and played manually. A little too expensive and time-consuming,
> unfortunately.

Hmm...I see what you mean.  Now, this should be *fairly* easy to achieve
on any system where you have sox installed, since you can wrap sox's
"play" facility inside an octave function, and it looks like you can play
binary data from a file, if you use the correct sox incantations.

At the moment, that's the tricky part for me; sox is giving me an
(undocumented?) "drop through" error when I just tried to do the obvious
thing and play a simple binary file (of a sine wave) written from octave.

But the basic approach would be to grab the vector, fopen/fwrite/fclose a
temp file, and call system() with the correct magic incantation to play.
Somebody out there may have already done this...

> Matlab says
> 
> >> help sound
> 
>  SOUND Play vector as sound.
>     SOUND(Y,FS) sends the signal in vector Y (with sample frequency
>     FS) out to the speaker on platforms that support sound. Values in
>     Y are assumed to be in the range -1.0 <= y <= 1.0. Values outside
>     that range are clipped.  Stereo sounds are played, on platforms
>     that support it, when Y is an N-by-2 matrix.

Again, all of this should all be doable with sox, (and I'd have done it if
I could get play to work right off the bat).
  
>     SOUND(Y) plays the sound at the default sample rate of 8192 Hz.
>  
>     SOUND(Y,FS,BITS) plays the sound using BITS bits/sample if
>     possible.  Most platforms support BITS=8 or 16.

All doable.
  
>     See also SOUNDSC.

Trivial. :-)

Seriously, I haven't gotten raw formats to work with sox yet (is there a
trick?), but if the lightbulb goes "on" for somebody, then this should be
a workable approach.

jking




-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]