SimHub plugin[s] for output to MIDI and vJoy

blekenbleu

SimHub+Arduino hacker
Premium
SimHub is very capable on its own, and many plugins
(I find more all the time) expand its capabilities.
One capability lacking is more elaborate tactile and audio effects.

21 Jan 2024: @Wotever addressed this in SimHub 9.1.20
by ShakeIt Bass shakers CUSTOM Forced Frequencies:
forced.jpg

Consequently, MIDIio plugin is now mostly useful for repurposing
MIDI CC changes as vJoy inputs or custom SimHub properties.

Computer control of audio typically uses
MIDI (Musical Instrument Digital Interface),
originally a quite simple protocol, but obfuscated in version 2.0.
However, original MIDI is still very alive.

There is already a SimMidi (download here) with a SimHub plugin,
but it is about using MIDI controllers with vJoy and/or autohotkey,
with game telemetry via SimHub to e.g. control LEDs.

SimHub includes a MIDI plugin by @Wotever that enables use of MIDI controller button events equivalent to HID keystrokes,
as described here.
However, this plugin supports neither sending any MIDI messages
nor handling e.g. slider control changes.
Meanwhile, SimHub includes 2 MIDI libraries:
.. which seems overkill; NAudio is perhaps used only for audio (ShakeIt)?

This search/project thread is instead about using SimHub to
e.g. control volume of some (virtual) device by MIDI OUT.
One such virtual MIDI device could be an Equalizer APO plugin
to control volume of digital audio channels to sound cards.
With a MIDI Out plugin, SimHub custom Shakeit effects could
control sounds and tactile signals made elsewhere or indeed by other ShakeIt effects. This would enable independently controlling
frequencies and amplitudes of a tactile effect using telemetry values.

Fanatec's McLaren GT3 V2 rim has dual clutch paddles with a bite-point mode which is lost when using Sim Racing Machines' adapter.
SimHub is already capable of reading those paddles;
a plugin that could send appropriate messages to vJoy
would allow a custom SimHub effect to implement bite-point mode.
Perhaps either or both of these capabilities already exist,
somewhere in the plethora of SimHub plugins...?

Meanwhile, this thread can serve as a log of beginner misconceptions
and errors associated with hacking a SimHub plugin, e.g.
  • SimHub plugins are Visual Studio C# projects.
  • 2 example projects are bundled with SimHub, in a PluginSdk folder.
  • Other projects typically are also in that PluginSdk folder, to build successfully.
  • Existing projects built with earlier target framework e.g. 4.6,
    but they need target framework change to build for current SimHub.
MIDIio v0.2.7 is now released. 'beta 7':
  • waits for configured Joystick properties to become non-null.
  • vJoy button numbering now matches SimHub convention.
  • SimHub plugin logging is less verbose.
 
Last edited:

C# Expressions​

Stumbled across while experimenting with the Demo plugin;
perhaps useful for configuring which MIDI slider signals to monitor,
instead of bothering to master C# UI hacking:
C#.gif

.. which Available properties appear in CustomExpression.
The only other documentation / working example found so far in the discord #code channel:
C#:
init(value);
return null;
 
}  // ending the CustomExpression class, allowing a static declaration...
static int KKDash = 0;

