Mapping, Lists, and Music.


I'm currently working on creating a program that a user could use to create music by input notes and chords from a .csv

The top row of the csv lists the chords, and the columns underneath them list the notes to be played for that chord.

From there, I build the following block:

Play Chord

Where the notes are pulled from the csv as follows:


Everything is working exactly as it is supposed to, but instead of the user having to know which column number on the CSV corresponds to which chord, I'd love for them to be able to simply enter "C" into the field, and have the program pull from column 2.

I've tried playing around with the "Map" command, but I'm fairly new to coding and I'm not having much luck. I feel like this should be possible, but I'm not familiar enough with the Snap! system to figure it out.

Does anyone have any thoughts on how I could better approach this?


Is this a homework assignment? I've just read two new forum posts about the same problem!

It would be easier if you transposed the matrix (interchange rows and columns) so that one item of the list of lists would be [C G4 C4 E4 C5] and then you could use FIND FIRST to find the row whose first item is the chord name. If that array came from a spreadsheet program, it'll transpose it for you. (Or you could wait until Snap! 6.0 is released; it'll have a TRANSPOSE block in a library.)

Got it! That makes great sense and is much easier than what I was trying to do.

Not a homework assignment for us, but something that we're working on developing as a homework assignment for students. It's part of an idea about getting kids interested in coding and computational thinking through music. If we can get it to work like we want it to, we'll share the finished product here on the forum.

Thanks again.

List indexes start with 1,not A!

Snap 6.1.2 is already here!

That reply was back in June, which was before the Snap! 6.0 release.