grrrr / nsgt

Non Stationary Gabor Transform (NSGT), Python implementation
http://grrrr.org/research/software/nsgt
Artistic License 2.0
95 stars 28 forks source link

assemble_coeffs function in ./examples/spectrograms.py returns error #15

Open JamesOwers opened 8 years ago

JamesOwers commented 8 years ago

Observing c created on line 108, I see it generates objects of dimension 1 x 66 (a 2d array) therefore the function complains that the index [2] is out of range. This error may well be due to my misunderstanding of arguments.

$ ./spectrogram.py /path/to/wav/audio.wav'
Traceback (most recent call last):
  File "./spectrogram.py", line 112, in <module>
    coefs = assemble_coeffs(c, ncoefs)
  File "./spectrogram.py", line 27, in assemble_coeffs
    out = np.empty((ncoefs,cq0.shape[1],cq0.shape[2]), dtype=cq0.dtype)

If it helps, here is info about the wav file being input:

$ soxi 'MASS/sargon-silenci (metal)/sargon-silenci_1-19_with_effects.wav'

Input File     : 'MASS/sargon-silenci (metal)/sargon-silenci_1-19_with_effects.wav'
Channels       : 2
Sample Rate    : 44100
Precision      : 24-bit
Duration       : 00:00:18.00 = 793801 samples = 1350 CDDA sectors
File Size      : 4.76M
Bit Rate       : 2.12M
Sample Encoding: 24-bit Signed Integer PCM

Seeing as the default for --sr is 44100 I thought it would be fine to run with no additional args set.

JamesOwers commented 8 years ago

I've had a crack at diagnosing - struggled with the generators. Running np.array(list(c)).shape returns (3, 2, 66) i.e. c is a generator that produces lists of lists ('shape' (2,66)). Is this as expected or is something going wrong upstream? I'm afraid I've run out of time trying to pick through NSGT_sliced.forward.

grrrr commented 8 years ago

The list of lists is on purpose, because the output is not necessarily rectangular (only with —matrixform it is).

I would suggest that you start with a set of trusty command line options, like

myinput.wav —output=myoutput.h5 --fmin=80 --fmax=14000 --bins=202 --scale=log --real --matrixform --reducedform=2 --fps=100 --downmix-after

and --plot, if you like

Am 15.06.2016 um 17:49 schrieb James Owers notifications@github.com:

I've had a crack at diagnosing - struggled with the generators. Running np.array(list(c)).shape returns (3, 2, 66) i.e. c is a generator that produces lists of lists ('shape' (2,66)). Is this as expected or is something going wrong upstream? I'm afraid I've run out of time trying to pick through NSGT_sliced.forward.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/grrrr/nsgt/issues/15#issuecomment-226230976, or mute the thread https://github.com/notifications/unsubscribe/AAJ-JisjRSf-5mS_qIsH7wOibQVIqd7Vks5qMB8jgaJpZM4I2Yv8.

JamesOwers commented 8 years ago

Ok, thanks for the tip. I can get it to run with just the argument --matrixform added. The documented help for this is simply "Use regular time division over frequency bins (matrix form)"; have you any clues as to why running without this doesn't work? Is there a bug here or is this simply expected?