class KKDAsh{}
static void init(global::SimHub.Plugins.PluginManager pluginManager){
 
        pluginManager.AttachDelegate("KartKraft_Dash", typeof(KKDAsh), () => KKDash);
        pluginManager.AddAction("KartKraft_Dash_toggle", typeof(KKDAsh), (a, b) =>
        {
            KKDash = (KKDash + 1) % 3;
        });
 
Last edited:
The oldest plugin found in SimHub is SimHub.Plugins.VJoyFeeder.dll,
which @Wotever probably uses for game controller inputs.
@lukester1975 also addressed HID input-to-vJoy support
with his Leo Bodnar SLI-Pro and SLI-F1 plugin for SimHub.

SimHub plugin development is usefully eased
using Visual Studio Community 2022, which now fully supports
relative paths to e.g. SimHubWPF.exe (wanted for debugging).
Here are my How-To articles about:
While SimHub includes sample plugins,
this one is updated based on my experiences:
 
Last edited:

SimHub plugin 101​

Scraped from the discord #code channel;
@Wotever 01/05/2018:
"the sdk gives you the ability to create a plugin so it is only a few things
  • read game data
  • create new properties
  • read other plugin properties
  • create inputs
  • create events
everything else is coded in the plugins themselves"

That implies that sending data out from SimHub must be
via a plugin that can set properties, e.g. ShakeIt effects,
which are constrained to floats between 0 and 100.
For example, to send a MIDI command,
one might set the integer part to the channel value
with data as the fraction.

An exchange mostly between @Andreas Dahl and @romainrob:
  • check logs for NullReferenceExceptions, etc.
  • see attached DataPlugDemo.cs(.txt)
  • Choose debug in the drop-down menu here. And run it with the start button,
    instead of building in release mode and manually starting SimHub.
    It will then break and tell you what wrong when an error occurs
    unknown.png

    unknown.png
  • Debug mode helps a ton to understand what's actually going on while the code is running
  • The init run once when the plugin starts
    DataUpdate runs once every frame. So keep it fast, avoid things like while loops for example.
    Declare all needed values a "level" above DataUpdate, end, int...
    Looks like that:

    C#:
    namespace User.PluginSdkDemo
    {
        public class DataPluginDemo : IPlugin, IDataPlugin, IWPFSettings
        {
            DECLARE STUFF HERE
            public void DataUpdate(PluginManager pluginManager, ref GameData data)
            {
            }
    
            public void Init(PluginManager pluginManager)
            {
            }
        }
    }
  • Properties can be placed anywhere in a class outside of methods,
    usually just below the "public class xxxx", making them them easier to find

Is it possible to create an array of properties in a plugin?​

A good plugin example​

3 property declarations​

  1. SetPropertyValue : simplest but slowest, set the value at each update loop
  2. Attachproperty : allows adding a "wrapper" for a property,
    which can be set at each game loop
    (a convoluted variation of the previous one,
    skipping SetPropertyValue costs,
    but keeping disavantages of requiring computations for each loop.)
    C#:
    public AttachedProperty<int> RGBIntensity = new AttachedProperty<int>();
    public void Init(PluginManager pluginManager)
    {
        RGBIntensity.Value = initialvalue;
        pluginManager.AttachProperty("RGBIntensity", typeof(SerialDashPlugin), properties.RGBIntensity);
    }
    
    void anotherfunc(){
          // This update has no particular CPU costs except computing "newvalue"
           RGBIntensity.Value = newvalue;
    }
  3. AttachDelegate with zero costs if not in use
 

Attachments

  • DataPlugDemo.cs.txt
    3.8 KB · Views: 215
Last edited:

We interrupt this irregular unscheduled thread​

Extracting vJoy from SLI-Pro and SLI-F1 plugin for SimHub is non-trivial,
and debugging more than one thing at a time
typically varies between problematic to doomed,
sorting vJoy itself will become a separate activity, not involving SimHub. Similarly for MIDI.

On the subject of MIDI,
a simple multichannel MIDI-controlled VST mixer plugin is unavailable
However, both MIDI Mixer and Voicemeeter support MIDI control of Windows audio channel volumes.
MIDI Mixer currently controls volume per device, rather than per channel.
Beyond that, Voicemeeter integrates with Equalizer APO to some extent.

While already having access to a MIDI controller,
its size (100x25cm) would be hard to use near the sim workstation.
Korg's nanoKONTROL2 is for me worthwhile for regular sim use.
Three Voicemeeter flavors:
  • original
    • one "virtual" input (max 8 channels)
    • two "real" inputs (max 2 channels each)
  • banana
    • more GUI sliders - 3 "real" + 2 "virtual"
    • 6 cell parametric equalization x 8 channels
    • VBAN (networked audio)
    • 8x8 Gain Matrix
  • potato
    • even more (than needed) GUI sliders
    • nagware
Voicemeeter is nominally constrained to a single MIDI controller;
workaround by merging MIDI controllers using MIDI Yoke and MIDI-OX.
Sorting MIDI feedback from Voicemeeter to multiple controllers is for the user.

More about VoiceMeeter
 
Last edited:

Android Wireless Mixer - MIDI app

Impatience led to finding an Android app to serve as a small MIDI control surface.
Installation instructions are here:
The Wireless Mixer is also free on Amazon's app store for cheap Fire tablets.
An alternative wireless MIDI solution could leverage rtpMIDI and TouchDAW on Android.
Using rtpMIDI would also enable support of iOS WiFi MIDI mixer apps and devices.

Disappointingly, SimHub's MIDI plugin seemingly supports only CC messages (buttons),
not e.g. sliders:
JavaScript:
var midi = $prop('InputStatus.PluginManager.DSMIDI out_ControlChange_0');
var s = 1;
for (var i = 1; i < 126; i++)
  if (null != $prop('InputStatus.PluginManager.DSMIDI out_ControlChange_'+i)) {
    midi += $prop('InputStatus.PluginManager.DSMIDI out_ControlChange_'+i)<<s;
    s++;
  }
return s+','+midi.toString(16)
Raw result
29,162c02e4

JavaScript:
if (null == root['s'])
  root['s'] = 1;
var s = root['s'];
while (null == $prop('InputStatus.PluginManager.DSMIDI out_ControlChange_'+s)) {
  if (126 <= s)
    s = 1;
  else s++;
}
if (root['s'] == s)
  s++;
root['s'] = s;
return s * $prop('InputStatus.PluginManager.DSMIDI out_ControlChange_'+s)/2;
 
Last edited:

VoiceMeeter Banana Windows configuration​

Words have meaning only when used appropriately.
VoiceMeeter folks refer to "Hardware Inputs" and "Virtual Inputs",
which none of them are.
So-called "Hardware Inputs" are merely those for connection
to Windows' Sound Recording devices, other than their own,
named "VoiceMeeter Output" and "VoiceMeeter Aux Output"
with one being no more or less "Aux" than the other, IMO.
FWIW one of those Recording "devices" is named "What U Hear":
SoundRecording.png

... how hardware is that?

So-called "Virtual Inputs" are Sound Playback devices that VB provides,
namely "VoiceMeeter Input" and "VoiceMeeter Aux Input",
but again the one seems no more "Aux" than the other...

For Windows users, VM Banana simply adds
2 playback devices and 2 recording devices.
If one so chooses, either VM playback or record device could
(like any other) be designated a Default Device.

A key point: how many channels are available
for "VoiceMeeter Input" and "VoiceMeeter Aux Input"
is configured using Windows' Configure, e.g.:
SoundPlayBack.png

SpeakerSetup.png


That's it, for Windows VM configuration, except for the usual Windows limitations:
  • Recording devices can typically be shared.
  • Playback devices, usually NOT:
    • once a Playback device is allocated to VM (or any other app),
      do not expect it to work with others.
    • For the specific case of VM, playback devices allocated to it
      may now be accessed via one of VM's playback devices,
      depending on VM's proprietary internal routing.
FWIW, Default Playback device on my gaming PC is a Sound Blaster X-Fi;
all other (non-VM) playback devices are allocated to VoiceMeeter,
and both VM Banana (7.1 channel) playback devices are allocated to SimHub ShakeIt.

VM proprietary internal routing is for another reply.
 
Last edited:

REAPER? (NOT!)​

VM proprietary internal routing
.. turns out to be disappointing,
with MIDI control only for sliders associated with inputs or busses, NOT channels.
REAPER offers per-track MIDI controls and seems highly regarded,
but in my brief (and yet far too long) experience
is practically impossible to configure for multichannel audio.
A positive from that exercise was discovering
SonicAxiom_multi-channel_level_trimmer_8x_mono,
a VST plugin with 8 MIDI-controllable sliders for multichannel audio.

Success came only after stumbling over
Using Voicemeeter, Equalizer APO and VSTHost,
where VSTHost glues a VST plugin to VoiceMeeter Banana and MIDI:
SimHubShakeItMIDI.jpg
 
Last edited:

Android Wireless Mixer controls​

Settings icon is second from left:
settings.png


Touching that launches a semi-transparent overlay at screen bottom:
icons.jpg


Touching its settings icon launches this menu,
with a MIDI channel option visible after scrolling down:
menu.jpg


.. then touching MIDI channel launches a channel menu:
channel.jpg


... now, on to the next reply...
 
Last edited:

SimHub ShakeIt to VoiceMeeter to VSTHost to SonicAxiom multi-channel trimmer​

... controlled by Android Wireless Mixer - MIDI

One issue with many nominally instructional videos:
  • instructors are entirely too familiar with their subject
    • rushing thru mouse actions that are new to viewers
In stills, then:
  • Enable VoiceMeeter Banana VAIO to A1 and B1
    • A1 is configured for a multichannel sound card,
      e.g. a 7.1 Realtek motherboard chip, in this case.
    • B1 is VoiceMeeter VAIO Recording device
      for any multichannel audio app that cares to use it.
  • In VoiceMeeter Menu > System settings / Options > PATCH INSERT,
    enable IN #4 VIRTUAL INPUTs:
    PatchInsert.png
  • Install SonicAxiom_multi-channel_level_trimmer_8x_mono
    • put that .dll in C:\Program Files\Vstplugins\
      which folder may need adding.
  • Install VSTHost after downloading e.g. vsthostx64.zip.
  • Configure the mess:
    • first, thanks to Vasr for sorting VSTHost with VoiceMeeter and a multichannel VST,
      then usefully describing its configuration.
    • Since VSTHost configuration has somewhat evolved
      and this is for the SonicAxiom plugin instead of Dirac,
      dedicated instructions are wanted.
    • In VSTHost, for connection to those VoiceMeeter PATCH INSERTs,
      • File > check Plugin Auto-Connect
      • File > Set Plugin Path..:
        PluginPath.gif
      • File > Plugins:
        Plugins.png
      • Devices > Wave...:
        Wave.gif
      • Engine > Configure...:
        Engine.gif

        Assign Output Channels to match Input channels.
    • SonicAxiom configuration: right-click the [i]:
      SonicAxiom.png

      to be continued...
 
Last edited:

SonicAxiom_multi-channel_level_trimmer configuration​

After right-click , hover mouse pointer over Window to expose a menu:
trimmerWindow.png

You will be accessing that menu several times...
Also, note Bypass,
which can be used to test VST routing to/from VSTHost
if/when SonicAxiom configuration is wrong.
  • Info (after configuration)
    Info.png
  • MIDI Settings
    MIDIsettings.gif
  • MIDI -> Parameter: As with VSTHost ,
    after right-click in Parameter column to select level
    right-click in Type and select *Learn*,
    then manipulate corresponding slider on Android Wireless Mixer:
    VstMIDI.png
This VST plugin really is just trimmers, not full-range volume controls,
so appropriate for fine-tuning tactile mixes.
If anyone finds a full-range multichannel VST volume plugin with MIDI control,
please do not hesitate to reply.
 

mcfx_gain_delay_8​

Another, more interesting 8-channel VST plugin alternative
that offers MIDI control for both gain and delay.
It gains are from -18 to +18dB, which wants SimHub output reduced
in order to exploit maximum dynamic range control by MIDI.

Delay controls are interesting
for multiple transducers driven by the same signal,
since their responses may be out of phase at crossover frequencies
resulting in destructive interference. Dialing more or less delay
into channels for each transducer enables smoothing response
over that range more effectively than e.g. by parametric EQ.

Since the plugin is still hosted by VSTHost,
configuration procedure is basically the same,
except that there are more (53) possible parameters for MIDI control.
mcfx_gain_delay.png

The signal generator will be a convenience
for tweaking delays at crossover frequencies.
 
Last edited:

MIDIShift

If you have a pair of 7.1 sound cards,
then you may want 16 sliders to control their volumes
or even 32 sliders to also control delays.

MIDIShift is an application that will allow
a single control surface to suddenly act as either of two,
based on a MIDI button press.

MidiView
Mere mortals may occasionally get confused
or even make mistakes.
MidiView can monitor a MIDI port's traffic.
This allows, e.g. verifying that ports are active
or Hex values for some MIDI messages.

Blue Cat's Gain Suite

Another free potential alternative to mcfx_gain_delay_8
or SonicAxiom_multi-channel_level_trimmer,
in previous replies. Not tested; posted here as a reminder...
 
Last edited:

Midi Controller Pro

for iPad

It turns out that iOS developers are more into monetization than Android developers
and not at all shy about charging for apps that are probably very broken
but certainly unobvious and undocumented.

Despite that, and 'Pro' in its name, this app does allow one
to send MIDI controls from an iPad to Windows MIDI
without paying for it (in money).
It provides its own Windows UDP-to-MIDI tool, mcpw.exe:

mcpw.png


One minor catch: one must program their own MIDI control surface..!
Actually, several are provided, but are IMO both confusing and bizarre.
With neither aptitude nor patience for GUI design, here is my sad attempt:
MidiCpro.jpg

.. and primitive and crude as it is, far too many hours have been spent on it.
While layout is tedious, assigning MIDI controls is exasperating.
First, any edit action first requires double-tapping in the background
to launch the menu:
menu.jpg

.. where MIDI assignment is hidden under Selected Items.
Developer documentation is here: https://www.turboirc.com/mcp/manual2.htm
Bottom line: iPad Control of SimHub effect channel volumes and delays is possible,
but I suggest instead using a cheap Amazon Fire tablet.

FWIW, attached is the profile for that iPad layout.
 

Attachments

  • eight.mc.txt
    10.8 KB · Views: 95
Last edited:

Old too soon: Open Stage Control

This is the easy/right way to do cross-platform:
  • configure a server on a real PC with a real OS
  • deploy web clients for portable devices
Other than its absurdly low contrast theme,
Open Stage Control already has quite a nice example mixer UI:
30510969-39451104-9acf-11e7-8ee0-6e93fa34464d.png


Here is the first relevant (MIDI) tutorial stumbled into: VI CONTROL: Open Stage Control (Tutorial)
Enough of this silliness
  • MIDI debugging practice sufficient to begin sorting a SimHub plugin
  • A USB MIDI surface arrived with 8 sliders + 8 knobs + many buttons.
    • control volume and delays for e.g. SimHub tactile effect channels...
    • easier to use in a driving sim with a VR headset.
 
Last edited:
@blekenbleu Great thread, but damn, these Simhub>Voicemeeter>VST Plugins>Soundcard Signal Chains are complicated. Which is the best pratice way so far?

Can't you just route the e.g. 8 VM input channels (coming from Simhub) to the VM Banana 8x AUX send channels, and route these AUX channels to the Soundcard? (So that you don't need the SonicAxium Plug In).

