## audacity-nyquist

 [Audacity-nyquist] RE: [Audacity-users] Anti-aliasing Finite Impulse Response (FIR) filter (fwd) From: David R. Sky - 2006-03-21 08:08:40 ```Hi, I'd like to help the sender of the following email in creating the plug-in he describes, but there are several things I don't yet understand. I'm not experienced enough with Nyquist/dsp yet to understand much of what Gary is talking about, and I'd like to learn. Is there somewhere in particular any of you would suggest starting (to learn)? Thanks David ---------- Forwarded message ---------- From: Gary Nelson < Subject: RE: [Audacity-users] Anti-aliasing Finite Impulse Response (FIR) filter David We need to convolve the impulse response of our FIR filter with the audio file in 32-bit floating mode. The impulse response is an even function so we add a pair of samples to left and right of a center point and multiply by a filter coefficient. A trivial filter would have three coefficients, say .25, .5, .25. The coefficients add to 1 so that the filter has unity gain. We can make the filter have any gain by making the sum of the filter coefficients equal the desired gain. To convolve this filter with a file of audio samples, we would pad the file with an extra zero sample at each end, then position the filter centered on the first sample, add the sample to the left to the sample to the right, multiply by .25 and add the center sample * .5 to get the first filtered result. Then move the filter to the right one sample and do it again to create the second output sample. Slide the filter past all the audio samples to create the filtered output. If we want to discard every other sample, we can slide the filter to the right 2 samples to create the second desired output. The filter we will want to use will also have an odd number of samples where all the sample pairs at equal distances from the center will have the same value -- ie, if we folded the impulse response about the center sample, the halves would be identical. That is the definition of an even function. The filter we want will have perhaps 1001 or so samples, but the concept will be the same as the trivial example above. What say we make the trivial example work to get the concept and structure of the solution, then expand to any number of samples. We can test the results by using the function and run our filter over it and then plot the spectrum. Also, if we can put the impulse response in an audio file and run the spectrum, we will see the transfer function of the filter. I think we want to make this filter start rolling off at about 19kHz and be down 100 dB by 22kHz and have no funny side lobes above 22.05kHz that will alias back into our audio band. Let's make this work without the decimation (bimation) first, and then add that feature. I don't understand how we will change the resulting file characteristics to say that its sample rate is 44.1 instead of 88.2. The file will be half as long and that also will need to be handled. I have perused the Nyquist documents and a couple examples, but can't say that I have any idea how to do this problem. I wrote a lot of these filter algorithms in assembly language years ago but am rusty to say the least. Thanks Gary Nelson ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 -- Mailing list: Audacity-users@... To UNSUBSCRIBE, use the form at the bottom of this web page: https://lists.sourceforge.net/lists/listinfo/audacity-users ```
 RE: [Audacity-nyquist] RE: [Audacity-users] Anti-aliasing Finite Impulse Response (FIR) filter (fwd) From: Gary Nelson - 2006-03-21 16:26:32 ```David Thanks. I have followed your move to this list. Is there any filter program we can start with to see how filtering is done? Apparently Nyquist is an interpreted language? Is there any compiled version that we can use after we understand what wants to be done and we need to get more speed? Thanks Gary -----Original Message----- From: audacity-nyquist-admin@... [mailto:audacity-nyquist-admin@...] On Behalf Of David R. Sky Sent: Tuesday, March 21, 2006 12:09 AM To: Audacity-nyquist@... Subject: [Audacity-nyquist] RE: [Audacity-users] Anti-aliasing Finite Impulse Response (FIR) filter (fwd) Hi, I'd like to help the sender of the following email in creating the plug-in he describes, but there are several things I don't yet understand. I'm not experienced enough with Nyquist/dsp yet to understand much of what Gary is talking about, and I'd like to learn. Is there somewhere in particular any of you would suggest starting (to learn)? Thanks David ---------- Forwarded message ---------- From: Gary Nelson < Subject: RE: [Audacity-users] Anti-aliasing Finite Impulse Response (FIR) filter David We need to convolve the impulse response of our FIR filter with the audio file in 32-bit floating mode. The impulse response is an even function so we add a pair of samples to left and right of a center point and multiply by a filter coefficient. A trivial filter would have three coefficients, say .25, .5, .25. The coefficients add to 1 so that the filter has unity gain. We can make the filter have any gain by making the sum of the filter coefficients equal the desired gain. To convolve this filter with a file of audio samples, we would pad the file with an extra zero sample at each end, then position the filter centered on the first sample, add the sample to the left to the sample to the right, multiply by .25 and add the center sample * .5 to get the first filtered result. Then move the filter to the right one sample and do it again to create the second output sample. Slide the filter past all the audio samples to create the filtered output. If we want to discard every other sample, we can slide the filter to the right 2 samples to create the second desired output. The filter we will want to use will also have an odd number of samples where all the sample pairs at equal distances from the center will have the same value -- ie, if we folded the impulse response about the center sample, the halves would be identical. That is the definition of an even function. The filter we want will have perhaps 1001 or so samples, but the concept will be the same as the trivial example above. What say we make the trivial example work to get the concept and structure of the solution, then expand to any number of samples. We can test the results by using the function and run our filter over it and then plot the spectrum. Also, if we can put the impulse response in an audio file and run the spectrum, we will see the transfer function of the filter. I think we want to make this filter start rolling off at about 19kHz and be down 100 dB by 22kHz and have no funny side lobes above 22.05kHz that will alias back into our audio band. Let's make this work without the decimation (bimation) first, and then add that feature. I don't understand how we will change the resulting file characteristics to say that its sample rate is 44.1 instead of 88.2. The file will be half as long and that also will need to be handled. I have perused the Nyquist documents and a couple examples, but can't say that I have any idea how to do this problem. I wrote a lot of these filter algorithms in assembly language years ago but am rusty to say the least. Thanks Gary Nelson ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 -- Mailing list: Audacity-users@... To UNSUBSCRIBE, use the form at the bottom of this web page: https://lists.sourceforge.net/lists/listinfo/audacity-users ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Audacity-nyquist mailing list Audacity-nyquist@... https://lists.sourceforge.net/lists/listinfo/audacity-nyquist ```
 RE: [Audacity-nyquist] RE: [Audacity-users] Anti-aliasing Finite Impulse Response (FIR) filter (fwd) From: David R. Sky - 2006-03-21 17:17:33 ```Gary wrote: > Thanks. I have followed your move to this list. > Is there any filter program we can start with to see how filtering is done? David: It sounds like you want some type of lowpass filter. There are several which are ready-to-work in Audacity: lp, lowpass2, lowpass4, lowpass6 and lowpass8, from single to 8-pole Butterworth. (The lowpass filter under the Audacity effects menu uses the lp function. In Audacity, the sound which has been selected is by default 's'. If we call the cutoff frequency 'f', lp works like this: (lp s f) which works on mono and stereo signals. Lowpass2 through lowpass8 need a bit of code addition in order to work on stereo audio, but that's quite simple. You can test what the effects of running any Nyquist function by first selecting some audio in Audacity then using the Nyquist Prompt under the effects menu. With each of these lowpass filters the layout is the same: lowpass function, s, cutoff frequency. For instance: (lowpass2 s 1000) Gary: > Apparently Nyquist is an interpreted language? Is there any compiled > version that we can use after we understand what wants to be done and we > need to get more speed? > David: Yes, there is a 'stand-alone' version of Nyquist, which can be accessed somewhere on Roger Dannenberg's website http://www.cs.cmu.edu/~music/nyquist I may have missed an 'rbd/' before the music/. I have rarely used the stand-alone version because it doesn't work with my screen reader. In regard to processing at 88.2 khz, I think that can be done using 'force-srate' (force-srate 88200 {other code}) I _suspect_ you could try this with a lowpass filter: (force-srate 88200 (lp s 44100)) which I think means 'apply a single-pole lowpass filter at cutoff frequency 44.1khz and sampling rate of 88.2khz'. I'm not sure if you already need your audio to have been sampled at 88.2khz. David ```
 RE: [Audacity-nyquist] How do I make Nyquist work in Audacity? From: Gary Nelson - 2006-03-21 19:12:42 ```David, I have the source for your Buzz Generator. I wonder if we could tag up by phone. I would appreciate a walk through of that code to understand how it works. I don't see how to get it into Audacity. I can call you as I have a flat rate phone service as long as you are in the US GN ```
 RE: [Audacity-nyquist] Anti-aliasing Finite Impulse Response (FIR) filter (fwd) From: Alex S. Brown - 2006-03-21 20:35:18 ```Gary, Besides using the stand-alone Nyquist, you can also write compiled plug ins for Audacity or for Nyquist itself. In that way you could use Nyquist as a prototyping language and then write a compilable version in C or some other language. Audacity supports LADSPA and VST plug-ins. See http://audacity.sourceforge.net/download/plugins for details. I do not know how to write them, but I understand these plug-ins can be authored and compiled. The full Nyquist documentation, which comes with the standalone package, includes instructions on how to write plug-ins for Nyquist. That might be the best of both worlds for you. You can read more in Appendix 1: http://www.cs.cmu.edu/~rbd/doc/nyquist/part14.html#139 If you review the whole documentation set, you will find other ways to link Nyquist into other libraries. Here is the main on-line documentation group: http://www.cs.cmu.edu/~rbd/doc/nyquist/root.html I see ways to call C routines, if you need to. I emphasize that I have never done these extensions myself, and some may not work with Audacity's version of Nyquist, but they are tools to try out. Quoting "David R. Sky" : > Gary wrote: > > Apparently Nyquist is an interpreted language? Is there any compiled > > version that we can use after we understand what wants to be done and we > > need to get more speed? > > > David: > Yes, there is a 'stand-alone' version of Nyquist, which can be accessed > somewhere on Roger Dannenberg's website > > http://www.cs.cmu.edu/~music/nyquist > ---------------------- Alex S. Brown, PMP alexsbrown@... http://www.alexsbrown.com/ http://www.linkedin.com/in/alexsbrown ```