diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cbd4bdd..7ee4ebb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,11 +20,17 @@ jobs: run: | set -ex git submodule update --init --recursive - - name: Use Circle develop branch for WM8960 and i2c display support until it is merged upstream + - name: Use Circle develop branch for SSD1306 display rotation support until it is merged upstream run: | set -ex + cd circle-stdlib/ + git checkout e318f89 # Needed to support Circle develop? + cd - cd circle-stdlib/libs/circle - git checkout 646c362 # develop + git checkout ec09d7e # develop + cd - + cd circle-stdlib/libs/circle-newlib + git checkout 48bf91d # needed for circle ec09d7e cd - - name: Install toolchains run: | diff --git a/src/Rules.mk b/src/Rules.mk index 39b9f25..d466b74 100644 --- a/src/Rules.mk +++ b/src/Rules.mk @@ -23,6 +23,7 @@ LIBS += \ $(CIRCLEHOME)/addon/SDCard/libsdcard.a \ $(CIRCLEHOME)/lib/usb/libusb.a \ $(CIRCLEHOME)/lib/input/libinput.a \ + $(CIRCLEHOME)/lib/sound/libsound.a \ $(CIRCLEHOME)/addon/fatfs/libfatfs.a \ $(CIRCLEHOME)/lib/fs/libfs.a \ $(CIRCLEHOME)/lib/sched/libsched.a \ diff --git a/src/circle_stdlib_app.h b/src/circle_stdlib_app.h index 75cbde2..3c38f0d 100644 --- a/src/circle_stdlib_app.h +++ b/src/circle_stdlib_app.h @@ -214,8 +214,10 @@ public: return false; } - // Initialize newlib stdio with a reference to Circle's file system and console - CGlueStdioInit (mFileSystem, mConsole); + // Initialize newlib stdio with a reference to Circle's console + // (Remove mFileSystem as a parameter to mirror change in circle-stdlib's + // commit "Remove obsolete FATFS-related code", dated Dec 2022) + CGlueStdioInit (mConsole); mLogger.Write (GetKernelName (), LogNotice, "Compile time: " __DATE__ " " __TIME__); diff --git a/src/config.cpp b/src/config.cpp index 1143476..b5279a8 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -70,6 +70,7 @@ void CConfig::Load (void) m_bMIDIRXProgramChange = m_Properties.GetNumber ("MIDIRXProgramChange", 1) != 0; m_bIgnoreAllNotesOff = m_Properties.GetNumber ("IgnoreAllNotesOff", 0) != 0; + m_bMIDIAutoVoiceDumpOnPC = m_Properties.GetNumber ("MIDIAutoVoiceDumpOnPC", 1) != 0; m_bLCDEnabled = m_Properties.GetNumber ("LCDEnabled", 0) != 0; m_nLCDPinEnable = m_Properties.GetNumber ("LCDPinEnable", 4); @@ -84,6 +85,8 @@ void CConfig::Load (void) m_nSSD1306LCDI2CAddress = m_Properties.GetNumber ("SSD1306LCDI2CAddress", 0); m_nSSD1306LCDWidth = m_Properties.GetNumber ("SSD1306LCDWidth", 128); m_nSSD1306LCDHeight = m_Properties.GetNumber ("SSD1306LCDHeight", 32); + m_bSSD1306LCDRotate = m_Properties.GetNumber ("SSD1306LCDRotate", 0) != 0; + m_bSSD1306LCDMirror = m_Properties.GetNumber ("SSD1306LCDMirror", 0) != 0; m_nLCDColumns = m_Properties.GetNumber ("LCDColumns", 16); m_nLCDRows = m_Properties.GetNumber ("LCDRows", 2); @@ -171,6 +174,11 @@ bool CConfig::GetIgnoreAllNotesOff (void) const return m_bIgnoreAllNotesOff; } +bool CConfig::GetMIDIAutoVoiceDumpOnPC (void) const +{ + return m_bMIDIAutoVoiceDumpOnPC; +} + bool CConfig::GetLCDEnabled (void) const { return m_bLCDEnabled; @@ -231,6 +239,16 @@ unsigned CConfig::GetSSD1306LCDHeight (void) const return m_nSSD1306LCDHeight; } +bool CConfig::GetSSD1306LCDRotate (void) const +{ + return m_bSSD1306LCDRotate; +} + +bool CConfig::GetSSD1306LCDMirror (void) const +{ + return m_bSSD1306LCDMirror; +} + unsigned CConfig::GetLCDColumns (void) const { return m_nLCDColumns; diff --git a/src/config.h b/src/config.h index be75100..8a34239 100644 --- a/src/config.h +++ b/src/config.h @@ -76,6 +76,7 @@ public: const char *GetMIDIThruOut (void) const; // "" if not specified bool GetMIDIRXProgramChange (void) const; // true if not specified bool GetIgnoreAllNotesOff (void) const; + bool GetMIDIAutoVoiceDumpOnPC (void) const; // true if not specified // HD44780 LCD // GPIO pin numbers are chip numbers, not header positions @@ -93,6 +94,8 @@ public: unsigned GetSSD1306LCDI2CAddress (void) const; unsigned GetSSD1306LCDWidth (void) const; unsigned GetSSD1306LCDHeight (void) const; + bool GetSSD1306LCDRotate (void) const; + bool GetSSD1306LCDMirror (void) const; unsigned GetLCDColumns (void) const; unsigned GetLCDRows (void) const; @@ -153,6 +156,7 @@ private: std::string m_MIDIThruOut; bool m_bMIDIRXProgramChange; bool m_bIgnoreAllNotesOff; + bool m_bMIDIAutoVoiceDumpOnPC; bool m_bLCDEnabled; unsigned m_nLCDPinEnable; @@ -167,6 +171,8 @@ private: unsigned m_nSSD1306LCDI2CAddress; unsigned m_nSSD1306LCDWidth; unsigned m_nSSD1306LCDHeight; + bool m_bSSD1306LCDRotate; + bool m_bSSD1306LCDMirror; unsigned m_nLCDColumns; unsigned m_nLCDRows; diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 898c187..9b3deac 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -203,7 +203,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign if (ucStatus == MIDI_SYSTEM_EXCLUSIVE_BEGIN) { // MIDI SYSEX per MIDI channel - uint8_t ucSysExChannel = (pMessage[2] & 0x07); + uint8_t ucSysExChannel = (pMessage[2] & 0x0F); if (m_ChannelMap[nTG] == ucSysExChannel || m_ChannelMap[nTG] == OmniMode) { LOGNOTE("MIDI-SYSEX: channel: %u, len: %u, TG: %u",m_ChannelMap[nTG],nLength,nTG); diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 0240ea5..6a3897e 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -20,9 +20,9 @@ #include "minidexed.h" #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -377,6 +377,8 @@ void CMiniDexed::BankSelectLSB (unsigned nBankLSB, unsigned nTG) void CMiniDexed::ProgramChange (unsigned nProgram, unsigned nTG) { + assert (m_pConfig); + nProgram=constrain((int)nProgram,0,31); assert (nTG < CConfig::ToneGenerators); @@ -387,7 +389,16 @@ void CMiniDexed::ProgramChange (unsigned nProgram, unsigned nTG) assert (m_pTG[nTG]); m_pTG[nTG]->loadVoiceParameters (Buffer); - m_SerialMIDI.SendSystemExclusiveVoice(nProgram,0,nTG); + + if (m_pConfig->GetMIDIAutoVoiceDumpOnPC()) + { + // Only do the voice dump back out over MIDI if we have a specific + // MIDI channel configured for this TG + if (m_nMIDIChannel[nTG] < CMIDIDevice::Channels) + { + m_SerialMIDI.SendSystemExclusiveVoice(nProgram,0,nTG); + } + } m_UI.ParameterChanged (); } @@ -474,6 +485,8 @@ void CMiniDexed::SetResonance (int nResonance, unsigned nTG) void CMiniDexed::SetMIDIChannel (uint8_t uchChannel, unsigned nTG) { assert (nTG < CConfig::ToneGenerators); + assert (uchChannel < CMIDIDevice::ChannelUnknown); + m_nMIDIChannel[nTG] = uchChannel; for (unsigned i = 0; i < CConfig::MaxUSBMIDIDevices; i++) @@ -948,13 +961,7 @@ void CMiniDexed::ProcessSound (void) assert (CConfig::ToneGenerators == 8); - // swap stereo channels if needed uint8_t indexL=0, indexR=1; - if (m_bChannelsSwapped) - { - indexL=1; - indexR=0; - } // BEGIN TG mixing float32_t tmp_float[nFrames*2]; @@ -1003,6 +1010,13 @@ void CMiniDexed::ProcessSound (void) } // END adding reverb + // swap stereo channels if needed prior to writing back out + if (m_bChannelsSwapped) + { + indexL=1; + indexR=0; + } + // Convert dual float array (left, right) to single int16 array (left/right) for(uint16_t i=0; i #include #include -#include +#include #include #include "common.h" #include "effect_mixer.hpp" diff --git a/src/minidexed.ini b/src/minidexed.ini index 7d73416..bb3edd7 100644 --- a/src/minidexed.ini +++ b/src/minidexed.ini @@ -16,6 +16,7 @@ MIDIBaudRate=31250 #MIDIThru=umidi1,ttyS1 MIDIRXProgramChange=1 IgnoreAllNotesOff=0 +MIDIAutoVoiceDumpOnPC=1 # HD44780 LCD LCDEnabled=1 @@ -34,6 +35,8 @@ LCDI2CAddress=0x00 SSD1306LCDI2CAddress=0x0 SSD1306LCDWidth=128 SSD1306LCDHeight=32 +SSD1306LCDRotate=0 +SSD1306LCDMirror=0 # Default is 16x2 display (e.g. HD44780) LCDColumns=16 diff --git a/src/userinterface.cpp b/src/userinterface.cpp index f34e561..0bcd931 100644 --- a/src/userinterface.cpp +++ b/src/userinterface.cpp @@ -58,7 +58,9 @@ bool CUserInterface::Initialize (void) unsigned i2caddr = m_pConfig->GetLCDI2CAddress (); unsigned ssd1306addr = m_pConfig->GetSSD1306LCDI2CAddress (); if (ssd1306addr != 0) { - m_pSSD1306 = new CSSD1306Device (m_pConfig->GetSSD1306LCDWidth (), m_pConfig->GetSSD1306LCDHeight (), m_pI2CMaster, ssd1306addr); + m_pSSD1306 = new CSSD1306Device (m_pConfig->GetSSD1306LCDWidth (), m_pConfig->GetSSD1306LCDHeight (), + m_pI2CMaster, ssd1306addr, + m_pConfig->GetSSD1306LCDRotate (), m_pConfig->GetSSD1306LCDMirror ()); LOGDBG ("LCD: SSD1306"); if (!m_pSSD1306->Initialize ()) {