Bugzilla – Bug 336
Enh: Support (and test) 64 bit Nyquist in Audacity.
Last modified: 2019-05-26 11:48:38 UTC
Created attachment 145 [details] nyquist script This bug was reported on Debian: http://bugs.debian.org/617599 I have a nyquist script using snd-fft api which have a random beaviour on my computer where floats are 32 bits and long 64 bits. Each time I execute the script, result is different, when it should be about equal. I 'd like to know if same random issue occur on 32 bits systems. To reproduce the bug. Use a 64 amd processor. Install the nyquist script in ~/.audacity-files/plug-ins/fft.ny >From a console, launch audacity. If you cannot load a sound with bass such as bachata, use the audacity menu: Générer/Sons/ Sinuosiadal 40Hz Amplitue 0,8 or nicer and more audible : Générer/Risset Drum/50 Hz Decay 2s Launch the FFT script from Analyse/FFT ... Choose to Validate or Debug And look the 60 values displayed in the console. Values about offset 40 or 50 are assumed to be greater than others for a signal frequency around 40 or 50 Hz.. Here is a patch that probably only work on amd 64 bits machines and compatibles as it assumes sizeof long equals sizeof double.
Created attachment 146 [details] nyquist.patch
Hi Benjamin, sorry for the long delay, but I looked at this patch and found some issues. The other thing is, I (am not sure, but I) think nyquist is maintained separately from audacity, please let us know if you sent it upstream so we don't have to. > --- ./lib-src/libnyquist/nyquist/nyqsrc/fft.c.original 2011-03-10 21:44:23.000000000 +0100 > +++ ./lib-src/libnyquist/nyquist/nyqsrc/fft.c 2011-03-10 21:58:01.000000000 +0100 [...] > @@ -138,9 +138,9 @@ LVAL snd_fft(sound_type s, long len, lon > maxlen = ((s->extra[0] / sizeof(long)) - OFFSET) / 3; > if (maxlen != len) xlfail("len changed from initial value"); > } > - samples = (float *) &(s->extra[OFFSET]); > + samples = (double *) &(s->extra[OFFSET]); > temp_fft = samples + len; > - window = temp_fft + len; > + window = samples + 2* len; > /* step 1: refill buffer with samples */ > fillptr = s->FILLCNT; > while (fillptr < maxlen) { The patch makes the same mistake as the bug, and assumes the size of these types are the 64 bit size. (I'm guessing the original bug is assuming the types are the 32 bit size.) s->extra is allocated as a long buffer, and then treated as a double with the assumption that sizeof(double)==sizeof(long), which blows up on my machine since they are different. FYI I am running 32 bit ubuntu, so sizeof(double)!=sizeof(long), here's my output
Added Roger to Cc list. Added "patch" and "nyquist" keywords. Might have been helpful if the report had included a link to "fft.ny". Is there any reason to suppose this is platform-specific?
Good point, Gale - this probably also breaks on other (non-linux) 64 bit systems.
This is confusing to me. Longs are 32 bits unless you compile for a 64-bit architecture. Nyquist assumes a 32-bit architecture. If you want to run Nyquist on a 64-bit architecture, I think this bug is one of many places where the 32-bit assumption is important, but only one. I'm very interested in making Nyquist compile on a 64-bit architecture, or more specifically, compile when sizeof(long) > 4, but this will require a systematic review.
*** STEPS UPDATED *** (and title too). Title was: Nyquist snd_fft: random script output 32 bits float versus 64 bits long Changed to Enh: Support 64 bit in Nyquist.
I think Nyquist is fully 64-bit compatible. The code in question has been changed in the Nyquist release upstream and we've used the 64-bit version for a couple hundred students over a few semesters, which is not to say every esoteric feature is well-tested, but it seems pretty solid.
*** STEPS UPDATED *** Title changed too to reflect comment 7
Changed hardware to linux, since we do not (yet) distribute 64 bit Audacity on Mac or Windows. (I'm actually checking a bug in our bugzilla here, so you can ignore this comment entirely :-) )
Back to All-Platforms, as we may be supporting 64 bit (for Mac) in 2.3.1, and if so will probably shift to 64 bit on all platforms.
While not having tested specifically for this on 64-bit Audacity on Mac - the Nyquist plug-ins and Nyquist Prompt all seem to work fine. Is this bug closable?
In the light of comment #7, and absence of related problems being reported since then, I'm closing this as Fixed.