Re: [Audacity-nyquist] newest rectifier plugs
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
From: Alex S. B. <ale...@al...> - 2005-11-29 18:49:15
|
I cannot speak to your DC/filter issues, but I have used the snd-fetch function quite a bit working on sound detection. I would warn you that snd-fetch is best used as a one-pass method to examine and manipulate a sound. If you try to keep the whole sound in memory and use snd-fetch to move through it, the RAM use for your script will grow dramatically with the length of the sound. Basically, Nyquist will read the entire sound into memory and hold onto the whole thing until the script is done. Depending on your algorithm, there may be ways around this effect, but generally snd-fetch does not let you go backwards or do random access within the sound. I believe Nyquist will accumulate all the samples in RAM if you try to hold onto the sound variable while using snd-fetch to move through it. The DSP in XLisp chapter is excellent to start working with those functions, but the memory utilization of these functions takes some time to understand. The plug-ins that ship with Audacity actually suffers from some of these problems. Others on this mailing list helped me a lot to fix up my plug-ins. I think your proposal of using snd-fetch to add the samples into a single variable would either destroy the sound variable or accumulate all samples in memory if you tried to keep a copy of the sound variable. There may be a built-in function of Nyquist that does a similar calculation, without the memory problems. Something like snd-avg might help, although sometimes these functions have the same memory-use problems as snd-fetch. If anyone has suggestions, please jump in! I hate posting a reply only about the problems of a suggested approach. Quoting edg...@we...: [snip] > Now there are two problems. First, Nyquist is designed to work in one pass > only. This not a bad idea because this way cou can work with a minimum of > memory because all audio data can be left on the hard disc, in principle > only the actual sample is needed. But this leads to the next problem: if > you want to write a two pass filter you have to keep the sound in memory > between the first and the second pass by assigning it for example to a > global variable what quickly can lead to a memory overflow depending to > the length of the audio. > > There could be a solution by using the snd-fetch function with that you can > access single sample values. For example like fetch the first sample and > save its value in a variable, then fetch the second sample, add it to the > value in the variable and store the result again in the same variable. By > adding up all samples one after the other in the same variable and dividing > the variable value at the end by the number of samples that is given by the > len variable you could calculate the average off all samples with only one > variable. > > But this is only a theory because I never have worked with the snd-fetch > function and neither with the xlisp object system that is needed for this. > Maybe Steven or Sami (or whoever reads this) knows how to do. Or maybe > this is a reason to learn more about the xlisp object system. > > The snd-fetch function and how this could work is explained in the Nyquist > manual under "DSP in XLisp". ---------------------- Alex S. Brown, PMP ale...@al... http://www.alexsbrown.com/ |