2
0
Fork 0

Remove record to DRO, add export to SBI. UI needs work.

This commit is contained in:
bsutherland 2015-11-30 23:29:58 +09:00
parent 6efe9e45c9
commit 63aa06b044
4 changed files with 64 additions and 31 deletions

View file

@ -7,7 +7,7 @@
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved. and re-saved.
Created with Introjucer version: 3.1.1 Created with Introjucer version: 3.1.0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -895,7 +895,7 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter)
addAndMakeVisible (recordButton = new ToggleButton ("record button")); addAndMakeVisible (recordButton = new ToggleButton ("record button"));
recordButton->setTooltip (TRANS("Start recording all register writes to a DRO file - an OPL recording file format defined by DOSBox")); recordButton->setTooltip (TRANS("Start recording all register writes to a DRO file - an OPL recording file format defined by DOSBox"));
recordButton->setButtonText (TRANS("Record to DRO")); recordButton->setButtonText (TRANS("Record to DRO (not working yet)"));
recordButton->addListener (this); recordButton->addListener (this);
recordButton->setColour (ToggleButton::textColourId, Colour (0xff007f00)); recordButton->setColour (ToggleButton::textColourId, Colour (0xff007f00));
@ -922,6 +922,12 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter)
percussionLabel->setColour (TextEditor::textColourId, Colours::black); percussionLabel->setColour (TextEditor::textColourId, Colours::black);
percussionLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); percussionLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
addAndMakeVisible (exportButton = new TextButton ("export button"));
exportButton->setButtonText (TRANS("Export .SBI instrument"));
exportButton->addListener (this);
exportButton->setColour (TextButton::buttonColourId, Colour (0xff007f00));
exportButton->setColour (TextButton::buttonOnColourId, Colours::lime);
//[UserPreSize] //[UserPreSize]
frequencyComboBox->setColour (ComboBox::textColourId, Colour (COLOUR_MID)); frequencyComboBox->setColour (ComboBox::textColourId, Colour (COLOUR_MID));
@ -1149,6 +1155,7 @@ PluginGui::~PluginGui()
recordButton = nullptr; recordButton = nullptr;
percussionComboBox = nullptr; percussionComboBox = nullptr;
percussionLabel = nullptr; percussionLabel = nullptr;
exportButton = nullptr;
//[Destructor]. You can add your own custom destruction code here.. //[Destructor]. You can add your own custom destruction code here..
@ -1252,9 +1259,10 @@ void PluginGui::resized()
emulatorSlider->setBounds (200, 32, 40, 24); emulatorSlider->setBounds (200, 32, 40, 24);
emulatorLabel->setBounds (112, 32, 72, 24); emulatorLabel->setBounds (112, 32, 72, 24);
emulatorLabel2->setBounds (248, 32, 72, 24); emulatorLabel2->setBounds (248, 32, 72, 24);
recordButton->setBounds (40, 456, 128, 24); recordButton->setBounds (24, 560, 296, 24);
percussionComboBox->setBounds (256, 488, 112, 24); percussionComboBox->setBounds (256, 488, 112, 24);
percussionLabel->setBounds (40, 488, 163, 24); percussionLabel->setBounds (40, 488, 163, 24);
exportButton->setBounds (40, 456, 168, 24);
//[UserResized] Add your own custom resize handling here.. //[UserResized] Add your own custom resize handling here..
for (unsigned int i = 0; i < channels.size(); ++i) for (unsigned int i = 0; i < channels.size(); ++i)
channels[i]->setBounds(456+44*i+4, 36, 20, 20); channels[i]->setBounds(456+44*i+4, 36, 20, 20);
@ -1576,30 +1584,28 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
else if (buttonThatWasClicked == recordButton) else if (buttonThatWasClicked == recordButton)
{ {
//[UserButtonCode_recordButton] -- add your button handler code here.. //[UserButtonCode_recordButton] -- add your button handler code here..
recordButton->setToggleState(false, dontSendNotification);
if (!processor->isAnyInstanceRecording()) {
WildcardFileFilter wildcardFilter ("*.dro", String::empty, "DRO files");
FileBrowserComponent browser (FileBrowserComponent::saveMode,
File::nonexistent,
&wildcardFilter,
nullptr);
FileChooserDialogBox dialogBox ("Record to",
"Specify DRO output file",
browser,
true,
Colours::darkgreen);
if (dialogBox.show())
{
File selectedFile = browser.getSelectedFile(0);
processor->startRecording(&selectedFile);
setRecordButtonState(true);
}
} else {
setRecordButtonState(false);
processor->stopRecording();
}
//[/UserButtonCode_recordButton] //[/UserButtonCode_recordButton]
} }
else if (buttonThatWasClicked == exportButton)
{
//[UserButtonCode_exportButton] -- add your button handler code here..
WildcardFileFilter wildcardFilter("*.sbi", String::empty, "SBI files");
FileBrowserComponent browser(FileBrowserComponent::saveMode,
File::nonexistent,
&wildcardFilter,
nullptr);
FileChooserDialogBox dialogBox("Export to",
"Specify SBI output file",
browser,
true,
Colours::darkgreen);
if (dialogBox.show())
{
File selectedFile = browser.getSelectedFile(0);
processor->saveInstrumentToFile(selectedFile.getFullPathName());
}
//[/UserButtonCode_exportButton]
}
//[UserbuttonClicked_Post] //[UserbuttonClicked_Post]
//[/UserbuttonClicked_Post] //[/UserbuttonClicked_Post]
@ -1918,8 +1924,8 @@ BEGIN_JUCER_METADATA
<SLIDER name="tremolo slider" id="ab64abee7ac8874b" memberName="tremoloSlider" <SLIDER name="tremolo slider" id="ab64abee7ac8874b" memberName="tremoloSlider"
virtualName="" explicitFocusOrder="0" pos="632 456 112 24" thumbcol="ff00af00" virtualName="" explicitFocusOrder="0" pos="632 456 112 24" thumbcol="ff00af00"
trackcol="7f007f00" textboxtext="ff007f00" textboxbkgd="ff000000" trackcol="7f007f00" textboxtext="ff007f00" textboxbkgd="ff000000"
textboxhighlight="ff00af00" min="1" max="4.7999999999999998224" textboxhighlight="ff00af00" min="1" max="4.7999999999999998"
int="3.7999999999999998224" style="LinearHorizontal" textBoxPos="TextBoxLeft" int="3.7999999999999998" style="LinearHorizontal" textBoxPos="TextBoxLeft"
textBoxEditable="1" textBoxWidth="44" textBoxHeight="20" skewFactor="1"/> textBoxEditable="1" textBoxWidth="44" textBoxHeight="20" skewFactor="1"/>
<LABEL name="frequency label" id="134ce8f87da62b88" memberName="frequencyLabel5" <LABEL name="frequency label" id="134ce8f87da62b88" memberName="frequencyLabel5"
virtualName="" explicitFocusOrder="0" pos="472 456 152 24" tooltip="OPL global tremolo depth" virtualName="" explicitFocusOrder="0" pos="472 456 152 24" tooltip="OPL global tremolo depth"
@ -2069,9 +2075,9 @@ BEGIN_JUCER_METADATA
editableSingleClick="0" editableDoubleClick="0" focusDiscardsChanges="0" editableSingleClick="0" editableDoubleClick="0" focusDiscardsChanges="0"
fontname="Default font" fontsize="15" bold="0" italic="0" justification="33"/> fontname="Default font" fontsize="15" bold="0" italic="0" justification="33"/>
<TOGGLEBUTTON name="record button" id="880010ee79039cbe" memberName="recordButton" <TOGGLEBUTTON name="record button" id="880010ee79039cbe" memberName="recordButton"
virtualName="" explicitFocusOrder="0" pos="40 456 128 24" tooltip="Start recording all register writes to a DRO file - an OPL recording file format defined by DOSBox" virtualName="" explicitFocusOrder="0" pos="24 560 296 24" tooltip="Start recording all register writes to a DRO file - an OPL recording file format defined by DOSBox"
txtcol="ff007f00" buttonText="Record to DRO" connectedEdges="0" txtcol="ff007f00" buttonText="Record to DRO (not working yet)"
needsCallback="1" radioGroupId="0" state="0"/> connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
<COMBOBOX name="percussion combo box" id="75a838b61782e17b" memberName="percussionComboBox" <COMBOBOX name="percussion combo box" id="75a838b61782e17b" memberName="percussionComboBox"
virtualName="" explicitFocusOrder="0" pos="256 488 112 24" editable="0" virtualName="" explicitFocusOrder="0" pos="256 488 112 24" editable="0"
layout="33" items="Off&#10;Bass drum&#10;Snare&#10;Tom&#10;Cymbal&#10;Hi-hat" layout="33" items="Off&#10;Bass drum&#10;Snare&#10;Tom&#10;Cymbal&#10;Hi-hat"
@ -2081,6 +2087,10 @@ BEGIN_JUCER_METADATA
textCol="ff007f00" edTextCol="ff000000" edBkgCol="0" labelText="Percussion mode" textCol="ff007f00" edTextCol="ff000000" edBkgCol="0" labelText="Percussion mode"
editableSingleClick="0" editableDoubleClick="0" focusDiscardsChanges="0" editableSingleClick="0" editableDoubleClick="0" focusDiscardsChanges="0"
fontname="Default font" fontsize="15" bold="0" italic="0" justification="33"/> fontname="Default font" fontsize="15" bold="0" italic="0" justification="33"/>
<TEXTBUTTON name="export button" id="88c84ed1e2b284d3" memberName="exportButton"
virtualName="" explicitFocusOrder="0" pos="40 456 168 24" bgColOff="ff007f00"
bgColOn="ff00ff00" buttonText="Export .SBI instrument" connectedEdges="0"
needsCallback="1" radioGroupId="0"/>
</JUCER_COMPONENT> </JUCER_COMPONENT>
END_JUCER_METADATA END_JUCER_METADATA

