2
0
Fork 0

Add selection of DOSBox / ZDoom emulation as a parameter.

This commit is contained in:
bruce 2014-09-28 15:29:27 +09:00
parent 0d847a2ff0
commit 22685630c2
5 changed files with 55 additions and 28 deletions

View file

@ -809,16 +809,16 @@ PluginGui::PluginGui (JuceOplvstiAudioProcessor* ownerFilter)
groupComponent5->setColour (GroupComponent::outlineColourId, Colour (0xff007f00));
groupComponent5->setColour (GroupComponent::textColourId, Colour (0xff007f00));
addAndMakeVisible (feedbackSlider2 = new Slider ("feedback slider"));
feedbackSlider2->setRange (0, 1, 1);
feedbackSlider2->setSliderStyle (Slider::LinearHorizontal);
feedbackSlider2->setTextBoxStyle (Slider::NoTextBox, true, 44, 20);
feedbackSlider2->setColour (Slider::thumbColourId, Colour (0xff00af00));
feedbackSlider2->setColour (Slider::trackColourId, Colour (0x7f007f00));
feedbackSlider2->setColour (Slider::textBoxTextColourId, Colour (0xff007f00));
feedbackSlider2->setColour (Slider::textBoxBackgroundColourId, Colours::black);
feedbackSlider2->setColour (Slider::textBoxHighlightColourId, Colour (0xff00af00));
feedbackSlider2->addListener (this);
addAndMakeVisible (emulatorSlider = new Slider ("emulator slider"));
emulatorSlider->setRange (0, 1, 1);
emulatorSlider->setSliderStyle (Slider::LinearHorizontal);
emulatorSlider->setTextBoxStyle (Slider::NoTextBox, true, 44, 20);
emulatorSlider->setColour (Slider::thumbColourId, Colour (0xff00af00));
emulatorSlider->setColour (Slider::trackColourId, Colour (0x7f007f00));
emulatorSlider->setColour (Slider::textBoxTextColourId, Colour (0xff007f00));
emulatorSlider->setColour (Slider::textBoxBackgroundColourId, Colours::black);
emulatorSlider->setColour (Slider::textBoxHighlightColourId, Colour (0xff00af00));
emulatorSlider->addListener (this);
addAndMakeVisible (emulatorLabel = new Label ("emulator label",
TRANS("DOSBox")));
@ -1057,7 +1057,7 @@ PluginGui::~PluginGui()
keyscaleAttenuationComboBox = nullptr;
groupComponent4 = nullptr;
groupComponent5 = nullptr;
feedbackSlider2 = nullptr;
emulatorSlider = nullptr;
emulatorLabel = nullptr;
emulatorLabel2 = nullptr;
@ -1157,9 +1157,9 @@ void PluginGui::resized()
keyscaleAttenuationComboBox->setBounds (264, 144, 72, 24);
groupComponent4->setBounds (16, 856, 408, 64);
groupComponent5->setBounds (16, 8, 408, 48);
feedbackSlider2->setBounds (184, 24, 72, 24);
emulatorLabel->setBounds (104, 24, 72, 24);
emulatorLabel2->setBounds (264, 24, 72, 24);
emulatorSlider->setBounds (200, 24, 40, 24);
emulatorLabel->setBounds (120, 24, 72, 24);
emulatorLabel2->setBounds (248, 24, 72, 24);
//[UserResized] Add your own custom resize handling here..
for (unsigned int i = 0; i < channels.size(); ++i)
channels[i]->setBounds(32+44*i+4, 880+4, 16, 16);
@ -1311,10 +1311,11 @@ void PluginGui::sliderValueChanged (Slider* sliderThatWasMoved)
processor->setIntParameter("Modulator Feedback", (int)sliderThatWasMoved->getValue());
//[/UserSliderCode_feedbackSlider]
}
else if (sliderThatWasMoved == feedbackSlider2)
else if (sliderThatWasMoved == emulatorSlider)
{
//[UserSliderCode_feedbackSlider2] -- add your slider handling code here..
//[/UserSliderCode_feedbackSlider2]
//[UserSliderCode_emulatorSlider] -- add your slider handling code here..
processor->setEnumParameter("Emulator", sliderThatWasMoved->getValue() < 0.5 ? 0 : 1);
//[/UserSliderCode_emulatorSlider]
}
//[UsersliderValueChanged_Post]
@ -1919,19 +1920,19 @@ BEGIN_JUCER_METADATA
<GROUPCOMPONENT name="new group" id="7abc643f4d6a2dbf" memberName="groupComponent5"
virtualName="" explicitFocusOrder="0" pos="16 8 408 48" outlinecol="ff007f00"
textcol="ff007f00" title="Emulator" textpos="33"/>
<SLIDER name="feedback slider" id="88ec3755c4760ed9" memberName="feedbackSlider2"
virtualName="" explicitFocusOrder="0" pos="184 24 72 24" thumbcol="ff00af00"
<SLIDER name="emulator slider" id="88ec3755c4760ed9" memberName="emulatorSlider"
virtualName="" explicitFocusOrder="0" pos="200 24 40 24" thumbcol="ff00af00"
trackcol="7f007f00" textboxtext="ff007f00" textboxbkgd="ff000000"
textboxhighlight="ff00af00" min="0" max="1" int="1" style="LinearHorizontal"
textBoxPos="NoTextBox" textBoxEditable="0" textBoxWidth="44"
textBoxHeight="20" skewFactor="1"/>
<LABEL name="emulator label" id="22c2c30d0f337081" memberName="emulatorLabel"
virtualName="" explicitFocusOrder="0" pos="104 24 72 24" textCol="ff007f00"
virtualName="" explicitFocusOrder="0" pos="120 24 72 24" textCol="ff007f00"
edTextCol="ff000000" edBkgCol="0" labelText="DOSBox" editableSingleClick="0"
editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
fontsize="15" bold="0" italic="0" justification="34"/>
<LABEL name="emulator label" id="4f8869b5724c0195" memberName="emulatorLabel2"
virtualName="" explicitFocusOrder="0" pos="264 24 72 24" textCol="ff007f00"
virtualName="" explicitFocusOrder="0" pos="248 24 72 24" textCol="ff007f00"
edTextCol="ff000000" edBkgCol="0" labelText="ZDoom" editableSingleClick="0"
editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
fontsize="15" bold="0" italic="0" justification="33"/>

