[CM] Rearranging a sequence

Landspeedrecord landspeedrecord@gmail.com
Tue, 10 Apr 2007 19:57:53 -0400


Thanks Rick!  Using fold-objects in conjunction with cons would have
taken me weeks to figure out so I appreciate your help.

However, what I want to do is exactly what you are saying I shouldn't.
 The only thing I want to shuflle/reorder is the midi time.  All the
other midi information (keynum, duration, amp, chan) is supposed to
stay together so that the notes remain the same but just come out in a
different temporal order.  Why do I want to do this?  Because I am
trying to manipulate midi files that correspond to .rex files (chopped
up rhythms produced by propellerheads recycle). If I can rearrange the
midi file I can come up with endless variations of the looped audio
file.

I am confused.  I thought the midi "time" value was just another
slot/keyword value of the MIDI class (i.e. the same as keynum or
duration).  I figured that it was only until the seq was put into the
scheduler that the midi time became "cemented" in.  Do I have it all
wrong?

On 4/9/07, Rick Taube <taube@uiuc.edu> wrote:
> you shouldnt "rearrange the time values" of the seq's objects -- the
> purpose of a seq is maintain a time-ordered list of events!
>
> assuming you want to scramble keynumbers or something like that you
> could do this
>
> ;; create a seq of midis
>
> (defparameter myseq
>    (new seq :subobjects (loop for i to 100
>                           collect (new midi :time i :keynum i))))
>
> ;; look at the first ten
>
> (list-objects myseq :end 10)
>
> 0. #i(midi time 0 keynum 0 duration 0.5 amplitude 64 channel 0)
> 1. #i(midi time 1 keynum 1 duration 0.5 amplitude 64 channel 0)
> 2. #i(midi time 2 keynum 2 duration 0.5 amplitude 64 channel 0)
> 3. #i(midi time 3 keynum 3 duration 0.5 amplitude 64 channel 0)
> 4. #i(midi time 4 keynum 4 duration 0.5 amplitude 64 channel 0)
> 5. #i(midi time 5 keynum 5 duration 0.5 amplitude 64 channel 0)
> 6. #i(midi time 6 keynum 6 duration 0.5 amplitude 64 channel 0)
> 7. #i(midi time 7 keynum 7 duration 0.5 amplitude 64 channel 0)
> 8. #i(midi time 8 keynum 8 duration 0.5 amplitude 64 channel 0)
> 9. #i(midi time 9 keynum 9 duration 0.5 amplitude 64 channel 0)
>
> ;; gather the keynumbers
>
> (defparameter seqkeys
>    (fold-objects #'cons myseq '() :slot 'keynum))
>
> ;; now shuffle the keynums and put them back
>
> (let ((mixedup (shuffle seqkeys)))
>    (loop for m in (subobjects myseq)
>       for k in mixedup
>       do (sv m :keynum k))
>    )
>
> ;; look at them again
>
> (list-objects myseq :end 10)
>
> 0. #i(midi time 0 keynum 60 duration 0.5 amplitude 64 channel 0)
> 1. #i(midi time 1 keynum 68 duration 0.5 amplitude 64 channel 0)
> 2. #i(midi time 2 keynum 15 duration 0.5 amplitude 64 channel 0)
> 3. #i(midi time 3 keynum 51 duration 0.5 amplitude 64 channel 0)
> 4. #i(midi time 4 keynum 29 duration 0.5 amplitude 64 channel 0)
> 5. #i(midi time 5 keynum 52 duration 0.5 amplitude 64 channel 0)
> 6. #i(midi time 6 keynum 35 duration 0.5 amplitude 64 channel 0)
> 7. #i(midi time 7 keynum 74 duration 0.5 amplitude 64 channel 0)
> 8. #i(midi time 8 keynum 25 duration 0.5 amplitude 64 channel 0)
> 9. #i(midi time 9 keynum 16 duration 0.5 amplitude 64 channel 0)
> CM>
>
>
>
>
>
>
> On Apr 9, 2007, at 6:52 PM, Landspeedrecord wrote:
>
> > I having been trying to rearrange the time values of a MIDI file, i.e.
> > rearrange the ordering of the notes while keeping all the other MIDI
> > information intact.  I can load the MIDI into a seq object but from
> > there I hit a brick wall.
>