|
|
|
@ -9,8 +9,10 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
|
|
|
|
|
Opl = new Hiopl(44100); // 1 second at 44100
|
|
|
|
|
Opl->SetSampleRate(44100);
|
|
|
|
|
Opl->EnableWaveformControl();
|
|
|
|
|
Opl->EnableSustain(1, 1);
|
|
|
|
|
Opl->EnableSustain(1, 2);
|
|
|
|
|
for (int i = 1; i <= Hiopl::CHANNELS; i++) {
|
|
|
|
|
Opl->EnableSustain(i, 1);
|
|
|
|
|
Opl->EnableSustain(i, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const String waveforms[] = {"Sine", "Half Sine", "Abs Sine", "Quarter Sine"};
|
|
|
|
|
params.push_back(new EnumFloatParameter("Carrier Wave",
|
|
|
|
@ -18,7 +20,7 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
|
|
|
|
|
); setParameter(params.size()-1, 0.0f);
|
|
|
|
|
params.push_back(new EnumFloatParameter("Modulator Wave",
|
|
|
|
|
StringArray(waveforms, sizeof(waveforms)/sizeof(String)))
|
|
|
|
|
); setParameter(params.size()-1,0.0f);
|
|
|
|
|
); setParameter(params.size()-1, 0.0f);
|
|
|
|
|
/*
|
|
|
|
|
const String levels[] = {"-0.75 dB", "-1.5 dB", "-3 dB", "-6 dB", "-12 dB", "-24 dB"};
|
|
|
|
|
params.push_back(new EnumFloatParameter("Carrier Attenuation",
|
|
|
|
@ -29,9 +31,9 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
|
|
|
|
|
); setParameter(params.size()-1,0.75f);
|
|
|
|
|
*/
|
|
|
|
|
params.push_back(new IntFloatParameter("Carrier Attenuation", 0, 63));
|
|
|
|
|
setParameter(params.size()-1,0.0f);
|
|
|
|
|
setParameter(params.size()-1, 0.0f);
|
|
|
|
|
params.push_back(new IntFloatParameter("Modulator Attenuation", 0, 63));
|
|
|
|
|
setParameter(params.size()-1,0.75f);
|
|
|
|
|
setParameter(params.size()-1, 0.75f);
|
|
|
|
|
|
|
|
|
|
const String frq_multipliers[] = {
|
|
|
|
|
"x0.5", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x10", "x12", "x12", "x15", "x15"
|
|
|
|
@ -44,24 +46,30 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
|
|
|
|
|
); setParameter(params.size()-1, 0.15f);
|
|
|
|
|
|
|
|
|
|
params.push_back(new IntFloatParameter("Modulator Feedback", 0, 7));
|
|
|
|
|
setParameter(params.size()-1,0.0f);
|
|
|
|
|
setParameter(params.size()-1, 0.0f);
|
|
|
|
|
|
|
|
|
|
params.push_back(new IntFloatParameter("Carrier Attack", 0, 15));
|
|
|
|
|
setParameter(params.size()-1,0.5f);
|
|
|
|
|
setParameter(params.size()-1, 0.5f);
|
|
|
|
|
params.push_back(new IntFloatParameter("Carrier Decay", 0, 15));
|
|
|
|
|
setParameter(params.size()-1,0.25f);
|
|
|
|
|
setParameter(params.size()-1, 0.25f);
|
|
|
|
|
params.push_back(new IntFloatParameter("Carrier Sustain", 0, 15));
|
|
|
|
|
setParameter(params.size()-1,0.125f);
|
|
|
|
|
setParameter(params.size()-1, 0.125f);
|
|
|
|
|
params.push_back(new IntFloatParameter("Carrier Release", 0, 15));
|
|
|
|
|
setParameter(params.size()-1,0.5f);
|
|
|
|
|
setParameter(params.size()-1, 0.5f);
|
|
|
|
|
params.push_back(new IntFloatParameter("Modulator Attack", 0, 15));
|
|
|
|
|
setParameter(params.size()-1,0.5f);
|
|
|
|
|
setParameter(params.size()-1, 0.5f);
|
|
|
|
|
params.push_back(new IntFloatParameter("Modulator Decay", 0, 15));
|
|
|
|
|
setParameter(params.size()-1,0.25f);
|
|
|
|
|
setParameter(params.size()-1, 0.25f);
|
|
|
|
|
params.push_back(new IntFloatParameter("Modulator Sustain", 0, 15));
|
|
|
|
|
setParameter(params.size()-1,0.25f);
|
|
|
|
|
setParameter(params.size()-1, 0.25f);
|
|
|
|
|
params.push_back(new IntFloatParameter("Modulator Release", 0, 15));
|
|
|
|
|
setParameter(params.size()-1,0.25f);
|
|
|
|
|
setParameter(params.size()-1, 0.25f);
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < params.size(); i++) {
|
|
|
|
|
paramIdxByName[params[i]->getName()] = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//programs["
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -85,6 +93,22 @@ float JuceOplvstiAudioProcessor::getParameter (int index)
|
|
|
|
|
return params[index]->getParameter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void JuceOplvstiAudioProcessor::setIntParameter (String name, int value)
|
|
|
|
|
{
|
|
|
|
|
int i = paramIdxByName[name];
|
|
|
|
|
IntFloatParameter* p = (IntFloatParameter*)params[i];
|
|
|
|
|
p->setParameterValue(value);
|
|
|
|
|
setParameter(i, p->getParameter());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void JuceOplvstiAudioProcessor::setEnumParameter (String name, int index)
|
|
|
|
|
{
|
|
|
|
|
int i = paramIdxByName[name];
|
|
|
|
|
EnumFloatParameter* p = (EnumFloatParameter*)params[i];
|
|
|
|
|
p->setParameterIndex(index);
|
|
|
|
|
setParameter(i, p->getParameter());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void JuceOplvstiAudioProcessor::setParameter (int index, float newValue)
|
|
|
|
|
{
|
|
|
|
|
FloatParameter* p = params[index];
|
|
|
|
@ -95,22 +119,22 @@ void JuceOplvstiAudioProcessor::setParameter (int index, float newValue)
|
|
|
|
|
osc = 1;
|
|
|
|
|
}
|
|
|
|
|
if (name.endsWith("Wave")) {
|
|
|
|
|
Opl->SetWaveform(1, osc, (Waveform)((EnumFloatParameter*)p)->getParameterIndex());
|
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetWaveform(c, osc, (Waveform)((EnumFloatParameter*)p)->getParameterIndex());
|
|
|
|
|
} else if (name.endsWith("Attenuation")) {
|
|
|
|
|
//Opl->SetAttenuation(1, osc, 0x1<<((EnumFloatParameter*)p)->getParameterIndex());
|
|
|
|
|
Opl->SetAttenuation(1, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetAttenuation(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
} else if (name.endsWith("Frequency Multiplier")) {
|
|
|
|
|
Opl->SetFrequencyMultiple(1, osc, (FreqMultiple)((EnumFloatParameter*)p)->getParameterIndex());
|
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetFrequencyMultiple(c, osc, (FreqMultiple)((EnumFloatParameter*)p)->getParameterIndex());
|
|
|
|
|
} else if (name.endsWith("Attack")) {
|
|
|
|
|
Opl->SetEnvelopeAttack(1, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeAttack(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
} else if (name.endsWith("Decay")) {
|
|
|
|
|
Opl->SetEnvelopeDecay(1, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeDecay(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
} else if (name.endsWith("Sustain")) {
|
|
|
|
|
Opl->SetEnvelopeSustain(1, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeSustain(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
} else if (name.endsWith("Release")) {
|
|
|
|
|
Opl->SetEnvelopeRelease(1, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeRelease(c, osc, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
} else if (name.endsWith("Feedback")) {
|
|
|
|
|
Opl->SetModulatorFeedback(1, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetModulatorFeedback(c, ((IntFloatParameter*)p)->getParameterValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -218,14 +242,15 @@ void JuceOplvstiAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuf
|
|
|
|
|
MidiMessage midi_message(0);
|
|
|
|
|
int sample_number;
|
|
|
|
|
while (midi_buffer_iterator.getNextEvent(midi_message,sample_number)) {
|
|
|
|
|
int ch = 1 + (midi_message.getNoteNumber() % Hiopl::CHANNELS); // kind of hackish, but..
|
|
|
|
|
if (midi_message.isNoteOn()) {
|
|
|
|
|
//note on at sample_number samples after
|
|
|
|
|
//the beginning of the current buffer
|
|
|
|
|
float noteHz = (float)MidiMessage::getMidiNoteInHertz(midi_message.getNoteNumber());
|
|
|
|
|
Opl->KeyOn(1, noteHz);
|
|
|
|
|
Opl->KeyOn(ch, noteHz);
|
|
|
|
|
}
|
|
|
|
|
else if (midi_message.isNoteOff()) {
|
|
|
|
|
Opl->KeyOff(1);
|
|
|
|
|
Opl->KeyOff(ch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Opl->Generate(buffer.getNumSamples(), buffer.getSampleData(0));
|
|
|
|
|