Jump to content

Exclude intervals from rnd sample?


Recommended Posts

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))

 

 

 

Link to comment
Share on other sites

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))
 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy