2013-09-04 13:37:36 +00:00
|
|
|
#include "PluginProcessor.h"
|
2013-09-25 16:28:34 +00:00
|
|
|
#include "PluginGui.h"
|
2013-09-09 16:14:43 +00:00
|
|
|
#include "EnumFloatParameter.h"
|
2013-09-12 12:17:31 +00:00
|
|
|
#include "IntFloatParameter.h"
|
2013-11-13 09:15:17 +00:00
|
|
|
#include "SbiLoader.h"
|
2013-09-04 13:37:36 +00:00
|
|
|
|
2017-05-28 13:57:32 +00:00
|
|
|
#include <iterator>
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
const char *AdlibBlasterAudioProcessor::PROGRAM_INDEX = "Program Index";
|
2014-08-26 21:24:51 +00:00
|
|
|
|
2013-09-04 13:37:36 +00:00
|
|
|
//==============================================================================
|
2015-02-24 20:07:55 +00:00
|
|
|
AdlibBlasterAudioProcessor::AdlibBlasterAudioProcessor()
|
2014-08-25 21:09:39 +00:00
|
|
|
: i_program(-1)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-13 17:13:18 +00:00
|
|
|
// Initalize OPL
|
2013-09-22 11:10:28 +00:00
|
|
|
velocity = false;
|
2016-02-07 10:22:18 +00:00
|
|
|
Opl = new Hiopl();
|
2013-09-12 13:10:19 +00:00
|
|
|
Opl->SetSampleRate(44100);
|
2013-09-12 13:58:22 +00:00
|
|
|
Opl->EnableWaveformControl();
|
2014-11-01 13:26:48 +00:00
|
|
|
|
2013-09-13 17:13:18 +00:00
|
|
|
// Initialize parameters
|
|
|
|
|
2013-11-05 16:50:37 +00:00
|
|
|
const String waveforms[] = {"Sine", "Half Sine", "Abs Sine", "Quarter Sine", "Alternating Sine", "Camel Sine", "Square", "Logarithmic Sawtooth"};
|
2013-09-09 16:14:43 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Carrier Wave",
|
|
|
|
StringArray(waveforms, sizeof(waveforms)/sizeof(String)))
|
2013-09-13 17:13:18 +00:00
|
|
|
);
|
2013-09-09 16:14:43 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Modulator Wave",
|
|
|
|
StringArray(waveforms, sizeof(waveforms)/sizeof(String)))
|
2013-09-13 17:13:18 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const String frq_multipliers[] = {
|
|
|
|
"x0.5", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x10", "x12", "x12", "x15", "x15"
|
|
|
|
};
|
|
|
|
params.push_back(new EnumFloatParameter("Carrier Frequency Multiplier",
|
|
|
|
StringArray(frq_multipliers, sizeof(frq_multipliers)/sizeof(String)))
|
|
|
|
);
|
|
|
|
params.push_back(new EnumFloatParameter("Modulator Frequency Multiplier",
|
|
|
|
StringArray(frq_multipliers, sizeof(frq_multipliers)/sizeof(String)))
|
|
|
|
);
|
|
|
|
|
2013-09-12 15:52:06 +00:00
|
|
|
const String levels[] = {"0.00 dB", "0.75 dB", "1.50 dB", "2.25 dB", "3.00 dB", "3.75 dB", "4.50 dB", "5.25 dB", "6.00 dB", "6.75 dB", "7.50 dB", "8.25 dB", "9.00 dB", "9.75 dB", "10.50 dB", "11.25 dB", "12.00 dB", "12.75 dB", "13.50 dB", "14.25 dB", "15.00 dB", "15.75 dB", "16.50 dB", "17.25 dB", "18.00 dB", "18.75 dB", "19.50 dB", "20.25 dB", "21.00 dB", "21.75 dB", "22.50 dB", "23.25 dB", "24.00 dB", "24.75 dB", "25.50 dB", "26.25 dB", "27.00 dB", "27.75 dB", "28.50 dB", "29.25 dB", "30.00 dB", "30.75 dB", "31.50 dB", "32.25 dB", "33.00 dB", "33.75 dB", "34.50 dB", "35.25 dB", "36.00 dB", "36.75 dB", "37.50 dB", "38.25 dB", "39.00 dB", "39.75 dB", "40.50 dB", "41.25 dB", "42.00 dB", "42.75 dB", "43.50 dB", "44.25 dB", "45.00 dB", "45.75 dB", "46.50 dB", "47.25 dB"};
|
2013-09-10 17:30:05 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Carrier Attenuation",
|
|
|
|
StringArray(levels, sizeof(levels)/sizeof(String)))
|
2013-09-13 17:13:18 +00:00
|
|
|
);
|
2013-09-10 17:30:05 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Modulator Attenuation",
|
|
|
|
StringArray(levels, sizeof(levels)/sizeof(String)))
|
2013-09-13 17:13:18 +00:00
|
|
|
);
|
2013-09-14 16:06:45 +00:00
|
|
|
|
2013-09-22 11:10:28 +00:00
|
|
|
const String depth[] = {"Light", "Heavy"};
|
|
|
|
params.push_back(new EnumFloatParameter("Tremolo Depth",
|
|
|
|
StringArray(depth, sizeof(depth)/sizeof(String)))
|
|
|
|
);
|
|
|
|
params.push_back(new EnumFloatParameter("Vibrato Depth",
|
|
|
|
StringArray(depth, sizeof(depth)/sizeof(String)))
|
|
|
|
);
|
|
|
|
|
2013-11-05 16:50:37 +00:00
|
|
|
const String onoff[] = {"Disable", "Enable"};
|
2013-09-14 16:06:45 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Carrier Tremolo",
|
|
|
|
StringArray(onoff, sizeof(onoff)/sizeof(String)))
|
|
|
|
);
|
|
|
|
params.push_back(new EnumFloatParameter("Carrier Vibrato",
|
|
|
|
StringArray(onoff, sizeof(onoff)/sizeof(String)))
|
|
|
|
);
|
|
|
|
params.push_back(new EnumFloatParameter("Carrier Sustain",
|
|
|
|
StringArray(onoff, sizeof(onoff)/sizeof(String)))
|
|
|
|
);
|
2013-09-22 11:10:28 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Carrier Keyscale Rate",
|
2013-09-14 16:06:45 +00:00
|
|
|
StringArray(onoff, sizeof(onoff)/sizeof(String)))
|
|
|
|
);
|
|
|
|
params.push_back(new EnumFloatParameter("Modulator Tremolo",
|
|
|
|
StringArray(onoff, sizeof(onoff)/sizeof(String)))
|
|
|
|
);
|
|
|
|
params.push_back(new EnumFloatParameter("Modulator Vibrato",
|
|
|
|
StringArray(onoff, sizeof(onoff)/sizeof(String)))
|
|
|
|
);
|
|
|
|
params.push_back(new EnumFloatParameter("Modulator Sustain",
|
|
|
|
StringArray(onoff, sizeof(onoff)/sizeof(String)))
|
|
|
|
);
|
2013-09-22 11:10:28 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Modulator Keyscale Rate",
|
2013-09-14 16:06:45 +00:00
|
|
|
StringArray(onoff, sizeof(onoff)/sizeof(String)))
|
|
|
|
);
|
|
|
|
|
2013-09-12 15:52:06 +00:00
|
|
|
const String ksrs[] = {"None","1.5 dB/8ve","3 dB/8ve","6 dB/8ve"};
|
2013-09-22 11:10:28 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Carrier Keyscale Level",
|
2013-09-12 15:52:06 +00:00
|
|
|
StringArray(ksrs, sizeof(ksrs)/sizeof(String)))
|
2013-09-13 17:13:18 +00:00
|
|
|
);
|
2013-09-22 11:10:28 +00:00
|
|
|
params.push_back(new EnumFloatParameter("Modulator Keyscale Level",
|
2013-09-12 15:52:06 +00:00
|
|
|
StringArray(ksrs, sizeof(ksrs)/sizeof(String)))
|
2013-09-13 17:13:18 +00:00
|
|
|
);
|
2013-09-12 13:58:22 +00:00
|
|
|
|
2013-09-14 16:29:54 +00:00
|
|
|
const String algos[] = {"Frequency Modulation", "Additive"};
|
|
|
|
params.push_back(new EnumFloatParameter("Algorithm",
|
|
|
|
StringArray(algos, sizeof(algos)/sizeof(String)))
|
|
|
|
);
|
|
|
|
|
2013-09-12 13:58:22 +00:00
|
|
|
params.push_back(new IntFloatParameter("Modulator Feedback", 0, 7));
|
2013-09-12 12:17:31 +00:00
|
|
|
params.push_back(new IntFloatParameter("Carrier Attack", 0, 15));
|
|
|
|
params.push_back(new IntFloatParameter("Carrier Decay", 0, 15));
|
2013-09-14 16:06:45 +00:00
|
|
|
params.push_back(new IntFloatParameter("Carrier Sustain Level", 0, 15));
|
2013-09-12 12:17:31 +00:00
|
|
|
params.push_back(new IntFloatParameter("Carrier Release", 0, 15));
|
|
|
|
params.push_back(new IntFloatParameter("Modulator Attack", 0, 15));
|
|
|
|
params.push_back(new IntFloatParameter("Modulator Decay", 0, 15));
|
2013-09-14 16:06:45 +00:00
|
|
|
params.push_back(new IntFloatParameter("Modulator Sustain Level", 0, 15));
|
2013-09-12 12:17:31 +00:00
|
|
|
params.push_back(new IntFloatParameter("Modulator Release", 0, 15));
|
2013-09-12 15:21:30 +00:00
|
|
|
|
2013-11-04 14:46:00 +00:00
|
|
|
const String sensitivitySettings[] = {"None", "Low", "High"};
|
|
|
|
params.push_back(new EnumFloatParameter("Carrier Velocity Sensitivity",
|
|
|
|
StringArray(sensitivitySettings, sizeof(sensitivitySettings)/sizeof(String)))
|
|
|
|
);
|
|
|
|
params.push_back(new EnumFloatParameter("Modulator Velocity Sensitivity",
|
|
|
|
StringArray(sensitivitySettings, sizeof(sensitivitySettings)/sizeof(String)))
|
|
|
|
);
|
|
|
|
|
2014-09-28 07:30:42 +00:00
|
|
|
const String emulators[] = {"DOSBox", "ZDoom"};
|
|
|
|
params.push_back(new EnumFloatParameter("Emulator",
|
|
|
|
StringArray(emulators, sizeof(emulators)/sizeof(String)))
|
|
|
|
);
|
|
|
|
|
2015-01-01 11:55:03 +00:00
|
|
|
const String percussion[] = { "Off", "Bass drum", "Snare", "Tom", "Cymbal", "Hi-hat" };
|
|
|
|
params.push_back(new EnumFloatParameter("Percussion Mode",
|
|
|
|
StringArray(percussion, sizeof(percussion) / sizeof(String)))
|
|
|
|
);
|
|
|
|
|
2013-09-12 15:52:06 +00:00
|
|
|
for(unsigned int i = 0; i < params.size(); i++) {
|
2013-09-12 15:21:30 +00:00
|
|
|
paramIdxByName[params[i]->getName()] = i;
|
|
|
|
}
|
|
|
|
|
2013-09-14 16:06:45 +00:00
|
|
|
initPrograms();
|
2013-09-12 13:58:22 +00:00
|
|
|
|
2013-09-13 17:13:18 +00:00
|
|
|
for(std::map<String,std::vector<float>>::iterator it = programs.begin(); it != programs.end(); ++it) {
|
|
|
|
program_order.push_back(it->first);
|
|
|
|
}
|
2013-09-29 04:25:37 +00:00
|
|
|
|
2013-09-13 17:13:18 +00:00
|
|
|
setCurrentProgram(0);
|
2013-09-13 17:40:28 +00:00
|
|
|
for (int i = 0; i < Hiopl::CHANNELS+1; i++) {
|
|
|
|
active_notes[i] = NO_NOTE;
|
2017-05-28 13:57:32 +00:00
|
|
|
channel_enabled[i] = true;
|
2013-09-29 04:25:37 +00:00
|
|
|
}
|
2013-12-23 07:51:29 +00:00
|
|
|
currentScaledBend = 1.0f;
|
2014-08-25 21:36:25 +00:00
|
|
|
|
|
|
|
for (int i = 1; i <= Hiopl::CHANNELS; ++i)
|
|
|
|
available_channels.push_back(i);
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::initPrograms()
|
2013-09-14 16:06:45 +00:00
|
|
|
{
|
2013-09-14 16:47:55 +00:00
|
|
|
// these ones from the Syndicate in-game music
|
2013-09-14 16:06:45 +00:00
|
|
|
const float i_params_0[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.000000f, 0.330000f, // waveforms
|
2013-09-14 16:06:45 +00:00
|
|
|
0.066667f, 0.133333f, // frq multipliers
|
|
|
|
0.142857f, 0.412698f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:06:45 +00:00
|
|
|
0.0f, 0.0f, 1.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 1.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
2013-09-14 16:29:54 +00:00
|
|
|
0.000000f, // algorithm
|
2013-09-14 16:06:45 +00:00
|
|
|
0.000000f, // feedback
|
|
|
|
0.5f, 0.3f, 0.3f, 0.3f, // adsr
|
|
|
|
0.5f, 0.3f, 0.1f, 0.6f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:06:45 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_0 (i_params_0, i_params_0 + sizeof(i_params_0) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Mercenary Bass"] = std::vector<float>(v_i_params_0);
|
2013-09-14 16:06:45 +00:00
|
|
|
|
|
|
|
const float i_params_19189[] = {
|
|
|
|
0.000000f, 0.000000f, // waveforms
|
|
|
|
0.066667f, 0.200000f, // frq multipliers
|
|
|
|
0.000000f, 0.285714f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:06:45 +00:00
|
|
|
0.0f, 0.0f, 0.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
2013-09-14 16:29:54 +00:00
|
|
|
0.000000f, // algorithm
|
2013-09-14 16:06:45 +00:00
|
|
|
0.571429f, // feedback
|
|
|
|
1.0f, 1.0f, 0.0f, 0.3f, // adsr
|
|
|
|
1.0f, 0.5f, 0.2f, 0.3f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:06:45 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_19189 (i_params_19189, i_params_19189 + sizeof(i_params_19189) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Patrol Bass"] = std::vector<float>(v_i_params_19189);
|
2013-09-14 16:06:45 +00:00
|
|
|
|
|
|
|
const float i_params_38377[] = {
|
2014-09-28 07:30:42 +00:00
|
|
|
0.000000f, 0.160000f, // waveforms
|
2013-09-14 16:06:45 +00:00
|
|
|
0.066667f, 0.066667f, // frq multipliers
|
|
|
|
0.000000f, 0.460317f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:06:45 +00:00
|
|
|
0.0f, 0.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
2013-09-14 16:29:54 +00:00
|
|
|
0.000000f, // algorithm
|
2013-09-14 16:06:45 +00:00
|
|
|
0.000000f, // feedback
|
|
|
|
1.0f, 0.3f, 0.5f, 0.5f, // adsr
|
|
|
|
1.0f, 0.1f, 0.9f, 1.0f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:06:45 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_38377 (i_params_38377, i_params_38377 + sizeof(i_params_38377) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Subdue Bass"] = std::vector<float>(v_i_params_38377);
|
2013-09-14 16:06:45 +00:00
|
|
|
|
|
|
|
const float i_params_38392[] = {
|
|
|
|
0.000000f, 0.000000f, // waveforms
|
|
|
|
0.000000f, 0.000000f, // frq multipliers
|
|
|
|
0.000000f, 0.000000f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:06:45 +00:00
|
|
|
0.0f, 0.0f, 1.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
2013-09-14 16:29:54 +00:00
|
|
|
0.000000f, // algorithm
|
2013-09-14 16:06:45 +00:00
|
|
|
0.000000f, // feedback
|
|
|
|
0.1f, 0.1f, 0.7f, 0.1f, // adsr
|
|
|
|
0.1f, 0.9f, 0.1f, 0.1f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:06:45 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_38392 (i_params_38392, i_params_38392 + sizeof(i_params_38392) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Dark Future Sweep"] = std::vector<float>(v_i_params_38392);
|
2013-09-14 16:06:45 +00:00
|
|
|
|
|
|
|
const float i_params_39687[] = {
|
|
|
|
0.000000f, 0.000000f, // waveforms
|
|
|
|
0.066667f, 0.333333f, // frq multipliers
|
|
|
|
0.000000f, 0.301587f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:06:45 +00:00
|
|
|
0.0f, 0.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 1.000000f, // KSR/8ve
|
2013-09-14 16:29:54 +00:00
|
|
|
0.000000f, // algorithm
|
2013-09-14 16:06:45 +00:00
|
|
|
0.571429f, // feedback
|
|
|
|
1.0f, 0.3f, 0.1f, 0.3f, // adsr
|
|
|
|
1.0f, 0.7f, 0.0f, 0.4f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:06:45 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_39687 (i_params_39687, i_params_39687 + sizeof(i_params_39687) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Sinister Bass"] = std::vector<float>(v_i_params_39687);
|
2013-09-14 16:06:45 +00:00
|
|
|
|
|
|
|
const float i_params_76784[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.000000f, 0.330000f, // waveforms
|
2013-09-14 16:06:45 +00:00
|
|
|
0.066667f, 0.133333f, // frq multipliers
|
|
|
|
0.000000f, 0.428571f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:06:45 +00:00
|
|
|
0.0f, 0.0f, 1.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
2013-09-14 16:29:54 +00:00
|
|
|
0.000000f, // algorithm
|
2013-09-14 16:06:45 +00:00
|
|
|
0.000000f, // feedback
|
|
|
|
1.0f, 0.3f, 0.4f, 0.4f, // adsr
|
|
|
|
1.0f, 0.4f, 0.5f, 0.3f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:06:45 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_76784 (i_params_76784, i_params_76784 + sizeof(i_params_76784) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Buzcut Bass"] = std::vector<float>(v_i_params_76784);
|
2013-09-14 16:06:45 +00:00
|
|
|
|
|
|
|
const float i_params_97283[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.000000f, 0.330000f, // waveforms
|
2013-09-14 16:06:45 +00:00
|
|
|
0.133333f, 0.400000f, // frq multipliers
|
|
|
|
0.000000f, 0.365079f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:06:45 +00:00
|
|
|
0.0f, 0.0f, 0.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.660000f, // KSR/8ve
|
2013-09-14 16:29:54 +00:00
|
|
|
0.000000f, // algorithm
|
2013-09-14 16:06:45 +00:00
|
|
|
0.000000f, // feedback
|
|
|
|
0.6f, 0.7f, 0.0f, 0.2f, // adsr
|
|
|
|
0.6f, 0.7f, 0.1f, 0.1f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:06:45 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_97283 (i_params_97283, i_params_97283 + sizeof(i_params_97283) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Death Toll Bell"] = std::vector<float>(v_i_params_97283);
|
2013-09-14 16:47:55 +00:00
|
|
|
|
|
|
|
// The start of the Dune 2 introduction
|
|
|
|
const float i_params_3136[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.000000f, 0.330000f, // waveforms
|
2013-09-14 16:47:55 +00:00
|
|
|
0.133333f, 0.133333f, // frq multipliers
|
|
|
|
0.000000f, 0.333333f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:47:55 +00:00
|
|
|
0.0f, 0.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.330000f, // KSR/8ve
|
|
|
|
0.000000f, // algorithm
|
|
|
|
0.571429f, // feedback
|
|
|
|
1.0f, 0.1f, 0.1f, 0.3f, // adsr
|
|
|
|
1.0f, 0.4f, 0.2f, 0.3f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:47:55 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_3136 (i_params_3136, i_params_3136 + sizeof(i_params_3136) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Westwood Chime"] = std::vector<float>(v_i_params_3136);
|
2013-09-14 16:47:55 +00:00
|
|
|
|
|
|
|
const float i_params_7254[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.000000f, 0.160000f, // waveforms
|
2013-09-14 16:47:55 +00:00
|
|
|
0.066667f, 0.066667f, // frq multipliers
|
|
|
|
0.253968f, 0.476190f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:47:55 +00:00
|
|
|
1.0f, 1.0f, 1.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
1.0f, 1.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.330000f, // KSR/8ve
|
|
|
|
0.000000f, // algorithm
|
|
|
|
0.571429f, // feedback
|
|
|
|
0.1f, 0.1f, 0.1f, 0.1f, // adsr
|
|
|
|
0.2f, 0.1f, 0.1f, 0.0f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:47:55 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_7254 (i_params_7254, i_params_7254 + sizeof(i_params_7254) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Desert Pipe"] = std::vector<float>(v_i_params_7254);
|
2013-09-14 16:47:55 +00:00
|
|
|
|
|
|
|
const float i_params_20108[] = {
|
|
|
|
0.000000f, 0.000000f, // waveforms
|
|
|
|
0.400000f, 0.066667f, // frq multipliers
|
|
|
|
0.238095f, 0.000000f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:47:55 +00:00
|
|
|
1.0f, 1.0f, 1.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 1.0f, 1.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.330000f, // KSR/8ve
|
|
|
|
0.000000f, // algorithm
|
|
|
|
0.000000f, // feedback
|
|
|
|
0.1f, 0.1f, 0.1f, 0.1f, // adsr
|
|
|
|
0.1f, 0.1f, 0.1f, 0.1f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:47:55 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_20108 (i_params_20108, i_params_20108 + sizeof(i_params_20108) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Y2180 Strings"] = std::vector<float>(v_i_params_20108);
|
2013-09-14 16:47:55 +00:00
|
|
|
|
|
|
|
const float i_params_27550[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.500000f, 0.000000f, // waveforms
|
2013-09-14 16:47:55 +00:00
|
|
|
0.000000f, 0.066667f, // frq multipliers
|
|
|
|
0.238095f, 0.793651f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-14 16:47:55 +00:00
|
|
|
0.0f, 1.0f, 0.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 0.0f, 1.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
|
|
|
0.000000f, // algorithm
|
|
|
|
0.571429f, // feedback
|
|
|
|
1.0f, 0.0f, 1.0f, 1.0f, // adsr
|
|
|
|
0.9f, 0.1f, 0.0f, 1.0f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-14 16:47:55 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_27550 (i_params_27550, i_params_27550 + sizeof(i_params_27550) / sizeof(float));
|
2013-09-20 17:20:09 +00:00
|
|
|
programs["Emperor Chord"] = std::vector<float>(v_i_params_27550);
|
|
|
|
|
|
|
|
const float i_params_harpsi[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.330000f, 0.160000f, // waveforms
|
2013-09-20 17:20:09 +00:00
|
|
|
0.066667f, 0.200000f, // frq multipliers
|
|
|
|
0.142857f, 0.260000f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-20 17:20:09 +00:00
|
|
|
0.0f, 0.0f, 1.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
0.0f, 1.0f, 1.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
|
|
|
0.000000f, // algorithm
|
|
|
|
0.000000f, // feedback
|
|
|
|
0.85f, 0.3f, 0.3f, 0.3f, // adsr
|
|
|
|
0.85f, 0.3f, 0.1f, 0.6f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-20 17:20:09 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_harpsi (i_params_harpsi, i_params_harpsi + sizeof(i_params_harpsi) / sizeof(float));
|
|
|
|
programs["Harpsi"] = std::vector<float>(v_i_params_harpsi);
|
|
|
|
|
|
|
|
const float i_params_tromba[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.000000f, 0.160000f, // waveforms
|
2013-09-20 17:20:09 +00:00
|
|
|
0.066667f, 0.000000f, // frq multipliers
|
|
|
|
0.142857f, 0.220000f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-20 17:20:09 +00:00
|
|
|
0.0f, 0.0f, 1.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
1.0f, 0.0f, 1.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
|
|
|
0.000000f, // algorithm
|
|
|
|
0.500000f, // feedback
|
|
|
|
0.45f, 0.3f, 0.3f, 0.3f, // adsr
|
|
|
|
0.45f, 0.45f, 0.1f, 0.6f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-20 17:20:09 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_tromba (i_params_tromba, i_params_tromba + sizeof(i_params_tromba) / sizeof(float));
|
|
|
|
programs["Tromba"] = std::vector<float>(v_i_params_tromba);
|
2013-09-14 16:47:55 +00:00
|
|
|
|
2013-09-22 10:13:36 +00:00
|
|
|
const float i_params_bassdrum[] = {
|
2013-11-05 16:50:37 +00:00
|
|
|
0.000000f, 0.500000f, // waveforms
|
2013-09-22 10:13:36 +00:00
|
|
|
0.000000f, 0.000000f, // frq multipliers
|
|
|
|
0.000000f, 0.090000f, // attenuation
|
2013-09-22 11:10:28 +00:00
|
|
|
0.000000f, 0.000000f, // tremolo / vibrato depth
|
2013-09-22 10:13:36 +00:00
|
|
|
1.0f, 1.0f, 1.0f, 0.0f, // tre / vib / sus / ks
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f, // tre / vib / sus / ks
|
|
|
|
0.000000f, 0.000000f, // KSR/8ve
|
|
|
|
0.000000f, // algorithm
|
|
|
|
0.500000f, // feedback
|
|
|
|
1.00f, 0.5f, 0.3f, 0.4f, // adsr
|
|
|
|
1.00f, 0.75f, 0.5f, 0.5f, // adsr
|
2013-11-04 14:46:00 +00:00
|
|
|
0.0f, 0.0f, // velocity sensitivity
|
2014-09-28 07:30:42 +00:00
|
|
|
0.0f, // emulator
|
2015-01-01 11:55:03 +00:00
|
|
|
0.0f, // percussion mode
|
2013-09-22 10:13:36 +00:00
|
|
|
};
|
|
|
|
std::vector<float> v_i_params_bassdrum (i_params_bassdrum, i_params_bassdrum + sizeof(i_params_bassdrum) / sizeof(float));
|
|
|
|
programs["bassdrum"] = std::vector<float>(v_i_params_bassdrum);
|
|
|
|
|
2013-09-14 16:06:45 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::applyPitchBend()
|
2013-12-23 07:51:29 +00:00
|
|
|
{ // apply the currently configured pitch bend to all active notes.
|
|
|
|
for (int i = 1; i <= Hiopl::CHANNELS; i++) {
|
|
|
|
if (NO_NOTE != active_notes[i]) {
|
|
|
|
float f = (float)MidiMessage::getMidiNoteInHertz(active_notes[i]);
|
|
|
|
f *= currentScaledBend;
|
|
|
|
Opl->SetFrequency(i, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
AdlibBlasterAudioProcessor::~AdlibBlasterAudioProcessor()
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2014-08-31 10:28:05 +00:00
|
|
|
for (unsigned int i=0; i < params.size(); ++i)
|
2014-08-25 21:09:39 +00:00
|
|
|
delete params[i];
|
2015-01-09 05:20:19 +00:00
|
|
|
delete Opl;
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
2015-02-24 20:07:55 +00:00
|
|
|
const String AdlibBlasterAudioProcessor::getName() const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
return JucePlugin_Name;
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
int AdlibBlasterAudioProcessor::getNumParameters()
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2014-09-28 07:30:42 +00:00
|
|
|
return (int)params.size();
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
float AdlibBlasterAudioProcessor::getParameter (int index)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-09 16:14:43 +00:00
|
|
|
return params[index]->getParameter();
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::setIntParameter (String name, int value)
|
2013-09-12 15:21:30 +00:00
|
|
|
{
|
|
|
|
int i = paramIdxByName[name];
|
|
|
|
IntFloatParameter* p = (IntFloatParameter*)params[i];
|
|
|
|
p->setParameterValue(value);
|
|
|
|
setParameter(i, p->getParameter());
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::setEnumParameter (String name, int index)
|
2013-09-12 15:21:30 +00:00
|
|
|
{
|
|
|
|
int i = paramIdxByName[name];
|
|
|
|
EnumFloatParameter* p = (EnumFloatParameter*)params[i];
|
|
|
|
p->setParameterIndex(index);
|
|
|
|
setParameter(i, p->getParameter());
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
int AdlibBlasterAudioProcessor::getIntParameter (String name)
|
2013-09-29 04:25:37 +00:00
|
|
|
{
|
|
|
|
int i = paramIdxByName[name];
|
|
|
|
IntFloatParameter* p = (IntFloatParameter*)params[i];
|
|
|
|
return p->getParameterValue();
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
int AdlibBlasterAudioProcessor::getEnumParameter (String name)
|
2013-09-29 04:25:37 +00:00
|
|
|
{
|
|
|
|
int i = paramIdxByName[name];
|
|
|
|
EnumFloatParameter* p = (EnumFloatParameter*)params[i];
|
|
|
|
return p->getParameterIndex();
|
|
|
|
}
|
|
|
|
|
2017-03-04 03:44:56 +00:00
|
|
|
bool AdlibBlasterAudioProcessor::getBoolParameter(String name)
|
|
|
|
{
|
|
|
|
return 0 != getEnumParameter(name);
|
|
|
|
}
|
|
|
|
|
2015-01-01 11:55:03 +00:00
|
|
|
// Parameters which apply directly to the OPL
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::setParameter (int index, float newValue)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-10 17:30:05 +00:00
|
|
|
FloatParameter* p = params[index];
|
|
|
|
p->setParameter(newValue);
|
|
|
|
String name = p->getName();
|
2013-09-12 13:10:19 +00:00
|
|
|
int osc = 2; // Carrier
|
2013-09-12 12:17:31 +00:00
|
|
|
if (name.startsWith("Modulator")) {
|
2013-09-12 13:10:19 +00:00
|
|
|
osc = 1;
|
2013-09-12 12:17:31 +00:00
|
|
|
}
|
|
|
|
if (name.endsWith("Wave")) {
|
2013-09-12 15:21:30 +00:00
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetWaveform(c, osc, (Waveform)((EnumFloatParameter*)p)->getParameterIndex());
|
2013-09-12 12:17:31 +00:00
|
|
|
} else if (name.endsWith("Attenuation")) {
|
2013-09-12 15:52:06 +00:00
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetAttenuation(c, osc, ((EnumFloatParameter*)p)->getParameterIndex());
|
2013-09-12 12:17:31 +00:00
|
|
|
} else if (name.endsWith("Frequency Multiplier")) {
|
2013-09-12 15:21:30 +00:00
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetFrequencyMultiple(c, osc, (FreqMultiple)((EnumFloatParameter*)p)->getParameterIndex());
|
2013-09-12 12:17:31 +00:00
|
|
|
} else if (name.endsWith("Attack")) {
|
2013-09-12 15:21:30 +00:00
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeAttack(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
2013-09-12 13:10:19 +00:00
|
|
|
} else if (name.endsWith("Decay")) {
|
2013-09-12 15:21:30 +00:00
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeDecay(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
2013-09-14 16:06:45 +00:00
|
|
|
} else if (name.endsWith("Sustain Level")) {
|
2013-09-12 15:21:30 +00:00
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeSustain(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
2013-09-12 13:10:19 +00:00
|
|
|
} else if (name.endsWith("Release")) {
|
2013-09-12 15:21:30 +00:00
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeRelease(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
2013-09-12 13:58:22 +00:00
|
|
|
} else if (name.endsWith("Feedback")) {
|
2013-09-12 15:21:30 +00:00
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetModulatorFeedback(c, ((IntFloatParameter*)p)->getParameterValue());
|
2013-09-22 11:10:28 +00:00
|
|
|
} else if (name.endsWith("Keyscale Level")) {
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetKsl(c, osc, ((EnumFloatParameter*)p)->getParameterIndex());
|
|
|
|
} else if (name.endsWith("Keyscale Rate")) {
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->EnableKsr(c, osc, ((EnumFloatParameter*)p)->getParameterIndex() > 0);
|
2013-09-14 16:06:45 +00:00
|
|
|
} else if (name.endsWith("Sustain")) {
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->EnableSustain(c, osc, ((EnumFloatParameter*)p)->getParameterIndex() > 0);
|
|
|
|
} else if (name.endsWith("Tremolo")) {
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->EnableTremolo(c, osc, ((EnumFloatParameter*)p)->getParameterIndex() > 0);
|
|
|
|
} else if (name.endsWith("Vibrato")) {
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->EnableVibrato(c, osc, ((EnumFloatParameter*)p)->getParameterIndex() > 0);
|
2013-09-14 16:29:54 +00:00
|
|
|
} else if (name.endsWith("Algorithm")) {
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->EnableAdditiveSynthesis(c, ((EnumFloatParameter*)p)->getParameterIndex() > 0);
|
2013-09-22 11:10:28 +00:00
|
|
|
} else if (name.startsWith("Tremolo Depth")) {
|
|
|
|
Opl->TremoloDepth(((EnumFloatParameter*)p)->getParameterIndex() > 0);
|
|
|
|
} else if (name.startsWith("Vibrato Depth")) {
|
|
|
|
Opl->VibratoDepth(((EnumFloatParameter*)p)->getParameterIndex() > 0);
|
2014-09-28 06:29:27 +00:00
|
|
|
} else if (name.startsWith("Emulator")) {
|
|
|
|
Opl->SetEmulator((Emulator)((EnumFloatParameter*)p)->getParameterIndex());
|
2015-01-01 11:55:03 +00:00
|
|
|
} else if (name.startsWith("Percussion")) {
|
|
|
|
Opl->SetPercussionMode(((EnumFloatParameter*)p)->getParameterIndex() > 0);
|
2013-09-10 17:30:05 +00:00
|
|
|
}
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::loadInstrumentFromFile(String filename)
|
2013-11-13 09:15:17 +00:00
|
|
|
{
|
|
|
|
FILE* f = fopen(filename.toUTF8(), "rb");
|
|
|
|
unsigned char buf[MAX_INSTRUMENT_FILE_SIZE_BYTES];
|
2014-09-28 07:30:42 +00:00
|
|
|
int n = (int)fread(buf, 1, MAX_INSTRUMENT_FILE_SIZE_BYTES, f);
|
2013-11-13 15:18:47 +00:00
|
|
|
fclose(f);
|
2013-11-13 09:15:17 +00:00
|
|
|
SbiLoader* loader = new SbiLoader();
|
|
|
|
loader->loadInstrumentData(n, buf, this);
|
2015-11-30 14:29:58 +00:00
|
|
|
delete loader;
|
2013-11-13 15:18:47 +00:00
|
|
|
updateGuiIfPresent();
|
2013-11-13 09:15:17 +00:00
|
|
|
}
|
|
|
|
|
2015-11-30 14:29:58 +00:00
|
|
|
void AdlibBlasterAudioProcessor::saveInstrumentToFile(String filename)
|
|
|
|
{
|
|
|
|
// http://www.shikadi.net/moddingwiki/SBI_Format
|
|
|
|
const Bit32u sbi_registers[] = {
|
|
|
|
0x20, 0x23, 0x40, 0x43, 0x60, 0x63, 0x80, 0x83, 0xe0, 0xe3, 0xc0
|
|
|
|
};
|
|
|
|
FILE* f = fopen(filename.toUTF8(), "wb");
|
|
|
|
if (f) {
|
|
|
|
fwrite("SBI\x1d", 1, 4, f);
|
|
|
|
fwrite("JuceOPLVSTi instrument \0", 1, 32, f);
|
|
|
|
for (int i = 0; i < 11; i++) {
|
|
|
|
Bit8u regVal = Opl->_ReadReg(sbi_registers[i]);
|
|
|
|
fwrite(®Val, 1, 1, f);
|
|
|
|
}
|
|
|
|
fwrite(" ", 1, 5, f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-01 11:55:03 +00:00
|
|
|
// Used to configure parameters from .SBI instrument file
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::setParametersByRegister(int register_base, int op, uint8 value)
|
2013-11-13 09:15:17 +00:00
|
|
|
{
|
2013-11-13 15:18:47 +00:00
|
|
|
const String operators[] = {"Modulator", "Carrier"};
|
2013-11-13 09:15:17 +00:00
|
|
|
register_base &= 0xF0;
|
|
|
|
switch (register_base) {
|
|
|
|
case 0x20:
|
2013-11-13 15:18:47 +00:00
|
|
|
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);
|
2013-11-13 09:15:17 +00:00
|
|
|
break;
|
|
|
|
case 0x40:
|
2013-11-13 15:18:47 +00:00
|
|
|
setEnumParameter(operators[op] + " Keyscale Level", (value & 0xc0) >> 6);
|
|
|
|
setEnumParameter(operators[op] + " Attenuation", value & 0x3f);
|
2013-11-13 09:15:17 +00:00
|
|
|
break;
|
|
|
|
case 0x60:
|
2013-11-13 15:18:47 +00:00
|
|
|
setIntParameter(operators[op] + " Attack", (value & 0xf0) >> 4);
|
|
|
|
setIntParameter(operators[op] + " Decay", value & 0x0f);
|
2013-11-13 09:15:17 +00:00
|
|
|
break;
|
|
|
|
case 0x80:
|
2013-11-13 15:18:47 +00:00
|
|
|
setIntParameter(operators[op] + " Sustain Level", (value & 0xf0) >> 4);
|
|
|
|
setIntParameter(operators[op] + " Release", value & 0x0f);
|
2013-11-13 09:15:17 +00:00
|
|
|
break;
|
|
|
|
case 0xC0:
|
2013-11-13 15:18:47 +00:00
|
|
|
setIntParameter("Modulator Feedback", (value & 0xe) >> 1);
|
|
|
|
setEnumParameter("Algorithm", value & 0x1);
|
2013-11-13 09:15:17 +00:00
|
|
|
break;
|
|
|
|
case 0xE0:
|
2013-11-13 15:18:47 +00:00
|
|
|
setEnumParameter(operators[op] + " Wave", value & 0x7);
|
2013-11-13 09:15:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
const String AdlibBlasterAudioProcessor::getParameterName (int index)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-09 16:14:43 +00:00
|
|
|
return params[index]->getName();
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
const String AdlibBlasterAudioProcessor::getParameterText (int index)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-09 16:14:43 +00:00
|
|
|
return params[index]->getParameterText();
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
const String AdlibBlasterAudioProcessor::getInputChannelName (int channelIndex) const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
return String (channelIndex + 1);
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
const String AdlibBlasterAudioProcessor::getOutputChannelName (int channelIndex) const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
return String (channelIndex + 1);
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
bool AdlibBlasterAudioProcessor::isInputChannelStereoPair (int index) const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-11-13 09:15:17 +00:00
|
|
|
return false;
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
bool AdlibBlasterAudioProcessor::isOutputChannelStereoPair (int index) const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2015-02-24 20:07:55 +00:00
|
|
|
return true; //// Jeff-Russ changed to true for AU version. for vsti make it false
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
bool AdlibBlasterAudioProcessor::acceptsMidi() const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
#if JucePlugin_WantsMidiInput
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
bool AdlibBlasterAudioProcessor::producesMidi() const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
#if JucePlugin_ProducesMidiOutput
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
bool AdlibBlasterAudioProcessor::silenceInProducesSilenceOut() const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
double AdlibBlasterAudioProcessor::getTailLengthSeconds() const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
int AdlibBlasterAudioProcessor::getNumPrograms()
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2014-09-28 07:30:42 +00:00
|
|
|
return (int)programs.size();
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
int AdlibBlasterAudioProcessor::getCurrentProgram()
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-13 17:13:18 +00:00
|
|
|
return i_program;
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::updateGuiIfPresent()
|
2013-11-13 15:18:47 +00:00
|
|
|
{
|
|
|
|
PluginGui* gui = (PluginGui*)getActiveEditor();
|
|
|
|
if (gui) {
|
|
|
|
gui->updateFromParameters();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::setCurrentProgram (int index)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2014-08-25 21:09:39 +00:00
|
|
|
if (i_program==index)
|
|
|
|
return;
|
|
|
|
|
2013-09-13 17:13:18 +00:00
|
|
|
i_program = index;
|
|
|
|
std::vector<float> &v_params = programs[getProgramName(index)];
|
|
|
|
for (unsigned int i = 0; i < params.size() && i < v_params.size(); i++) {
|
|
|
|
setParameter(i, v_params[i]);
|
|
|
|
}
|
2013-11-13 15:18:47 +00:00
|
|
|
updateGuiIfPresent();
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
const String AdlibBlasterAudioProcessor::getProgramName (int index)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-13 17:13:18 +00:00
|
|
|
return program_order[index];
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::changeProgramName (int index, const String& newName)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2016-02-07 10:47:22 +00:00
|
|
|
Opl->SetSampleRate((int)sampleRate);
|
|
|
|
Opl->EnableWaveformControl();
|
2013-09-04 13:37:36 +00:00
|
|
|
// Use this method as the place to do any pre-playback
|
|
|
|
// initialisation that you need..
|
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::releaseResources()
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
|
|
|
// When playback stops, you can use this as an opportunity to free up any
|
|
|
|
// spare memory, etc.
|
|
|
|
}
|
|
|
|
|
2015-01-06 03:13:44 +00:00
|
|
|
static const Drum DRUM_INDEX[] = { BDRUM, SNARE, TOM, CYMBAL, HIHAT };
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-04 14:19:22 +00:00
|
|
|
buffer.clear(0, 0, buffer.getNumSamples());
|
2013-09-04 15:36:55 +00:00
|
|
|
MidiBuffer::Iterator midi_buffer_iterator(midiMessages);
|
|
|
|
|
2014-08-25 21:09:39 +00:00
|
|
|
MidiMessage midi_message;
|
2013-09-04 15:36:55 +00:00
|
|
|
int sample_number;
|
2015-01-01 11:55:03 +00:00
|
|
|
int perc = getEnumParameter("Percussion Mode");
|
2013-09-04 15:36:55 +00:00
|
|
|
while (midi_buffer_iterator.getNextEvent(midi_message,sample_number)) {
|
|
|
|
if (midi_message.isNoteOn()) {
|
|
|
|
//note on at sample_number samples after
|
2013-09-09 16:14:43 +00:00
|
|
|
//the beginning of the current buffer
|
2013-09-13 17:40:28 +00:00
|
|
|
int n = midi_message.getNoteNumber();
|
|
|
|
float noteHz = (float)MidiMessage::getMidiNoteInHertz(n);
|
2014-08-25 21:36:25 +00:00
|
|
|
int ch;
|
|
|
|
|
2015-01-06 03:13:44 +00:00
|
|
|
if (perc > 0) {
|
2015-01-01 11:55:03 +00:00
|
|
|
for (int i = 1; i <= Hiopl::CHANNELS; i++) {
|
|
|
|
Opl->SetFrequency(i, noteHz, false);
|
|
|
|
}
|
2015-01-06 03:13:44 +00:00
|
|
|
Opl->HitPercussion(DRUM_INDEX[perc - 1]);
|
2015-01-01 11:55:03 +00:00
|
|
|
} else {
|
|
|
|
if (!available_channels.empty())
|
|
|
|
{
|
|
|
|
ch = available_channels.front();
|
|
|
|
available_channels.pop_front();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ch = used_channels.back(); // steal earliest/longest running active channel if out of free channels
|
|
|
|
used_channels.pop_back();
|
|
|
|
Opl->KeyOff(ch);
|
|
|
|
}
|
2014-08-25 21:36:25 +00:00
|
|
|
|
2015-01-01 11:55:03 +00:00
|
|
|
used_channels.push_front(ch);
|
2014-08-25 21:36:25 +00:00
|
|
|
|
2015-01-01 11:55:03 +00:00
|
|
|
switch (getEnumParameter("Carrier Velocity Sensitivity")) {
|
2013-11-04 14:46:00 +00:00
|
|
|
case 0:
|
|
|
|
Opl->SetAttenuation(ch, 2, getEnumParameter("Carrier Attenuation"));
|
|
|
|
break;
|
|
|
|
case 1:
|
2017-01-29 03:54:08 +00:00
|
|
|
Opl->SetAttenuation(ch, 2, 32 - (midi_message.getVelocity() / 4));
|
2013-11-04 14:46:00 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2017-01-29 03:54:08 +00:00
|
|
|
Opl->SetAttenuation(ch, 2, 63 - (midi_message.getVelocity() / 2));
|
2013-11-04 14:46:00 +00:00
|
|
|
break;
|
2015-01-01 11:55:03 +00:00
|
|
|
}
|
|
|
|
switch (getEnumParameter("Modulator Velocity Sensitivity")) {
|
2013-11-04 14:46:00 +00:00
|
|
|
case 0:
|
|
|
|
Opl->SetAttenuation(ch, 1, getEnumParameter("Modulator Attenuation"));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Opl->SetAttenuation(ch, 1, 32 - (midi_message.getVelocity() / 4));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Opl->SetAttenuation(ch, 1, 63 - (midi_message.getVelocity() / 2));
|
|
|
|
break;
|
2015-01-01 11:55:03 +00:00
|
|
|
}
|
|
|
|
Opl->KeyOn(ch, noteHz);
|
|
|
|
active_notes[ch] = n;
|
|
|
|
applyPitchBend();
|
2013-09-22 11:10:28 +00:00
|
|
|
}
|
2013-09-04 15:36:55 +00:00
|
|
|
}
|
|
|
|
else if (midi_message.isNoteOff()) {
|
2015-01-01 11:55:03 +00:00
|
|
|
if (perc > 0) {
|
|
|
|
Opl->ReleasePercussion();
|
2013-09-13 17:40:28 +00:00
|
|
|
}
|
2015-01-01 11:55:03 +00:00
|
|
|
else {
|
|
|
|
int n = midi_message.getNoteNumber();
|
|
|
|
int ch = 1;
|
|
|
|
while (ch <= Hiopl::CHANNELS && n != active_notes[ch]) {
|
|
|
|
ch += 1;
|
|
|
|
}
|
|
|
|
if (ch <= Hiopl::CHANNELS)
|
2014-08-25 21:36:25 +00:00
|
|
|
{
|
2015-01-01 11:55:03 +00:00
|
|
|
for (auto i = used_channels.begin(); i != used_channels.end(); ++i)
|
2014-08-25 21:36:25 +00:00
|
|
|
{
|
2015-01-01 11:55:03 +00:00
|
|
|
if (*i == ch)
|
|
|
|
{
|
|
|
|
used_channels.erase(i);
|
|
|
|
available_channels.push_back(ch);
|
2014-08-25 21:36:25 +00:00
|
|
|
|
2015-01-01 11:55:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-08-25 21:36:25 +00:00
|
|
|
}
|
|
|
|
|
2015-01-01 11:55:03 +00:00
|
|
|
Opl->KeyOff(ch);
|
|
|
|
active_notes[ch] = NO_NOTE;
|
|
|
|
}
|
2014-08-25 21:09:39 +00:00
|
|
|
}
|
2014-08-25 21:36:25 +00:00
|
|
|
}
|
2013-12-23 07:51:29 +00:00
|
|
|
else if (midi_message.isPitchWheel()) {
|
|
|
|
int bend = midi_message.getPitchWheelValue() - 0x2000; // range -8192 to 8191
|
|
|
|
// 1.05946309436 == (2^(1/1200))^100 == 1 semitone == 100 cents
|
|
|
|
currentScaledBend = 1.0f + bend * .05775f / 8192;
|
|
|
|
applyPitchBend();
|
|
|
|
}
|
2013-09-04 15:36:55 +00:00
|
|
|
}
|
2015-02-13 18:08:38 +00:00
|
|
|
/// Jeff-Russ: getSampleData(int) is deprecated. use getWritePointer(int)
|
|
|
|
Opl->Generate(buffer.getNumSamples(), buffer.getWritePointer(0));
|
2015-02-24 20:07:55 +00:00
|
|
|
|
|
|
|
/// Jeff-Russ added loop to copy left channel to right channel. uncomment when building to {0,2} AU
|
|
|
|
// const float* LChanRead = buffer.getReadPointer(0, 0);
|
|
|
|
// float* RChanWrite = buffer.getWritePointer(1, 0);
|
|
|
|
// for (int i = 0; i < buffer.getNumSamples(); i++) { RChanWrite[i] = LChanRead[i]; }
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
2015-02-24 20:07:55 +00:00
|
|
|
bool AdlibBlasterAudioProcessor::hasEditor() const
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-25 16:28:34 +00:00
|
|
|
return true; // (change this to false if you choose to not supply an editor)
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
AudioProcessorEditor* AdlibBlasterAudioProcessor::createEditor()
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-29 04:25:37 +00:00
|
|
|
PluginGui* gui = new PluginGui(this);
|
|
|
|
gui->updateFromParameters();
|
|
|
|
return gui;
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
//==============================================================================
|
2014-08-25 21:09:39 +00:00
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
// JUCE requires that JSON names are valid Identifiers (restricted character set) even though the JSON standard allows any valid string.
|
|
|
|
// Per http://www.juce.com/forum/topic/problem-spaces-json-identifier jules allowed Strings to bypass the assertion check
|
|
|
|
// but a regression occured in 4317f60 re-enabling this check, so we need to sanitize the names.
|
|
|
|
// Technically, the code still works without this, but it will trigger a gargantuan number of assertions hindering effective debugging.
|
|
|
|
Identifier stringToIdentifier(const String &s)
|
2014-08-25 21:09:39 +00:00
|
|
|
{
|
2014-08-26 21:24:51 +00:00
|
|
|
return s.replaceCharacters(" ", "_");
|
2014-08-25 21:09:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::getStateInformation(MemoryBlock& destData)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2014-08-26 21:24:51 +00:00
|
|
|
ReferenceCountedObjectPtr<DynamicObject> v(new DynamicObject);
|
2014-08-25 21:09:39 +00:00
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
v->setProperty(stringToIdentifier(PROGRAM_INDEX), i_program);
|
2014-08-25 21:09:39 +00:00
|
|
|
|
2013-09-22 10:13:36 +00:00
|
|
|
for (int i = 0; i < getNumParameters(); i++) {
|
2014-08-26 21:24:51 +00:00
|
|
|
double p = getParameter(i);
|
|
|
|
|
|
|
|
v->setProperty(stringToIdentifier(getParameterName(i)), p);
|
2013-09-22 10:13:36 +00:00
|
|
|
}
|
2014-08-26 21:24:51 +00:00
|
|
|
|
|
|
|
String s = JSON::toString(v.get());
|
|
|
|
|
|
|
|
destData.setSize(s.length());
|
|
|
|
destData.copyFrom(s.getCharPointer(), 0, destData.getSize());
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 20:07:55 +00:00
|
|
|
void AdlibBlasterAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2014-08-26 21:24:51 +00:00
|
|
|
if (sizeInBytes < 1)
|
2014-08-25 21:09:39 +00:00
|
|
|
return;
|
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
const char *first = static_cast<const char *>(data);
|
|
|
|
const char *last = first + sizeInBytes - 1;
|
2014-08-25 21:09:39 +00:00
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
// simple check for JSON data - assume always object
|
|
|
|
if (*first=='{' && *last=='}')
|
2014-08-25 21:09:39 +00:00
|
|
|
{
|
2014-08-26 21:24:51 +00:00
|
|
|
// json format
|
|
|
|
String s(first, sizeInBytes);
|
|
|
|
var v = JSON::fromString(s);
|
2014-08-25 21:09:39 +00:00
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
{
|
|
|
|
var program = v[stringToIdentifier(PROGRAM_INDEX)];
|
2014-08-25 21:09:39 +00:00
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
if (!program.isVoid())
|
|
|
|
i_program = program;
|
|
|
|
}
|
|
|
|
|
2015-01-01 11:55:03 +00:00
|
|
|
for (int i=0; i < getNumParameters(); ++i)
|
2014-08-25 21:09:39 +00:00
|
|
|
{
|
2014-08-26 21:24:51 +00:00
|
|
|
var param = v[stringToIdentifier(getParameterName(i))];
|
2014-08-25 21:09:39 +00:00
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
if (!param.isVoid())
|
|
|
|
setParameter(i, param);
|
2014-08-25 21:09:39 +00:00
|
|
|
}
|
|
|
|
|
2014-08-26 21:24:51 +00:00
|
|
|
updateGuiIfPresent();
|
|
|
|
|
2014-08-25 21:09:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-22 10:13:36 +00:00
|
|
|
float* fdata = (float*)data;
|
2014-08-25 21:09:39 +00:00
|
|
|
const int parametersToLoad = std::min<int>(sizeInBytes / sizeof(float), getNumParameters());
|
|
|
|
|
|
|
|
for (int i = 0; i < parametersToLoad; i++) {
|
2013-09-22 10:13:36 +00:00
|
|
|
setParameter(i, fdata[i]);
|
2014-08-25 21:09:39 +00:00
|
|
|
}
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|
|
|
|
|
2017-05-28 13:57:32 +00:00
|
|
|
bool AdlibBlasterAudioProcessor::isChannelEnabled(const int idx) const {
|
|
|
|
return channel_enabled[idx];
|
|
|
|
}
|
|
|
|
|
2014-08-25 21:36:25 +00:00
|
|
|
// @param idx 1-based channel index
|
2017-05-28 13:57:32 +00:00
|
|
|
void AdlibBlasterAudioProcessor::disableChannel(const int idx)
|
2014-08-25 21:36:25 +00:00
|
|
|
{
|
2017-05-28 13:57:32 +00:00
|
|
|
if (isChannelEnabled(idx)) {
|
|
|
|
std::deque<int>::const_iterator pos = std::find(available_channels.begin(), available_channels.end(), idx);
|
|
|
|
if (pos != available_channels.end()) {
|
|
|
|
available_channels.erase(pos);
|
|
|
|
channel_enabled[idx] = false;
|
|
|
|
}
|
|
|
|
}
|
2014-08-25 21:36:25 +00:00
|
|
|
}
|
|
|
|
|
2017-05-28 13:57:32 +00:00
|
|
|
void AdlibBlasterAudioProcessor::enableChannel(const int idx)
|
|
|
|
{
|
|
|
|
if (!isChannelEnabled(idx)) {
|
|
|
|
available_channels.push_back(idx);
|
|
|
|
channel_enabled[idx] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdlibBlasterAudioProcessor::toggleChannel(const int idx)
|
|
|
|
{
|
|
|
|
isChannelEnabled(idx) ? disableChannel(idx) : enableChannel(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* CHANNEL_DISABLED_STRING = "x";
|
|
|
|
|
2015-01-09 06:53:33 +00:00
|
|
|
// @param idx 1-based channel index
|
2015-02-24 20:07:55 +00:00
|
|
|
const char* AdlibBlasterAudioProcessor::getChannelEnvelopeStage(int idx) const
|
2015-01-09 06:53:33 +00:00
|
|
|
{
|
2017-05-28 13:57:32 +00:00
|
|
|
return isChannelEnabled(idx) ? Opl->GetState(idx) : CHANNEL_DISABLED_STRING;
|
2015-01-09 06:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-04 13:37:36 +00:00
|
|
|
//==============================================================================
|
|
|
|
// This creates new instances of the plugin..
|
|
|
|
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
|
|
|
{
|
2015-02-24 20:07:55 +00:00
|
|
|
return new AdlibBlasterAudioProcessor();
|
2013-09-04 13:37:36 +00:00
|
|
|
}
|