1 (edited by thomas.dubreuil 2024-02-23 03:55:43)

Topic: ADI-2 Pro Volume Control with a Wheel

Follow-up to my post in "ADI-2 remote application" thread.
This is an open thread to share ideas, how to implement simple volume control with a wheel.
My solution(s) is perfectible.

Since few years now, I am using a wheel to control the volume of my ADI-2 Pro (FsR BE)
This is very useful in studio work, near the mouse.

I have a Microsoft Surface Dial (bluetooth).
and a "generic" USB wheel (Google like: "USB Volume knob")
I got the black/metal one with blue light (image here: cubeupload.com/im/qrP722m4/3OwTrr.png)
Both are working wonderfully.

It was a scratch in the head how to do that, and over the years I found various ways.
I share them here hoping someone with more skills can find the perfect solution

1) ADI-2 Pro FSr Volume control through Broadlink RM-4 Pro using Home Assistant.

Since ADI-2 Pro FsR already has a remote, I tought it would be cool if I could "pilote" this remote, or another universal remote.
I found it was possible with Broadlink RM4 Pro universal remote, and a bit of work...
Broadlink RM4 Pro is natively integrated in Home Assistant : an open-source software for home automation and more, running on Debian (Linux OS).
So, you need to have Home Assistant installed, either on a VM or a dedicated device.
When integrated your RM4 Pro in Home Assistant, you can easily learn your ADI-2 Pro remote commands.
Using developper tools and calling "Learn command" service with your RM4 as target.
https://u.cubeupload.com/qrP722m4/l1bmGB.png
This will put the RM4 in "learn mode" .
Then you simply press the button you want to learn on your remote and it will write the IR data to a file in .storage folder
/homeassistant/.storage/broadlink_remote_YOUR-RM4-MAC-Address_codes
example of data:

"Rme Adi2 Pro": { "Power Toggle": "JgBYAAABJpYRFBE5EhQRFBE6ERQRFBIUERQRFBI5ERQROhE5ERQSFBITERQSFBEUERQSOREUEjkRORE6ETkRORI5ERQSOREUEQAFigABKEsSAAxXAAEnSxEADQU=" }

Then you can run the commands from Home assistant, using the data or creating a script in scripts.yaml file like this:

volume_up:
  alias: adi_2_volume_up
  sequence:
  - service: remote.send_command
    data:
      device: Rme Adi2 Pro
      command: Power Toggle
#This is the command you created/named while learning it (you can also rename it editing the file in .storage folder)
    target:
      device_id: your_device_id
#This is your RM4 device ID

Then with HASS.Agent : a Windows Service to control Home Assistant from your PC.
I just set up "fast actions" to run the script from a simple keyboard shortcut.
https://u.cubeupload.com/qrP722m4/Q334z4.png

Finally I customize wheel settings with my shortcuts.
The ways are different for Surface dial or Usb wheel, but it's not difficult at all.

Conclusion:
Until now this is the best way for me because I haven't found another way to implement the "volume push"  (= changing selected volume output" ) .
With a wheel click I can toggle between Speakers volume or Headphone volume and  I set volume +or- turning knob left or right.

Problems with this solutions:
- You need universal remote (Broadlink RM4)
- You need Home Assistant, so either a local VM or dedicated device (mini PC running VM, or raspberry Pi)
- You need to install a service on your computer to send commands from your computer (Hass Agent) to Home Assistant.

2) ADI-2 volume control, sending midi sysex commands
Since ADI-2 Remote application release, I saw ADI-2 Pro can be controlled with midi sending sysex.

In the topic mentioned above (adi-2 remote), they provide a .ods (excel) file with a map for every midi controlable function (first post : rme-audio.de/downloads/adi2remote_midi_protocol.zip ). Very cool !!!
The problem is, the mathematics behind functions, bytes, hex, sysex is not totally understandable for me...
A bit of explanation is provided here...
https://www.audiosciencereview.com/foru … st-1733035
But I could'nt get past the device id...too difficult to calculate.

So, I found the easiest solution would be, again, to learn the command (instead of hits and misses for monthes...)

