2
0
Fork 0
Preset name now displays in Load button.
Active folder and preset is displayed with a tick on the Load drop down menu.
Relocated - + preset navigation buttons.
This commit is contained in:
George Reales 2020-06-23 09:54:09 +02:00
parent 521eeeb4c6
commit 7aff1e75ed
7 changed files with 4874 additions and 35 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<JUCERPROJECT id="wUKQiT" name="OPL" projectType="audioplug" version="1.6.0"
<JUCERPROJECT id="wUKQiT" name="OPL" projectType="audioplug" version="1.7.0"
bundleIdentifier="com.discodsp.OPL" pluginName="OPL" pluginDesc="Digital sound synthesis chip developed by Yamaha in the mid 1980s"
pluginManufacturer="discoDSP" pluginManufacturerCode="DDSP" pluginCode="OPL1"
pluginChannelConfigs="{0, 2}" pluginIsSynth="1" pluginWantsMidiIn="1"

View file

@ -62,6 +62,8 @@ private:
//==============================================================================
std::unique_ptr<PluginGui> comp;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginEditor)
};

View file

@ -143,6 +143,10 @@ void PluginGui::updateFromParameters()
tooltipWindow.setColour(tooltipWindow.backgroundColourId, Colour(0x0));
tooltipWindow.setColour(tooltipWindow.textColourId, Colour(COLOUR_MID));
if (processor->lastLoadFile.length() > 0) {
File file(processor->lastLoadFile);
loadButton->setButtonText(file.getFileNameWithoutExtension());
}
}
void PluginGui::setRecordButtonState(bool recording) {
@ -1157,9 +1161,9 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter)
exportButton->addListener (this);
exportButton->setColour (TextButton::buttonColourId, Colour (0xff007f00));
exportButton->setColour (TextButton::buttonOnColourId, Colours::lime);
#if!JUCE_IOS
exportButton->setBounds (728, 512, 96, 24);
#endif
exportButton->setBounds (728, 512, 48, 24);
loadButton.reset (new TextButton ("load button"));
addAndMakeVisible (loadButton.get());
loadButton->setButtonText (TRANS("Load"));
@ -1168,7 +1172,7 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter)
loadButton->setColour (TextButton::buttonColourId, Colour (0xff007f00));
loadButton->setColour (TextButton::buttonOnColourId, Colours::lime);
loadButton->setBounds (728, 472, 48, 24);
loadButton->setBounds (728, 472, 96, 24);
versionLabel.reset (new Label ("version label",
String()));
@ -2032,7 +2036,7 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter)
previousButton->setColour (TextButton::buttonColourId, Colour (0xff007f00));
previousButton->setColour (TextButton::buttonOnColourId, Colours::lime);
previousButton->setBounds (776, 472, 24, 24);
previousButton->setBounds (776, 512, 24, 24);
nextButton.reset (new TextButton ("next button"));
addAndMakeVisible (nextButton.get());
@ -2042,7 +2046,7 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter)
nextButton->setColour (TextButton::buttonColourId, Colour (0xff007f00));
nextButton->setColour (TextButton::buttonOnColourId, Colours::lime);
nextButton->setBounds (800, 472, 24, 24);
nextButton->setBounds (800, 512, 24, 24);
drawable1 = Drawable::createFromImageData (gui_svg, gui_svgSize);
@ -2210,6 +2214,11 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter)
//[Constructor] You can add your own custom stuff here..
processor = ownerFilter;
startTimer(1000/30);
// Update GUI Only
if (processor->lastLoadFile.length() > 0) {
File file(processor->lastLoadFile);
loadButton->setButtonText(file.getFileNameWithoutExtension());
}
//[/Constructor]
}
@ -3001,7 +3010,7 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
void PluginGui::filesDropped (const StringArray& files, int x, int y)
{
if (isInterestedInFileDrag(files)) {
processor->loadInstrumentFromFile(files[0]);
this->loadandUpdateInstrument(files[0]);
}
}
@ -3013,20 +3022,20 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
}
void PluginGui::loadPreNextFile(bool pre){
if (pre){
selectedIdxFile -=1;
processor->selectedIdxFile -=1;
}
else{
selectedIdxFile +=1;
processor->selectedIdxFile +=1;
}
if (allSbiFiles.size() > 0){
if (selectedIdxFile > allSbiFiles.size() -1 ){
selectedIdxFile = 0;
if (processor->selectedIdxFile > allSbiFiles.size() -1 ){
processor->selectedIdxFile = 0;
}
if (selectedIdxFile <0 ){
selectedIdxFile = allSbiFiles.size() - 1;
if (processor->selectedIdxFile <0 ){
processor->selectedIdxFile = allSbiFiles.size() - 1;
}
if (allSbiFiles[selectedIdxFile].existsAsFile()){
processor->loadInstrumentFromFile(allSbiFiles[selectedIdxFile].getFullPathName());
if (allSbiFiles[processor->selectedIdxFile].existsAsFile()){
this->loadandUpdateInstrument(allSbiFiles[processor->selectedIdxFile].getFullPathName());
} else {
loadBrowserFile();
}
@ -3047,15 +3056,15 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
}
}
}
if (selectedIdxFile > allSbiFiles.size() - 1){
selectedIdxFile = 0;
if (processor->selectedIdxFile > allSbiFiles.size() - 1){
processor->selectedIdxFile = 0;
}
if (selectedIdxFile <0 ){
selectedIdxFile = allSbiFiles.size() - 1;
if (processor->selectedIdxFile <0 ){
processor->selectedIdxFile = allSbiFiles.size() - 1;
}
if(hasFile){
if (allSbiFiles[selectedIdxFile].existsAsFile()){
processor->loadInstrumentFromFile(allSbiFiles[selectedIdxFile].getFullPathName());
if (allSbiFiles[processor->selectedIdxFile].existsAsFile()){
this->loadandUpdateInstrument(allSbiFiles[processor->selectedIdxFile].getFullPathName());
} else {
loadBrowserFile();
}
@ -3080,7 +3089,7 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
if (browser.browseForFileToOpen()){
File selectedFile = browser.getResult();
instrumentLoadDirectory = selectedFile.getParentDirectory();
processor->loadInstrumentFromFile(selectedFile.getFullPathName());
this->loadandUpdateInstrument(selectedFile.getFullPathName());
}
return 0;
}
@ -3098,22 +3107,34 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
dir.findChildFiles (files, File::findFiles, false, "*.sbi");
files.sort();
if (files.size() > 0){
bool selectedSub = false;
PopupMenu subMenu;
for (auto file : files){
allSbiFiles.add(file);
hasFile = true;
subMenu.addItem(allSbiFiles.size(), file.getFileNameWithoutExtension());
if (processor->lastLoadFile == file.getFullPathName()){
selectedSub = true;
subMenu.addItem(allSbiFiles.size(), file.getFileNameWithoutExtension(), true, true);
} else {
subMenu.addItem(allSbiFiles.size(), file.getFileNameWithoutExtension());
}
}
menuLoad.addSubMenu(dir.getFileName(), subMenu);
if(selectedSub){
menuLoad.addSubMenu (std::move (dir.getFileName()), std::move (subMenu), true, nullptr, true, 0);
}
else{
menuLoad.addSubMenu(dir.getFileName(), subMenu);
}
}
}
if(hasFile){
//int id = menuLoad.show();
menuLoad.showMenuAsync (PopupMenu::Options().withParentComponent (this->getTopLevelComponent()), [this](int id){
if (id > 0) {
this->selectedIdxFile = id -1;
if (this->allSbiFiles[selectedIdxFile].existsAsFile()){
this->processor->loadInstrumentFromFile(allSbiFiles[selectedIdxFile].getFullPathName());
processor->selectedIdxFile = id -1;
if (this->allSbiFiles[processor->selectedIdxFile].existsAsFile()){
this->loadandUpdateInstrument(allSbiFiles[processor->selectedIdxFile].getFullPathName());
} else {
this->loadBrowserFile();
}
@ -3128,6 +3149,14 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked)
}
return hasFile;
}
void PluginGui::loadandUpdateInstrument(String path) {
processor->loadInstrumentFromFile(path);
File file(path);
loadButton->setButtonText(file.getFileNameWithoutExtension());
}
//[/MiscUserCode]
@ -3584,11 +3613,11 @@ BEGIN_JUCER_METADATA
txtcol="ff007f00" buttonText="Record to DRO (not working yet)"
connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
<TEXTBUTTON name="export button" id="88c84ed1e2b284d3" memberName="exportButton"
virtualName="" explicitFocusOrder="0" pos="728 512 96 24" bgColOff="ff007f00"
virtualName="" explicitFocusOrder="0" pos="728 512 48 24" bgColOff="ff007f00"
bgColOn="ff00ff00" buttonText="Export" connectedEdges="3" needsCallback="1"
radioGroupId="0"/>
<TEXTBUTTON name="load button" id="a42176161523f448" memberName="loadButton"
virtualName="" explicitFocusOrder="0" pos="728 472 48 24" bgColOff="ff007f00"
virtualName="" explicitFocusOrder="0" pos="728 472 96 24" bgColOff="ff007f00"
bgColOn="ff00ff00" buttonText="Load" connectedEdges="3" needsCallback="1"
radioGroupId="0"/>
<LABEL name="version label" id="cd68ca110847cc18" memberName="versionLabel"
@ -4017,11 +4046,11 @@ BEGIN_JUCER_METADATA
fontname="Default font" fontsize="15.0" kerning="0.0" bold="0"
italic="0" justification="36"/>
<TEXTBUTTON name="previous button" id="984b463c7d35a177" memberName="previousButton"
virtualName="" explicitFocusOrder="0" pos="776 472 24 24" bgColOff="ff007f00"
virtualName="" explicitFocusOrder="0" pos="776 512 24 24" bgColOff="ff007f00"
bgColOn="ff00ff00" buttonText="-" connectedEdges="3" needsCallback="1"
radioGroupId="0"/>
<TEXTBUTTON name="next button" id="d6684ea8f9f9ded7" memberName="nextButton"
virtualName="" explicitFocusOrder="0" pos="800 472 24 24" bgColOff="ff007f00"
virtualName="" explicitFocusOrder="0" pos="800 512 24 24" bgColOff="ff007f00"
bgColOn="ff00ff00" buttonText="+" connectedEdges="3" needsCallback="1"
radioGroupId="0"/>
</JUCER_COMPONENT>

View file

@ -130,6 +130,7 @@ public:
private:
//[UserVariables] -- You can add your own custom variables in this section.
void loadandUpdateInstrument(String path);
class OPLComboBoxLookAndFeelMethods:
public OPLLookAndFeel
{
@ -155,7 +156,7 @@ return options;
TooltipWindow tooltipWindow;
PopupMenu menuLoad;
Array<File> allSbiFiles;
int selectedIdxFile = 0;
#if!JUCE_IOS
File instrumentLoadDirectory = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile("discoDSP").getChildFile("OPL"); // File();
File instrumentSaveDirectory = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile("discoDSP").getChildFile("OPL"); // File();

4790
Source/PluginGuiiOS.cpp Normal file

File diff suppressed because it is too large Load diff

View file

@ -534,6 +534,7 @@ void AdlibBlasterAudioProcessor::setParameter (int index, float newValue)
void AdlibBlasterAudioProcessor::loadInstrumentFromFile(String filename)
{
lastLoadFile = filename;
FILE* f = fopen(filename.toUTF8(), "rb");
unsigned char buf[MAX_INSTRUMENT_FILE_SIZE_BYTES];
int n = (int)fread(buf, 1, MAX_INSTRUMENT_FILE_SIZE_BYTES, f);
@ -859,6 +860,9 @@ void AdlibBlasterAudioProcessor::getStateInformation(MemoryBlock& destData)
v->setProperty(stringToIdentifier(getParameterName(i)), p);
}
v->setProperty("lastLoadFile", lastLoadFile);
v->setProperty("selectedIdxFile", selectedIdxFile);
String s = JSON::toString(v.get());
destData.setSize(s.length());
@ -896,6 +900,16 @@ void AdlibBlasterAudioProcessor::setStateInformation (const void* data, int size
setParameter(i, param);
}
var file = v["lastLoadFile"];
if (file.isString()){
lastLoadFile = file;
}
var idx = v["selectedIdxFile"];
if (idx.isInt()){
selectedIdxFile = idx;
}
updateGuiIfPresent();
return;

View file

@ -87,6 +87,9 @@ public:
void getStateInformation (MemoryBlock& destData);
void setStateInformation (const void* data, int sizeInBytes);
public:
String lastLoadFile;
int selectedIdxFile = -1;
private:
Hiopl *Opl;
std::vector<FloatParameter*> params;