[CM] Loop question
T. Kriewall
kriewall@u.washington.edu
Sun, 22 Feb 2004 19:00:41 -0800 (PST)
Yet another question!
I have a function which works properly (thanks to Rick Taube's help):
(defun leadmod ()
(setq filedata (import-events "Testfile.MID"))
(setq keynumlist (map-slot filedata 'keynum))
(setq durlist (map-slot filedata 'duration))
(setq amplist (map-slot filedata 'amplitude))
(setq timelist (map-slot filedata 'time))
(loop for pitches in keynumlist
for durations in durlist
for amplitudes in amplist
for times in timelist
for freq = (hertz pitches)
collect
(new karplus_strong
:time times
:duration durations
:freq freq
:amp amplitudes
:imeth 6
:iparm 0
:idel 2
)
))
The output (excluding the header info) looks something like:
s
i1 0.000 2.000 293.665 1.000 6 0 2
i1 2.000 1.000 246.942 0.693 6 0 2
i1 3.000 0.500 220.000 0.693 6 0 2
i1 3.500 0.250 195.998 0.693 6 0 2
i1 4.000 0.125 174.614 0.079 6 0 2
e
This is all good. Note the start time (second) column.
Now, if I modify the function such that it replicates notes:
(defun leadmod ()
(setq filedata (import-events "Testfile.MID"))
(setq keynumlist (map-slot filedata 'keynum))
(setq durlist (map-slot filedata 'duration))
(setq amplist (map-slot filedata 'amplitude))
(setq timelist (map-slot filedata 'time))
(loop for k from 1 to 2 collect
(loop for pitches in keynumlist
for durations in durlist
for amplitudes in amplist
for times in timelist
for freq = (hertz pitches)
collect
(new karplus_strong
:time times
:duration durations
:freq freq
:amp amplitudes
:imeth 6
:iparm 0
:idel 2
)
))
)
My output becomes (note the start time column):
s
i1 0 2.000 293.665 1.000 6 0 2
i1 0 1.000 246.942 0.693 6 0 2
i1 0 0.500 220.000 0.693 6 0 2
i1 0 0.250 195.998 0.693 6 0 2
i1 0 0.125 174.614 0.079 6 0 2
i1 0 2.000 293.665 1.000 6 0 2
i1 0 1.000 246.942 0.693 6 0 2
i1 0 0.500 220.000 0.693 6 0 2
i1 0 0.250 195.998 0.693 6 0 2
i1 0 0.125 174.614 0.079 6 0 2
e
Everything is fine with the exception of the start time. What am I
doing that's fixing it to zero while all the other values are fine?
The calling function, incidentally, is:
(events (leadmod) "testout.sco"
:header "<headerstuff>"
:handler NIL)
Thanks again!
Tom