View file

@ -172,7 +172,7 @@ private:
ScopedPointer<ComboBox> keyscaleAttenuationComboBox;
ScopedPointer<GroupComponent> groupComponent4;
ScopedPointer<GroupComponent> groupComponent5;
ScopedPointer<Slider> feedbackSlider2;
ScopedPointer<Slider> emulatorSlider;
ScopedPointer<Label> emulatorLabel;
ScopedPointer<Label> emulatorLabel2;

View file

@ -18,6 +18,11 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
// Initialize parameters
const String emulators[] = {"DOSBox", "ZDoom"};
params.push_back(new EnumFloatParameter("Emulator",
StringArray(emulators, sizeof(emulators)/sizeof(String)))
);
const String waveforms[] = {"Sine", "Half Sine", "Abs Sine", "Quarter Sine", "Alternating Sine", "Camel Sine", "Square", "Logarithmic Sawtooth"};
params.push_back(new EnumFloatParameter("Carrier Wave",
StringArray(waveforms, sizeof(waveforms)/sizeof(String)))
@ -133,6 +138,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
{
// these ones from the Syndicate in-game music
const float i_params_0[] = {
0.0f, // emulator
0.000000f, 0.330000f, // waveforms
0.066667f, 0.133333f, // frq multipliers
0.142857f, 0.412698f, // attenuation
@ -150,6 +156,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Mercenary Bass"] = std::vector<float>(v_i_params_0);
const float i_params_19189[] = {
0.0f, // emulator
0.000000f, 0.000000f, // waveforms
0.066667f, 0.200000f, // frq multipliers
0.000000f, 0.285714f, // attenuation
@ -167,6 +174,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Patrol Bass"] = std::vector<float>(v_i_params_19189);
const float i_params_38377[] = {
0.0f, // emulator
0.000000f, 0.160000f, // waveforms
0.066667f, 0.066667f, // frq multipliers
0.000000f, 0.460317f, // attenuation
@ -184,6 +192,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Subdue Bass"] = std::vector<float>(v_i_params_38377);
const float i_params_38392[] = {
0.0f, // emulator
0.000000f, 0.000000f, // waveforms
0.000000f, 0.000000f, // frq multipliers
0.000000f, 0.000000f, // attenuation
@ -201,6 +210,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Dark Future Sweep"] = std::vector<float>(v_i_params_38392);
const float i_params_39687[] = {
0.0f, // emulator
0.000000f, 0.000000f, // waveforms
0.066667f, 0.333333f, // frq multipliers
0.000000f, 0.301587f, // attenuation
@ -218,6 +228,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Sinister Bass"] = std::vector<float>(v_i_params_39687);
const float i_params_76784[] = {
0.0f, // emulator
0.000000f, 0.330000f, // waveforms
0.066667f, 0.133333f, // frq multipliers
0.000000f, 0.428571f, // attenuation
@ -235,6 +246,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Buzcut Bass"] = std::vector<float>(v_i_params_76784);
const float i_params_97283[] = {
0.0f, // emulator
0.000000f, 0.330000f, // waveforms
0.133333f, 0.400000f, // frq multipliers
0.000000f, 0.365079f, // attenuation
@ -253,6 +265,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
// The start of the Dune 2 introduction
const float i_params_3136[] = {
0.0f, // emulator
0.000000f, 0.330000f, // waveforms
0.133333f, 0.133333f, // frq multipliers
0.000000f, 0.333333f, // attenuation
@ -270,6 +283,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Westwood Chime"] = std::vector<float>(v_i_params_3136);
const float i_params_7254[] = {
0.0f, // emulator
0.000000f, 0.160000f, // waveforms
0.066667f, 0.066667f, // frq multipliers
0.253968f, 0.476190f, // attenuation
@ -287,6 +301,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Desert Pipe"] = std::vector<float>(v_i_params_7254);
const float i_params_20108[] = {
0.0f, // emulator
0.000000f, 0.000000f, // waveforms
0.400000f, 0.066667f, // frq multipliers
0.238095f, 0.000000f, // attenuation
@ -304,6 +319,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Y2180 Strings"] = std::vector<float>(v_i_params_20108);
const float i_params_27550[] = {
0.0f, // emulator
0.500000f, 0.000000f, // waveforms
0.000000f, 0.066667f, // frq multipliers
0.238095f, 0.793651f, // attenuation
@ -321,6 +337,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Emperor Chord"] = std::vector<float>(v_i_params_27550);
const float i_params_harpsi[] = {
0.0f, // emulator
0.330000f, 0.160000f, // waveforms
0.066667f, 0.200000f, // frq multipliers
0.142857f, 0.260000f, // attenuation
@ -338,6 +355,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Harpsi"] = std::vector<float>(v_i_params_harpsi);
const float i_params_tromba[] = {
0.0f, // emulator
0.000000f, 0.160000f, // waveforms
0.066667f, 0.000000f, // frq multipliers
0.142857f, 0.220000f, // attenuation
@ -355,6 +373,7 @@ void JuceOplvstiAudioProcessor::initPrograms()
programs["Tromba"] = std::vector<float>(v_i_params_tromba);
const float i_params_bassdrum[] = {
0.0f, // emulator
0.000000f, 0.500000f, // waveforms
0.000000f, 0.000000f, // frq multipliers
0.000000f, 0.090000f, // attenuation
@ -477,6 +496,8 @@ void JuceOplvstiAudioProcessor::setParameter (int index, float newValue)
Opl->TremoloDepth(((EnumFloatParameter*)p)->getParameterIndex() > 0);
} else if (name.startsWith("Vibrato Depth")) {
Opl->VibratoDepth(((EnumFloatParameter*)p)->getParameterIndex() > 0);
} else if (name.startsWith("Emulator")) {
Opl->SetEmulator((Emulator)((EnumFloatParameter*)p)->getParameterIndex());
}
}

View file

@ -6,11 +6,10 @@
// A wrapper around the DOSBox and ZDoom OPL emulators.
Hiopl::Hiopl(int buflen, Emulator emulator) {
Buf32 = new Bit32s[buflen*2];
adlib = new DBOPL::Handler();
zdoom = JavaOPLCreate(false);
this->SetEmulator(emulator);
_op1offset[1] = 0x0;
_op1offset[2] = 0x1;
_op1offset[3] = 0x2;
@ -31,6 +30,11 @@ Hiopl::Hiopl(int buflen, Emulator emulator) {
_op2offset[8] = 0x14;
_op2offset[9] = 0x15;
SetEmulator(emulator);
_ClearRegisters();
}
void Hiopl::_ClearRegisters() {
for (int i = 0; i < 256; i++) {
_WriteReg(i, 0);
}
@ -61,11 +65,11 @@ void Hiopl::_WriteReg(Bit32u reg, Bit8u value, Bit8u mask) {
if (mask > 0) {
value = (regCache[reg] & (~mask)) | (value & mask);
}
if (DOSBOX == emulator) {
//if (DOSBOX == emulator) {
adlib->WriteReg(reg, value);
} else if (ZDOOM == emulator) {
//} else if (ZDOOM == emulator) {
zdoom->WriteReg(reg, value);
}
//}
regCache[reg] = value;
}

View file

@ -25,7 +25,7 @@ class Hiopl {
static const int CHANNELS = 9;
static const int OSCILLATORS = 2;
Hiopl(int buflen, Emulator emulator=ZDOOM);
void Hiopl::SetEmulator(Emulator emulator);
void SetEmulator(Emulator emulator);
void Generate(int length, short* buffer);
void Generate(int length, float* buffer);
@ -68,6 +68,7 @@ class Hiopl {
int _GetOffset(int ch, int osc);
int _GetOffset(int ch);
void _milliHertzToFnum(unsigned int milliHertz, unsigned int *fnum, unsigned int *block, unsigned int conversionFactor=49716);
void _ClearRegisters();
std::map<int, int> _op1offset;
std::map<int, int> _op2offset;
};