bugGNU Octave - Bugs: bug #43515, signal package: specgram example...

 
 

bug #43515: signal package: specgram example in docstring needs tweaking

Submitter:  Doug Stewart <dastew>
Submitted:  Sun 02 Nov 2014 02:35:11 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  mtmiller
Originator Name:  Doug Stewart Open/Closed:  * Closed
Release:  * other Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 11 Jan 2015 04:55:50 PM UTC, comment #13: 
Mike Miller <mtmiller>
Group Member
Tue 04 Nov 2014 02:22:43 PM UTC, comment #12: 

I know, that's why I assigned this bug to myself :)

The main problem is that the demo as written now requires an audio file, which I'd rather avoid adding to the package just for a demo. So the demo will stay disabled. The rest of your changes are of course fine, I'll take care of merging it.

Mike Miller <mtmiller>
Group Member
Tue 04 Nov 2014 01:58:44 PM UTC, comment #11: 

Hi Mike Miller.
Carandraug says the you are the closest one to a maintainer of the signal pkg. If you would review my two suggestions and push them then this bug report can be closed.
thanks

Doug Stewart <dastew>
Mon 03 Nov 2014 01:31:45 AM UTC, comment #10: 

Here is a patch to make the second demo work.
This should be applied after the first patch.

(file #32359)

Doug Stewart <dastew>
Sun 02 Nov 2014 07:15:35 PM UTC, comment #9: 

This  problem  might be a result of the fix to
bug #30509, 'imshow' doesn't reverse 'ydir'

Doug Stewart <dastew>
Sun 02 Nov 2014 07:11:31 PM UTC, comment #8: 

here is a patch.

(file #32357)

Doug Stewart <dastew>
Sun 02 Nov 2014 06:40:47 PM UTC, comment #7: 

If the last two lines of the example are set to:

            imagesc(t, f, log(S));   # display in log scale
            set (gca, 'ydir','normal')

then the plot looks good to me.

Doug Stewart <dastew>
Sun 02 Nov 2014 04:28:54 PM UTC, comment #6: 

I mean just for this plot. Don't change image or imagesc.

Or use some other way to plot it

Doug Stewart <dastew>
Sun 02 Nov 2014 04:26:07 PM UTC, comment #5: 

So to fix it we should change the ydir property.

Doug Stewart <dastew>
Sun 02 Nov 2014 04:17:35 PM UTC, comment #4: 

That is correct, try calling `image()` or `demo image` for example. The y-axis for images always runs top to bottom. See the `ydir` axis property.

Mike Miller <mtmiller>
Group Member
Sun 02 Nov 2014 04:10:10 PM UTC, comment #3: 

Yes that is the issue that I see. But I don't understand image and imagesc --- is the 0,0 location in the top left corner for images and in the bottom left corner for plots? the array that spegram produces expects the 0,0 to be in the bottom left corner. and when we look at a spectogram we expect 0,0 to be in the bottom left corner.

Doug Stewart <dastew>
Sun 02 Nov 2014 03:44:44 PM UTC, comment #2: 

Thanks for your bug report. Can you suggest an appropriate fix for the y-axis label? Is that the only issue you see with the example in the docstring?

Mike Miller <mtmiller>
Group Member
Sun 02 Nov 2014 03:12:00 AM UTC, comment #1: 

flipud  flips the image but not the Y axis.

Doug Stewart <dastew>
Sun 02 Nov 2014 02:35:11 AM UTC, original submission:  

the example given in specgram has a wrong Y axis
+verbatum+
 ## Speech spectrogram
              [x, Fs] = auload(file_in_loadpath("sample.wav")); # audio file
              step = fix(5*Fs/1000);     # one spectral slice every 5 ms
              window = fix(40*Fs/1000);  # 40 ms data window
              fftn = 2^nextpow2(window); # next highest power of 2
              [S, f, t] = specgram(x, fftn, Fs, window, window-step);
              S = abs(S(2:fftn*4000/Fs,:)); # magnitude in range 0<f<=4000 Hz.
              S = S/max(S(:));           # normalize magnitude so that max is 0 dB.
              S = max(S, 10^(-40/10));   # clip below -40 dB.
              S = min(S, 10^(-3/10));    # clip above -3 dB.
              imagesc(t, f, flipud(log(S)));   # display in log scale
-verbatum-


Zero frequency is at the top left but should be at the bottom left.

Specgram works OK but the problem is with preparations and plotting with imagesc

Doug Stewart <dastew>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #32359:  487demoworking.patch added by dastew (1KiB - text/x-patch)
file #32357:  486patchYdirection.patch added by dastew (868B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by dastew (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-01-11 mtmiller StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2014-11-03 dastew Attached File- Added 487demoworking.patch, #32359
    2014-11-02 dastew Attached File- Added 486patchYdirection.patch, #32357
    2014-11-02 mtmiller CategoryPlotting Octave Package
        Item GroupIncorrect Result Documentation
        StatusNone Confirmed
        Assigned toNone mtmiller
        Releasedev other
        SummarySpecgram example is wrong signal package: specgram example in docstring needs tweaking

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code