wavwrite error

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

wavwrite error

harish3679
Hello guys,

I have problem executing this piece of code, as it throws an error for
sampling frequency. Please, do share your suggestions


dur = 1.0;
fs = 8000;
tt = 0 : (1/fs) : dur;
xx = sin( 2*pi*2000*tt );
wavwrite("sound.wav",xx', fs, 16)

>> wavwrite("sound.wav",xx', fs, 16)
error: wavwrite: sample rate FS must be a positive number
error: called from
    wavwrite at line 91 column 5

Thanks and Regards!!
Harish



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: wavwrite error

Pantxo
harish3679 wrote

> Hello guys,
>
> I have problem executing this piece of code, as it throws an error for
> sampling frequency. Please, do share your suggestions
>
>
> dur = 1.0;
> fs = 8000;
> tt = 0 : (1/fs) : dur;
> xx = sin( 2*pi*2000*tt );
> wavwrite("sound.wav",xx', fs, 16)
>
>>> wavwrite("sound.wav",xx', fs, 16)
> error: wavwrite: sample rate FS must be a positive number
> error: called from
>     wavwrite at line 91 column 5
>
> Thanks and Regards!!
> Harish
>
>
>
> --
> Sent from:
> http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

I don't know what version of Octave you are using but "wavwrite" was removed
in the latest release in favor of "audiowrite" (which has been there since
Octave 4.4).

The problem in your example is that the order of the arguments is not
correct for wavwrite (the filename should be at the end)  but it is correct
for audiowrite. So if your version of Octave is sufficiently recent,
replacing "wavwrite" by "audiowrite" and removing "16" (16 bits per sample
is the default) should do the trick .

Pantxo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: wavwrite error

Bagus Tris Atmaja
In reply to this post by harish3679

H i,

If you used Octave prior to 4.4.0, take a look into `help(wavread)`. The argument should be the signal, fs, bits and filename in the last.
So, change the order of your last line like the following:
>>> wavwrite(,xx', fs, 16, "sound.wav")

Best,
/bta



On Mon, Sep 10, 2018 at 4:18 PM harish3679 <[hidden email]> wrote:
Hello guys,

I have problem executing this piece of code, as it throws an error for
sampling frequency. Please, do share your suggestions


dur = 1.0;
fs = 8000;
tt = 0 : (1/fs) : dur;
xx = sin( 2*pi*2000*tt );
wavwrite("sound.wav",xx', fs, 16)

>> wavwrite("sound.wav",xx', fs, 16)
error: wavwrite: sample rate FS must be a positive number
error: called from
    wavwrite at line 91 column 5

Thanks and Regards!!
Harish



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html