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