Quotes from the Nyquist Wish List, posts 155498, 179094, and 179118:
Looking at the code in audacity/src/effects/Generator.cpp (that’s where the empty audio track is created) I see that the problem is that Audacity creates the sound block-wise (the .au files in the _data directory), so the Audacity sound infrastructure must be initialized before the sound is generated. This is a reasonable behavior, because otherwise Audacity would crash if the generated sound is bigger than the computer’s memory.
The proceeding is approximately like this:
- Initialize a temporary memory buffer and draw an empty audio track
- Compute samples until the buffer is full, draw the related part of the waveform and write the buffer into an .au file
- Repeat the second step until the sound is fully generated
Drawing the waveform step-wise from the samples in memory is faster than from samples read from disk. But working this way also means that the creation of the Audacity sound object cannot be delayed until the code from a Nyquist plugin has finished (to investigate if the returned value is a sound or a label list), because if the returned sound is bigger than the memory, then at that time Audacity already would have crashed.
This is the reason why in case of a Nyquist plugin, the empty audio track is created first, then the plugin code is run, and if the plugin returnes a value that is not a sound, an empty audio track remains. The other reason is that the built-in Audacity Generate effects do not return anything other than a sound, so there is no infrastructure provided to remove the empty audio track if the returned value is not a sound. But it probably would look the same kind of annoying if first an empty audio track appears that some time later mystically disappears again.
Another problem is that the only reason why returning label-lists works with Process and Analyze plugins is that these plugins compute the sound in memory, so the returned value can be tested for being a sound, a string, or a label-list. This means that fixing the Nyquist memory problems would make it impossible to return strings or label-lists from Process and Analyze plugins, too.
Conclusions:
- The infrastructure in Generator.cpp would need to be rewritten to make Nyquist Generate effects produce label lists only, or multi-channel sounds.
- The Nyquist s (= sixteenth) variable would need to be clobbered again to make it possible to detect the number of channels for multi-channel sounds.
- Using the Nyquist s variable for the Audacity sound object was the most stupid idea ever.
We need a better Nyquist infrastructure. The particular problem here is that rewriting the Generator.cpp infrastructure is a non-trivial task.
I still think that putting “Regular Interval Labels” into the Analyze menu is a bug, but I also have no idea how to change this in an easy way.
Question: Has anybody an idea how a Nyquist plugin could signal the return-type (sound, string, label-list), e.g. at the time after the plugin header has been parsed by the Audacity Nyquist interface?
- edgar