Den 2010-11-29 18:01:03 skrev Roger Dannenberg <

[hidden email]>:

> This is in nyquist/lib/spectrum.lsp:

>

> (defun raised-cosine ()

> (scale 0.5

> (sum (const 1)

> (lfo (/ 1.0 (get-duration 1)) 1 *sine-table* 270))))

>

> Quick explanation: a raised-cosine is a smooth envelope you get from

> 1-cos(x) over one period. Note that the "-" flips the negative-going

> 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

brick-wall 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, (GET-DURATION

> 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 5-10

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 0-180° but the duration for that one isn't

necessarily the same as for the other one…

> The waveform is *SINE-TABLE* 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 (control-srate-abs 44100 (raised-cosine)) 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 0-180° and one 180-360°).

>> 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=0-180° and 180-360° 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 pre-defined 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 (270-450° 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=(hz-to-step 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/intelisp-dev2dev> _______________________________________________

> Audacity-nyquist mailing list

>

[hidden email]
>

https://lists.sourceforge.net/lists/listinfo/audacity-nyquist------------------------------------------------------------------------------

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/intelisp-dev2dev_______________________________________________

Audacity-nyquist mailing list

[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist