Problem with Simple Transformations example

3 messages Options
Embed this post
Permalink
John Colket

Problem with Simple Transformations example

Reply Threaded More More options
Print post
Permalink
Hello,

  I am new to nyquist and was having some difficulties with one of the
examples in the manual under "Simple Transformations" from:

http://audacity-forum.de/download/edgar/nyquist/nyquist-doc/manual/part4.html#29

I start up Audacity, generate 5 seconds of silence, then try to run this
code in the Nyquist prompt:

(defun tone-seq () (seqrep (i 16) (stretch 0.25 (osc-note c4))))
(defun pitch-rise () (stretch 4.0 (scale 16 (ramp))))
(defun chromatic-scale () (transpose (pitch-rise) (tone-seq)))
(play (sustain (stretch 4 (sum 0.2 (ramp))) (chromatic-scale)))

I am supposed to get a 16 note chromatic scale of varying durations.  
Although I do get the varying durations, the pitches are wrong - I get 4
non-chromatic notes, followed by 12 notes of the same pitch.  This is
contrary to what is said in the manual.

Note that

(play (chromatic-scale))

does seems to work OK.

I am running 1.3.8 beta under Windows XP SP3. (Also with Audacity ®
1.3.9-alpha-Aug 10 2009 (Unicode)).

I figure I've got misplaced parentheses or something. :)  Can anyone
tell me what I am doing wrong ?

- John


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Roger Dannenberg

Re: Problem with Simple Transformations example

Reply Threaded More More options
Print post
Permalink
I tried this with Nyquist and hear the same thing. I'll report back when
I figure out what's going on. -Roger

John Colket wrote:

> Hello,
>
>   I am new to nyquist and was having some difficulties with one of the
> examples in the manual under "Simple Transformations" from:
>
> http://audacity-forum.de/download/edgar/nyquist/nyquist-doc/manual/part4.html#29
>
> I start up Audacity, generate 5 seconds of silence, then try to run this
> code in the Nyquist prompt:
>
> (defun tone-seq () (seqrep (i 16) (stretch 0.25 (osc-note c4))))
> (defun pitch-rise () (stretch 4.0 (scale 16 (ramp))))
> (defun chromatic-scale () (transpose (pitch-rise) (tone-seq)))
> (play (sustain (stretch 4 (sum 0.2 (ramp))) (chromatic-scale)))
>
> I am supposed to get a 16 note chromatic scale of varying durations.  
> Although I do get the varying durations, the pitches are wrong - I get 4
> non-chromatic notes, followed by 12 notes of the same pitch.  This is
> contrary to what is said in the manual.
>
>
>  

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Roger Dannenberg

Re: Problem with Simple Transformations example

Reply Threaded More More options
Print post
Permalink
In reply to this post by John Colket
Thanks for your question. Nyquist is correct, but the example and
documentation was wrong. (I believe this was developed and tested a long
time ago, and probably there was a bug in Nyquist at the time.) Anyway,
starting at the last line "(PLAY...)" there is a SUSTAIN transformation
on everything. This applies to CHROMATIC-SCALE, which  includes
TRANSPOSE by PITCH-RISE which is based on RAMP. What's happening is that
the SUSTAIN, which was intended to apply only to the durations of
OSC-NOTEs, also applies to the RAMP in PITCH-RISE. The initial stretch
factor is 0.2, so what would be a 4s ramp is shortened to 4s * 0.2 =
0.8s. If you listen carefully, you'll notice the initial notes are going
up in musical 4ths, i.e. 5 semitones, the reciprocal of 0.2. Why does
sustain apply to ramps? RAMP might logically be used to construct or
control an envelope and you'd want envelopes to scale according to the
sustain factor. A fix is shown below: I added (SUSTAIN-ABS 1 ...) to
"protect" PITCH-RISE from modification by a SUSTAIN.

This is now a good example of how nested environments can easily go
awry. Most of the time, anything you write can be stretched or shifted
safely and you don't even have to think about it, but when you have
continuous controls at different levels of hierarchy, the built-in
semantics don't always do "the right thing."

-Roger


(defun tone-seq () (seqrep (i 16) (stretch 0.25 (osc-note c4))))
(defun pitch-rise () (stretch 4.0 (scale 16 (ramp))))
(defun chromatic-scale () (transpose (sustain-abs 1 (pitch-rise)) (tone-seq)))
(play (sustain (stretch 4 (sum 0.2 (ramp))) (chromatic-scale)))


John Colket wrote:

> Hello,
>
>   I am new to nyquist and was having some difficulties with one of the
> examples in the manual under "Simple Transformations" from:
>
> http://audacity-forum.de/download/edgar/nyquist/nyquist-doc/manual/part4.html#29
>
> I start up Audacity, generate 5 seconds of silence, then try to run this
> code in the Nyquist prompt:
>
> (defun tone-seq () (seqrep (i 16) (stretch 0.25 (osc-note c4))))
> (defun pitch-rise () (stretch 4.0 (scale 16 (ramp))))
> (defun chromatic-scale () (transpose (pitch-rise) (tone-seq)))
> (play (sustain (stretch 4 (sum 0.2 (ramp))) (chromatic-scale)))
>
> I am supposed to get a 16 note chromatic scale of varying durations.  
> Although I do get the varying durations, the pitches are wrong - I get 4
> non-chromatic notes, followed by 12 notes of the same pitch.  This is
> contrary to what is said in the manual.
>
>  

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist