Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.
Close
From: Johnny Rosenberg <gurus.knugum@gm...>  20101129 16:14:11

I'm trying to learn some basics of Nyquist for creating Audacity effects. Of course there are a lot of things that I don't understand yet, but here is what I need to know at the moment: I want to create a cosine (actually two – one 0180° and one 180360°). I already figured out that there is no cosine function available, so I guess I need to fiddle with a sine wave somehow. Actually, what I'm trying to achieve, is something like k·(½cos(x)+½), where x=0180° and 180360° respectively, but once I figure out the cos(x) thing I guess the rest shouldn't be too hard to do. Let's just say that I want to create a cos wave from 180° to 360° for now. So I searched a bit among the predefined functions in the Nyquist manual and found a few that I guess could come in handy in this case: (sine freq time) (osc pitch [duration table phase]) Let's say that the available variables are the following: time=5 ms (I guess that the sine function needs the time in seconds, so let's say the actual value of time is 0.005). This is the time from 180° to 360° of the final cosine wave (270450° of a sine wave), so I guess we should send 2*time to the sine function. The sine wave should of course be at least 1¼ period, that is 450°, to make this possible. freq=100 Hz – that is 1/(2*time) duration=5 ms, right? phase=270° pitch=(hztostep 1/time/4) or what? What else I don't understand is that table thing. How do I handle that? It would be nice if someone could write some simple code that illustrates how to use those functions I mentioned above.  Kind regards Johnny Rosenberg 
From: Johnny Rosenberg <gurus.knugum@gm...>  20101129 16:14:11

I'm trying to learn some basics of Nyquist for creating Audacity effects. Of course there are a lot of things that I don't understand yet, but here is what I need to know at the moment: I want to create a cosine (actually two – one 0180° and one 180360°). I already figured out that there is no cosine function available, so I guess I need to fiddle with a sine wave somehow. Actually, what I'm trying to achieve, is something like k·(½cos(x)+½), where x=0180° and 180360° respectively, but once I figure out the cos(x) thing I guess the rest shouldn't be too hard to do. Let's just say that I want to create a cos wave from 180° to 360° for now. So I searched a bit among the predefined functions in the Nyquist manual and found a few that I guess could come in handy in this case: (sine freq time) (osc pitch [duration table phase]) Let's say that the available variables are the following: time=5 ms (I guess that the sine function needs the time in seconds, so let's say the actual value of time is 0.005). This is the time from 180° to 360° of the final cosine wave (270450° of a sine wave), so I guess we should send 2*time to the sine function. The sine wave should of course be at least 1¼ period, that is 450°, to make this possible. freq=100 Hz – that is 1/(2*time) duration=5 ms, right? phase=270° pitch=(hztostep 1/time/4) or what? What else I don't understand is that table thing. How do I handle that? It would be nice if someone could write some simple code that illustrates how to use those functions I mentioned above.  Kind regards Johnny Rosenberg 
From: Roger Dannenberg <rbd@cs...>  20101129 17:01:09

This is in nyquist/lib/spectrum.lsp: (defun raisedcosine () (scale 0.5 (sum (const 1) (lfo (/ 1.0 (getduration 1)) 1 *sinetable* 270)))) Quick explanation: a raisedcosine is a smooth envelope you get from 1cos(x) over one period. Note that the "" flips the negativegoing cosine curve to a positive pulse, and the offset makes it start and return to zero. Is this what you are trying to do? The duration here is given by the environment (so in Audacity, the duration would be that of the selection). Specifically, the duration is the second argument, 1, to LFO but this is scaled by the duration from the environment. The frequency is scaled to 1/dur to get one period. For this, (GETDURATION 1) returns the duration, and this is converted from period to frequency by division. The waveform is *SINETABLE* and the initial phase of the sine table is 270. (I could have used an initial phase of 90 to get Cosine, but 270 gives us negative Cosine, which is what we want.) The output is at the default control sample rate (probably 2205Hz). You could run this in (controlsrateabs 44100 (raisedcosine)) to get a different sample rate. Roger On 11/29/10 11:14 AM, Johnny Rosenberg wrote: > I'm trying to learn some basics of Nyquist for creating Audacity effects. > Of course there are a lot of things that I don't understand yet, but here > is what I need to know at the moment: > > I want to create a cosine (actually two – one 0180° and one 180360°). I > already figured out that there is no cosine function available, so I guess > I need to fiddle with a sine wave somehow. > > Actually, what I'm trying to achieve, is something like k·(½cos(x)+½), > where x=0180° and 180360° respectively, but once I figure out the cos(x) > thing I guess the rest shouldn't be too hard to do. Let's just say that I > want to create a cos wave from 180° to 360° for now. > > So I searched a bit among the predefined functions in the Nyquist manual > and found a few that I guess could come in handy in this case: > > (sine freq time) > (osc pitch [duration table phase]) > > Let's say that the available variables are the following: > time=5 ms (I guess that the sine function needs the time in seconds, so > let's say the actual value of time is 0.005). This is the time from 180° > to 360° of the final cosine wave (270450° of a sine wave), so I guess we > should send 2*time to the sine function. The sine wave should of course be > at least 1¼ period, that is 450°, to make this possible. > > freq=100 Hz – that is 1/(2*time) > > duration=5 ms, right? > > phase=270° > > pitch=(hztostep 1/time/4) or what? > > What else I don't understand is that table thing. How do I handle that? > > It would be nice if someone could write some simple code that illustrates > how to use those functions I mentioned above. > > 
From: Johnny Rosenberg <gurus.knugum@gm...>  20101129 20:29:44

Den 20101129 18:01:03 skrev Roger Dannenberg <rbd@...>: > This is in nyquist/lib/spectrum.lsp: > > (defun raisedcosine () > (scale 0.5 > (sum (const 1) > (lfo (/ 1.0 (getduration 1)) 1 *sinetable* 270)))) > > Quick explanation: a raisedcosine is a smooth envelope you get from > 1cos(x) over one period. Note that the "" flips the negativegoing > cosine curve to a positive pulse, and the offset makes it start and > return to zero. Is this what you are trying to do? Yes, but this was only an example that is somewhat simpler than what I really want to do. I don't want you to do my work for me, I just want to know better how it works… But the idea is to start at somewhere between 0 and 1, ending up at 1. It is supposed to be some kind of envelope that I'm going to multiply by a sound later on. I am planning to do some kind of brickwall limiter (I was writing a lot about that a couple of years ago but it ended up with nothing and now I want to try again…). It seems like the existing envelope functions are linear and I am not sure that gives the absolute best sound quality. My thought is that if I use the shape of a cosine wave there will only be one overtone. A ramp has a lot of them. No matter if I'm right or wrong, at least I want to test my idea. Maybe I will be very disappointed, but then at least I tried. Your example above will probably be enough to get me started, but I wouldn't be surprised if I come back with more questions… > The duration here is > given by the environment (so in Audacity, the duration would be that of > the selection). Specifically, the duration is the second argument, 1, to > LFO but this is scaled by the duration from the environment. The > frequency is scaled to 1/dur to get one period. For this, (GETDURATION > 1) returns the duration, and this is converted from period to frequency > by division. The duration I am looking for will be user defined, probably around 510 ms or so. What I am going to do is to look for peaks exceeding a certain level and then reduce them to that certain level, one by one. So I will also need a (modified) cosine 0180° but the duration for that one isn't necessarily the same as for the other one… > The waveform is *SINETABLE* and the initial phase of the > sine table is 270. (I could have used an initial phase of 90 to get > Cosine, but 270 gives us negative Cosine, which is what we want.) But then me need more than one period of the sine wave, don't we? We need to end at 450°, right? > > The output is at the default control sample rate (probably 2205Hz). That sounds quite absurd. Why 2205 Hz? 1/20 of 44100 Hz…? > You > could run this in (controlsrateabs 44100 (raisedcosine)) to get a > different sample rate. > > Roger Thanks for your reply, Roger. I am going to do some more thinking about this, I guess. Regards Johnny Rosenberg > On 11/29/10 11:14 AM, Johnny Rosenberg wrote: >> I'm trying to learn some basics of Nyquist for creating Audacity >> effects. >> Of course there are a lot of things that I don't understand yet, but >> here >> is what I need to know at the moment: >> >> I want to create a cosine (actually two – one 0180° and one 180360°). >> I >> already figured out that there is no cosine function available, so I >> guess >> I need to fiddle with a sine wave somehow. >> >> Actually, what I'm trying to achieve, is something like k·(½cos(x)+½), >> where x=0180° and 180360° respectively, but once I figure out the >> cos(x) >> thing I guess the rest shouldn't be too hard to do. Let's just say that >> I >> want to create a cos wave from 180° to 360° for now. >> >> So I searched a bit among the predefined functions in the Nyquist >> manual >> and found a few that I guess could come in handy in this case: >> >> (sine freq time) >> (osc pitch [duration table phase]) >> >> Let's say that the available variables are the following: >> time=5 ms (I guess that the sine function needs the time in seconds, so >> let's say the actual value of time is 0.005). This is the time from 180° >> to 360° of the final cosine wave (270450° of a sine wave), so I guess >> we >> should send 2*time to the sine function. The sine wave should of course >> be >> at least 1¼ period, that is 450°, to make this possible. >> >> freq=100 Hz – that is 1/(2*time) >> >> duration=5 ms, right? >> >> phase=270° >> >> pitch=(hztostep 1/time/4) or what? >> >> What else I don't understand is that table thing. How do I handle that? >> >> It would be nice if someone could write some simple code that >> illustrates >> how to use those functions I mentioned above. >> >> > >  > Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! > Tap into the largest installed PC base & get more eyes on your game by > optimizing for Intel(R) Graphics Technology. Get started today with the > Intel(R) Software Partner Program. Five $500 cash prizes are up for > grabs. > http://p.sf.net/sfu/intelispdev2dev > _______________________________________________ > Audacitynyquist mailing list > Audacitynyquist@... > https://lists.sourceforge.net/lists/listinfo/audacitynyquist 
From: Roger Dannenberg <rbd@cs...>  20101129 20:52:45

On 11/29/10 3:29 PM, Johnny Rosenberg wrote: > Den 20101129 18:01:03 skrev Roger Dannenberg<rbd@...>: > >> This is in nyquist/lib/spectrum.lsp: >> >> (defun raisedcosine () >> (scale 0.5 >> (sum (const 1) >> (lfo (/ 1.0 (getduration 1)) 1 *sinetable* 270)))) >> >> Quick explanation: a raisedcosine is a smooth envelope you get from >> 1cos(x) over one period. Note that the "" flips the negativegoing >> cosine curve to a positive pulse, and the offset makes it start and >> return to zero. Is this what you are trying to do? > Yes, but this was only an example that is somewhat simpler than what I > really want to do. I don't want you to do my work for me, I just want to > know better how it works… But the idea is to start at somewhere between 0 > and 1, ending up at 1. This was supposed to be just an example. It goes from 0 to 1 and back, so it's similar. If the LFO ran at half the frequency, it would end at 1 instead of coming back down. > It is supposed to be some kind of envelope that I'm > going to multiply by a sound later on. I am planning to do some kind of > brickwall limiter (I was writing a lot about that a couple of years ago > but it ended up with nothing and now I want to try again…). It seems like > the existing envelope functions are linear and I am not sure that gives > the absolute best sound quality. My thought is that if I use the shape of > a cosine wave there will only be one overtone. A ramp has a lot of them. > > No matter if I'm right or wrong, at least I want to test my idea. Maybe I > will be very disappointed, but then at least I tried. Your example above > will probably be enough to get me started, but I wouldn't be surprised if > I come back with more questions… > >> The duration here is >> given by the environment (so in Audacity, the duration would be that of >> the selection). Specifically, the duration is the second argument, 1, to >> LFO but this is scaled by the duration from the environment. The >> frequency is scaled to 1/dur to get one period. For this, (GETDURATION >> 1) returns the duration, and this is converted from period to frequency >> by division. > The duration I am looking for will be user defined, probably around 510 > ms or so. What I am going to do is to look for peaks exceeding a certain > level and then reduce them to that certain level, one by one. So I will > also need a (modified) cosine 0180° but the duration for that one isn't > necessarily the same as for the other one… Since Nyquist automatically stretches behaviors to the selection duration, you need to explicitly override that default to get a shorter duration. The normal way is using STRETCH to change duration by a ratio, and STRETCHABS to get a fixed duration, e.g. (STRETCHABS 0.01 (RAISEDCOSINE)) >> The waveform is *SINETABLE* and the initial phase of the >> sine table is 270. (I could have used an initial phase of 90 to get >> Cosine, but 270 gives us negative Cosine, which is what we want.) > But then me need more than one period of the sine wave, don't we? We need > to end at 450°, right? Right. LFO is "low frequency oscillator"  it is a table lookup oscillator that produces a periodic signal of any length generated from one period stored in a table. >> The output is at the default control sample rate (probably 2205Hz). > That sounds quite absurd. Why 2205 Hz? 1/20 of 44100 Hz…? Yes. You can change the default if you don't like it, but it's a reasonable control rate. >> You >> could run this in (controlsrateabs 44100 (raisedcosine)) to get a >> different sample rate. >> >> Roger > Thanks for your reply, Roger. I am going to do some more thinking about > this, I guess. You might also look at the dynamics compressor in nyquist/lib/compress.lsp as well as the comments. > Regards > > Johnny Rosenberg > > > >> On 11/29/10 11:14 AM, Johnny Rosenberg wrote: >>> I'm trying to learn some basics of Nyquist for creating Audacity >>> effects. >>> Of course there are a lot of things that I don't understand yet, but >>> here >>> is what I need to know at the moment: >>> >>> I want to create a cosine (actually two – one 0180° and one 180360°). >>> I >>> already figured out that there is no cosine function available, so I >>> guess >>> I need to fiddle with a sine wave somehow. >>> >>> Actually, what I'm trying to achieve, is something like k·(½cos(x)+½), >>> where x=0180° and 180360° respectively, but once I figure out the >>> cos(x) >>> thing I guess the rest shouldn't be too hard to do. Let's just say that >>> I >>> want to create a cos wave from 180° to 360° for now. >>> >>> So I searched a bit among the predefined functions in the Nyquist >>> manual >>> and found a few that I guess could come in handy in this case: >>> >>> (sine freq time) >>> (osc pitch [duration table phase]) >>> >>> Let's say that the available variables are the following: >>> time=5 ms (I guess that the sine function needs the time in seconds, so >>> let's say the actual value of time is 0.005). This is the time from 180° >>> to 360° of the final cosine wave (270450° of a sine wave), so I guess >>> we >>> should send 2*time to the sine function. The sine wave should of course >>> be >>> at least 1¼ period, that is 450°, to make this possible. >>> >>> freq=100 Hz – that is 1/(2*time) >>> >>> duration=5 ms, right? >>> >>> phase=270° >>> >>> pitch=(hztostep 1/time/4) or what? >>> >>> What else I don't understand is that table thing. How do I handle that? >>> >>> It would be nice if someone could write some simple code that >>> illustrates >>> how to use those functions I mentioned above. >>> >>> >>  >> Increase Visibility of Your 3D Game App& Earn a Chance To Win $500! >> Tap into the largest installed PC base& get more eyes on your game by >> optimizing for Intel(R) Graphics Technology. Get started today with the >> Intel(R) Software Partner Program. Five $500 cash prizes are up for >> grabs. >> http://p.sf.net/sfu/intelispdev2dev >> _______________________________________________ >> Audacitynyquist mailing list >> Audacitynyquist@... >> https://lists.sourceforge.net/lists/listinfo/audacitynyquist >  > Increase Visibility of Your 3D Game App& Earn a Chance To Win $500! > Tap into the largest installed PC base& get more eyes on your game by > optimizing for Intel(R) Graphics Technology. Get started today with the > Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. > http://p.sf.net/sfu/intelispdev2dev > _______________________________________________ > Audacitynyquist mailing list > Audacitynyquist@... > https://lists.sourceforge.net/lists/listinfo/audacitynyquist 