COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 04-01-2020, 07:59 AM   #1
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 301
Default Sidechain pain

I'm working to implement sidechaining in one of my plugins and I am finding it to be quite a challenge. What works in AAX and VST3 doesn't work in VST2; what works in one DAW doesn't work in another DAW, etc.

I have studied the SideChain example as well as every related thread on this forum but there doesn't seem to be a consensus on approach.

I have tried to make the plugin "self connecting" to sidechain signals by using the IsInChannelConnected() functions but as others here have commented it doesn't always work. Some hosts show connected to channels 3 & 4 of a “4-2” plugin, for example, but then don't apply signals there.

So I am wondering how everyone else is doing this. Is it necessary to put a "switch" on the plugin GUI to turn sidechaining on/off PLUS use the "4-2" configuration, etc.? Or is there an automatic sidechain detection approach that generally works everywhere?

Any tips greatly appreciated!

Last edited by Nonlinear; 04-01-2020 at 04:30 PM.
Nonlinear is offline   Reply With Quote
Old 04-02-2020, 03:16 AM   #2
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: UK
Posts: 1,213
Default

side chain is quite the PITA

i still have to implement it for iPlug2
__________________
VirtualCZ | pMix | Endless Series | iPlug2 | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is offline   Reply With Quote
Old 04-02-2020, 10:25 AM   #3
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 301
Default

Quote:
Originally Posted by olilarkin View Post
side chain is quite the PITA

i still have to implement it for iPlug2
One thing I have done that helped mitigate the issues was to place a "Side chain input" switch on the UI. That takes care of some of the internal switching issues (user selects internal or external side chain input).

This "switch" is common on plugins I use from other developers and is, perhaps, part of the trick to making side chaining work everywhere. It seems we can't rely on the signals from the hosts to do this switching. Maybe this is already well known here but just thought I'd mention it.

As far as iPlug1, it seems there are many interface issues in iPlugVST3.cpp. My side chain setup currently works in DAWs but it crashes Tracktions "Pluginval" with this error:

if (mScChans && numIns == 2) // numIns = num Input BUSes
Exception thrown at 0x00007FFDC3BEA859 in pluginval.exe: Microsoft C++ exception: std:: out_of_range at memory location 0x00000080A4AFCAD0.
if (mScChans && numIns == 2) // numIns = num Input BUSes
Exception thrown at 0x00007FFDC3BEA859 in pluginval.exe: Microsoft C++ exception: std:: out_of_range at memory location 0x00000080A4AFA5A0.

So there is an I/O issue somewhere - which is weird because it works! Any advice on what could be wrong here? Code in that block of iPlugVST3.cpp (setBusArrangements) seems to make sense.

Last edited by Nonlinear; 04-02-2020 at 11:21 AM.
Nonlinear is offline   Reply With Quote
Old 04-02-2020, 03:11 PM   #4
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 301
Default

Quick question - the "setBusArrangements" block in iPlugVST3.cpp has a final return value of "kResultFalse". The purpose of this block is to check and set up all the I/O buses - shouldn't the final result at the end of all the checking and set up be "kResultTrue"?

I have tried it both ways and it doesn't seem to make any difference. Why not?
Nonlinear is offline   Reply With Quote
Old 04-02-2020, 03:46 PM   #5
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: UK
Posts: 1,213
Default

- I would suggest using the steinberg vst3 validator rather than pluginval for testing this stuff. It's made by steinberg for testing vst3 conformity.

- also I would not assume the WDL-OL "iPlug1" VST3 implementation is correct. Check the VST3 docs.

https://steinbergmedia.github.io/vst...stsdk/faq.html

- that return kResultFalse at the end, would not be hit in the case of correct busses, in which case the method returns kResultTrue at an earlier stage. In theory
__________________
VirtualCZ | pMix | Endless Series | iPlug2 | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is offline   Reply With Quote
Old 04-02-2020, 06:42 PM   #6
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 301
Default

Quote:
Originally Posted by olilarkin View Post
- I would suggest using the steinberg vst3 validator rather than pluginval for testing this stuff. It's made by steinberg for testing vst3 conformity.

- also I would not assume the WDL-OL "iPlug1" VST3 implementation is correct. Check the VST3 docs.

https://steinbergmedia.github.io/vst...stsdk/faq.html

- that return kResultFalse at the end, would not be hit in the case of correct busses, in which case the method returns kResultTrue at an earlier stage. In theory
Yes, understand. I will be checking through the VST3 docs as well.

In the meantime I found the cause of the crash in pluginval. It seems to be with this line narrowed down from my post above:

bus = FCast<AudioBus>(audioInputs.at(1));

Apparently pluginval checks some SpeakerArr that is not recognized. I commented out this line and then set the sidechain buses directly without the "if (bus && (SpeakerArr::getChannelCount(bus->getArrangement()) != reqNumSideChainChannels))" check.

