Do not hardcode initial voice

pull/34/head
probonopd 2 years ago committed by GitHub
parent 7c6ceb9312
commit d86a45324f
  1. 19
      src/kernel.cpp
  2. 39
      src/minidexed.cpp
  3. 1
      src/minidexed.h

@ -7,21 +7,6 @@
#include <circle/logger.h>
#include "voices.c"
uint8_t fmpiano_sysex[156] = {
95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14, // OP6 eg_rate_1-4, level_1-4, kbd_lev_scl_brk_pt, kbd_lev_scl_lft_depth, kbd_lev_scl_rht_depth, kbd_lev_scl_lft_curve, kbd_lev_scl_rht_curve, kbd_rate_scaling, amp_mod_sensitivity, key_vel_sensitivity, operator_output_level, osc_mode, osc_freq_coarse, osc_freq_fine, osc_detune
95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 00, 99, 00, 01, 00, 00, // OP5
95, 29, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 06, 89, 00, 01, 00, 07, // OP4
95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 07, // OP3
95, 50, 35, 78, 99, 75, 00, 00, 00, 00, 00, 00, 00, 03, 00, 07, 58, 00, 14, 00, 07, // OP2
96, 25, 25, 67, 99, 75, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 10, // OP1
94, 67, 95, 60, 50, 50, 50, 50, // 4 * pitch EG rates, 4 * pitch EG level
04, 06, 00, // algorithm, feedback, osc sync
34, 33, 00, 00, 00, 04, // lfo speed, lfo delay, lfo pitch_mod_depth, lfo_amp_mod_depth, lfo_sync, lfo_waveform
03, 24, // pitch_mod_sensitivity, transpose
70, 77, 45, 80, 73, 65, 78, 79, 00, 00 // 10 * char for name ("DEFAULT ")
}; // FM-Piano
LOGMODULE ("kernel");
CKernel::CKernel (void)
@ -76,10 +61,6 @@ CStdlibApp::TShutdownMode CKernel::Run (void)
{
std::cout << "Hello MiniDexed!\n";
// m_pDexed->loadVoiceParameters(voices_banks[0][0]);
m_pDexed->loadVoiceParameters(fmpiano_sysex);
m_pDexed->setTranspose(24);
while(42==42)
{
boolean bUpdated = mUSBHCI.UpdatePlugAndPlay ();

@ -45,6 +45,9 @@ bool CMiniDexed::Initialize (void)
activate();
s_pThis->ChangeProgram(0);
s_pThis->setTranspose(24);
return true;
}
@ -173,22 +176,7 @@ void CMiniDexed::MIDIPacketHandler (unsigned nCable, u8 *pPacket, unsigned nLeng
if (pPacket[0] == MIDI_PROGRAM_CHANGE)
{
if(pPacket[1] > 31) {
return;
}
printf ("Loading voice %u\n", (unsigned) pPacket[1]+1); // MIDI numbering starts with 0, user interface with 1
uint8_t Buffer[156];
s_pThis->m_SysExFileLoader.GetVoice (pPacket[1], Buffer);
s_pThis->loadVoiceParameters(Buffer);
char buf_name[11];
memset(buf_name, 0, 11); // Initialize with 0x00 chars
s_pThis->setName(buf_name);
printf ("%s\n", buf_name);
// Print to optional HD44780 display
s_pThis->LCDWrite("\x1B[?25l"); // cursor off
CString String;
String.Format ("\n\r%i\n\r%s", pPacket[1]+1, buf_name); // MIDI numbering starts with 0, user interface with 1
s_pThis->LCDWrite ((const char *) String);
s_pThis->ChangeProgram(pPacket[1]);
return;
}
@ -220,6 +208,25 @@ void CMiniDexed::MIDIPacketHandler (unsigned nCable, u8 *pPacket, unsigned nLeng
}
}
void CMiniDexed::ChangeProgram(unsigned program) {
if(program > 31) {
return;
}
printf ("Loading voice %u\n", (unsigned) program+1); // MIDI numbering starts with 0, user interface with 1
uint8_t Buffer[156];
s_pThis->m_SysExFileLoader.GetVoice (program, Buffer);
s_pThis->loadVoiceParameters(Buffer);
char buf_name[11];
memset(buf_name, 0, 11); // Initialize with 0x00 chars
s_pThis->setName(buf_name);
printf ("%s\n", buf_name);
// Print to optional HD44780 display
s_pThis->LCDWrite("\x1B[?25l"); // cursor off
CString String;
String.Format ("\n\r%i\n\r%s", program+1, buf_name); // MIDI numbering starts with 0, user interface with 1
s_pThis->LCDWrite ((const char *) String);
}
void CMiniDexed::USBDeviceRemovedHandler (CDevice *pDevice, void *pContext)
{
if (s_pThis->m_pMIDIDevice == (CUSBMIDIDevice *) pDevice)

@ -60,6 +60,7 @@ class CMiniDexed : public Dexed
protected:
static void MIDIPacketHandler (unsigned nCable, u8 *pPacket, unsigned nLength);
static void KeyStatusHandlerRaw (unsigned char ucModifiers, const unsigned char RawKeys[6]);
static void ChangeProgram(unsigned program);
static void USBDeviceRemovedHandler (CDevice *pDevice, void *pContext);
CUSBMIDIDevice * volatile m_pMIDIDevice;
CPCKeyboard m_PCKeyboard;

Loading…
Cancel
Save