Old 01-05-2019, 09:02 PM   #1
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 265
Default How to use EnumTrackMIDIProgramNames?

Does anybody know? From the docs:

boolean retval, string programName = reaper.EnumTrackMIDIProgramNames(integer track, integer programNumber, string programName)

I'm assuming it would get the preset list for an FX, although there is not a setting for which fx slot to check.... so maybe not?

It says "returns false if there are no plugins on the track that support MIDI programs,or if all programs have been enumerated". So maybe this means it gets all the programs for all the fx in the chain on that track that support it, indiscriminately? I guess that's okay, as I can limit myself to one such vst per track.

I tried:

retval, programName = reaper.EnumTrackMIDIProgramNames( track, programNumber, programName )

But retval always returns FALSE, even when there is an fx with programs on the track.

Just wondering if anybody has a piece of sample code using it that I could dissect....

Thanks in Advance!
-eric
__________________
e moon
http://ericmoonmusic.com
>>{ Very Stable Genius }<<

Last edited by woodslanding; 01-05-2019 at 11:35 PM.
woodslanding is offline   Reply With Quote
Old 01-08-2019, 04:01 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,324
Default

use a while loop like


Quote:
track = reaper.GetSelectedTrack(0,0) -- Get first selected track, you can put that into a track loop too



programNumber = 0 -- First index

retval = true -- Start loop

while retval then

retval, programName = reaper.EnumTrackMIDIProgramNames( track, programNumber, '' )
programNumber = programNumber + 1
if retval then
-- DO WHAT YOU WANT HERE
end

end -- this will stop once there is no value returned



(not tested bu you get the idea)
X-Raym is offline   Reply With Quote
Old 01-08-2019, 10:26 PM   #3
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 265
Default

definitely not tested

The method is looking for a track number, not a track! Which seems strange, as all similar methods take a track....

Problem I'm having is that retval always returns false, even when there is a vst with midi programs on the track (programs that are showing up just fine in the dropdown menu, and successfully addressed with MPL's script.) This is the part I don't understand.

It also seems an odd limitation to me that it does not ask for an fx slot, and will only furnish programs for the 1st fx that supports them. I put my compliant fx in the first slot, but even then the method returns false.

It could well be the method is broken. I can find 0 examples of anybody using it ever, but I wanted to make sure it wasn't my ignorance before filing a bug report.

Here is my code:
Code:
-- Console Message
function Msg(g)
    reaper.ShowConsoleMsg(tostring(g).."\n")
  end
  
  Msg('in action')
  
    --track = reaper.GetSelectedTrack(0,0) -- Get first selected track, you can put that into a track loop too
    
    --method needs a track number, not a track?
    local _, track, _, fx_id = reaper.GetFocusedFX()
    --track = 3; 
    programNumber = 0 -- First index
    
    Msg('track = '..track)
    retval = true -- Start loop
    while retval
    do
      retval, programName = reaper.EnumTrackMIDIProgramNames( track, programNumber, '' )
      
      programNumber = programNumber + 1
      if retval then
           Msg(programNumber..programName)
      else Msg('retval is false')
      end
      
      end -- this will stop once there is no value returned

Thanks for your help!
__________________
e moon
http://ericmoonmusic.com
>>{ Very Stable Genius }<<

Last edited by woodslanding; 01-08-2019 at 10:45 PM.
woodslanding is offline   Reply With Quote
Old 01-12-2019, 02:10 PM   #4
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 265
Default

Okay.... Guess I'll file that bug report.
__________________
e moon
http://ericmoonmusic.com
>>{ Very Stable Genius }<<
woodslanding is offline   Reply With Quote
Old 01-13-2019, 06:20 AM   #5
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,527
Default

I think that function is only meant for use with a virtual instrument plugin that is first in the track's FX chain.

There is a painful way to enumerate the preset names of any effect that involves going through all the presets one by one (making the plugin load the preset, which can take a considerable time) and then getting the name of the current preset.

edit : code to do it that way :

Code:
local track = reaper.GetTrack(0,0)
local fxindex = 2
local retval, numberOfPresets = reaper.TrackFX_GetPresetIndex(track, fxindex)
for i=0,numberOfPresets-1 do
  reaper.TrackFX_SetPresetByIndex(track, fxindex, i)
  local retval, presetname = reaper.TrackFX_GetPreset(track, fxindex, "")
  reaper.ShowConsoleMsg(presetname.."\n") 
end
This is certainly not optimal, not only because it needs to change the actual preset in the plugin as many times as there are presets, but it also of course leaves the plugin's state at the last available preset.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 01-13-2019 at 07:16 AM.
Xenakios is online now   Reply With Quote
Old Yesterday, 08:10 PM   #6
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 265
Default

And it crashes reaper under Guitar Rig, and probably any other vsts that take time to change presets!

But whatever the original method is supposed to do, it doesn't work. I did try with a vsti plugin in the first slot (not ideal, as I need a midi processing plugin in the first slot), and it still didn't work.
__________________
e moon
http://ericmoonmusic.com
>>{ Very Stable Genius }<<

Last edited by woodslanding; Yesterday at 08:18 PM.
woodslanding is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:58 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.