View file

@ -7,7 +7,7 @@
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved. and re-saved.
Created with Introjucer version: 3.1.1 Created with Introjucer version: 3.1.0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -181,6 +181,7 @@ private:
ScopedPointer<ToggleButton> recordButton; ScopedPointer<ToggleButton> recordButton;
ScopedPointer<ComboBox> percussionComboBox; ScopedPointer<ComboBox> percussionComboBox;
ScopedPointer<Label> percussionLabel; ScopedPointer<Label> percussionLabel;
ScopedPointer<TextButton> exportButton;
//============================================================================== //==============================================================================

View file

@ -3,6 +3,7 @@
#include "EnumFloatParameter.h" #include "EnumFloatParameter.h"
#include "IntFloatParameter.h" #include "IntFloatParameter.h"
#include "SbiLoader.h" #include "SbiLoader.h"
#include "SbiWriter.h"
const char *AdlibBlasterAudioProcessor::PROGRAM_INDEX = "Program Index"; const char *AdlibBlasterAudioProcessor::PROGRAM_INDEX = "Program Index";
@ -556,9 +557,29 @@ void AdlibBlasterAudioProcessor::loadInstrumentFromFile(String filename)
fclose(f); fclose(f);
SbiLoader* loader = new SbiLoader(); SbiLoader* loader = new SbiLoader();
loader->loadInstrumentData(n, buf, this); loader->loadInstrumentData(n, buf, this);
delete loader;
updateGuiIfPresent(); updateGuiIfPresent();
} }
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(&regVal, 1, 1, f);
}
fwrite(" ", 1, 5, f);
fclose(f);
}
}
// Used to configure parameters from .SBI instrument file // Used to configure parameters from .SBI instrument file
void AdlibBlasterAudioProcessor::setParametersByRegister(int register_base, int op, uint8 value) void AdlibBlasterAudioProcessor::setParametersByRegister(int register_base, int op, uint8 value)
{ {

View file

@ -56,6 +56,7 @@ public:
int getIntParameter (String name); int getIntParameter (String name);
int getEnumParameter (String name); int getEnumParameter (String name);
void loadInstrumentFromFile(String filename); void loadInstrumentFromFile(String filename);
void saveInstrumentToFile(String filename);
void setParametersByRegister(int register_base, int op, uint8 value); void setParametersByRegister(int register_base, int op, uint8 value);
int isChannelActive(int idx) const; int isChannelActive(int idx) const;