I found those two small command line applications (github.com/gbevin/ReceiveMIDI)
and the other one called sendmidi, as its name says...(github.com/gbevin/SendMIDI)

The cool thing is, this tool is multi-platform, so you might be able to make it work with different devices/os

First you will list your available midi ports :

receivemidi list

Second you will write the commands to the console

receivemidi dev "ADI-2 Pro Midi Port 1" syx

(the device name is the one you got from receivemidi list commands)
Here, you can either use the adi-2 pro, or the remote buttons and it will write the sysex commands on the console.
You just have to copy the code provided and find a way to send the commands, here is an example for me:

This commands set Output 1-2 to -41.5 db:

sendmidi dev "ADI-2 Pro Midi Port 1" system-exclusive hex 00 20 0D 72 02 1B 1C61

From my understanding, everyone should have 00 20 0D (manufacture), 72 is device ID (ADI-2 Pro) 02 is "sending command", for the rest I don't get it totally I'd need a formula.
Note that those values are PARTICULAR for my device, you need to learn the one from yours if you don't have ADI-2 Pro Fs.
The Device ID is provided in .ods map in adi-2 pro remote topic : rme-audio.de/downloads/adi2remote_midi_protocol.zip

I wrapped all this into 2 batch scripts to be able to set volume level +0.5 and -0.5
You create a .bat or .cmd file and put sendmidi.exe next to it.

Output 1-2 : increment volume by +0.5db

@echo off
set "sendmidi=%~dp0\sendmidi.exe"
set "volume_sensor_folder=%~dp0\VolumeLevel_ADI"
set "default_volume=1C61"
if not exist "%volume_sensor_folder%" ( mkdir "%volume_sensor_folder%" >nul 2>&1 )
cd /d "%volume_sensor_folder%"
for %%a in ("%volume_sensor_folder%\*") do ( set "current_volume=%%~na")
if "%current_volume%"=="" (set "current_volume=%default_volume%")
set /a "decimal_volume=0x%current_volume%"
set /a "new_volume=%decimal_volume%+5"
cmd /C exit %new_volume%
set "new_hex_volume=%=ExitCode:~-4%"
set "val1=%new_hex_volume:~0,2%"
set "val2=%new_hex_volume:~-2%"
cd /d "%volume_sensor_folder%"
del /f /s /q "%volume_sensor_folder%\*" >nul 2>&1
echo >"%volume_sensor_folder%\%new_hex_volume%"
"%sendmidi%" dev "ADI-2 Pro Midi Port 1" system-exclusive hex 00 20 0D 72 02 1B %val1% %val2%
goto :eof

Output 1-2 : Lower volume by -0.5db

@echo off
set "sendmidi=%~dp0\sendmidi.exe"
set "volume_sensor_folder=%~dp0\VolumeLevel_ADI"
set "default_volume=1C61"
if not exist "%volume_sensor_folder%" ( mkdir "%volume_sensor_folder%" >nul 2>&1 )
cd /d "%volume_sensor_folder%"
for %%a in ("%volume_sensor_folder%\*") do ( set "current_volume=%%~na")
if "%current_volume%"=="" (set "current_volume=%default_volume%")
set /a "decimal_volume=0x%current_volume%"
set /a "new_volume=%decimal_volume%-5"
cmd /C exit %new_volume%
set "new_hex_volume=%=ExitCode:~-4%"
set "val1=%new_hex_volume:~0,2%"
set "val2=%new_hex_volume:~-2%"
cd /d "%volume_sensor_folder%"
del /f /s /q "%volume_sensor_folder%\*" >nul 2>&1
echo >"%volume_sensor_folder%\%new_hex_volume%"
"%sendmidi%" dev "ADI-2 Pro Midi Port 1" system-exclusive hex 00 20 0D 72 02 1B %val1% %val2%
goto :eof

If you want smaller increment, for example 0.1, you just need to change the line

set /a "new_volume=%decimal_volume%+5

to

set /a "new_volume=%decimal_volume%+1

Conclusion:
The biggest problem with this method is we can't have the "volume push" to toggle between Output 1-2 or 3-4 for volume control.
It seems it hasn't been implemented in the remote and midi Sysex, as in the IR controls (in the real remote)
So I can either control Output 1-2 or Output/Phone 3-4.
For those understanding a bit of coding or coding logic, second caveheat is the scripting part.
Only working solution I found is:
Create a folder and set a default volume, to write "current volume" to a file.
That way the script can increment/lower from current volume. You only can set a value with that method, so to set a new value related to current value (+0.5db more), you need to write the current value to a file...
Also I have to toggle between decimal and hex value back and forth, not "optimal"

3) Broadlink Rm4 without Home Assistant with Python
As a reply of my initial post, user @bluetail posted that he developped a cool UI to control Broadlink RM4,
made on python and based on "python broadlink module" (github.com/mjg59/python-broadlink/tree/master)

Basically after installing Python and module you can send commands directly from your computer to Broadlink RM4 universal remote. 
Then just download those two files, broadlink_cli and broadlink discovery

Open CMD line and navigate to it:

cd /d "path_of_folder_containing_broadlink_discovery"

After that you need to discover your device, to get its ID and mac address

python broadlink_discovery --timeout 10 --dst-ip 192.168.1.61

(Replace with your own Broadlink RM4 IP)
It will echo something like this:
Manufacturer : Broadlink DeviceModel : RM4 pro DevType : 0x649b Host :  192.168.1.61 Mac : abcabcabc

Then you will need to learn commands (and saving to text for convenience)

python broadlink_cli --type 0x649b --host 192.168.1.61 --mac abcabcabc --learnfile volumepush.txt

Push the volume button (or the one you want to learn) on your remote
It will echo:
Saving to volumepush.txt

Do the same for volume+ and volume- or any command you'd like to record...

Finally, you can send commands using also broadlink_cli

python broadlink_cli --type 0x649b --host 192.168.1.61 --mac MAC -send DATA

Where MAC is the mac address of your RM4
Where DATA is the data you wrote to (and copy from) .txt file

Then, you can do a simple shortcut script like this (putting broadlink_cli next to the script)

@echo off
cd /d "%~dp0"
python broadlink_cli --type 0x649b --host 192.168.1.61 --mac MAC --send DATA
goto :eof

