sonic-pi icon indicating copy to clipboard operation
sonic-pi copied to clipboard

Problem using .shuffle with scale

Open rbnpi opened this issue 2 years ago • 0 comments

If you apply .shuffle to a scale as in puts (scale :c4,:major).shuffle it returns => (ring <SonicPi::Scale :C :major [60, 62, 64, 65, 67, 69, 71, 72]) No error is raised, but it clearly doesn't alter the order. If you try .reverse it works and you get this puts (scale :c4,:major).reverse => (ring 72, 71, 69, 67, 65, 64, 62, 60) if you reverse twice you get puts (scale :c4, :major).reverse.reverse =>(ring 60, 62, 64, 65, 67, 69, 71, 72) This will then work if you apply shuffle. It seems that the initial <SonicPi:Scale :C major before the list of notes in the first example causes this problem. The documention in the western_theory.rb file has examples like line 717-8 puts (scale :C, :major) # returns the following ring of MIDI note numbers: (ring 60, 62, 64, 65, 67, 69, 71, 72)", "# anywhere you can use a list or ring of notes, you can also use scale Which is not what is returned in reality. You can pick out notes from the list OK, for example by using tick with the ring, so it usually doesn't matter,but .shuffle seems to be thrown by the preamble.

New in_thread user @Wibby is to be credited in raising this issue which I am reporting.

rbnpi avatar Feb 24 '23 18:02 rbnpi