Skip to content

Commit

Permalink
New MIDI parameter syntax for --ctrlmidich arg
Browse files Browse the repository at this point in the history
As part of issue jamulussoftware#95, this implements a new way of specifying various
controllers.  The previous possibilities are retained.  This leaves

--ctrlmidich <n> receives on channel n (if 0, on all channels), offset
   to first fader is 70 (Behringer X-Touch)

--ctrlmidich <n>;<off> for specifying a different offset

--ctrlmidich <n>;f<off>*<channels>;p<off>*<channels> specified offsets
for fader controllers and pan controllers, respectively.

There are also s<off> and m<off> specs for Solo and Mute buttons,
respectively.

This only concerns the command line parsing: the actual implementation
is only there for the volume faders.
  • Loading branch information
dakhubgit committed Feb 2, 2021
1 parent d10ebfd commit 72b75a4
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions src/soundbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

#include "soundbase.h"

char const sMidiCtlChar[] =
{
[EMidiCtlType::Fader] = 'f',
[EMidiCtlType::Pan] = 'p',
[EMidiCtlType::Solo] = 's',
[EMidiCtlType::Mute] = 'm',
[EMidiCtlType::None] = '\0'
};


/* Implementation *************************************************************/
CSoundBase::CSoundBase ( const QString& strNewSystemDriverTechniqueName,
Expand Down Expand Up @@ -248,17 +257,51 @@ void CSoundBase::ParseCommandLineArgument ( const QString& strMIDISetup )
iCtrlMIDIChannel = slMIDIParams[0].toUInt();
}

bool bSimple = true;

// [offset for level]
if ( slMIDIParams.count() >= 2 )
{
iMIDIOffsetFader = slMIDIParams[1].toUInt();
int i = slMIDIParams[1].toUInt (&bSimple);
if (bSimple)
iMIDIOffsetFader = i;
}

for (int i = 0; i < MAX_NUM_CHANNELS; i++)
if (bSimple)
{
if (i + iMIDIOffsetFader > 127)
break;
aMidiCtls[i + iMIDIOffsetFader] = { EMidiCtlType::Fader, i };
for (int i = 0; i < MAX_NUM_CHANNELS; i++)
{
if (i + iMIDIOffsetFader > 127)
break;
aMidiCtls[i + iMIDIOffsetFader] = { EMidiCtlType::Fader, i };
}
return;
}

// We have named controllers

for (int i = 1; i < slMIDIParams.count(); i++)
{
QString sParm = slMIDIParams[i].toLower ().remove ( ' ' );
if ( sParm.isEmpty() )
continue;

int iCtrl = QString ( sMidiCtlChar ).indexOf ( sParm[0] );
if (iCtrl < 0)
continue;
EMidiCtlType eTyp = static_cast<EMidiCtlType>( iCtrl );

const QStringList slP = sParm.mid ( 1 ).split ( '*' );
int iFirst = slP[0].toUInt ();
int iNum = ( slP.count() > 1 ) ? slP[1].toUInt () : 1;
for (int iOff = 0; iOff < iNum; iOff++)
{
if (iOff >= MAX_NUM_CHANNELS)
break;
if (iFirst + iOff >= 128)
break;
aMidiCtls[iFirst + iOff] = { eTyp, iOff };
}
}
}
}
Expand Down

0 comments on commit 72b75a4

Please sign in to comment.