returning SOUND to outer DOLIST loop?

Using Nyquist scripts in Audacity.
Post and download new plug-ins.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
dmonty
Posts: 20
Joined: Sat Feb 25, 2017 9:15 pm
Operating System: Linux *buntu

returning SOUND to outer DOLIST loop?

Post by dmonty » Sat Mar 11, 2017 6:39 pm

I'm new to nyquist/lisp. Having trouble returning a SOUND object inside a DOLIST loop.

The dolist loop on line 28 returns NIL. I need the SOUNDs generated inside the loop on line 68 to be appended together outside the loop.

https://github.com/dmonty2/audacity-pem ... mf-list.ny

End goal is to have the user enter a list of frequencies [email protected]:time1,[email protected]:time2... audacity will output a seqence of wav1,wav2,...

Thanks.

steve
Site Admin
Posts: 47311
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: returning SOUND to outer DOLIST loop?

Post by steve » Sun Mar 12, 2017 9:21 pm

Example 1

Code: Select all

(setf mylist (list 'a 'b 'c 'd))
(setf num 4)

(print
  (dolist (x mylist)
    (print x)
    (dotimes (i num)
      (setf i (1+ i)))))
prints:

Code: Select all

A
B
C
D
NIL
Note that "NIL" is the return value of the 'dolist'

------------------------------------

Example 2

Code: Select all

(setf mylist (list 'a 'b 'c 'd))
(setf num 4)

(print
  (dolist (x mylist j)
    (print x)
    (dotimes (j num)
      (setf j (1+ j)))))
Error.
'j' is local to 'dotimes', so as the return value of dolist it is unbound.

------------------------------------

Example 3

Code: Select all

(setf mylist (list 'a 'b 'c 'd))
(setf num 4)

(print
  (let ((count 0))
    (dolist (x mylist count)
      (print x)
      (dotimes (j num)
        (setf count (1+ count))))))
prints:

Code: Select all

A
B
C
D
16
Note that "count = 16" is the return value of the 'dolist'

------------------------------------

See also: http://www.audacity-forum.de/download/e ... ef-095.htm

Does that help?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

dmonty
Posts: 20
Joined: Sat Feb 25, 2017 9:15 pm
Operating System: Linux *buntu

Re: returning SOUND to outer DOLIST loop?

Post by dmonty » Mon Mar 13, 2017 6:58 am

Thanks. The script is now working.

Post Reply