Skip to content

Commit

Permalink
Merge branch 'main' into print-performance-number
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd authored Aug 13, 2023
2 parents a4221a6 + b2c95bd commit 624ed76
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 45 deletions.
20 changes: 10 additions & 10 deletions performance/000008_AmpUpright.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
BankNumber1=2
VoiceNumber1=6
MIDIChannel1=0
Volume1=47
VoiceNumber1=2
MIDIChannel1=1
Volume1=87
Pan1=0
Detune1=0
Detune1=2
Cutoff1=99
Resonance1=0
NoteLimitLow1=0
Expand All @@ -15,7 +15,7 @@ PitchBendStep1=0
PortamentoMode1=0
PortamentoGlissando1=0
PortamentoTime1=0
VoiceData1=5F 15 00 26 5C 3E 60 00 30 05 0A 03 00 04 00 01 55 00 01 00 07 4D 48 48 22 32 62 00 00 27 00 14 00 01 00 00 04 5F 01 02 00 0A 59 3C 17 23 63 5E 00 00 2E 03 02 03 03 03 00 01 5E 01 00 00 00 5F 1C 06 23 63 59 4B 00 05 00 63 00 01 02 00 06 4F 00 05 00 09 58 5C 47 3F 63 43 5B 5A 27 0C 14 03 00 02 00 01 5A 00 01 00 05 58 1C 1B 32 63 5A 00 00 11 63 05 03 00 02 00 03 63 00 01 00 07 00 00 00 00 32 32 32 32 0A 05 01 0E 05 00 00 00 00 01 18 41 31 31 50 6E 34 4D 46 78 64 74
VoiceData1=43 0B 0B 2A 63 58 00 00 02 00 4E 03 01 06 00 00 50 00 05 00 0E 45 0A 0D 2A 63 58 00 00 22 08 09 03 00 01 00 04 51 00 01 00 0B 4E 49 33 37 63 3A 00 00 33 0C 0B 03 03 01 00 02 5C 01 06 09 06 40 15 07 2C 63 4F 00 00 1E 00 00 00 00 07 00 03 63 00 01 00 08 42 0B 00 27 63 4F 00 00 20 00 09 00 00 03 00 01 4C 00 01 01 00 40 15 07 2C 63 4F 00 00 1E 00 00 00 00 07 00 02 63 00 01 00 03 63 63 63 63 32 32 32 32 08 07 01 23 00 00 00 01 00 02 18 50 69 61 6E 6F 42 6F 20 31 5C 55
MonoMode1=0
ModulationWheelRange1=99
ModulationWheelTarget1=1
Expand Down Expand Up @@ -53,11 +53,11 @@ BreathControlTarget2=0
AftertouchRange2=99
AftertouchTarget2=0
BankNumber3=2
VoiceNumber3=2
MIDIChannel3=1
Volume3=87
VoiceNumber3=6
MIDIChannel3=0
Volume3=47
Pan3=0
Detune3=2
Detune3=0
Cutoff3=99
Resonance3=0
NoteLimitLow3=0
Expand All @@ -69,7 +69,7 @@ PitchBendStep3=0
PortamentoMode3=0
PortamentoGlissando3=0
PortamentoTime3=0
VoiceData3=43 0B 0B 2A 63 58 00 00 02 00 4E 03 01 06 00 00 50 00 05 00 0E 45 0A 0D 2A 63 58 00 00 22 08 09 03 00 01 00 04 51 00 01 00 0B 4E 49 33 37 63 3A 00 00 33 0C 0B 03 03 01 00 02 5C 01 06 09 06 40 15 07 2C 63 4F 00 00 1E 00 00 00 00 07 00 03 63 00 01 00 08 42 0B 00 27 63 4F 00 00 20 00 09 00 00 03 00 01 4C 00 01 01 00 40 15 07 2C 63 4F 00 00 1E 00 00 00 00 07 00 02 63 00 01 00 03 63 63 63 63 32 32 32 32 08 07 01 23 00 00 00 01 00 02 18 50 69 61 6E 6F 42 6F 20 31 5C 55
VoiceData3=5F 15 00 26 5C 3E 60 00 30 05 0A 03 00 04 00 01 55 00 01 00 07 4D 48 48 22 32 62 00 00 27 00 14 00 01 00 00 04 5F 01 02 00 0A 59 3C 17 23 63 5E 00 00 2E 03 02 03 03 03 00 01 5E 01 00 00 00 5F 1C 06 23 63 59 4B 00 05 00 63 00 01 02 00 06 4F 00 05 00 09 58 5C 47 3F 63 43 5B 5A 27 0C 14 03 00 02 00 01 5A 00 01 00 05 58 1C 1B 32 63 5A 00 00 11 63 05 03 00 02 00 03 63 00 01 00 07 00 00 00 00 32 32 32 32 0A 05 01 0E 05 00 00 00 00 01 18 41 31 31 50 6E 34 4D 46 78 64 74
MonoMode3=0
ModulationWheelRange3=99
ModulationWheelTarget3=1
Expand Down
81 changes: 80 additions & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ void CConfig::Load (void)
m_nDoubleClickTimeout = m_Properties.GetNumber ("DoubleClickTimeout", 400);
m_nLongPressTimeout = m_Properties.GetNumber ("LongPressTimeout", 600);

