Page 1 of 1

Any way to assign an instrument to a track via the API?

Posted: 12 Jun 2019 10:30
by MusikMan74
Via its Mixer object name?

i.e.
ra:select-track 0
then
ra:set-block-track-instrument 'DPiano-E 1'
setTrackInstrument.png
setTrackInstrument.png (108.27 KiB) Viewed 9338 times

Re: Any way to assign an instrument to a track via the API?

Posted: 12 Jun 2019 11:01
by kjetil
Yes, you use the function setInstrumentForTrack:

Code: Select all

void setInstrumentForTrack | int64_t instrument_id | int tracknum ? -1 | int blocknum ? -1 | int windownum ? -1
It doesn't take instrument name as argument though. Since instrument names are not unique, that wouldn't work. So you need to get the instrument id. You get the id of the current instrument by calling getCurrentInstrument, if that works. (Also, in the picture, "D Piano10" probably doesn't have id 10. 10 is just a number displayed to make things easier to read.)

Re: Any way to assign an instrument to a track via the API?

Posted: 12 Jun 2019 11:06
by kjetil
To get the id of the 10th instrument shown in that menu, do this:

Code: Select all

ra.getAudioInstrumentId(10)

Re: Any way to assign an instrument to a track via the API?

Posted: 12 Jun 2019 13:10
by MusikMan74
Thanks for the useful info; I have a follow-up question:

Is there currently a way to get a LIST of all available instrument IDs and their corresponding names, i.e.

id=27, DPiano-A 1
id=28, EPiano-A 1
etc.




Trying to familiarize myself with the API functions list in

https://github.com/kmatheussen/radium/b ... rotos.conf

so I can ask fewer questions. :D

Re: Any way to assign an instrument to a track via the API?

Posted: 12 Jun 2019 13:19
by kjetil
Use getNumAudioInstruments to find number of audio instruments. Use getAudioInstrumentId to get instrument id from instrument number. Use getInstrumentName to get instrument name from instrument id.

Re: Any way to assign an instrument to a track via the API?

Posted: 12 Jun 2019 13:21
by MusikMan74
Perfect.