eboats Posted May 22 Share Posted May 22 I'd like to get a random sequence of a set of pitches but want to exclude certain intervals like 7 and 4 from appearing in the resulting sequence. I don't see an interval exclude property for rnd-sample. What would be a way to do this? (setf seq (rnd-sample 16 '(c4 d4 f4 fs4 g4 a4 b4 ds5) :norep t)) Quote Link to comment Share on other sites More sharing options...
jesele Posted May 22 Share Posted May 22 I'll bet there is some builtin function that I don't know of, but here's an option: (setf res (interval-to-pitch (remove-if (lambda (x) (or (= 4 x) (= 7 x))) (pitch-to-interval seq)))) (pitch-to-interval res) Jesper Edit: if you want exactly 16 you could do like this. (bad programming, I know ) (setf seq (rnd-sample 24 '(c4 d4 f4 fs4 g4 a4 b4 ds5) :norep t)) (setf res (subseq (interval-to-pitch (remove-if (lambda (x) (or (= 4 x) (= 7 x))) (pitch-to-interval seq))) 0 16)) Quote Link to comment Share on other sites More sharing options...
opmo Posted May 22 Share Posted May 22 or: (setf seq (rnd-sample 16 '(c4 d4 f4 fs4 g4 a4 b4 ds5) :norep t)) (interval-to-pitch (filter-remove '(-7 7 -4 4) (pitch-to-interval seq)) :start (car seq)) => (a4 c4 a4 g4 e5 fs5 e5 d6 e5 d6 fs5) A simple way is to work with intervals and then convert them to pitches: (setf seq (rnd-sample 16 '(-4 -3 -2 -1 1 2 3 4) :norep t)) => (-4 2 -2 2 -1 -4 4 -1 1 -2 -1 3 -2 2 -2 -3) (interval-to-pitch seq :start 'a4) => (a4 f4 g4 f4 g4 fs4 d4 fs4 f4 fs4 e4 eb4 fs4 e4 fs4 e4 cs4) This way the length of the list will not change. jesele 1 Quote Link to comment Share on other sites More sharing options...
eboats Posted May 22 Author Share Posted May 22 Thanks much for the tips, very helpful! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.