Hi Marinus and Steve!
Only to make the rest of the forum know what we are talking about, here two links to Trevor Wishart's Homepage
ant the Books
he has written.
I think was Marinus wants to do is a form of Granular Synthesis
, not with arbitrary 'grains', but with clearly defined 'wavesets', starting and stopping at zero-crossings (if I have understood this right). Nyquist has no automatically built-in support for granular synthesis, but the missing functions could by written by hand. Here is how this could work:
- Analysis to get the sample-index of the zero-crossing of every waveset - Not impossible but must be written by hand. The implementation of Nyquist in Audacity has the problem that for sample-based analysis to find the zero-crossings, the entire selected sound from the Audacity track must be loaded into memory. This will crash Audacity with long sounds if Audacity runs out of memory. CMU Nyquist does not have this problem.
- Storage of the sample-index in a buffer - I'm not quite sure what you mean here. With Nyquist you could either store all samples between the zero-crossings as a Nyquist wavetable to use it in a wavetable oscillator, or you could store the start and stop times of every waveset or the times of all zero-crossings in seconds or as sample numbers in Lisp variables or a Lisp array. The 'most natural way' with Nyquist would be to store the wavesets as wavetables and use them in wavetable oscillators. This way you could pitch every waveset up or down an arbitrary amount of Hertz or MIDI steps, and also repeat every waveset an arbitrary number of times, i.e. you could play wavesets like notes, where Nyquist 'MIDI steps' and 'notes' are just simply floating-point numbers, not limited to 128 MIDI key numbers. Everything needed for this is already built-in.
- Creation of a variable length temporary buffer/ or better the new sound-file - Nyquist produces sounds on a sample-by-sample basis (not really, in blocks of 1024 samples each). CMU Nyquist tries to write out the samples into a soundfile as fast as possible to free the memory. Nyquist in Audacity tries to return the samples to Audacity as fast as it can, where it's left to Audacity to write the samples into the project's audio files.
- According to the amount of repitions of a waveset write it to the temporary buffer - No problem, that's what Nyquist does by default.
- Repeat for every waveset the last step - Yes, of course, no problem.
- Replace or create sound-file with the result of this processing - Nyquist in Audacity automatically returns the temporary sample buffer back into the Audacity track. If the returned sound has a different length than the originally selected sound then the length of the Audacity selection is automatically changed to the new length.
The only thing that would need to be written from scratch ist the function to split a sound into wavesets and to find the zero-crossings. Nyquist has built-in functions to fade from one waveset to the next during composition.
If you want to perform the proceedings into two steps:
- Decomposition - Split an arbitrary sound file into wavesets and store every waveset in its own sound file.
- Composition - Combine an arbitrary number of wavesets from separate soundfiles into a new bigger audio sound file.
Then this task wold probably easier to solve with the standalone Nyquist version:
The Nyquist 3.0x zip-file from the download page contains a file "lib/gran.lsp" with some basic example code for granular synthesis.