diff --git a/JuceOPLVSTi.jucer b/JuceOPLVSTi.jucer index 49453ee..9cd15ff 100644 --- a/JuceOPLVSTi.jucer +++ b/JuceOPLVSTi.jucer @@ -10,6 +10,10 @@ pluginAAXCategory="AAX_ePlugInCategory_Dynamics" jucerVersion="3.1.0"> + + + loadInstrumentFromFile(files[0]); } - //message = "files dropped: " + files.joinIntoString ("\n"); - - //somethingIsBeingDraggedOver = false; - //repaint(); } //[/MiscUserCode] diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index ee5ae21..0c1777f 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -465,26 +465,43 @@ void JuceOplvstiAudioProcessor::loadInstrumentFromFile(String filename) FILE* f = fopen(filename.toUTF8(), "rb"); unsigned char buf[MAX_INSTRUMENT_FILE_SIZE_BYTES]; int n = fread(buf, 1, MAX_INSTRUMENT_FILE_SIZE_BYTES, f); + fclose(f); SbiLoader* loader = new SbiLoader(); loader->loadInstrumentData(n, buf, this); - fclose(f); + updateGuiIfPresent(); } void JuceOplvstiAudioProcessor::setParametersByRegister(int register_base, int op, uint8 value) { + const String operators[] = {"Modulator", "Carrier"}; register_base &= 0xF0; switch (register_base) { case 0x20: + setEnumParameter(operators[op] + " Tremolo", (value & 0x80) ? 1 : 0); + setEnumParameter(operators[op] + " Vibrato", (value & 0x40) ? 1 : 0); + setEnumParameter(operators[op] + " Sustain", (value & 0x20) ? 1 : 0); + setEnumParameter(operators[op] + " Keyscale Rate", (value & 0x10) ? 1 : 0); + setEnumParameter(operators[op] + " Frequency Multiplier", value & 0x0f); break; case 0x40: + setEnumParameter(operators[op] + " Keyscale Level", (value & 0xc0) >> 6); + setEnumParameter(operators[op] + " Attenuation", value & 0x3f); break; case 0x60: + setIntParameter(operators[op] + " Attack", (value & 0xf0) >> 4); + setIntParameter(operators[op] + " Decay", value & 0x0f); break; case 0x80: + setIntParameter(operators[op] + " Sustain Level", (value & 0xf0) >> 4); + setIntParameter(operators[op] + " Release", value & 0x0f); break; case 0xC0: + setIntParameter("Modulator Feedback", (value & 0xe) >> 1); + setEnumParameter("Algorithm", value & 0x1); break; case 0xE0: + printf("Setting wave to %d", value & 0x7); + setEnumParameter(operators[op] + " Wave", value & 0x7); break; default: break; @@ -559,6 +576,14 @@ int JuceOplvstiAudioProcessor::getCurrentProgram() return i_program; } +void JuceOplvstiAudioProcessor::updateGuiIfPresent() +{ + PluginGui* gui = (PluginGui*)getActiveEditor(); + if (gui) { + gui->updateFromParameters(); + } +} + void JuceOplvstiAudioProcessor::setCurrentProgram (int index) { i_program = index; @@ -566,10 +591,7 @@ void JuceOplvstiAudioProcessor::setCurrentProgram (int index) for (unsigned int i = 0; i < params.size() && i < v_params.size(); i++) { setParameter(i, v_params[i]); } - PluginGui* gui = (PluginGui*)getActiveEditor(); - if (gui) { - gui->updateFromParameters(); - } + updateGuiIfPresent(); } const String JuceOplvstiAudioProcessor::getProgramName (int index) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 61561d2..1118cc4 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -52,6 +52,8 @@ public: void loadInstrumentFromFile(String filename); void setParametersByRegister(int register_base, int op, uint8 value); + void updateGuiIfPresent(); + const String getParameterName (int index); const String getParameterText (int index); diff --git a/Source/SbiLoader.cpp b/Source/SbiLoader.cpp index 1531598..b571f48 100644 --- a/Source/SbiLoader.cpp +++ b/Source/SbiLoader.cpp @@ -7,8 +7,8 @@ SbiLoader::SbiLoader(void) void SbiLoader::loadInstrumentData(int n, const unsigned char* data, JuceOplvstiAudioProcessor *proc) { - if (strncmp("SBI", (const char*)data, 3)) { - data += 40; + if (0 == strncmp("SBI", (const char*)data, 3)) { + data += 36; proc->setParametersByRegister(0x20, 0, data[0]); proc->setParametersByRegister(0x20, 1, data[1]); proc->setParametersByRegister(0x40, 0, data[2]); diff --git a/Source/hiopl.cpp b/Source/hiopl.cpp index 5c70fe4..2d370ab 100644 --- a/Source/hiopl.cpp +++ b/Source/hiopl.cpp @@ -34,7 +34,6 @@ Hiopl::Hiopl(int buflen) { } void Hiopl::Generate(int length, short* buffer) { - //printf("Generating %d samples\n", length); adlib->Generate(length, Buf32); for (int i = 0; i < length; i++) { buffer[i] = (short)(Buf32[i]);