2
0
Fork 0

Attenuation set in dB, add keyscaling.

This commit is contained in:
bruce 2013-09-12 23:52:06 +08:00
parent 02fad2dbc4
commit 6c85dbf251
3 changed files with 28 additions and 10 deletions

View file

@ -12,6 +12,8 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
for (int i = 1; i <= Hiopl::CHANNELS; i++) { for (int i = 1; i <= Hiopl::CHANNELS; i++) {
Opl->EnableSustain(i, 1); Opl->EnableSustain(i, 1);
Opl->EnableSustain(i, 2); Opl->EnableSustain(i, 2);
Opl->EnableKeyscaling(i, 1);
Opl->EnableKeyscaling(i, 2);
} }
const String waveforms[] = {"Sine", "Half Sine", "Abs Sine", "Quarter Sine"}; const String waveforms[] = {"Sine", "Half Sine", "Abs Sine", "Quarter Sine"};
@ -21,19 +23,21 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
params.push_back(new EnumFloatParameter("Modulator Wave", params.push_back(new EnumFloatParameter("Modulator Wave",
StringArray(waveforms, sizeof(waveforms)/sizeof(String))) StringArray(waveforms, sizeof(waveforms)/sizeof(String)))
); setParameter(params.size()-1, 0.0f); ); setParameter(params.size()-1, 0.0f);
/* 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"};
const String levels[] = {"-0.75 dB", "-1.5 dB", "-3 dB", "-6 dB", "-12 dB", "-24 dB"};
params.push_back(new EnumFloatParameter("Carrier Attenuation", params.push_back(new EnumFloatParameter("Carrier Attenuation",
StringArray(levels, sizeof(levels)/sizeof(String))) StringArray(levels, sizeof(levels)/sizeof(String)))
); setParameter(params.size()-1,0.0f); ); setParameter(params.size()-1,0.0f);
params.push_back(new EnumFloatParameter("Modulator Attenuation", params.push_back(new EnumFloatParameter("Modulator Attenuation",
StringArray(levels, sizeof(levels)/sizeof(String))) StringArray(levels, sizeof(levels)/sizeof(String)))
); setParameter(params.size()-1,0.75f); ); setParameter(params.size()-1,0.75f);
*/
params.push_back(new IntFloatParameter("Carrier Attenuation", 0, 63)); const String ksrs[] = {"None","1.5 dB/8ve","3 dB/8ve","6 dB/8ve"};
setParameter(params.size()-1, 0.0f); params.push_back(new EnumFloatParameter("Carrier KSR",
params.push_back(new IntFloatParameter("Modulator Attenuation", 0, 63)); StringArray(ksrs, sizeof(ksrs)/sizeof(String)))
setParameter(params.size()-1, 0.75f); ); setParameter(params.size()-1,0.0f);
params.push_back(new EnumFloatParameter("Modulator KSR",
StringArray(ksrs, sizeof(ksrs)/sizeof(String)))
); setParameter(params.size()-1,0.0f);
const String frq_multipliers[] = { const String frq_multipliers[] = {
"x0.5", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x10", "x12", "x12", "x15", "x15" "x0.5", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x10", "x12", "x12", "x15", "x15"
@ -65,7 +69,7 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
params.push_back(new IntFloatParameter("Modulator Release", 0, 15)); 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++) { for(unsigned int i = 0; i < params.size(); i++) {
paramIdxByName[params[i]->getName()] = i; paramIdxByName[params[i]->getName()] = i;
} }
@ -121,8 +125,8 @@ void JuceOplvstiAudioProcessor::setParameter (int index, float newValue)
if (name.endsWith("Wave")) { if (name.endsWith("Wave")) {
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetWaveform(c, 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")) { } else if (name.endsWith("Attenuation")) {
//Opl->SetAttenuation(1, osc, 0x1<<((EnumFloatParameter*)p)->getParameterIndex()); for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetAttenuation(c, osc, ((EnumFloatParameter*)p)->getParameterIndex());
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetAttenuation(c, 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")) { } else if (name.endsWith("Frequency Multiplier")) {
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetFrequencyMultiple(c, 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")) { } else if (name.endsWith("Attack")) {
@ -135,6 +139,8 @@ void JuceOplvstiAudioProcessor::setParameter (int index, float newValue)
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeRelease(c, osc, ((IntFloatParameter*)p)->getParameterValue()); for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetEnvelopeRelease(c, osc, ((IntFloatParameter*)p)->getParameterValue());
} else if (name.endsWith("Feedback")) { } else if (name.endsWith("Feedback")) {
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetModulatorFeedback(c, ((IntFloatParameter*)p)->getParameterValue()); for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetModulatorFeedback(c, ((IntFloatParameter*)p)->getParameterValue());
} else if (name.endsWith("")) {
for(int c=1;c<=Hiopl::CHANNELS;c++) Opl->SetAttenuation(c, osc, ((EnumFloatParameter*)p)->getParameterIndex());
} }
} }

View file

@ -92,6 +92,11 @@ void Hiopl::SetAttenuation(int ch, int osc, int level) {
_WriteReg(0x40+offset, (Bit8u)level, 0x3f); _WriteReg(0x40+offset, (Bit8u)level, 0x3f);
} }
void Hiopl::SetKsr(int ch, int osc, int level) {
int offset = this->_GetOffset(ch, osc);
_WriteReg(0x40+offset, (Bit8u)level<<6, 0xc0);
}
void Hiopl::SetFrequencyMultiple(int ch, int osc, FreqMultiple mult) { void Hiopl::SetFrequencyMultiple(int ch, int osc, FreqMultiple mult) {
int offset = this->_GetOffset(ch, osc); int offset = this->_GetOffset(ch, osc);
_WriteReg(0x20+offset, (Bit8u)mult, 0xf); _WriteReg(0x20+offset, (Bit8u)mult, 0xf);
@ -122,6 +127,11 @@ void Hiopl::EnableSustain(int ch, int osc) {
_WriteReg(0x20+offset, (Bit8u)0x20, 0x20); _WriteReg(0x20+offset, (Bit8u)0x20, 0x20);
} }
void Hiopl::EnableKeyscaling(int ch, int osc) {
int offset = this->_GetOffset(ch, osc);
_WriteReg(0x20+offset, (Bit8u)0x10, 0x10);
}
void Hiopl::SetModulatorFeedback(int ch, int level) { void Hiopl::SetModulatorFeedback(int ch, int level) {
int offset = this->_GetOffset(ch); int offset = this->_GetOffset(ch);
_WriteReg(0xc0+offset, (Bit8u)level, 0x0e); _WriteReg(0xc0+offset, (Bit8u)level, 0x0e);

View file

@ -23,8 +23,10 @@ class Hiopl {
void Generate(int length, float* buffer); void Generate(int length, float* buffer);
void SetSampleRate(int hz); void SetSampleRate(int hz);
void EnableWaveformControl(); void EnableWaveformControl();
void EnableKeyscaling(int ch, int osc);
void SetWaveform(int ch, int osc, Waveform wave); void SetWaveform(int ch, int osc, Waveform wave);
void SetAttenuation(int ch, int osc, int level); void SetAttenuation(int ch, int osc, int level);
void SetKsr(int ch, int osc, int level);
void SetFrequencyMultiple(int ch, int osc, FreqMultiple mult); void SetFrequencyMultiple(int ch, int osc, FreqMultiple mult);
void SetEnvelopeAttack(int ch, int osc, int t); void SetEnvelopeAttack(int ch, int osc, int t);
void SetEnvelopeDecay(int ch, int osc, int t); void SetEnvelopeDecay(int ch, int osc, int t);