Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 336 - Enh: Support (and test) 64 bit Nyquist in Audacity.
Enh: Support (and test) 64 bit Nyquist in Audacity.
Status: CLOSED FIXED
Product: Audacity
Classification: Unclassified
Component: Nyquist
1.3.12
Per OS macOS and Linux
: P5 Enhancement
Assigned To: Default Assignee for New Bugs
: nyquist, patch
Depends on: 564
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-26 16:16 UTC by Benjamin Drung
Modified: 2019-05-26 11:48 UTC (History)
4 users (show)

See Also:
Steps To Reproduce:
Nyquist compiled for 64 bit is untested in Audacity, possibly needing to use a nyquist library update from upstream.
Release Note:
First Git SHA:
Group: 64Bit
Workaround:
Closed: 2019-05-26 00:00:00


Attachments
nyquist script (780 bytes, application/octet-stream)
2011-03-26 16:16 UTC, Benjamin Drung
Details
nyquist.patch (3.64 KB, patch)
2011-03-26 16:16 UTC, Benjamin Drung
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Drung 2011-03-26 16:16:22 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.
Comment 1 Benjamin Drung 2011-03-26 16:16:38 UTC
Created attachment 146 [details]
nyquist.patch
Comment 2 Michael Chinen 2012-01-15 21:06:17 UTC
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
Comment 3 Gale Andrews 2012-01-16 09:12:00 UTC
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?
Comment 4 Michael Chinen 2012-01-16 13:48:25 UTC
Good point, Gale - this probably also breaks on other (non-linux) 64 bit systems.
Comment 5 Roger Dannenberg 2012-01-16 14:49:39 UTC
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.
Comment 6 James Crook 2017-08-11 12:45:44 UTC
*** 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.
Comment 7 Roger Dannenberg 2017-08-11 23:39:58 UTC
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.
Comment 8 James Crook 2017-08-12 05:59:32 UTC
*** STEPS UPDATED ***

Title changed too to reflect comment 7
Comment 9 James Crook 2017-11-29 12:34:23 UTC
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 :-) )
Comment 10 James Crook 2018-09-05 10:04:49 UTC
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.
Comment 11 Peter Sampson 2019-05-26 07:24:13 UTC
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?
Comment 12 Steve Daulton 2019-05-26 09:39:55 UTC
In the light of comment #7, and absence of related problems being reported since then, I'm closing this as Fixed.