m_nButtonPinPgmUp = m_Properties.GetNumber ("ButtonPinPgmUp", 0);
m_nButtonPinPgmDown = m_Properties.GetNumber ("ButtonPinPgmDown", 0);
m_nButtonPinTGUp = m_Properties.GetNumber ("ButtonPinTGUp", 0);
m_nButtonPinTGDown = m_Properties.GetNumber ("ButtonPinTGDown", 0);

m_ButtonActionPgmUp = m_Properties.GetString ("ButtonActionPgmUp", "");
m_ButtonActionPgmDown = m_Properties.GetString ("ButtonActionPgmDown", "");
m_ButtonActionTGUp = m_Properties.GetString ("ButtonActionTGUp", "");
m_ButtonActionTGDown = m_Properties.GetString ("ButtonActionTGDown", "");

m_nMIDIButtonCh = m_Properties.GetNumber ("MIDIButtonCh", 0);
m_nMIDIButtonNotes = m_Properties.GetNumber ("MIDIButtonNotes", 0);
m_nMIDIButtonPrev = m_Properties.GetNumber ("MIDIButtonPrev", 0);
Expand All @@ -127,13 +137,19 @@ void CConfig::Load (void)
m_nMIDIButtonSelect = m_Properties.GetNumber ("MIDIButtonSelect", 0);
m_nMIDIButtonHome = m_Properties.GetNumber ("MIDIButtonHome", 0);

m_nMIDIButtonPgmUp = m_Properties.GetNumber ("MIDIButtonPgmUp", 0);
m_nMIDIButtonPgmDown = m_Properties.GetNumber ("MIDIButtonPgmDown", 0);
m_nMIDIButtonTGUp = m_Properties.GetNumber ("MIDIButtonTGUp", 0);
m_nMIDIButtonTGDown = m_Properties.GetNumber ("MIDIButtonTGDown", 0);

m_bEncoderEnabled = m_Properties.GetNumber ("EncoderEnabled", 0) != 0;
m_nEncoderPinClock = m_Properties.GetNumber ("EncoderPinClock", 10);
m_nEncoderPinData = m_Properties.GetNumber ("EncoderPinData", 9);

m_bMIDIDumpEnabled = m_Properties.GetNumber ("MIDIDumpEnabled", 0) != 0;
m_bProfileEnabled = m_Properties.GetNumber ("ProfileEnabled", 0) != 0;
m_bPerformanceSelectToLoad = m_Properties.GetNumber ("PerformanceSelectToLoad", 1) != 0;
m_bPerformanceSelectChannel = m_Properties.GetNumber ("PerformanceSelectChannel", 0);
}

const char *CConfig::GetSoundDevice (void) const
Expand Down Expand Up @@ -351,6 +367,46 @@ unsigned CConfig::GetLongPressTimeout (void) const
return m_nLongPressTimeout;
}

unsigned CConfig::GetButtonPinPgmUp (void) const
{
return m_nButtonPinPgmUp;
}

unsigned CConfig::GetButtonPinPgmDown (void) const
{
return m_nButtonPinPgmDown;
}

unsigned CConfig::GetButtonPinTGUp (void) const
{
return m_nButtonPinTGUp;
}

unsigned CConfig::GetButtonPinTGDown (void) const
{
return m_nButtonPinTGDown;
}

const char *CConfig::GetButtonActionPgmUp (void) const
{
return m_ButtonActionPgmUp.c_str();
}

const char *CConfig::GetButtonActionPgmDown (void) const
{
return m_ButtonActionPgmDown.c_str();
}

const char *CConfig::GetButtonActionTGUp (void) const
{
return m_ButtonActionTGUp.c_str();
}

const char *CConfig::GetButtonActionTGDown (void) const
{
return m_ButtonActionTGDown.c_str();
}

unsigned CConfig::GetMIDIButtonCh (void) const
{
return m_nMIDIButtonCh;
Expand Down Expand Up @@ -386,6 +442,26 @@ unsigned CConfig::GetMIDIButtonHome (void) const
return m_nMIDIButtonHome;
}

unsigned CConfig::GetMIDIButtonPgmUp (void) const
{
return m_nMIDIButtonPgmUp;
}

unsigned CConfig::GetMIDIButtonPgmDown (void) const
{
return m_nMIDIButtonPgmDown;
}

unsigned CConfig::GetMIDIButtonTGUp (void) const
{
return m_nMIDIButtonTGUp;
}

unsigned CConfig::GetMIDIButtonTGDown (void) const
{
return m_nMIDIButtonTGDown;
}

bool CConfig::GetEncoderEnabled (void) const
{
return m_bEncoderEnabled;
Expand Down Expand Up @@ -416,4 +492,7 @@ bool CConfig::GetPerformanceSelectToLoad (void) const
return m_bPerformanceSelectToLoad;
}


unsigned CConfig::GetPerformanceSelectChannel (void) const
{
return m_bPerformanceSelectChannel;
}
35 changes: 33 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ class CConfig // Configuration for MiniDexed
unsigned GetDoubleClickTimeout (void) const;
unsigned GetLongPressTimeout (void) const;

// GPIO Button Program and TG Selection
// GPIO pin numbers are chip numbers, not header positions
unsigned GetButtonPinPgmUp (void) const;
unsigned GetButtonPinPgmDown (void) const;
unsigned GetButtonPinTGUp (void) const;
unsigned GetButtonPinTGDown (void) const;

// Action type for buttons: "click", "doubleclick", "longpress", ""
const char *GetButtonActionPgmUp (void) const;
const char *GetButtonActionPgmDown (void) const;
const char *GetButtonActionTGUp (void) const;
const char *GetButtonActionTGDown (void) const;

// MIDI Button Navigation
unsigned GetMIDIButtonCh (void) const;
unsigned GetMIDIButtonNotes (void) const;
Expand All @@ -131,6 +144,12 @@ class CConfig // Configuration for MiniDexed
unsigned GetMIDIButtonBack (void) const;
unsigned GetMIDIButtonSelect (void) const;
unsigned GetMIDIButtonHome (void) const;

// MIDI Button Program and TG Selection
unsigned GetMIDIButtonPgmUp (void) const;
unsigned GetMIDIButtonPgmDown (void) const;
unsigned GetMIDIButtonTGUp (void) const;
unsigned GetMIDIButtonTGDown (void) const;

// KY-040 Rotary Encoder
// GPIO pin numbers are chip numbers, not header positions
Expand All @@ -144,6 +163,7 @@ class CConfig // Configuration for MiniDexed

// Load performance mode. 0 for load just rotating encoder, 1 load just when Select is pushed
bool GetPerformanceSelectToLoad (void) const;
unsigned GetPerformanceSelectChannel (void) const;

