bugGNU Octave - Bugs: bug #37540, wavwrite doesn't produce a valid...

 
 

bug #37540: wavwrite doesn't produce a valid wav file

Submitted by:  None
Submitted on:  Wed 10 Oct 2012 06:11:23 PM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: Mike Miller <mtmiller>
Originator Name: Guiu RocafortOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.3
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Tue 16 Oct 2012 02:34:58 AM UTC, comment #6:

As far as the affected file is an .m script I'm going to replace the wavwrite.m file with the updated one to have this fix included.

thank you for your time mike !

Guiu Rocafort <rocafort8>
Tue 16 Oct 2012 02:00:30 AM UTC, comment #5:

I had a similar patch ready assuming that would be your answer. I also added a line to the docstring and added a test for this case. Here is the changeset:
http://hg.savannah.gnu.org/hgweb/octave/rev/9a7f73fc304f

This fix will be available in the next major release of Octave. In the meantime you can stick to column vectors as a workaround or you can use the development source.

Mike Miller <mtmiller>
Project AdministratorIn charge of this item.
Mon 15 Oct 2012 10:19:50 AM UTC, comment #4:

I've tried the code and wavwrite generates a 8001 tracks wav with one sample each track when passing a 2xN matrix.

I've taken a look at the /usr/share/octave/3.2.4/m/audio/wavwrite.m file and I managed to fix the code so it behaves like matlab. I added a conditional that transposes the variable if it happens to be a row vector. I'm not sure if that's the best way of fixing it but it does the work ;)

I checked the modifications with 1x1, 1xn , nx1 and nxm cases and it seems i didn't broke anything.

Maybe should the documentation be modified to explicitily mention this behaviour ?

(file #26768, file #26769)

Guiu Rocafort <rocafort8>
Thu 11 Oct 2012 01:57:17 PM UTC, comment #3:

Thanks, I'll work on a fix for this since I also happen to be fixing an unrelated problem in wavread at the same time.

Can you try one more thing in Matlab, do you get a valid stereo WAVE file if the input is a 2xN matrix? Does this:

produce a stereo version of your example file or not?

Mike Miller <mtmiller>
Project AdministratorIn charge of this item.
Thu 11 Oct 2012 12:12:31 PM UTC, comment #2:

I can confirm that Matlab does behave differently using the row vector, I attach the result wav file generated by matlab with the example code and using row vector:

(file #26739)

Guiu Rocafort <rocafort8>
Wed 10 Oct 2012 07:30:16 PM UTC, comment #1:

Look at the help for wavwrite again. It requires that the first argument contain column vectors only, where each column is a channel. You are using row vectors, so your snippet here is attempting to create a WAVE file with 8001 channels of 1 sample each. Compare:

I don't see a bug here, unless you or someone else can demonstrate that Matlab behaves differently when given a row vector.

Mike Miller <mtmiller>
Project AdministratorIn charge of this item.
Wed 10 Oct 2012 06:11:23 PM UTC, original submission:

OS: GNU/Linux Kubuntu 12.04
Versions affected: 3.2.4 and 3.6.3 ( probably others also )

It seems like wavwrite don't produce a valid sound. I've tryed out generating a simple sine wave and generating the wav. The resulting wav cannot be reader by vlc neither mplayer. soundConverter complains about "Gstreamer: could not determine type of stream". And opening it with audacity causes it to crash. Because of all this, I'm arriving to the conclusion that the wav-generated file has not the right format.

I tryed out in versions 3.2.4 and 3.6.3 ( self complied ) and I've found the problem in both versions.

The full code that i've used to generate the wav file:

dur = 1.0;
fs = 8000;
tt = 0 : (1/fs) : dur;
xx = sin( 2pi2000*tt );
wavwrite( xx, fs,‘temp.wav’);

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #26768:  wavwrite.m added by rocafort8 (5KiB - text/x-objcsrc - modified wavwrite.m file which fix the row vector issue.)
file #26769:  wavwrite.diff added by rocafort8 (158B - text/x-patch - modified wavwrite.m file which fix the row vector issue.)
file #26739:  temp.wav added by rocafort8 (16KiB - audio/wav - wav file generated by matlab with row vector.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rocafort8 (Updated the item)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 16 Oct 2012 02:00:30 AM UTCmtmillerStatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
    Mon 15 Oct 2012 10:19:49 AM UTCrocafort8Attached File-=>Added wavwrite.m, #26768
      Attached File-=>Added wavwrite.diff, #26769
    Thu 11 Oct 2012 01:57:17 PM UTCmtmillerAssigned toNone=>mtmiller
      Operating SystemGNU/Linux=>Any
    Thu 11 Oct 2012 12:12:31 PM UTCrocafort8Attached File-=>Added temp.wav, #26739
    Wed 10 Oct 2012 07:30:16 PM UTCmtmillerStatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1