# How do I play samples at random values of a specific scale or chord?

I want to play a pattern that has note values randomly selected from a specific chord or scale.

The only way I know how to do this is to specify the scale values in a variable, then use the choose and up functions to pick the notes:

let pent = [0,2,4,7,9]

d1 $s "arpy*8" # up (choose(pent))  Is there a better way to do this using the new s n notation? edit retag close merge delete ## Comments Separate Q: how'd you get the nice text formatting? triple backtick doesn't seem supported, and \<pre\> doesn't have syntax coloring and I can't figure out how to escape angle brackets... ( 2016-06-13 11:39:08 -0500 )edit @bgold indent with four spaces, or highlight your text and choose the code format button in the rich text editor (which just indents your text by four spaces). ( 2016-06-13 12:11:02 -0500 )edit This isn't working for me. I get a "parse error on input 'dl' tidal" ( 2016-06-18 16:15:55 -0500 )edit @mitchk you'll get that error if you eval both lines as a single block. try eval'ing each line separately. I'll edit my question to add a line break. ( 2016-06-19 22:09:30 -0500 )edit ## 2 answers Sort by » oldest newest most voted You can modify the pitch model and then just use notes as index into that scale. E.g. in supercollider: ( ~dirt.orbits[0].set(\freq, #{ (~n.degreeToKey([0, 0.5, 1, 4, 5, 5.5, 9.2, 11], 12) + 60).midicps }); )  In Tidal: d1$ slow 2 $sound "gabor*16" # n (run 16)  There are more examples under pitch-model.scd more ## Comments do you know a way to do it in Tidal? I'm curious about the same question but in conjunction with tidal-midi so this answer won't work for me. any help much appreciated, thanks! ( 2016-06-26 14:58:13 -0500 )edit Not directly, but I can think of some weird hacky ways. Here's one:  d1$ spread' (<~) (fmap fromIntegral $irand 4)$ sound "[bd sn:2 hh cp]/4" 

Somewhat more flexible, using zoom (and also abusing spread'):

let selectFrom n = spread' (\x -> zoom (fromIntegral x/ fromIntegral n, fromIntegral (x + 1)/fromIntegral n)) (irand n)

d1 $sound$ selectFrom 4 "bd sn:2 hh cp"

more