Sep
20
2022

I’m pretty experienced in scripting, mainly web related, but a few different languages.  I’ve dabbled in AppleScript as well.  Thought about C (or the various flavors of it) but never committed to learning. After some time I have decided to try my hand at scripting for Reaper, the DAW.

In my first attempt I wanted to get the name of a selected track in a project and simply display that in a message to verify I was getting it correctly.  But I kept getting errors.  Errors I wasn’t immediately about to figure out.  It seems silly now that I have it, but this is the sort of thing you can expect when learning a new language.  And sadly the Reaper API Documentation doesn’t come with examples or much help in sorting it all out.  I spent quite a while searching online and the Reaper forums trying to find an answer for why my script wasn’t working.

So hopefully this snippet could save you some time. Select a track and run the script.  If no track is selected you’ll be asked to select one.  Otherwise you’ll see a message displaying the name of the track you selected followed by the name of the track in the console window.

sel_track = reaper.GetSelectedTrack(0,0)

if sel_track then
    -- do things to the track
    _, sel_track_name = reaper.GetTrackName(sel_track, "")
    reaper.ShowMessageBox(sel_track_name,"Selected Track:",0)
    reaper.ShowConsoleMsg(sel_track_name)
else
    reaper.ShowMessageBox("Please select a track!", "Error", 0)
end

There’s also a searchable Reaper API posted by Raymond Radet (X-Raym) HERE.

Follow comments on this post with this RSS 2.0 feed.
Leave a comment, or trackback from your own site.

You must be logged in to post a comment.

. . :   design & hosting by creed3.com   : . .