Skip to content

Problem using .shuffle with scale #3274

Open
@rbnpi

Description

@rbnpi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions