From 85a663ac21197e744771e74624a93814bba15821 Mon Sep 17 00:00:00 2001 From: BenZonneveld Date: Wed, 8 Jun 2022 00:04:26 +0200 Subject: [PATCH 01/26] Update build.yml Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bd04dd..f50db96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: BuildSysex env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 44d9c7e4327ef333f9563a4463433abf1bbb264e Mon Sep 17 00:00:00 2001 From: BenZonneveld Date: Wed, 8 Jun 2022 00:07:18 +0200 Subject: [PATCH 02/26] Update build.yml Minor update to build yaml --- .github/workflows/build.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f50db96..5e5d45f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,18 +46,6 @@ jobs: export PATH=$(readlink -f ./gcc-*aarch64-none*/bin/):$PATH RPI=3 bash -ex build.sh cp ./src/kernel*.img ./kernels/ - - name: Build for Raspberry Pi 2 - run: | - set -ex - export PATH=$(readlink -f ./gcc-*arm-none*/bin/):$PATH - RPI=2 bash -ex build.sh - cp ./src/kernel*.img ./kernels/ - - name: Build for Raspberry Pi 1 - run: | - set -ex - export PATH=$(readlink -f ./gcc-*arm-none*/bin/):$PATH - RPI=1 bash -ex build.sh - cp ./src/kernel*.img ./kernels/ - name: Get Raspberry Pi boot files run: | set -ex From a1c9ec0e76ce9b7188f7a6cc422778119721938f Mon Sep 17 00:00:00 2001 From: BeZo Date: Thu, 9 Jun 2022 01:21:04 +0200 Subject: [PATCH 03/26] Sysex patches --- .gitignore | 3 +++ build.sh | 11 +++++++++++ rebuild.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ src/mididevice.cpp | 40 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 rebuild.sh diff --git a/.gitignore b/.gitignore index 62c5120..6f289d8 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ MiniDexed* sdcard *.zip *.img + +# Visual Studio artefacts +.vs diff --git a/build.sh b/build.sh index 271501a..ae3e928 100755 --- a/build.sh +++ b/build.sh @@ -3,6 +3,7 @@ set -e set -x +echo "Clean: ${CLEAN}" if [ -z "${RPI}" ] ; then echo "\$RPI missing, exting" exit 1 @@ -22,19 +23,27 @@ fi # Build circle-stdlib library cd circle-stdlib/ +if [ ! -z "${CLEAN}" ] ; then make mrproper || true +fi ./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 make -j # Build additional libraries cd libs/circle/addon/display/ +if [ ! -z "${CLEAN}" ] ; then make clean || true +fi make -j cd ../sensor/ +if [ ! -z "${CLEAN}" ] ; then make clean || true +fi make -j cd ../Properties/ +if [ ! -z "${CLEAN}" ] ; then make clean || true +fi make -j cd ../../../.. @@ -42,7 +51,9 @@ cd .. # Build MiniDexed cd src +if [ ! -z "${CLEAN}" ] ; then make clean || true +fi make -j ls *.img cd .. diff --git a/rebuild.sh b/rebuild.sh new file mode 100644 index 0000000..99358dd --- /dev/null +++ b/rebuild.sh @@ -0,0 +1,42 @@ +export RPI=3 + +export CLEAN="true" + +export PATH=$(readlink -f ./gcc-*/bin/):$PATH + +# Build dependencies and MiniDexed +./build.sh +cp ./src/kernel*.img ./kernels/ +if [[ $? -ne 0 ]] ; then +exit +fi +# Get Raspberry Pi boot files +cd ./circle-stdlib/libs/circle/boot +make +if [ "${RPI}" -gt 2 ] +then + make armstub64 +fi +cd - + +# Make zip that contains Raspberry Pi 4 boot files. The contents can be copied to a FAT32 formatted partition on a microSD card +#cd sdcard +#../getsysex.sh +#cd .. +cp -r ./circle-stdlib/libs/circle/boot/* sdcard +if [[ $? -ne 0 ]] ; then +exit +fi +rm -rf sdcard/config*.txt sdcard/README sdcard/Makefile sdcard/armstub sdcard/COPYING.linux +cp ./src/config.txt ./src/*img sdcard/ +if [[ $? -ne 0 ]] ; then +exit +fi +echo "usbspeed=full" > sdcard/cmdline.txt +cd sdcard +cp ../kernels/* . || true +if [[ $? -ne 0 ]] ; then +exit +fi +zip -r ../MiniDexed_$(date +%Y-%m-%d).zip * +cd - diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 4e15cf1..b32d610 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -174,6 +174,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign { float32_t nMasterVolume=((pMessage[5] & 0x7c) & ((pMessage[6] & 0x7c) <<7))/(1<<14); LOGNOTE("Master volume: %f",nMasterVolume); + printf("Master volume: %f",nMasterVolume); m_pSynthesizer->setMasterVolume(nMasterVolume); } else @@ -187,6 +188,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign if (m_ChannelMap[nTG] == ucSysExChannel || m_ChannelMap[nTG] == OmniMode) { LOGNOTE("MIDI-SYSEX: channel: %u, len: %u, TG: %u",m_ChannelMap[nTG],nLength,nTG); + printf("MIDI-SYSEX: channel: %lu, len: %lu, TG: %lu\n",m_ChannelMap[nTG],nLength,nTG); HandleSystemExclusive(pMessage, nLength, nCable, nTG); } } @@ -334,8 +336,11 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL int16_t sysex_return; sysex_return = m_pSynthesizer->checkSystemExclusive(pMessage, nLength, nTG); + uint8_t instanceID = pMessage[2]&0xF; LOGDBG("SYSEX handler return value: %d", sysex_return); - + printf("SYSEX handler return value: %d\n", sysex_return); + printf("TG %i\n", nTG); + printf("%02X\n", instanceID); switch (sysex_return) { case -1: @@ -426,6 +431,39 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); m_pSynthesizer->setAftertouchTarget(pMessage[5],nTG); break; +/* BeZo patches */ + case 80: // Set midi channel + m_ChannelMap[instanceID] = pMessage[5]; + break; + case 81: // Reverb level + m_pSynthesizer->SetReverbSend (maplong (pMessage[5], 0, 127, 0, 99), instanceID); + break; + case 82: // Compressor toggle + break; + case 83: // Transpose + break; + case 84: // Detune + if (pMessage[5] == 0) + { + // "0 to 127, with 0 being no celeste (detune) effect applied at all." + m_pSynthesizer->SetMasterTune (0, instanceID); + } + else + { + m_pSynthesizer->SetMasterTune (maplong (pMessage[5], 1, 127, -99, 99), instanceID); + } + break; + case 85: // Panning + m_pSynthesizer->SetPan(pMessage[5], instanceID); + break; + case 86: // Volume + m_pSynthesizer->SetVol(pMessage[5], instanceID); + break; + case 87: // Pitch Bend + break; + case 88: // Portamento + break; +/* End of BeZo patches */ case 100: // load sysex-data into voice memory LOGDBG("One Voice bulk upload"); From b13c1f2705a7a82953e74d96e5a9be32160960e9 Mon Sep 17 00:00:00 2001 From: BeZo Date: Thu, 9 Jun 2022 03:00:59 +0200 Subject: [PATCH 04/26] Patches to support TG settings using sysex. --- build.sh | 49 +++++++++++++++++++++++----------------------- src/mididevice.cpp | 15 +++++++------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/build.sh b/build.sh index ae3e928..6752a10 100755 --- a/build.sh +++ b/build.sh @@ -22,34 +22,35 @@ if [ "${RPI}" -gt "1" ]; then fi # Build circle-stdlib library -cd circle-stdlib/ -if [ ! -z "${CLEAN}" ] ; then -make mrproper || true -fi -./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 -make -j +#cd circle-stdlib/ +#if [ ! -z "${CLEAN}" ] ; then +#make mrproper || true +#fi +#./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 +#make -j # Build additional libraries -cd libs/circle/addon/display/ -if [ ! -z "${CLEAN}" ] ; then -make clean || true -fi -make -j -cd ../sensor/ -if [ ! -z "${CLEAN}" ] ; then -make clean || true -fi -make -j -cd ../Properties/ -if [ ! -z "${CLEAN}" ] ; then -make clean || true -fi -make -j -cd ../../../.. - -cd .. +#cd libs/circle/addon/display/ +#if [ ! -z "${CLEAN}" ] ; then +#make clean || true +#fi +#make -j +#cd ../sensor/ +#if [ ! -z "${CLEAN}" ] ; then +#make clean || true +#fi +#make -j +#cd ../Properties/ +#if [ ! -z "${CLEAN}" ] ; then +#make clean || true +#fi +#make -j +#cd ../../../.. + +#cd .. # Build MiniDexed +echo "Build MiniDexed" cd src if [ ! -z "${CLEAN}" ] ; then make clean || true diff --git a/src/mididevice.cpp b/src/mididevice.cpp index b32d610..bf82130 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -174,7 +174,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign { float32_t nMasterVolume=((pMessage[5] & 0x7c) & ((pMessage[6] & 0x7c) <<7))/(1<<14); LOGNOTE("Master volume: %f",nMasterVolume); - printf("Master volume: %f",nMasterVolume); m_pSynthesizer->setMasterVolume(nMasterVolume); } else @@ -188,7 +187,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign if (m_ChannelMap[nTG] == ucSysExChannel || m_ChannelMap[nTG] == OmniMode) { LOGNOTE("MIDI-SYSEX: channel: %u, len: %u, TG: %u",m_ChannelMap[nTG],nLength,nTG); - printf("MIDI-SYSEX: channel: %lu, len: %lu, TG: %lu\n",m_ChannelMap[nTG],nLength,nTG); HandleSystemExclusive(pMessage, nLength, nCable, nTG); } } @@ -338,9 +336,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL sysex_return = m_pSynthesizer->checkSystemExclusive(pMessage, nLength, nTG); uint8_t instanceID = pMessage[2]&0xF; LOGDBG("SYSEX handler return value: %d", sysex_return); - printf("SYSEX handler return value: %d\n", sysex_return); - printf("TG %i\n", nTG); - printf("%02X\n", instanceID); + switch (sysex_return) { case -1: @@ -433,9 +429,11 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL break; /* BeZo patches */ case 80: // Set midi channel - m_ChannelMap[instanceID] = pMessage[5]; + LOGDBG("Set midi channel for TG %i", instanceID); + m_pSynthesizer->SetMIDIChannel(pMessage[5], instanceID); break; case 81: // Reverb level + LOGDBG("Set Reverb Level for TG %i", instanceID); m_pSynthesizer->SetReverbSend (maplong (pMessage[5], 0, 127, 0, 99), instanceID); break; case 82: // Compressor toggle @@ -443,6 +441,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL case 83: // Transpose break; case 84: // Detune + LOGDBG("Set detune for TG %i", instanceID); if (pMessage[5] == 0) { // "0 to 127, with 0 being no celeste (detune) effect applied at all." @@ -454,10 +453,12 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL } break; case 85: // Panning + LOGDBG("Set panning for TG %i", instanceID); m_pSynthesizer->SetPan(pMessage[5], instanceID); break; case 86: // Volume - m_pSynthesizer->SetVol(pMessage[5], instanceID); + LOGDBG("Set volume for TG %i", instanceID); + m_pSynthesizer->SetVolume(pMessage[5], instanceID); break; case 87: // Pitch Bend break; From bbd3db359c6634f84549d2b28dd70164817a4275 Mon Sep 17 00:00:00 2001 From: BeZo Date: Thu, 9 Jun 2022 08:45:04 +0200 Subject: [PATCH 05/26] Sysex implemented --- Synth_Dexed | 2 +- build.sh | 48 +++++++++++++++++++++++----------------------- src/mididevice.cpp | 2 ++ 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/Synth_Dexed b/Synth_Dexed index 8c677ce..28ef0da 160000 --- a/Synth_Dexed +++ b/Synth_Dexed @@ -1 +1 @@ -Subproject commit 8c677ceb4b3fb73f8643e30ff6cf4158dc8b9e53 +Subproject commit 28ef0da952b5c3b20204f14a56724290235b154d diff --git a/build.sh b/build.sh index 6752a10..0ac1723 100755 --- a/build.sh +++ b/build.sh @@ -22,32 +22,32 @@ if [ "${RPI}" -gt "1" ]; then fi # Build circle-stdlib library -#cd circle-stdlib/ -#if [ ! -z "${CLEAN}" ] ; then -#make mrproper || true -#fi -#./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 -#make -j +cd circle-stdlib/ +if [ ! -z "${CLEAN}" ] ; then +make mrproper || true +fi +./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 +make -j # Build additional libraries -#cd libs/circle/addon/display/ -#if [ ! -z "${CLEAN}" ] ; then -#make clean || true -#fi -#make -j -#cd ../sensor/ -#if [ ! -z "${CLEAN}" ] ; then -#make clean || true -#fi -#make -j -#cd ../Properties/ -#if [ ! -z "${CLEAN}" ] ; then -#make clean || true -#fi -#make -j -#cd ../../../.. - -#cd .. +cd libs/circle/addon/display/ +if [ ! -z "${CLEAN}" ] ; then +make clean || true +fi +make -j +cd ../sensor/ +if [ ! -z "${CLEAN}" ] ; then +make clean || true +fi +make -j +cd ../Properties/ +if [ ! -z "${CLEAN}" ] ; then +make clean || true +fi +make -j +cd ../../../.. + +cd .. # Build MiniDexed echo "Build MiniDexed" diff --git a/src/mididevice.cpp b/src/mididevice.cpp index bf82130..03134cb 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -187,6 +187,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign if (m_ChannelMap[nTG] == ucSysExChannel || m_ChannelMap[nTG] == OmniMode) { LOGNOTE("MIDI-SYSEX: channel: %u, len: %u, TG: %u",m_ChannelMap[nTG],nLength,nTG); + printf("MIDI-SYSEX: channel: %u, len: %lu, TG: %u",m_ChannelMap[nTG],nLength,nTG); HandleSystemExclusive(pMessage, nLength, nCable, nTG); } } @@ -490,6 +491,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL else if(sysex_return >= 500 && sysex_return < 600) { LOGDBG("SysEx send voice %u request",sysex_return-500); + printf("SysEx send voice %u request",sysex_return-500); SendSystemExclusiveVoice(sysex_return-500, nCable, nTG); } break; From d62cbb724f3be50e9e6e25cc72492035f8cf8407 Mon Sep 17 00:00:00 2001 From: BeZo Date: Thu, 9 Jun 2022 20:27:36 +0200 Subject: [PATCH 06/26] More sysex implementations --- build.sh | 48 +++++++++++------------ src/mididevice.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++--- src/mididevice.h | 1 + src/minidexed.cpp | 3 +- 4 files changed, 115 insertions(+), 31 deletions(-) diff --git a/build.sh b/build.sh index 0ac1723..6752a10 100755 --- a/build.sh +++ b/build.sh @@ -22,32 +22,32 @@ if [ "${RPI}" -gt "1" ]; then fi # Build circle-stdlib library -cd circle-stdlib/ -if [ ! -z "${CLEAN}" ] ; then -make mrproper || true -fi -./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 -make -j +#cd circle-stdlib/ +#if [ ! -z "${CLEAN}" ] ; then +#make mrproper || true +#fi +#./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 +#make -j # Build additional libraries -cd libs/circle/addon/display/ -if [ ! -z "${CLEAN}" ] ; then -make clean || true -fi -make -j -cd ../sensor/ -if [ ! -z "${CLEAN}" ] ; then -make clean || true -fi -make -j -cd ../Properties/ -if [ ! -z "${CLEAN}" ] ; then -make clean || true -fi -make -j -cd ../../../.. - -cd .. +#cd libs/circle/addon/display/ +#if [ ! -z "${CLEAN}" ] ; then +#make clean || true +#fi +#make -j +#cd ../sensor/ +#if [ ! -z "${CLEAN}" ] ; then +#make clean || true +#fi +#make -j +#cd ../Properties/ +#if [ ! -z "${CLEAN}" ] ; then +#make clean || true +#fi +#make -j +#cd ../../../.. + +#cd .. # Build MiniDexed echo "Build MiniDexed" diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 03134cb..74c643c 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -184,11 +184,11 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign { // MIDI SYSEX per MIDI channel uint8_t ucSysExChannel = (pMessage[2] & 0x07); - if (m_ChannelMap[nTG] == ucSysExChannel || m_ChannelMap[nTG] == OmniMode) + if ( nTG == ucSysExChannel || m_ChannelMap[nTG] == OmniMode ) { LOGNOTE("MIDI-SYSEX: channel: %u, len: %u, TG: %u",m_ChannelMap[nTG],nLength,nTG); - printf("MIDI-SYSEX: channel: %u, len: %lu, TG: %u",m_ChannelMap[nTG],nLength,nTG); - HandleSystemExclusive(pMessage, nLength, nCable, nTG); + //printf("MIDI-SYSEX: channel: %u, len: %lu, TG: %u",m_ChannelMap[nTG],nLength,nTG); + HandleSystemExclusive(pMessage, nLength, nCable, ucSysExChannel); } } else @@ -334,9 +334,15 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL { int16_t sysex_return; + if ( nTG >= CConfig::ToneGenerators ) return; + sysex_return = m_pSynthesizer->checkSystemExclusive(pMessage, nLength, nTG); uint8_t instanceID = pMessage[2]&0xF; + + if ( instanceID != nTG ) { printf("WARNING instanceID and nTG do not match!!!!!\n"); } + LOGDBG("SYSEX handler return value: %d", sysex_return); + //printf("SYSEX handler return value: %d for TG %i", sysex_return, instanceID); switch (sysex_return) { @@ -429,6 +435,14 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL m_pSynthesizer->setAftertouchTarget(pMessage[5],nTG); break; /* BeZo patches */ + case 78: // bank select + LOGDBG("Bank Select for TG %i\n", instanceID); + m_pSynthesizer->BankSelectLSB (pMessage[5], instanceID); + break; + case 79: // pgm select + LOGDBG("Patch Select for TG %i\n", instanceID); + m_pSynthesizer->ProgramChange (pMessage[5], instanceID); + break; case 80: // Set midi channel LOGDBG("Set midi channel for TG %i", instanceID); m_pSynthesizer->SetMIDIChannel(pMessage[5], instanceID); @@ -438,8 +452,12 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL m_pSynthesizer->SetReverbSend (maplong (pMessage[5], 0, 127, 0, 99), instanceID); break; case 82: // Compressor toggle + LOGDBG("Set Compressor "); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterCompressorEnable, maplong (pMessage[5], 0, 127, 0, 1) ); break; case 83: // Transpose + LOGDBG("Set Transpose for TG %i", instanceID); +// m_pSynthesizer->SetTranspose (maplong (pMessage[5], 0, 127, 0, 99), instanceID); break; case 84: // Detune LOGDBG("Set detune for TG %i", instanceID); @@ -464,6 +482,16 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL case 87: // Pitch Bend break; case 88: // Portamento + LOGDBG("Set portamento mode for TG %i", instanceID); + m_pSynthesizer->setPortamentoMode(pMessage[5],instanceID); + break; + case 89: // Mono Mode + LOGDBG("Set Mono mode for TG %i", instanceID); + m_pSynthesizer->setMonoMode(pMessage[5],instanceID); + break; + case 600: // Config requestnTG + LOGDBG("Config request received\n"); + SendSystemExclusiveConfig(nCable); break; /* End of BeZo patches */ case 100: @@ -480,7 +508,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL if(sysex_return >= 300 && sysex_return < 500) { LOGDBG("SysEx voice parameter change: Parameter %d value: %d",pMessage[4] + ((pMessage[3] & 0x03) * 128), pMessage[5]); - m_pSynthesizer->setVoiceDataElement(pMessage[4] + ((pMessage[3] & 0x03) * 128), pMessage[5],nTG); + m_pSynthesizer->setVoiceDataElement(pMessage[4] + ((pMessage[3] & 0x03) * 128), pMessage[5],instanceID); switch(pMessage[4] + ((pMessage[3] & 0x03) * 128)) { case 134: @@ -491,8 +519,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL else if(sysex_return >= 500 && sysex_return < 600) { LOGDBG("SysEx send voice %u request",sysex_return-500); - printf("SysEx send voice %u request",sysex_return-500); - SendSystemExclusiveVoice(sysex_return-500, nCable, nTG); + SendSystemExclusiveVoice(sysex_return-500, nCable, instanceID); } break; } @@ -514,3 +541,58 @@ void CMIDIDevice::SendSystemExclusiveVoice(uint8_t nVoice, const unsigned nCable LOGDBG("Send SYSEX voice dump %u to \"%s\"",nVoice,Iterator->first.c_str()); } } + +void CMIDIDevice::SendSystemExclusiveConfig(const unsigned nCable) +{ + uint8_t count = 0; + uint8_t configdump[196]; + + configdump[count++] = 0xF0; + configdump[count++] = 0x43; + configdump[count++] = 0x31; + + for ( uint8_t instance = 0 ; instance < CConfig::ToneGenerators; instance++) + { + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterVoiceBank, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterProgram, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterMIDIChannel, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterVolume, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterPan, instance) & 0x7F; + int16_t mastertune = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterMasterTune, instance); + configdump[count++] = (mastertune >> 9)&0x7f; + configdump[count++] = (mastertune & 0x7f); + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterCutoff, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterResonance, instance) & 0x7F; + configdump[count++] = 0; // Note limit low + configdump[count++] = 127; // Note limit high + configdump[count++] = 0; // Note shift + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterReverbSend, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterPitchBendRange, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterPitchBendStep, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterPortamentoMode, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterPortamentoGlissando, instance) & 0x7F; + configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterPortamentoTime, instance) & 0x7F; + configdump[count++] = 0; + configdump[count++] = 0; + configdump[count++] = 0; + configdump[count++] = 0; + configdump[count++] = 0; + configdump[count++] = 0; + } + configdump[count++] = 0xF7; + +// for ( size_t i=0 ; i< count; i++) +// { +// printf("%02X, ", configdump[i]); +// if ( (i+1) % 16 == 0 ) printf ("\n"); +// } + + TDeviceMap::const_iterator Iterator; + + // send voice dump to all MIDI interfaces + for(Iterator = s_DeviceMap.begin(); Iterator != s_DeviceMap.end(); ++Iterator) + { + Iterator->second->Send (configdump, sizeof(configdump)*sizeof(uint8_t)); + LOGDBG("Send SYSEX config dump to \"%s\"",Iterator->first.c_str()); + } +} diff --git a/src/mididevice.h b/src/mididevice.h index 1bd5396..b539b00 100644 --- a/src/mididevice.h +++ b/src/mididevice.h @@ -51,6 +51,7 @@ public: virtual void Send (const u8 *pMessage, size_t nLength, unsigned nCable = 0) {} virtual void SendSystemExclusiveVoice(uint8_t nVoice, const unsigned nCable, uint8_t nTG); + virtual void SendSystemExclusiveConfig(const unsigned nCable); protected: void MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsigned nCable = 0); diff --git a/src/minidexed.cpp b/src/minidexed.cpp index c09eb42..a261d23 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -1194,7 +1194,8 @@ void CMiniDexed::getSysExVoiceDump(uint8_t* dest, uint8_t nTG) dest[0] = 0xF0; // SysEx start dest[1] = 0x43; // ID=Yamaha - dest[2] = GetTGParameter(TGParameterMIDIChannel, nTG); // Sub-status and MIDI channel +// dest[2] = GetTGParameter(TGParameterMIDIChannel, nTG); // Sub-status and MIDI channel + dest[2] = nTG; // Sub-status and MIDI channel/Instance ID dest[3] = 0x00; // Format number (0=1 voice) dest[4] = 0x01; // Byte count MSB dest[5] = 0x1B; // Byte count LSB From 31c52b3bc24640cf92af87a9e716b9f1a11201b2 Mon Sep 17 00:00:00 2001 From: BeZo Date: Fri, 10 Jun 2022 23:11:53 +0200 Subject: [PATCH 07/26] More midi --- src/mididevice.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++---- src/mididevice.h | 8 ++++--- src/minidexed.cpp | 3 ++- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 74c643c..1b39083 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -489,10 +489,22 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL LOGDBG("Set Mono mode for TG %i", instanceID); m_pSynthesizer->setMonoMode(pMessage[5],instanceID); break; + case 90: // Set Cutoff + LOGDBG("Set Cutoff for TG %i", instanceID); + m_pSynthesizer->SetCutoff(pMessage[5], instanceID); + break; + case 91: // Set Reso + LOGDBG("Set Resonanece for TG %i", instanceID); + m_pSynthesizer->SetResonance(pMessage[5], instanceID); + break; case 600: // Config requestnTG LOGDBG("Config request received\n"); - SendSystemExclusiveConfig(nCable); + SendSystemExclusiveConfig(); break; +// case 601: +// printf("Get Bank Name\n"); +// std::string Value = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetBankName (nValue); +// break; /* End of BeZo patches */ case 100: // load sysex-data into voice memory @@ -519,13 +531,13 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL else if(sysex_return >= 500 && sysex_return < 600) { LOGDBG("SysEx send voice %u request",sysex_return-500); - SendSystemExclusiveVoice(sysex_return-500, nCable, instanceID); + SendSystemExclusiveVoice(sysex_return-500, instanceID); } break; } } -void CMIDIDevice::SendSystemExclusiveVoice(uint8_t nVoice, const unsigned nCable, uint8_t nTG) +void CMIDIDevice::SendSystemExclusiveVoice(uint8_t nVoice, uint8_t nTG) { uint8_t voicedump[163]; @@ -542,7 +554,7 @@ void CMIDIDevice::SendSystemExclusiveVoice(uint8_t nVoice, const unsigned nCable } } -void CMIDIDevice::SendSystemExclusiveConfig(const unsigned nCable) +void CMIDIDevice::SendSystemExclusiveConfig() { uint8_t count = 0; uint8_t configdump[196]; @@ -596,3 +608,35 @@ void CMIDIDevice::SendSystemExclusiveConfig(const unsigned nCable) LOGDBG("Send SYSEX config dump to \"%s\"",Iterator->first.c_str()); } } + +void CMIDIDevice::SendProgramChange(uint8_t pgm, uint8_t nTG) +{ + uint8_t PgmChange[2] = { 0xC0|(nTG & 0x0F), (pgm & 0x7f) }; + + TDeviceMap::const_iterator Iterator; + // send voice dump to all MIDI interfaces + for(Iterator = s_DeviceMap.begin(); Iterator != s_DeviceMap.end(); ++Iterator) + { + Iterator->second->Send (PgmChange, sizeof(PgmChange)*sizeof(uint8_t)); + LOGDBG("Send Program Change %i to \"%s\"",pgm&0x7f,Iterator->first.c_str()); + } +} + +void CMIDIDevice::SendBankChange(uint8_t bank, uint8_t nTG) +{ + SendCtrlChange(0xB0,32, (bank&0x7f)); +} + +void CMIDIDevice::SendCtrlChange(uint8_t ctrl, uint8_t val, uint8_t nTG) +{ + uint8_t CtrlMsg[3] = { 0xB0|(nTG & 0x0F), ctrl&0x7f, val&0x7f }; + + TDeviceMap::const_iterator Iterator; + + // send voice dump to all MIDI interfaces + for(Iterator = s_DeviceMap.begin(); Iterator != s_DeviceMap.end(); ++Iterator) + { + Iterator->second->Send (CtrlMsg, sizeof(CtrlMsg)*sizeof(uint8_t)); + LOGDBG("Send Ctrl change %02X = %i to \"%s\"",ctrl&0x7f, val&0x7f,Iterator->first.c_str()); + } +} diff --git a/src/mididevice.h b/src/mididevice.h index b539b00..a72b88c 100644 --- a/src/mididevice.h +++ b/src/mididevice.h @@ -50,9 +50,11 @@ public: u8 GetChannel (unsigned nTG) const; virtual void Send (const u8 *pMessage, size_t nLength, unsigned nCable = 0) {} - virtual void SendSystemExclusiveVoice(uint8_t nVoice, const unsigned nCable, uint8_t nTG); - virtual void SendSystemExclusiveConfig(const unsigned nCable); - + virtual void SendSystemExclusiveVoice(uint8_t nVoice, uint8_t nTG); + virtual void SendSystemExclusiveConfig(); + virtual void SendProgramChange(uint8_t pgm, uint8_t nTG); + virtual void SendBankChange(uint8_t bank, uint8_t nTG); + virtual void SendCtrlChange(uint8_t ctrl, uint8_t val, uint8_t nTG); protected: void MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsigned nCable = 0); void AddDevice (const char *pDeviceName); diff --git a/src/minidexed.cpp b/src/minidexed.cpp index a261d23..02c30f5 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -346,6 +346,7 @@ void CMiniDexed::BankSelectLSB (unsigned nBankLSB, unsigned nTG) assert (nTG < CConfig::ToneGenerators); m_nVoiceBankID[nTG] = nBankLSB; + m_SerialMIDI.SendBankChange(nBankLSB,nTG); m_UI.ParameterChanged (); } @@ -362,7 +363,7 @@ void CMiniDexed::ProgramChange (unsigned nProgram, unsigned nTG) assert (m_pTG[nTG]); m_pTG[nTG]->loadVoiceParameters (Buffer); - m_SerialMIDI.SendSystemExclusiveVoice(nProgram,0,nTG); + m_SerialMIDI.SendProgramChange(nProgram,nTG); m_UI.ParameterChanged (); } From 6d189f84e53ea6efe6437a641816c350f78b865e Mon Sep 17 00:00:00 2001 From: BeZo Date: Mon, 13 Jun 2022 03:19:51 +0200 Subject: [PATCH 08/26] More sysex --- src/mididevice.cpp | 63 ++++++++++++++++++++++++++-------------------- src/mididevice.h | 15 +++++++++++ src/minidexed.cpp | 15 ++++++++--- 3 files changed, 63 insertions(+), 30 deletions(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 1b39083..bc69fa2 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -34,18 +34,6 @@ LOGMODULE ("mididevice"); #define MIDI_NOTE_ON 0b1001 #define MIDI_AFTERTOUCH 0b1010 // TODO #define MIDI_CONTROL_CHANGE 0b1011 - #define MIDI_CC_BANK_SELECT_MSB 0 // TODO - #define MIDI_CC_MODULATION 1 - #define MIDI_CC_VOLUME 7 - #define MIDI_CC_PAN_POSITION 10 - #define MIDI_CC_BANK_SELECT_LSB 32 - #define MIDI_CC_BANK_SUSTAIN 64 - #define MIDI_CC_RESONANCE 71 - #define MIDI_CC_FREQUENCY_CUTOFF 74 - #define MIDI_CC_REVERB_LEVEL 91 - #define MIDI_CC_DETUNE_LEVEL 94 - #define MIDI_CC_ALL_SOUND_OFF 120 - #define MIDI_CC_ALL_NOTES_OFF 123 #define MIDI_PROGRAM_CHANGE 0b1100 #define MIDI_PITCH_BEND 0b1110 @@ -268,7 +256,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign m_pSynthesizer->SetReverbSend (maplong (pMessage[2], 0, 127, 0, 99), nTG); break; - case MIDI_CC_DETUNE_LEVEL: + case MIDI_CC_DETUNE_LEVEL+32: if (pMessage[2] == 0) { // "0 to 127, with 0 being no celeste (detune) effect applied at all." @@ -342,7 +330,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL if ( instanceID != nTG ) { printf("WARNING instanceID and nTG do not match!!!!!\n"); } LOGDBG("SYSEX handler return value: %d", sysex_return); - //printf("SYSEX handler return value: %d for TG %i", sysex_return, instanceID); + //printf("SYSEX handler return value: %d for TG %i\n", sysex_return, instanceID); switch (sysex_return) { @@ -501,10 +489,10 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL LOGDBG("Config request received\n"); SendSystemExclusiveConfig(); break; -// case 601: -// printf("Get Bank Name\n"); -// std::string Value = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetBankName (nValue); -// break; + case 601: + LOGDBG("Get Bank Name request received\n"); + SendBankName(instanceID); + break; /* End of BeZo patches */ case 100: // load sysex-data into voice memory @@ -593,12 +581,6 @@ void CMIDIDevice::SendSystemExclusiveConfig() } configdump[count++] = 0xF7; -// for ( size_t i=0 ; i< count; i++) -// { -// printf("%02X, ", configdump[i]); -// if ( (i+1) % 16 == 0 ) printf ("\n"); -// } - TDeviceMap::const_iterator Iterator; // send voice dump to all MIDI interfaces @@ -611,7 +593,7 @@ void CMIDIDevice::SendSystemExclusiveConfig() void CMIDIDevice::SendProgramChange(uint8_t pgm, uint8_t nTG) { - uint8_t PgmChange[2] = { 0xC0|(nTG & 0x0F), (pgm & 0x7f) }; + uint8_t PgmChange[2] = { (uint8_t)(0xC0|(nTG & 0x0F)), (uint8_t)(pgm & 0x7f) }; TDeviceMap::const_iterator Iterator; // send voice dump to all MIDI interfaces @@ -624,12 +606,12 @@ void CMIDIDevice::SendProgramChange(uint8_t pgm, uint8_t nTG) void CMIDIDevice::SendBankChange(uint8_t bank, uint8_t nTG) { - SendCtrlChange(0xB0,32, (bank&0x7f)); + SendCtrlChange14Bit(0, bank, nTG); } void CMIDIDevice::SendCtrlChange(uint8_t ctrl, uint8_t val, uint8_t nTG) { - uint8_t CtrlMsg[3] = { 0xB0|(nTG & 0x0F), ctrl&0x7f, val&0x7f }; + uint8_t CtrlMsg[3] = { (uint8_t)(0xB0|(nTG & 0x0F)), (uint8_t)(ctrl&0x7f), (uint8_t)(val&0x7f) }; TDeviceMap::const_iterator Iterator; @@ -640,3 +622,30 @@ void CMIDIDevice::SendCtrlChange(uint8_t ctrl, uint8_t val, uint8_t nTG) LOGDBG("Send Ctrl change %02X = %i to \"%s\"",ctrl&0x7f, val&0x7f,Iterator->first.c_str()); } } + +void CMIDIDevice::SendCtrlChange14Bit(uint8_t ctrl, int16_t val, uint8_t nTG) +{ + uint8_t lsb = (val & 0x7f); + uint8_t msb = (val >> 9)&0x7f; + SendCtrlChange(ctrl,msb,nTG); + SendCtrlChange(ctrl+32, lsb, nTG); +} + +void CMIDIDevice::SendBankName(uint8_t nTG) +{ + char *bankname = (char*)calloc(32,sizeof(char)); + snprintf(bankname,sizeof(bankname), "%s", m_pSynthesizer->GetSysExFileLoader()->GetBankName(m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterVoiceBank,nTG)).c_str()); + uint8_t banksysex[40] = { 0xF0, 0x43, (uint8_t)(0x50|nTG), 0,0,32 }; + memcpy(banksysex+6,bankname,32); + banksysex[38] = 00; + banksysex[39] = 0xF7; + TDeviceMap::const_iterator Iterator; + + // send voice dump to all MIDI interfaces + for(Iterator = s_DeviceMap.begin(); Iterator != s_DeviceMap.end(); ++Iterator) + { + Iterator->second->Send (banksysex, sizeof(banksysex)*sizeof(uint8_t)); + LOGDBG("Send Bank Name Sysex to \"%s\"",Iterator->first.c_str()); + } +} + diff --git a/src/mididevice.h b/src/mididevice.h index a72b88c..38002b7 100644 --- a/src/mididevice.h +++ b/src/mididevice.h @@ -29,6 +29,19 @@ #include #include +#define MIDI_CC_BANK_SELECT_MSB 0 // TODO +#define MIDI_CC_MODULATION 1 +#define MIDI_CC_VOLUME 7 +#define MIDI_CC_PAN_POSITION 10 +#define MIDI_CC_BANK_SELECT_LSB 32 +#define MIDI_CC_BANK_SUSTAIN 64 +#define MIDI_CC_RESONANCE 71 +#define MIDI_CC_FREQUENCY_CUTOFF 74 +#define MIDI_CC_REVERB_LEVEL 91 +#define MIDI_CC_DETUNE_LEVEL 94 +#define MIDI_CC_ALL_SOUND_OFF 120 +#define MIDI_CC_ALL_NOTES_OFF 123 + class CMiniDexed; class CMIDIDevice @@ -54,7 +67,9 @@ public: virtual void SendSystemExclusiveConfig(); virtual void SendProgramChange(uint8_t pgm, uint8_t nTG); virtual void SendBankChange(uint8_t bank, uint8_t nTG); + virtual void SendBankName( uint8_t nTG); virtual void SendCtrlChange(uint8_t ctrl, uint8_t val, uint8_t nTG); + virtual void SendCtrlChange14Bit(uint8_t ctrl, int16_t val, uint8_t nTG); protected: void MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsigned nCable = 0); void AddDevice (const char *pDeviceName); diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 02c30f5..357a51e 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -346,7 +346,7 @@ void CMiniDexed::BankSelectLSB (unsigned nBankLSB, unsigned nTG) assert (nTG < CConfig::ToneGenerators); m_nVoiceBankID[nTG] = nBankLSB; - m_SerialMIDI.SendBankChange(nBankLSB,nTG); + m_SerialMIDI.SendBankChange(m_nVoiceBankID[nTG],nTG); m_UI.ParameterChanged (); } @@ -363,7 +363,7 @@ void CMiniDexed::ProgramChange (unsigned nProgram, unsigned nTG) assert (m_pTG[nTG]); m_pTG[nTG]->loadVoiceParameters (Buffer); - m_SerialMIDI.SendProgramChange(nProgram,nTG); + m_SerialMIDI.SendProgramChange(m_nProgram[nTG],nTG); m_UI.ParameterChanged (); } @@ -377,7 +377,7 @@ void CMiniDexed::SetVolume (unsigned nVolume, unsigned nTG) assert (m_pTG[nTG]); m_pTG[nTG]->setGain (nVolume / 127.0f); - + m_SerialMIDI.SendCtrlChange(MIDI_CC_VOLUME, m_nVolume[nTG], nTG); m_UI.ParameterChanged (); } @@ -391,6 +391,7 @@ void CMiniDexed::SetPan (unsigned nPan, unsigned nTG) tg_mixer->pan(nTG,mapfloat(nPan,0,127,0.0f,1.0f)); reverb_send_mixer->pan(nTG,mapfloat(nPan,0,127,0.0f,1.0f)); + m_SerialMIDI.SendCtrlChange(MIDI_CC_PAN_POSITION, nPan, nTG); m_UI.ParameterChanged (); } @@ -403,6 +404,8 @@ void CMiniDexed::SetReverbSend (unsigned nReverbSend, unsigned nTG) reverb_send_mixer->gain(nTG,mapfloat(nReverbSend,0,99,0.0f,1.0f)); + m_SerialMIDI.SendCtrlChange(MIDI_CC_REVERB_LEVEL, m_nReverbSend[nTG], nTG); + m_UI.ParameterChanged (); } @@ -416,6 +419,8 @@ void CMiniDexed::SetMasterTune (int nMasterTune, unsigned nTG) assert (m_pTG[nTG]); m_pTG[nTG]->setMasterTune ((int8_t) nMasterTune); + m_SerialMIDI.SendCtrlChange14Bit(MIDI_CC_DETUNE_LEVEL, m_nMasterTune[nTG], nTG); + m_UI.ParameterChanged (); } @@ -429,6 +434,8 @@ void CMiniDexed::SetCutoff (int nCutoff, unsigned nTG) assert (m_pTG[nTG]); m_pTG[nTG]->setFilterCutoff (mapfloat (nCutoff, 0, 99, 0.0f, 1.0f)); + m_SerialMIDI.SendCtrlChange(MIDI_CC_FREQUENCY_CUTOFF, m_nCutoff[nTG], nTG); + m_UI.ParameterChanged (); } @@ -442,6 +449,8 @@ void CMiniDexed::SetResonance (int nResonance, unsigned nTG) assert (m_pTG[nTG]); m_pTG[nTG]->setFilterResonance (mapfloat (nResonance, 0, 99, 0.0f, 1.0f)); + m_SerialMIDI.SendCtrlChange(MIDI_CC_RESONANCE, m_nResonance[nTG], nTG); + m_UI.ParameterChanged (); } From d8316fd2ca657772080eec181e82ae7a1dd98169 Mon Sep 17 00:00:00 2001 From: BeZo Date: Tue, 14 Jun 2022 02:07:06 +0200 Subject: [PATCH 09/26] Small sysex changes --- src/mididevice.cpp | 114 ++++++++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 42 deletions(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index bc69fa2..b7f215c 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -368,59 +368,59 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL break; case 64: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setMonoMode(pMessage[5],nTG); + m_pSynthesizer->setMonoMode(pMessage[5], instanceID); break; case 65: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setPitchbendRange(pMessage[5],nTG); + m_pSynthesizer->setPitchbendRange(pMessage[5],instanceID); break; case 66: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setPitchbendStep(pMessage[5],nTG); + m_pSynthesizer->setPitchbendStep(pMessage[5],instanceID); break; case 67: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setPortamentoMode(pMessage[5],nTG); + m_pSynthesizer->setPortamentoMode(pMessage[5],instanceID); break; case 68: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setPortamentoGlissando(pMessage[5],nTG); + m_pSynthesizer->setPortamentoGlissando(pMessage[5],instanceID); break; case 69: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setPortamentoTime(pMessage[5],nTG); + m_pSynthesizer->setPortamentoTime(pMessage[5],instanceID); break; case 70: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setModWheelRange(pMessage[5],nTG); + m_pSynthesizer->setModWheelRange(pMessage[5],instanceID); break; case 71: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setModWheelTarget(pMessage[5],nTG); + m_pSynthesizer->setModWheelTarget(pMessage[5],instanceID); break; case 72: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setFootControllerRange(pMessage[5],nTG); + m_pSynthesizer->setFootControllerRange(pMessage[5],instanceID); break; case 73: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setFootControllerTarget(pMessage[5],nTG); + m_pSynthesizer->setFootControllerTarget(pMessage[5],instanceID); break; case 74: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setBreathControllerRange(pMessage[5],nTG); + m_pSynthesizer->setBreathControllerRange(pMessage[5],instanceID); break; case 75: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setBreathControllerTarget(pMessage[5],nTG); + m_pSynthesizer->setBreathControllerTarget(pMessage[5],instanceID); break; case 76: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setAftertouchRange(pMessage[5],nTG); + m_pSynthesizer->setAftertouchRange(pMessage[5],instanceID); break; case 77: LOGDBG("SysEx Function parameter change: %d Value %d",pMessage[4],pMessage[5]); - m_pSynthesizer->setAftertouchTarget(pMessage[5],nTG); + m_pSynthesizer->setAftertouchTarget(pMessage[5],instanceID); break; /* BeZo patches */ case 78: // bank select @@ -435,19 +435,23 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL LOGDBG("Set midi channel for TG %i", instanceID); m_pSynthesizer->SetMIDIChannel(pMessage[5], instanceID); break; - case 81: // Reverb level - LOGDBG("Set Reverb Level for TG %i", instanceID); - m_pSynthesizer->SetReverbSend (maplong (pMessage[5], 0, 127, 0, 99), instanceID); + case 81: // Set Cutoff + LOGDBG("Set Cutoff for TG %i", instanceID); + m_pSynthesizer->SetCutoff(pMessage[5], instanceID); break; - case 82: // Compressor toggle - LOGDBG("Set Compressor "); - m_pSynthesizer->SetParameter (CMiniDexed::ParameterCompressorEnable, maplong (pMessage[5], 0, 127, 0, 1) ); + case 82: // Set Reso + LOGDBG("Set Resonanece for TG %i", instanceID); + m_pSynthesizer->SetResonance(pMessage[5], instanceID); + break; + case 83: // Reverb level + LOGDBG("Set Reverb Level for TG %i", instanceID); + m_pSynthesizer->SetReverbSend (pMessage[5], instanceID); break; - case 83: // Transpose + case 84: // Transpose LOGDBG("Set Transpose for TG %i", instanceID); -// m_pSynthesizer->SetTranspose (maplong (pMessage[5], 0, 127, 0, 99), instanceID); +// m_pSynthesizer->SetTranspose (pMessage[5], instanceID); break; - case 84: // Detune + case 85: // Detune LOGDBG("Set detune for TG %i", instanceID); if (pMessage[5] == 0) { @@ -459,32 +463,48 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL m_pSynthesizer->SetMasterTune (maplong (pMessage[5], 1, 127, -99, 99), instanceID); } break; - case 85: // Panning + case 86: // Panning LOGDBG("Set panning for TG %i", instanceID); m_pSynthesizer->SetPan(pMessage[5], instanceID); break; - case 86: // Volume - LOGDBG("Set volume for TG %i", instanceID); - m_pSynthesizer->SetVolume(pMessage[5], instanceID); + case 87: // Note Limit Low + LOGDBG("Set Note Limit High mode for TG %i", instanceID); break; - case 87: // Pitch Bend + case 88: // Note Limit High + LOGDBG("Set Note Limit High mode for TG %i", instanceID); break; - case 88: // Portamento - LOGDBG("Set portamento mode for TG %i", instanceID); - m_pSynthesizer->setPortamentoMode(pMessage[5],instanceID); + case 89: // Compressor toggle + LOGDBG("Set Compressor "); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterCompressorEnable, pMessage[5] ); break; - case 89: // Mono Mode - LOGDBG("Set Mono mode for TG %i", instanceID); - m_pSynthesizer->setMonoMode(pMessage[5],instanceID); + case 90: // Reverb toggle + LOGDBG("Set Reverb Enable"); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterReverbEnable, pMessage[5] ); break; - case 90: // Set Cutoff - LOGDBG("Set Cutoff for TG %i", instanceID); - m_pSynthesizer->SetCutoff(pMessage[5], instanceID); + case 91: // Reverb Size + LOGDBG("Set Reverb Size"); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterReverbSize, pMessage[5] ); + break; + case 92: // Reverb Low Damp + LOGDBG("Set Reverb Low Damp"); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterReverbLowDamp, pMessage[5]); + break; + case 93: // Reverb High Damp + LOGDBG("Set Reverb High Damp"); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterReverbHighDamp, pMessage[5] ); + break; + case 94: // Reverb Lowpass + LOGDBG("Set Reverb Low pass"); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterReverbLowPass, pMessage[5]); + break; + case 95: // Reverb Diffusion + LOGDBG("Set Reverb Diffusion"); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterReverbDiffusion, pMessage[5] ); + break; + case 96: // Reverb Master Level + LOGDBG("Set Reverb Master Level"); + m_pSynthesizer->SetParameter (CMiniDexed::ParameterReverbLevel, pMessage[5] ); break; - case 91: // Set Reso - LOGDBG("Set Resonanece for TG %i", instanceID); - m_pSynthesizer->SetResonance(pMessage[5], instanceID); - break; case 600: // Config requestnTG LOGDBG("Config request received\n"); SendSystemExclusiveConfig(); @@ -545,12 +565,22 @@ void CMIDIDevice::SendSystemExclusiveVoice(uint8_t nVoice, uint8_t nTG) void CMIDIDevice::SendSystemExclusiveConfig() { uint8_t count = 0; - uint8_t configdump[196]; + uint8_t configdump[204]; configdump[count++] = 0xF0; configdump[count++] = 0x43; configdump[count++] = 0x31; + // FX Settings + configdump[count++] = ((m_pSynthesizer->GetParameter(CMiniDexed::ParameterCompressorEnable) & 0x7F)<<1) | + m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbEnable) & 0x7F; + configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbSize) & 0x7F; + configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbHighDamp) & 0x7F; + configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbLowDamp) & 0x7F; + configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbLowPass) & 0x7F; + configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbDiffusion) & 0x7F; + configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbLevel) & 0x7F; + for ( uint8_t instance = 0 ; instance < CConfig::ToneGenerators; instance++) { configdump[count++] = m_pSynthesizer->GetTGParameter(CMiniDexed::TGParameterVoiceBank, instance) & 0x7F; From 65ebb88a5f02c11a859772c2c88589cb13cff560 Mon Sep 17 00:00:00 2001 From: BeZo Date: Sun, 19 Jun 2022 21:38:18 +0200 Subject: [PATCH 10/26] Forgot to add these files --- build.sh | 50 +++++++++++++++++++++------------------- rebuild.sh | 2 +- src/mididevice.cpp | 7 +++--- src/minidexed.cpp | 2 +- src/minidexed.h | 1 + src/serialmididevice.cpp | 6 +++++ 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/build.sh b/build.sh index 6752a10..1eb5325 100755 --- a/build.sh +++ b/build.sh @@ -21,33 +21,35 @@ if [ "${RPI}" -gt "1" ]; then OPTIONS="${OPTIONS} -o ARM_ALLOW_MULTI_CORE" fi +if [ ! -z "${BUILDCIRCLE}" ] ; then # Build circle-stdlib library -#cd circle-stdlib/ -#if [ ! -z "${CLEAN}" ] ; then -#make mrproper || true -#fi -#./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 -#make -j +cd circle-stdlib/ +if [ ! -z "${CLEAN}" ] ; then +make mrproper || true +fi +./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 +make -j # Build additional libraries -#cd libs/circle/addon/display/ -#if [ ! -z "${CLEAN}" ] ; then -#make clean || true -#fi -#make -j -#cd ../sensor/ -#if [ ! -z "${CLEAN}" ] ; then -#make clean || true -#fi -#make -j -#cd ../Properties/ -#if [ ! -z "${CLEAN}" ] ; then -#make clean || true -#fi -#make -j -#cd ../../../.. - -#cd .. +cd libs/circle/addon/display/ +if [ ! -z "${CLEAN}" ] ; then +make clean || true +fi +make -j +cd ../sensor/ +if [ ! -z "${CLEAN}" ] ; then +make clean || true +fi +make -j +cd ../Properties/ +if [ ! -z "${CLEAN}" ] ; then +make clean || true +fi +make -j +cd ../../../.. + +cd .. +fi # Build MiniDexed echo "Build MiniDexed" diff --git a/rebuild.sh b/rebuild.sh index 99358dd..a6743ff 100644 --- a/rebuild.sh +++ b/rebuild.sh @@ -1,7 +1,7 @@ export RPI=3 export CLEAN="true" - +export BUILDCIRCLE="true" export PATH=$(readlink -f ./gcc-*/bin/):$PATH # Build dependencies and MiniDexed diff --git a/src/mididevice.cpp b/src/mididevice.cpp index b7f215c..a80e494 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -580,6 +580,7 @@ void CMIDIDevice::SendSystemExclusiveConfig() configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbLowPass) & 0x7F; configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbDiffusion) & 0x7F; configdump[count++] = m_pSynthesizer->GetParameter(CMiniDexed::ParameterReverbLevel) & 0x7F; + configdump[count++] = m_pSynthesizer->getMasterVolume() & 0x7F; for ( uint8_t instance = 0 ; instance < CConfig::ToneGenerators; instance++) { @@ -616,7 +617,7 @@ void CMIDIDevice::SendSystemExclusiveConfig() // send voice dump to all MIDI interfaces for(Iterator = s_DeviceMap.begin(); Iterator != s_DeviceMap.end(); ++Iterator) { - Iterator->second->Send (configdump, sizeof(configdump)*sizeof(uint8_t)); + Iterator->second->Send (configdump, count); LOGDBG("Send SYSEX config dump to \"%s\"",Iterator->first.c_str()); } } @@ -629,7 +630,7 @@ void CMIDIDevice::SendProgramChange(uint8_t pgm, uint8_t nTG) // send voice dump to all MIDI interfaces for(Iterator = s_DeviceMap.begin(); Iterator != s_DeviceMap.end(); ++Iterator) { - Iterator->second->Send (PgmChange, sizeof(PgmChange)*sizeof(uint8_t)); + Iterator->second->Send (PgmChange, 2); LOGDBG("Send Program Change %i to \"%s\"",pgm&0x7f,Iterator->first.c_str()); } } @@ -648,7 +649,7 @@ void CMIDIDevice::SendCtrlChange(uint8_t ctrl, uint8_t val, uint8_t nTG) // send voice dump to all MIDI interfaces for(Iterator = s_DeviceMap.begin(); Iterator != s_DeviceMap.end(); ++Iterator) { - Iterator->second->Send (CtrlMsg, sizeof(CtrlMsg)*sizeof(uint8_t)); + Iterator->second->Send (CtrlMsg, 3); LOGDBG("Send Ctrl change %02X = %i to \"%s\"",ctrl&0x7f, val&0x7f,Iterator->first.c_str()); } } diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 357a51e..b383fbf 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -391,7 +391,7 @@ void CMiniDexed::SetPan (unsigned nPan, unsigned nTG) tg_mixer->pan(nTG,mapfloat(nPan,0,127,0.0f,1.0f)); reverb_send_mixer->pan(nTG,mapfloat(nPan,0,127,0.0f,1.0f)); - m_SerialMIDI.SendCtrlChange(MIDI_CC_PAN_POSITION, nPan, nTG); + m_SerialMIDI.SendCtrlChange(MIDI_CC_PAN_POSITION, m_nPan[nTG], nTG); m_UI.ParameterChanged (); } diff --git a/src/minidexed.h b/src/minidexed.h index 6945845..8fc9fed 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -166,6 +166,7 @@ public: bool DoSavePerformance (void); void setMasterVolume (float32_t vol); + uint8_t getMasterVolume() { return (127*nMasterVolume); } private: int16_t ApplyNoteLimits (int16_t pitch, unsigned nTG); // returns < 0 to ignore note diff --git a/src/serialmididevice.cpp b/src/serialmididevice.cpp index aed64a6..0e06bc9 100644 --- a/src/serialmididevice.cpp +++ b/src/serialmididevice.cpp @@ -161,5 +161,11 @@ void CSerialMIDIDevice::Process (void) void CSerialMIDIDevice::Send (const u8 *pMessage, size_t nLength, unsigned nCable) { +// for (size_t i= 0; i < nLength; i++) +// { +// printf("%02X, ",pMessage[i]); +// if ( (i+1)%16 == 0 ) printf("\n"); +// } +// printf("\n"); m_SendBuffer.Write (pMessage, nLength); } From 959b123f45261ee394cd1ef8983a9d6f969a0049 Mon Sep 17 00:00:00 2001 From: BeZo Date: Mon, 20 Jun 2022 22:40:33 +0200 Subject: [PATCH 11/26] Added extra files --- Synth_Dexed | 2 +- circle-stdlib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Synth_Dexed b/Synth_Dexed index 28ef0da..a3a696b 160000 --- a/Synth_Dexed +++ b/Synth_Dexed @@ -1 +1 @@ -Subproject commit 28ef0da952b5c3b20204f14a56724290235b154d +Subproject commit a3a696b003ef76f79dbd91ff8188a123b74e5e17 diff --git a/circle-stdlib b/circle-stdlib index 61cf3a4..b6a188d 160000 --- a/circle-stdlib +++ b/circle-stdlib @@ -1 +1 @@ -Subproject commit 61cf3a47bf93628039078b7c840e44432e52343e +Subproject commit b6a188dbeef673457a0a82d709feeeefe7f944de From d944ec48ddf2d9eb1f501d6f7dc4d220103dc422 Mon Sep 17 00:00:00 2001 From: BeZo Date: Mon, 20 Jun 2022 22:42:57 +0200 Subject: [PATCH 12/26] This should fix the builds --- build.sh | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/build.sh b/build.sh index 1eb5325..aa1ad9b 100755 --- a/build.sh +++ b/build.sh @@ -1,10 +1,4 @@ -#!/bin/bash - -set -e -set -x - -echo "Clean: ${CLEAN}" -if [ -z "${RPI}" ] ; then +f [ -z "${RPI}" ] ; then echo "\$RPI missing, exting" exit 1 fi @@ -21,42 +15,29 @@ if [ "${RPI}" -gt "1" ]; then OPTIONS="${OPTIONS} -o ARM_ALLOW_MULTI_CORE" fi -if [ ! -z "${BUILDCIRCLE}" ] ; then # Build circle-stdlib library cd circle-stdlib/ -if [ ! -z "${CLEAN}" ] ; then make mrproper || true -fi ./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 make -j # Build additional libraries cd libs/circle/addon/display/ -if [ ! -z "${CLEAN}" ] ; then make clean || true -fi make -j cd ../sensor/ -if [ ! -z "${CLEAN}" ] ; then make clean || true -fi make -j cd ../Properties/ -if [ ! -z "${CLEAN}" ] ; then make clean || true -fi make -j cd ../../../.. cd .. -fi # Build MiniDexed -echo "Build MiniDexed" cd src -if [ ! -z "${CLEAN}" ] ; then make clean || true -fi make -j ls *.img cd .. From 5ed8b18f92dcff4e736539af789022328643cef3 Mon Sep 17 00:00:00 2001 From: BenZonneveld Date: Mon, 20 Jun 2022 22:46:59 +0200 Subject: [PATCH 13/26] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e5d45f..c5d45ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,9 @@ env: on: push: - branches: [ main ] + branches: [ main | SysExControl ] pull_request: - branches: [ main ] + branches: [ main | SysExControl ] jobs: Build: From d10c7849dfe6f18232d4d80cff6625b64dd7259c Mon Sep 17 00:00:00 2001 From: BenZonneveld Date: Mon, 20 Jun 2022 22:47:52 +0200 Subject: [PATCH 14/26] Update build.yml Update --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5d45ea..0f8738d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,9 @@ env: on: push: - branches: [ main | SysExControl ] + branches: [ SysExControl ] pull_request: - branches: [ main | SysExControl ] + branches: [ SysExControl ] jobs: Build: From fd345d8bba1f2a2f24508b109782a4e7f83a3638 Mon Sep 17 00:00:00 2001 From: probonopd Date: Tue, 21 Jun 2022 00:38:02 +0200 Subject: [PATCH 15/26] Restore build.yml Revert changes unrelated to the PR --- .github/workflows/build.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f8738d..6612e32 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,13 @@ -name: BuildSysex +name: Build env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} on: push: - branches: [ SysExControl ] + branches: [ main ] pull_request: - branches: [ SysExControl ] + branches: [ main ] jobs: Build: @@ -46,6 +46,18 @@ jobs: export PATH=$(readlink -f ./gcc-*aarch64-none*/bin/):$PATH RPI=3 bash -ex build.sh cp ./src/kernel*.img ./kernels/ + - name: Build for Raspberry Pi 2 + run: | + set -ex + export PATH=$(readlink -f ./gcc-*arm-none*/bin/):$PATH + RPI=2 bash -ex build.sh + cp ./src/kernel*.img ./kernels/ + - name: Build for Raspberry Pi 1 + run: | + set -ex + export PATH=$(readlink -f ./gcc-*arm-none*/bin/):$PATH + RPI=1 bash -ex build.sh + cp ./src/kernel*.img ./kernels/ - name: Get Raspberry Pi boot files run: | set -ex @@ -74,4 +86,3 @@ jobs: set -ex wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh bash ./upload.sh ./MiniDexed*.zip - From 6351fdcbcb7609b1643855615ebc170f68155386 Mon Sep 17 00:00:00 2001 From: probonopd Date: Tue, 21 Jun 2022 00:40:16 +0200 Subject: [PATCH 16/26] Restore build.sh Revert changes unrelated to the PR --- build.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index aa1ad9b..271501a 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,9 @@ -f [ -z "${RPI}" ] ; then +#!/bin/bash + +set -e +set -x + +if [ -z "${RPI}" ] ; then echo "\$RPI missing, exting" exit 1 fi From cb0f524255c5b23656b89b3e1b9782bb36ea136f Mon Sep 17 00:00:00 2001 From: BeZo Date: Tue, 5 Jul 2022 21:56:46 +0200 Subject: [PATCH 17/26] Moving Sysex check to mididevice.cpp --- src/mididevice.cpp | 100 +++++++++++++++++++++++++++++++++++++++++++++ src/mididevice.h | 1 + 2 files changed, 101 insertions(+) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index a80e494..ac5cf5a 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -680,3 +680,103 @@ void CMIDIDevice::SendBankName(uint8_t nTG) } } +int16_t CMidiDevice::checkSystemExclusive(const uint8_t* sysex, const uint16_t len) +/* + -1: SysEx end status byte not detected. + -2: SysEx vendor not Yamaha. + -3: Unknown SysEx parameter change. + -4: Unknown SysEx voice or function. + -5: Not a SysEx voice bulk upload. + -6: Wrong length for SysEx voice bulk upload (not 155). + -7: Checksum error for one voice. + -8: Not a SysEx bank bulk upload. + -9: Wrong length for SysEx bank bulk upload (not 4096). + -10: Checksum error for bank. + -11: Unknown SysEx message. + 64-77: Function parameter changed. + 100: Voice loaded. + 200: Bank loaded. + 300-455: Voice parameter changed. + 500-531: Send patch request. + 600 Send config request + 601 Send Bank Name +*/ +{ + int32_t bulk_checksum_calc = 0; + const int8_t bulk_checksum = sysex[161]; + + // Check for SYSEX end byte + if (sysex[len - 1] != 0xf7) + return(-1); + + // check for Yamaha sysex + if (sysex[1] != 0x43) + return(-2); + + // Decode SYSEX by means of length + switch (len) + { + case 4: + if ((sysex[2] & 0x30) == 0x30) // Send config request + return 600; + if ((sysex[2] & 0x70) == 0x40) // Send config request + return 601; + break; + case 5: + if ((sysex[2] & 0x70) == 0x20) // Send voice request + return(500 + (sysex[3] & 0x7c)); + break; + case 7: // parse parameter change + if (((sysex[3] & 0x7c) >> 2) != 0 && ((sysex[3] & 0x7c) >> 2) != 2) + return(-3); + + if ((sysex[3] & 0x7c) >> 2 == 0) // Voice parameter + { + setVoiceDataElement((sysex[4] & 0x7f) + ((sysex[3] & 0x03) * 128), sysex[5]); + doRefreshVoice(); + return((sysex[4] & 0x7f) + ((sysex[3] & 0x03) * 128)+300); + } + else if ((sysex[3] & 0x7c) >> 2 == 2) // Function parameter + return(sysex[4]); + else + return(-4); + break; + case 163: // 1 Voice bulk upload + if ((sysex[3] & 0x7f) != 0) + return(-5); + + if (((sysex[4] << 7) | sysex[5]) != 0x9b) + return(-6); + + // checksum calculation + for (uint8_t i = 0; i < 155 ; i++) + bulk_checksum_calc -= sysex[i + 6]; + bulk_checksum_calc &= 0x7f; + + if (bulk_checksum_calc != bulk_checksum) + return(-7); + + return(100); + break; + case 4104: // 1 Bank bulk upload + if ((sysex[3] & 0x7f) != 9) + return(-8); + + if (((sysex[4] << 7) | sysex[5]) != 0x1000) + return(-9); + + // checksum calculation + for (uint16_t i = 0; i < 4096 ; i++) + bulk_checksum_calc -= sysex[i + 6]; + bulk_checksum_calc &= 0x7f; + + if (bulk_checksum_calc != bulk_checksum) + return(-10); + + return(200); + break; + default: + return(-11); + } + return(SHRT_MIN); +} diff --git a/src/mididevice.h b/src/mididevice.h index 38002b7..d3eba67 100644 --- a/src/mididevice.h +++ b/src/mididevice.h @@ -74,6 +74,7 @@ protected: void MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsigned nCable = 0); void AddDevice (const char *pDeviceName); void HandleSystemExclusive(const uint8_t* pMessage, const size_t nLength, const unsigned nCable, const uint8_t nTG); + int16_t checkSystemExclusive(const uint8_t* sysex, const uint16_t len); private: CMiniDexed *m_pSynthesizer; CConfig *m_pConfig; From 92d5f4c4b634802dde236cc9f4bb92fa53a421af Mon Sep 17 00:00:00 2001 From: BeZo Date: Tue, 5 Jul 2022 21:58:14 +0200 Subject: [PATCH 18/26] This should fix the build issues --- src/mididevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index ac5cf5a..d137a06 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -324,7 +324,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL if ( nTG >= CConfig::ToneGenerators ) return; - sysex_return = m_pSynthesizer->checkSystemExclusive(pMessage, nLength, nTG); + sysex_return = checkSystemExclusive(pMessage, nLength, nTG); uint8_t instanceID = pMessage[2]&0xF; if ( instanceID != nTG ) { printf("WARNING instanceID and nTG do not match!!!!!\n"); } From 637bcec24f0970a317e07d899cdacf161c826729 Mon Sep 17 00:00:00 2001 From: BenZonneveld Date: Tue, 5 Jul 2022 22:02:46 +0200 Subject: [PATCH 19/26] Update rebuild.sh --- rebuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebuild.sh b/rebuild.sh index a6743ff..a5ea75a 100644 --- a/rebuild.sh +++ b/rebuild.sh @@ -1,6 +1,6 @@ export RPI=3 -export CLEAN="true" +export CLEAN="false" export BUILDCIRCLE="true" export PATH=$(readlink -f ./gcc-*/bin/):$PATH From 1902c47d64dd86757d1e1c4b5ad20c823ec6e5e1 Mon Sep 17 00:00:00 2001 From: BenZonneveld Date: Tue, 5 Jul 2022 22:04:47 +0200 Subject: [PATCH 20/26] Update rebuild.sh --- rebuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebuild.sh b/rebuild.sh index a5ea75a..a6743ff 100644 --- a/rebuild.sh +++ b/rebuild.sh @@ -1,6 +1,6 @@ export RPI=3 -export CLEAN="false" +export CLEAN="true" export BUILDCIRCLE="true" export PATH=$(readlink -f ./gcc-*/bin/):$PATH From cf03de9f880ff716f5c5f1dce206ce8f746b8754 Mon Sep 17 00:00:00 2001 From: BeZo Date: Tue, 5 Jul 2022 22:18:55 +0200 Subject: [PATCH 21/26] Upstream Dexed --- Synth_Dexed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synth_Dexed b/Synth_Dexed index a3a696b..28ef0da 160000 --- a/Synth_Dexed +++ b/Synth_Dexed @@ -1 +1 @@ -Subproject commit a3a696b003ef76f79dbd91ff8188a123b74e5e17 +Subproject commit 28ef0da952b5c3b20204f14a56724290235b154d From 613d721c886554af026aeda125d419e397ab4632 Mon Sep 17 00:00:00 2001 From: BeZo Date: Tue, 5 Jul 2022 22:31:07 +0200 Subject: [PATCH 22/26] Fixing build --- circle-stdlib | 2 +- serial.h | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 serial.h diff --git a/circle-stdlib b/circle-stdlib index b6a188d..09d328c 160000 --- a/circle-stdlib +++ b/circle-stdlib @@ -1 +1 @@ -Subproject commit b6a188dbeef673457a0a82d709feeeefe7f944de +Subproject commit 09d328c28f831ffe8910104c21aff32fa1b08fd5 diff --git a/serial.h b/serial.h new file mode 100644 index 0000000..f2490d9 --- /dev/null +++ b/serial.h @@ -0,0 +1,186 @@ +// +/// \file serial.h +// +// Circle - A C++ bare metal environment for Raspberry Pi +// Copyright (C) 2014-2021 R. Stange +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +#ifndef _circle_serial_h +#define _circle_serial_h + +#include +#include +#include +#include +#include +#include + +/// \class CSerialDevice +/// \brief Driver for PL011 UART +/// +/// \details GPIO pin mapping (chip numbers) +/// nDevice | TXD | RXD | Support +/// :-----: | :----: | :----: | :------ +/// 0 | GPIO14 | GPIO15 | All boards +/// ^ | GPIO32 | GPIO33 | Compute Modules +/// ^ | GPIO36 | GPIO37 | Compute Modules +/// 1 | | | None (AUX) +/// 2 | GPIO0 | GPIO1 | Raspberry Pi 4 only +/// 3 | GPIO4 | GPIO5 | Raspberry Pi 4 only +/// 4 | GPIO8 | GPIO9 | Raspberry Pi 4 only +/// 5 | GPIO12 | GPIO13 | Raspberry Pi 4 only +/// GPIO32/33 and GPIO36/37 can be selected with system option SERIAL_GPIO_SELECT.\n +/// GPIO0/1 are normally reserved for ID EEPROM.\n +/// Handshake lines CTS and RTS are not supported. + +#if RASPPI < 4 + #define SERIAL_DEVICES 1 +#else + #define SERIAL_DEVICES 6 +#endif + +#define SERIAL_BUF_SIZE 2048 // must be a power of 2 +#define SERIAL_BUF_MASK (SERIAL_BUF_SIZE-1) + +// serial options +#define SERIAL_OPTION_ONLCR 0 ///< Translate NL to NL+CR on output (default) + +// returned from Read/Write as negative value +#define SERIAL_ERROR_BREAK 1 +#define SERIAL_ERROR_OVERRUN 2 +#define SERIAL_ERROR_FRAMING 3 +#define SERIAL_ERROR_PARITY 4 + +class CSerialDevice : public CDevice +{ +public: + enum TParity + { + ParityNone, + ParityOdd, + ParityEven, + ParityUnknown + }; + +public: +#ifndef USE_RPI_STUB_AT + /// \param pInterruptSystem Pointer to interrupt system object (or 0 for polling driver) + /// \param bUseFIQ Use FIQ instead of IRQ + /// \param nDevice Device number (see: GPIO pin mapping) + CSerialDevice (CInterruptSystem *pInterruptSystem = 0, boolean bUseFIQ = FALSE, + unsigned nDevice = 0); + + ~CSerialDevice (void); +#endif + + /// \param nBaudrate Baud rate in bits per second + /// \param nDataBits Number of data bits (5..8, default 8) + /// \param nStopBits Number of stop bits (1..2, default 1) + /// \param Parity Parity setting (ParityNone (default), ParityOdd or ParityEven) + /// \return Operation successful? +#ifndef USE_RPI_STUB_AT + boolean Initialize (unsigned nBaudrate = 115200, + unsigned nDataBits = 8, unsigned nStopBits = 1, + TParity Parity = ParityNone); +#else + boolean Initialize (unsigned nBaudrate = 115200); +#endif + + /// \param pBuffer Pointer to data to be sent + /// \param nCount Number of bytes to be sent + /// \return Number of bytes successfully sent (< 0 on error) + int Write (const void *pBuffer, size_t nCount); + +#ifndef USE_RPI_STUB_AT + /// \param pBuffer Pointer to buffer for received data + /// \param nCount Maximum number of bytes to be received + /// \return Number of bytes received (0 no data available, < 0 on error) + int Read (void *pBuffer, size_t nCount); + + /// \return Serial options mask (see serial options) + unsigned GetOptions (void) const; + /// \param nOptions Serial options mask (see serial options) + void SetOptions (unsigned nOptions); + + typedef void TMagicReceivedHandler (void); + /// \param pMagic String for which is searched in the received data\n + /// (must remain valid after return from this method) + /// \param pHandler Handler which is called, when the magic string is found + /// \note Does only work with interrupt driver. + void RegisterMagicReceivedHandler (const char *pMagic, TMagicReceivedHandler *pHandler); + +protected: + /// \return Number of bytes buffer space available for Write() + /// \note Does only work with interrupt driver. + unsigned AvailableForWrite (void); + + /// \return Number of bytes already received available for Read() + /// \note Does only work with interrupt driver. + unsigned AvailableForRead (void); + + /// \return Next received byte which will be returned by Read() (-1 if no data available) + /// \note Does only work with interrupt driver. + int Peek (void); + + /// \brief Waits until all written bytes have been sent out + void Flush (void); + +private: + boolean Write (u8 uchChar); + + void InterruptHandler (void); + static void InterruptStub (void *pParam); + +private: + CInterruptSystem *m_pInterruptSystem; + boolean m_bUseFIQ; + unsigned m_nDevice; + uintptr m_nBaseAddress; + boolean m_bValid; + +#if SERIAL_GPIO_SELECT == 14 + CGPIOPin m_GPIO32; + CGPIOPin m_GPIO33; +#endif + CGPIOPin m_TxDPin; + CGPIOPin m_RxDPin; + + u8 m_RxBuffer[SERIAL_BUF_SIZE]; + volatile unsigned m_nRxInPtr; + volatile unsigned m_nRxOutPtr; + volatile int m_nRxStatus; + + u8 m_TxBuffer[SERIAL_BUF_SIZE]; + volatile unsigned m_nTxInPtr; + volatile unsigned m_nTxOutPtr; + + unsigned m_nOptions; + + const char *m_pMagic; + const char *m_pMagicPtr; + TMagicReceivedHandler *m_pMagicReceivedHandler; + + CSpinLock m_SpinLock; + CSpinLock m_LineSpinLock; + + static unsigned s_nInterruptUseCount; + static CInterruptSystem *s_pInterruptSystem; + static boolean s_bUseFIQ; + static volatile u32 s_nInterruptDeviceMask; + static CSerialDevice *s_pThis[SERIAL_DEVICES]; +#endif +}; + +#endif From 5ee4469e9571afd84869373526175a8a42fd86dd Mon Sep 17 00:00:00 2001 From: BeZo Date: Tue, 5 Jul 2022 23:09:48 +0200 Subject: [PATCH 23/26] Refactored the sysex check --- build.sh | 3 ++ src/mididevice.cpp | 112 ++++----------------------------------------- src/mididevice.h | 1 - 3 files changed, 12 insertions(+), 104 deletions(-) diff --git a/build.sh b/build.sh index 271501a..5823756 100755 --- a/build.sh +++ b/build.sh @@ -14,6 +14,7 @@ else export TOOLCHAIN_PREFIX="arm-none-eabi-" fi + # Define system options OPTIONS="-o USE_PWM_AUDIO_ON_ZERO -o SAVE_VFP_REGS_ON_IRQ -o REALTIME -o SCREEN_DMA_BURST_LENGTH=1" if [ "${RPI}" -gt "1" ]; then @@ -21,6 +22,8 @@ if [ "${RPI}" -gt "1" ]; then fi # Build circle-stdlib library +# Apply NL to NL+CR on output fix +cp serial.h circle-stdlib/libs/circle/include/circle/serial.h cd circle-stdlib/ make mrproper || true ./configure -r ${RPI} --prefix "${TOOLCHAIN_PREFIX}" ${OPTIONS} -o KERNEL_MAX_SIZE=0x400000 diff --git a/src/mididevice.cpp b/src/mididevice.cpp index d137a06..bb121ce 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -324,13 +324,20 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL if ( nTG >= CConfig::ToneGenerators ) return; - sysex_return = checkSystemExclusive(pMessage, nLength, nTG); + sysex_return = m_pSynthesizer->checkSystemExclusive(pMessage, nLength, nTG); uint8_t instanceID = pMessage[2]&0xF; + if ( sysex_return == -11 && (pMessage[0] == 0xF0 && (pMessage[1] == 0x43 && nLength == 4 ) + { + if ((pMessage[2] & 0x30) == 0x30) // Send config request + sysex_return = 600; + if ((pMessage[2] & 0x70) == 0x40) // Send Bank Name request + sysex_return = 601; + } if ( instanceID != nTG ) { printf("WARNING instanceID and nTG do not match!!!!!\n"); } LOGDBG("SYSEX handler return value: %d", sysex_return); - //printf("SYSEX handler return value: %d for TG %i\n", sysex_return, instanceID); + printf("SYSEX handler return value: %d for TG %i\n", sysex_return, instanceID); switch (sysex_return) { @@ -679,104 +686,3 @@ void CMIDIDevice::SendBankName(uint8_t nTG) LOGDBG("Send Bank Name Sysex to \"%s\"",Iterator->first.c_str()); } } - -int16_t CMidiDevice::checkSystemExclusive(const uint8_t* sysex, const uint16_t len) -/* - -1: SysEx end status byte not detected. - -2: SysEx vendor not Yamaha. - -3: Unknown SysEx parameter change. - -4: Unknown SysEx voice or function. - -5: Not a SysEx voice bulk upload. - -6: Wrong length for SysEx voice bulk upload (not 155). - -7: Checksum error for one voice. - -8: Not a SysEx bank bulk upload. - -9: Wrong length for SysEx bank bulk upload (not 4096). - -10: Checksum error for bank. - -11: Unknown SysEx message. - 64-77: Function parameter changed. - 100: Voice loaded. - 200: Bank loaded. - 300-455: Voice parameter changed. - 500-531: Send patch request. - 600 Send config request - 601 Send Bank Name -*/ -{ - int32_t bulk_checksum_calc = 0; - const int8_t bulk_checksum = sysex[161]; - - // Check for SYSEX end byte - if (sysex[len - 1] != 0xf7) - return(-1); - - // check for Yamaha sysex - if (sysex[1] != 0x43) - return(-2); - - // Decode SYSEX by means of length - switch (len) - { - case 4: - if ((sysex[2] & 0x30) == 0x30) // Send config request - return 600; - if ((sysex[2] & 0x70) == 0x40) // Send config request - return 601; - break; - case 5: - if ((sysex[2] & 0x70) == 0x20) // Send voice request - return(500 + (sysex[3] & 0x7c)); - break; - case 7: // parse parameter change - if (((sysex[3] & 0x7c) >> 2) != 0 && ((sysex[3] & 0x7c) >> 2) != 2) - return(-3); - - if ((sysex[3] & 0x7c) >> 2 == 0) // Voice parameter - { - setVoiceDataElement((sysex[4] & 0x7f) + ((sysex[3] & 0x03) * 128), sysex[5]); - doRefreshVoice(); - return((sysex[4] & 0x7f) + ((sysex[3] & 0x03) * 128)+300); - } - else if ((sysex[3] & 0x7c) >> 2 == 2) // Function parameter - return(sysex[4]); - else - return(-4); - break; - case 163: // 1 Voice bulk upload - if ((sysex[3] & 0x7f) != 0) - return(-5); - - if (((sysex[4] << 7) | sysex[5]) != 0x9b) - return(-6); - - // checksum calculation - for (uint8_t i = 0; i < 155 ; i++) - bulk_checksum_calc -= sysex[i + 6]; - bulk_checksum_calc &= 0x7f; - - if (bulk_checksum_calc != bulk_checksum) - return(-7); - - return(100); - break; - case 4104: // 1 Bank bulk upload - if ((sysex[3] & 0x7f) != 9) - return(-8); - - if (((sysex[4] << 7) | sysex[5]) != 0x1000) - return(-9); - - // checksum calculation - for (uint16_t i = 0; i < 4096 ; i++) - bulk_checksum_calc -= sysex[i + 6]; - bulk_checksum_calc &= 0x7f; - - if (bulk_checksum_calc != bulk_checksum) - return(-10); - - return(200); - break; - default: - return(-11); - } - return(SHRT_MIN); -} diff --git a/src/mididevice.h b/src/mididevice.h index d3eba67..38002b7 100644 --- a/src/mididevice.h +++ b/src/mididevice.h @@ -74,7 +74,6 @@ protected: void MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsigned nCable = 0); void AddDevice (const char *pDeviceName); void HandleSystemExclusive(const uint8_t* pMessage, const size_t nLength, const unsigned nCable, const uint8_t nTG); - int16_t checkSystemExclusive(const uint8_t* sysex, const uint16_t len); private: CMiniDexed *m_pSynthesizer; CConfig *m_pConfig; From 3e9ae9b59ea2b975c34ebc887a91a9ef15bec0fa Mon Sep 17 00:00:00 2001 From: BeZo Date: Tue, 5 Jul 2022 23:11:49 +0200 Subject: [PATCH 24/26] Refactored the sysex check --- src/mididevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index bb121ce..389e32f 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -327,7 +327,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL sysex_return = m_pSynthesizer->checkSystemExclusive(pMessage, nLength, nTG); uint8_t instanceID = pMessage[2]&0xF; - if ( sysex_return == -11 && (pMessage[0] == 0xF0 && (pMessage[1] == 0x43 && nLength == 4 ) + if ( sysex_return == -11 && pMessage[0] == 0xF0 && pMessage[1] == 0x43 && nLength == 4 ) { if ((pMessage[2] & 0x30) == 0x30) // Send config request sysex_return = 600; From 01ef041f6b97b914eaa4f4360fcf90d6f41e9ac6 Mon Sep 17 00:00:00 2001 From: BeZo Date: Tue, 5 Jul 2022 23:30:28 +0200 Subject: [PATCH 25/26] Build Fix and Working Sysex --- src/mididevice.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 389e32f..6847395 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -337,7 +337,6 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL if ( instanceID != nTG ) { printf("WARNING instanceID and nTG do not match!!!!!\n"); } LOGDBG("SYSEX handler return value: %d", sysex_return); - printf("SYSEX handler return value: %d for TG %i\n", sysex_return, instanceID); switch (sysex_return) { From 05f1e43534e5af72aa6bb8dcf698b95ab1ce428c Mon Sep 17 00:00:00 2001 From: BeZo Date: Wed, 6 Jul 2022 20:04:29 +0200 Subject: [PATCH 26/26] The check was not correct, fixed --- src/mididevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 6847395..3e420d4 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -329,7 +329,7 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL if ( sysex_return == -11 && pMessage[0] == 0xF0 && pMessage[1] == 0x43 && nLength == 4 ) { - if ((pMessage[2] & 0x30) == 0x30) // Send config request + if ((pMessage[2] & 0x70) == 0x30) // Send config request sysex_return = 600; if ((pMessage[2] & 0x70) == 0x40) // Send Bank Name request sysex_return = 601;