Old 01-21-2022, 07:18 AM   #1
mal4ishka
Human being with feelings
 
Join Date: Dec 2019
Posts: 24
Default API method for managing Media Explorer harware outputs?

Is there any API method for managing Media Explorer harware outputs?
For example I toggle master harware output from 1/2 (monitors) to 3/4 (headphones) and I need Media Explorer harware output to follow active master harware output.
mal4ishka is offline   Reply With Quote
Old 01-21-2022, 10:05 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Try this function:

Code:
function MediaExplorer_SetDeviceOutput(channel, mono)
--[[
Meo-Ada Mespotine - 21st of January 2022 - licensed under MIT-license

Sets the output-channel(s) of the Media Explorer

When Media Explorer is opened, playback will be stopped and the Media Explorer will flicker for a short time. This is due limitations in Reaper.

Parameters:
  channel: set to the channel number; 1 or higher; -1, Play through first track named "Media Explorer Preview" or first selected track
  mono: true, use the mono-channel; false, use stereo-channels
--]]
  if channel>-1 then
    channel=channel-1
    if mono==true then channel=channel+1024 end
  end
  local A=reaper.GetToggleCommandState(50124)
  if A==1 then reaper.Main_OnCommand(50124, 0) end
  reaper.BR_Win32_WritePrivateProfileString("reaper_explorer", "outputidx", channel, reaper.get_ini_file())
  if A==1 then reaper.Main_OnCommand(50124, 0) end
end

MediaExplorer_SetDeviceOutput(3, false) -- this sets hardwareoutput to channel 3 in stereo
The first parameter is the channel number(1 and higher; -1 for "Play through first track named "Media Explorer Preview" or first selected track") and the second parameter sets, if mono(true) or stereo(false).

However, this will flicker an already opened MediaExplorer quickly and stop any playback. This I cannot circumvent.
But at least, you can set it now programmatically.

Reaper's own API has no such function, afaik.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is online now   Reply With Quote
Old 01-21-2022, 11:44 AM   #3
mal4ishka
Human being with feelings
 
Join Date: Dec 2019
Posts: 24
Default

Man, thnx for help.
Since I planned to change hardware outputs with closed Media Explorer, flickering will never bother me(:
mal4ishka 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:31 AM.


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