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

Post Reply
MusikMan74
Posts: 34
Joined: 06 Jan 2018 23:03

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

Post 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 9343 times
kjetil
Site Admin
Posts: 582
Joined: 20 Jul 2017 20:45

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

Post 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.)
kjetil
Site Admin
Posts: 582
Joined: 20 Jul 2017 20:45

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

Post by kjetil »

To get the id of the 10th instrument shown in that menu, do this:

Code: Select all

ra.getAudioInstrumentId(10)
MusikMan74
Posts: 34
Joined: 06 Jan 2018 23:03

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

Post 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
kjetil
Site Admin
Posts: 582
Joined: 20 Jul 2017 20:45

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

Post 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.
MusikMan74
Posts: 34
Joined: 06 Jan 2018 23:03

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

Post by MusikMan74 »

Perfect.
Post Reply