It validates with zero errors in both Steinberg VST3 Test Host and in pluginval and it works in all the VST3 hosts I tested it in (Cakewalk, Cubase, Wavelab, Reaper) with both mono and stereo inputs as well as mono and stereo side chain inputs (only tested in Windows so far).

So...it LOOKS like it's working - but are there consequences of skirting that "If" check?

Last edited by Nonlinear; 04-02-2020 at 09:03 PM.
Nonlinear is offline   Reply With Quote
Old 05-10-2020, 12:44 PM   #7
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 351
Default

Is there any path to side-chain success with Iplug1 and AU? I have also been looking at all the forum posts and trying different things, but it looks like the plugin isn't being recognized as supporting 4 seperate inputs.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 05-11-2020, 05:33 AM   #8
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: UK
Posts: 1,213
Default

what format are you having trouble with?
__________________
VirtualCZ | pMix | Endless Series | iPlug2 | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is offline   Reply With Quote
Old 05-11-2020, 06:21 AM   #9
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 351
Default

Quote:
Originally Posted by olilarkin View Post
what format are you having trouble with?
I am having issues with the AU format. In resource.h, I have
PHP Code:
  #define PLUG_CHANNEL_IO "2-2 4-2"
  #define PLUG_SC_CHANS 2 
I have tried other channel settings as well, but Reaper does not appear to recognize the plugin as having side chain input support.

I am stepping through the debugger at this point, but I didn't know if someone had some suggestions based on their own trials.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 05-11-2020, 06:43 AM   #10
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 351
Default

To make things more confusing:

Reaper: AU sidechain doesn't work
Logic: AU sidechain does work
Studio One3: AU sidechain doesn't work
Live10: AU sidechain does work

All the same code.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 05-17-2020, 10:52 AM   #11
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 254
Default

I remember sidechaining was a pain in the ar... when i tried to get my plug properly working in different DAWs.
After spending hours with trying to find a proper working #define i gave up and switched to a somewhat brute force approach. But i had to twaek IPlugAU.cpp
If you don't mind to take your hands on it try what works for me.
Code:
My channel definitions in resource.h:

#define PLUG_CHANNEL_IO "2-2 3-2 4-2"
#define PLUG_SC_CHANS 2
Code:
In IPlugAU.cpp add the bottom lines