private:
CPropertiesFatFsFile m_Properties;
Expand Down Expand Up @@ -189,12 +209,20 @@ class CConfig // Configuration for MiniDexed
unsigned m_nButtonPinSelect;
unsigned m_nButtonPinHome;
unsigned m_nButtonPinShortcut;
unsigned m_nButtonPinPgmUp;
unsigned m_nButtonPinPgmDown;
unsigned m_nButtonPinTGUp;
unsigned m_nButtonPinTGDown;

std::string m_ButtonActionPrev;
std::string m_ButtonActionNext;
std::string m_ButtonActionBack;
std::string m_ButtonActionSelect;
std::string m_ButtonActionHome;
std::string m_ButtonActionPgmUp;
std::string m_ButtonActionPgmDown;
std::string m_ButtonActionTGUp;
std::string m_ButtonActionTGDown;

unsigned m_nDoubleClickTimeout;
unsigned m_nLongPressTimeout;
Expand All @@ -206,6 +234,10 @@ class CConfig // Configuration for MiniDexed
unsigned m_nMIDIButtonBack;
unsigned m_nMIDIButtonSelect;
unsigned m_nMIDIButtonHome;
unsigned m_nMIDIButtonPgmUp;
unsigned m_nMIDIButtonPgmDown;
unsigned m_nMIDIButtonTGUp;
unsigned m_nMIDIButtonTGDown;

bool m_bEncoderEnabled;
unsigned m_nEncoderPinClock;
Expand All @@ -214,8 +246,7 @@ class CConfig // Configuration for MiniDexed
bool m_bMIDIDumpEnabled;
bool m_bProfileEnabled;
bool m_bPerformanceSelectToLoad;


unsigned m_bPerformanceSelectChannel;
};

#endif
23 changes: 20 additions & 3 deletions src/mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,25 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
case MIDI_NOTE_ON:
if (nLength < 3)
{
break;
break;
}
m_pUI->UIMIDICmdHandler (ucChannel, ucStatus & 0xF0, pMessage[1], pMessage[2]);
break;
case MIDI_PROGRAM_CHANGE:
// Check for performance PC messages
if( m_pConfig->GetMIDIRXProgramChange() )
{
unsigned nPerfCh = m_pSynthesizer->GetPerformanceSelectChannel();
if( nPerfCh != Disabled)
{
if ((ucChannel == nPerfCh) || (nPerfCh == OmniMode))
{
//printf("Performance Select Channel %d\n", nPerfCh);
m_pSynthesizer->ProgramChangePerformance (pMessage[1]);
}
}
}
break;
}

// Process MIDI for each Tone Generator
Expand Down Expand Up @@ -336,9 +351,11 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
break;

case MIDI_PROGRAM_CHANGE:
// do program change only if enabled in config
if( m_pConfig->GetMIDIRXProgramChange() )
// do program change only if enabled in config and not in "Performance Select Channel" mode
if( m_pConfig->GetMIDIRXProgramChange() && ( m_pSynthesizer->GetPerformanceSelectChannel() == Disabled) ) {
//printf("Program Change to %d (%d)\n", ucChannel, m_pSynthesizer->GetPerformanceSelectChannel());
m_pSynthesizer->ProgramChange (pMessage[1], nTG);
}
break;

case MIDI_PITCH_BEND: {
Expand Down
5 changes: 3 additions & 2 deletions src/midipin.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
#include <circle/types.h>

// MIDI CC numbers go 0 to 127.
// NB: 0 is treated as "unused" so CC=0 won't work
// Normal GPIO pins are below 100.
// So use a "pin number" of 128 + MIDI CC message for a "MIDI Pin"
#define MIDI_PINS 128
#define ccToMidiPin(c) ((c)+MIDI_PINS)
#define MidiPinToCC(p) ((p)-MIDI_PINS)
#define ccToMidiPin(c) (((c)==0)?0:((c)+MIDI_PINS))
#define MidiPinToCC(p) (((p)>=MIDI_PINS)?((p)-MIDI_PINS):0)
#define isMidiPin(p) (((p)>=MIDI_PINS)?1:0)

class CMIDIPin
Expand Down
Loading

0 comments on commit 624ed76

Please sign in to comment.