Help with M4L Javascript and get_selected_notes

    Jul 21 2012 | 4:04 pm
    I'm trying to retrieve all the midi information from a specific clip on a specific track. I've managed to get data returned but what I am assuming is the pitch info doesn't match what's being played in the clip. The code is below:
    function myfunction(trk, slot){ var api = new LiveAPI(function(result){'select_all_notes'); var notes ='get_selected_notes','pitch'); //adding the pitch argument seems to make no difference /* SHOULD RETURN: count [int] is the number of note lines to follow. pitch [int] is the MIDI note number, 0...127, 60 is C3. time [double] is the note start time in beats of absolute clip time. duration [double] is the note length in beats. velocity [int] is the note velocity, 1 ... 127. muted [bool] is 1 if the note is deactivated. */ post(notes);
    }, "live_set tracks "+trk+" clip_slots "+slot+" clip"); }
    The output I get looks like this: "notes, 312, note, 46,13.12,0.12,76,0,note,48,13,0.12,73,0,note,48...etc"
    Based on the docs the first two values tell me the "count" or total number of notes in the clip. and then there is a "note" followed by 5 values. I am assuming that as per the docs, the values should be pitch, time, duration,velocity,muted in that order. However as I stated before, the pitches listed do not match what is being played and in this set I put together there is only one midi clip. Am I reading this wrong? or is there something wrong with how I'm calling the function?
    Furthermore, according to the docs, arguments can be added to "get_selected_notes" so if I wanted only the pitch values I could add the "pitch" argument to "get_selected_notes". When I tried to add the pitch argument in javascript it still returns everything though. What am I doing wrong?

    • Jul 21 2012 | 6:58 pm
      I also posted this question in the Ableton forums and figured it out. I filtered the data in js and took a second look. It turns out that "get_selected_notes" returns all the notes in ascending pitch order. So it would list all the E3s and then the E4s and so on. So that makes sense now. If I want to list the notes by order of appearance then I have to sort it myself.
    • Aug 06 2012 | 11:17 pm
      Oh, sorry I missed this at the time!
      I have a tool to help you here.
      Here's something that gets all the notes from a track, puts them into a neat JS dictionary, and then sorts them according to time.