Though, how about latency? Doesn't Voicemeeter (plus Plug Ins) add a lot of latency? Especially as Simhub doesn't provide ASIO connectivity. When I tested the Simhub/Soundcard latency (time from triggering the Simhub telemetry effect until Signal out at Soundcard out. Without Voicemeeter inbetween) I measured between 140 to 225 ms latency. (Depending on the Sound Card model). Which is a pretty high latency anyway.
 
Can't you just route the e.g. 8 VM input channels (coming from Simhub) to the VM Banana 8x AUX send channels, and route these AUX channels to the Soundcard?
(So that you don't need the SonicAxium Plug In).
SimHub channels can be routed directly to soundcards,
avoiding all complication.
My intention is to control VST plugin by MIDI and (eventually)
release a SimHub MIDI out plugin to modulate one SimHub effect
(e.g. wheel slip) by another (e.g. wheel load).
After all, a completely unloaded wheel should have no effect...

Meanwhile, I dial SimHub channel levels by touch
while wearing a VR headset,
using a Korg nanoKontroller2 MIDI controller.

As an alternative to SimHub MIDI out plugin,
I am hacking an ESP32 module to be a MIDI out,
driven from SimHub custom serial device...

Most sim cars that I drive have relatively soft suspensions;
tire reactions are less than instantaneous,
and latency has yet to bother me.
I measured between 140 to 225 ms latency
I wonder whether you have set Output tuning->Output Filtering;
those may add appreciable latency.
 
Last edited:

Latest News

What's needed for simracing in 2024?

  • More games, period

  • Better graphics/visuals

  • Advanced physics and handling

  • More cars and tracks

  • AI improvements

  • AI engineering

  • Cross-platform play

  • New game Modes

  • Other, post your idea


Results are only viewable after voting.
Back
Top