void IPlugAU::AssessInputConnections()
{
  TRACE;
  IMutexLock lock(this);

  SetInputChannelConnections(0, NInChannels(), false);

  int nIn = mInBuses.GetSize();
  for (int i = 0; i < nIn; ++i)
  {
    BusChannels* pInBus = mInBuses.Get(i);
    InputBusConnection* pInBusConn = mInBusConnections.Get(i);
      
*** Add this ***

      pInBus->mNHostChannels = (GetHost() == kHostAbletonLive)? (i>0)? 0:4 : 2;
      pInBus->mNPlugChannels = 2;
      pInBus->mPlugChannelStartIdx = (i>0)? 2:0;
Don't ask why i came up with the Live exception. It's too long ago that i remember. However with this changes sidechaining works with all AUs in Reaper, Live, Logic, andStudio One on my side.
stw is offline   Reply With Quote
Old 05-17-2020, 12:50 PM   #12
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 301
Default

Quote:
Originally Posted by stw View Post
Code:
#define PLUG_CHANNEL_IO "2-2 3-2 4-2"
Hmm - careful with "3-2". If I remember right that breaks (crashes) Reaper on Windows.
Nonlinear is offline   Reply With Quote
Old 05-17-2020, 02:12 PM   #13
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 254
Default

Quote:
Originally Posted by Nonlinear View Post
Hmm - careful with "3-2". If I remember right that breaks (crashes) Reaper on Windows.
hmm... not here.

And for the sake of completeness, here the channel defs for AAX
Code:
#ifdef AAX_API 
#define PLUG_CHANNEL_IO "2-2 3-2"
#define PLUG_SC_CHANS 1
#else
.
.
.
stw is offline   Reply With Quote
Old 05-17-2020, 03:07 PM   #14
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 301
Default

Quote:
Originally Posted by stw View Post
hmm... not here.
There are no mono channels in Reaper, AFAIK, so "3-2" doesn’t mean anything in that DAW. Maybe since you also list 2-2 and 4-2 it’s OK? IDK. When I tried 3-2 here it crashed. (But 3-2 IS required for AAX).


My current sidechain code works in Reaper as VST and VST3 but not AU. It shows up as "2/4-in" but when I try to turn on inputs 3/4 the main inputs disappear from the matrix. Reaper’s meters show the plugin is receiving the sidechain input but, as the matrix would indicate, there is no main signal in/out (no sound).

BTW, as with LVC Audio's experience, it DOES work as-is in Logic Pro X.

Will check your AU tweaks. Thank you for posting them.

UPDATE: Yes! AU side chain works properly in Reaper and Logic. Thank you!

Code:
      pInBus->mNHostChannels = (GetHost() == kHostAbletonLive)? (i>0)? 0:4 : 2;
      pInBus->mNPlugChannels = 2;
      pInBus->mPlugChannelStartIdx = (i>0)? 2:0;

Last edited by Nonlinear; 05-17-2020 at 06:13 PM.
Nonlinear is offline   Reply With Quote
Old 05-20-2020, 05:00 AM   #15
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 351
Default

I am getting closer, but I am still having some issues with AAX on both the Mac and PC. The KEY in ProTools is not visible to enable sidechaining.

Here is what I am using in resource.h (this was after experimenting with AU, VST, & VST3)

PHP Code:
#ifdef AU_API
#define PLUG_CHANNEL_IO "2-2 4-2"
#define PLUG_SC_CHANS 2
#elif AAX_API
#define PLUG_CHANNEL_IO "2-2 3-2"
#define PLUG_SC_CHANS 1
#elif VST_API
#define PLUG_CHANNEL_IO "2-1 3-2 2-2 4-2"
#define PLUG_SC_CHANS 2
#else
#define PLUG_CHANNEL_IO "2-2 4-2"
#define PLUG_SC_CHANS 2
#endif 

Testing all formats on different OSs are working in Reaper, Live10, Logic, and StudioOne 3 (well, StudioOne struggles with VST unless the plugin is placed on a stereo track).

Does PLUG_TYPE_IDS[], PLUG_TYPE_IDS_AS, or PLUG_DOES_AUDIOSUITE matter?

Does it matter if the PLUG_TYPE_PT isn't Dynamics (it is EQ)?

Is there anything else in resource.h that matters except PLUG_CHANNEL and PLUG_SC_CHANS?
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 05-20-2020, 05:48 AM   #16
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: UK
Posts: 1,213
Default

don't really have time to go into iPlug1 stuff, but i just made this work properly in iPlug2, you might be able to work it out from here

https://github.com/iPlug2/iPlug2/com...b4ec58cb590115
__________________
VirtualCZ | pMix | Endless Series | iPlug2 | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is offline   Reply With Quote
Old 05-20-2020, 09:21 AM   #17
Nonlinear
Human being with feelings
 
Join Date: Apr 2018
Posts: 301
Default

Quote:
Originally Posted by random_id View Post
I am getting closer, but I am still having some issues with AAX on both the Mac and PC. The KEY in ProTools is not visible to enable sidechaining.
I had that problem initially too and it turned out there was some code missing from the iPlugAAX .cpp/.h set that I was using. I’m on travel and can’t get to it right now but will post it when I get back on Saturday.

Last edited by Nonlinear; 05-20-2020 at 09:39 AM.
Nonlinear is offline   Reply With Quote
Old 05-20-2020, 02:39 PM   #18
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 254
Default

Quote:
Originally Posted by random_id View Post
I am getting closer, but I am still having some issues with AAX on both the Mac and PC. The KEY in ProTools is not visible to enable sidechaining.
I remember that i also made some changes to IPlugAAX.cpp. Sorry, i forgot abaout that. I'll look into it and check if these may have anything to do with that.
stw is offline   Reply With Quote
Old 05-21-2020, 02:40 AM   #19
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 254
Default

I looked at my IPlugAAX.cpp but the changes i implemented don't seem to have any influence on the sidechain key itself.
However i remember i took my AAX sidechaining infos from this thread back then:
https://forum.cockos.com/showthread.php?t=167892

Saverio aka Hornet also implemented that and upped it on Github.
https://github.com/hor-net/wdl-ol/bl...g/IPlugAAX.cpp

Maybe it helps...
stw is offline   Reply With Quote
Old 05-21-2020, 06:19 PM   #20
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 351
Default

I think I got it. I had to look at the changes made to Saverio's (Hornet's) code. There were changes in IPlugAAX.cpp, IPlugAAX_Describe.cpp, AAX_CIPlugParameters.h, and AAX_CIPlugParameters.cpp.

I also had to make one adjustment to his code in IPlugAAX.cpp. In RenderAudio(), I replaced lines 332 (#ifdef PLUG_SC_CHANS) to 346 (AttachInputBuffers(0, nuInChannels...) with this:

PHP Code:
int totalChannelIn numInChannels;
#ifdef PLUG_SC_CHANS
if (ioRenderInfo->mAudioSideChainAddr) {
printf("sidechain\n");
SetInputChannelConnections(0numInChannelstrue);
SetInputChannelConnections(NInChannels() - 11true);
totalChannelIn NInChannels();

else {
printf("no sidechain\n"); SetInputChannelConnections(0numInChannelstrue);
}
#else
SetInputChannelConnections(0numInChannelstrue);
#endif
printf("attach input buffers: 0 - %d\n"totalChannelIn);
AttachInputBuffers(0totalChannelInioRenderInfo->mAudioInputsnumSamples); 

Without this change, the AttachInputBuffers() never attached the side-chain input and the plugin never received any side-chain data. PT recognized the plugin as a side-chain-enabled plugin, but the side-chain buffers were never correctly connected.

I need to test on the Mac, but this appears to be working now.
__________________
Website: LVC-Audio
random_id 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 09:20 AM.


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