4) I'm sure someone with few skills can provide an easy (and multi platform) tool.
For RME devs, this might perhaps be simple, as setting basic shortcuts for vol+ vol- 
(I'm using alt+numeric value, but could be any shortcut which are not used in my daw),
or even different ways!!

For example, I use Elephant to control cutoff filter on some synths with my Surface Dial
(savethehuman5.com/elephant)
Let's make Surface Dial an universal audio volume controller for ADI-2 Pro!!!

If any day RME decided to make a dedicated (wireless) audio knob for ADI-2, I would buy right away.

2 (edited by HMANAZ 2024-02-24 19:36:49)

Re: ADI-2 Pro Volume Control with a Wheel

For this purpose, @drcwo has developed rooADI a remote extension for Roon that can control three very different controls. Including the Surface Dial, Nuimo, and Space Mouse. Check it out here —> https://community.roonlabs.com/t/rooadi … acs/258291

The system can control the remote independent of Roon.  If you are a Roon user, this is a no-brainer.  If you don’t have Roon, it’s worth a try.  Note: you will need a rooExtend SBC or a RPI.

Re: ADI-2 Pro Volume Control with a Wheel

Regarding setting volume through Home Assistant:
If one already uses Home Assistant maybe your also already familiar with the ESPHome integration? When that is the case, an alternative to Broadlink RM4 could be a cheap ESP device, for example a D1 Mini with an IR controller shield. Of course not exactly plug and play, but I wouldn't call Home Assistant plug and play. Something for the enthousiast! :-)

I use ESPHome myself to send IR commands to the RME ADI-2 DAC.

4 (edited by lyricalaloof 2024-03-06 04:36:10)

Re: ADI-2 Pro Volume Control with a Wheel

HMANAZ wrote:

For this purpose, @drcwo has developed rooADI a remote extension for Roon that can control three very different controls. Including the Surface Dial, Nuimo, and Space Mouse. Check it out here —> https://community.roonlabs.com/t/rooadi … acs/258291connections game

The system can control the remote independent of Roon.  If you are a Roon user, this is a no-brainer.  If you don’t have Roon, it’s worth a try.  Note: you will need a rooExtend SBC or a RPI.

ok I will try it

Re: ADI-2 Pro Volume Control with a Wheel

I could not find any way to send the Toggle remote via MIDI as well, did anybody find it?

On my ADI-2 Pro, as a dirty workaround, we can set the Toggle Ph / Line parameter which actually toggles the line/ph as a byproduct:
-set to 0 (off) to output only to the headphones (but it disables the Toggle button altogether on the device)
-set to 4 (all plugged) activates the line out (back to normal behaviour for the Toggle button)

In SysEx terms, that is the following commands:
F0 00 20 0D 72 02 61 20 00 F7 (deactivate Toggle, which enables headphones only)
F0 00 20 0D 72 02 61 20 04 F7 (reactivate Toggle, which enables the Line Out only)

Re: ADI-2 Pro Volume Control with a Wheel

Ah, found it!!
https://forum.rme-audio.de/viewtopic.ph … 72#p212972

"Page 3 (Device, address 12): Index 63, value 1 will do."

SysEx:
F0 00 20 0D 72 02 68 70 01 F7

Happy me...

7 (edited by Jolle 2024-03-22 15:53:19)

Re: ADI-2 Pro Volume Control with a Wheel

I registered on the forum to day to do exactly what you're trying with the midi sysex commands, controlling settings on the ADI that are already supported by the app, with a custom remote with a wheel through my Raspberry PI that is set up as a streamer using the USB interface.

I'll try out your scripts and add any new information I come up with!

8 (edited by Jolle 2024-03-27 07:10:57)

Re: ADI-2 Pro Volume Control with a Wheel

Just finished implementing a script for changing RME ADI volume up/down/mute with my BT remote and scroll wheel and Midi commands.

It's here for anyone who is interested:
https://github.com/JolleNo10/RmeAdiVolumeController/

Script can be used like this:

  • volcontrol.sh mute : Mutes the RME ADI unit. Concurrent triggers will toggle mute on and off.

  • volcontrol.sh down : Decreases volume by 0.2dB (configurable value).

  • volcontrol.sh up : Increases volume by 0.2dB (configurable value).

(more info on github)

I'm running it on my Raspberry Pi streamer with Volumio.
My controller is a Bluethooth Mini keyboard with a scroll wheel connected to the RP.

I'm calling the script with TriggerHappy, so playback control for next/prev/play/pause is sent to Volumio, while Volume up/down/mute is sent with Midi commands to the RME ADI. Each "click" of the scrollwheel triggers a call to the script.
Should be no issues calling the script in the same way with HomeAssistant.

Works without any issues for me until now. Might post a video of it later.

If anyone knows how to get the current volume from the returned status, please let me know, I couldn't really figure that out.

9 (edited by Bruno Z 2024-04-05 06:48:38)

Re: ADI-2 Pro Volume Control with a Wheel

I finally got around writing a Win app to control the volume and toggle speakers / headphones from global keyboard shortcuts, everything works just as expected.
As I understand it:
- to get the volumes, you need to first query the full ADI config (command 03 09) and read within that the various output volumes, iterate by blocks of 3 bytes until you find the following (the config dump is broken over multiple SysEx messages):
     * for Line Out, 1B XX YY with X <= 31 (top 3 bits 0), the volume in dB is (X*128+Y-4096)/10
     * for PH 3/4, 4B XX YY with X <= 31 (top 3 bits 0), the volume in dB is (X*128+Y-4096)/10
- to get which output is active, you wait for a Status message, bit 4 of the first byte means Line Out active, bit 6 means PH 3/4 active
- to set the volume, once you know which output is active, you send a 02 command with respectively 1B XX YY or 4B XX YY as constructed above

When toggling the output, the ADI actually sends a Volume info message (1B / 4B) after the switch, so if you are still listening for the Midi IN you get an updated volume as well.