diff --git a/README.md b/README.md
old mode 100644
new mode 100755
diff --git a/plugin/Builds/Linux/Makefile b/plugin/Builds/Linux/Makefile
old mode 100644
new mode 100755
diff --git a/plugin/Builds/MacOSX/Info.plist b/plugin/Builds/MacOSX/Info.plist
old mode 100644
new mode 100755
diff --git a/plugin/Builds/MacOSX/RecentFilesMenuTemplate.nib b/plugin/Builds/MacOSX/RecentFilesMenuTemplate.nib
old mode 100644
new mode 100755
diff --git a/plugin/Builds/MacOSX/SFZero.xcodeproj/project.pbxproj b/plugin/Builds/MacOSX/SFZero.xcodeproj/project.pbxproj
old mode 100644
new mode 100755
diff --git a/plugin/Builds/VisualStudio2015/SFZero.sln b/plugin/Builds/VisualStudio2015/SFZero.sln
old mode 100644
new mode 100755
diff --git a/plugin/Builds/VisualStudio2015/SFZero.vcxproj b/plugin/Builds/VisualStudio2015/SFZero.vcxproj
old mode 100644
new mode 100755
diff --git a/plugin/Builds/VisualStudio2015/SFZero.vcxproj.filters b/plugin/Builds/VisualStudio2015/SFZero.vcxproj.filters
old mode 100644
new mode 100755
diff --git a/plugin/Builds/VisualStudio2015/SFZero.vcxproj.user b/plugin/Builds/VisualStudio2015/SFZero.vcxproj.user
old mode 100644
new mode 100755
diff --git a/plugin/Builds/VisualStudio2015/resources.rc b/plugin/Builds/VisualStudio2015/resources.rc
old mode 100644
new mode 100755
diff --git a/plugin/Builds/iOS/build/Debug/.DS_Store b/plugin/Builds/iOS/build/Debug/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/plugin/Builds/iOS/build/Debug/.DS_Store differ
diff --git a/plugin/Builds/iOS/build/Release/.DS_Store b/plugin/Builds/iOS/build/Release/.DS_Store
new file mode 100644
index 0000000..1e54ce7
Binary files /dev/null and b/plugin/Builds/iOS/build/Release/.DS_Store differ
diff --git a/plugin/JuceLibraryCode/AppConfig.h b/plugin/JuceLibraryCode/AppConfig.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/JuceHeader.h b/plugin/JuceLibraryCode/JuceHeader.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/ReadMe.txt b/plugin/JuceLibraryCode/ReadMe.txt
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/SFZero/SFZero.h b/plugin/JuceLibraryCode/modules/SFZero/SFZero.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h b/plugin/JuceLibraryCode/modules/juce_audio_basics/juce_audio_basics.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h b/plugin/JuceLibraryCode/modules/juce_audio_devices/juce_audio_devices.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h b/plugin/JuceLibraryCode/modules/juce_audio_formats/juce_audio_formats.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_audio_plugin_client/juce_audio_plugin_client.h b/plugin/JuceLibraryCode/modules/juce_audio_plugin_client/juce_audio_plugin_client.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h b/plugin/JuceLibraryCode/modules/juce_audio_processors/juce_audio_processors.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.h b/plugin/JuceLibraryCode/modules/juce_audio_utils/juce_audio_utils.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_core/juce_core.h b/plugin/JuceLibraryCode/modules/juce_core/juce_core.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h b/plugin/JuceLibraryCode/modules/juce_data_structures/juce_data_structures.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_events/juce_events.h b/plugin/JuceLibraryCode/modules/juce_events/juce_events.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_graphics/juce_graphics.h b/plugin/JuceLibraryCode/modules/juce_graphics/juce_graphics.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h b/plugin/JuceLibraryCode/modules/juce_gui_basics/juce_gui_basics.h
old mode 100644
new mode 100755
diff --git a/plugin/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.h b/plugin/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.h
old mode 100644
new mode 100755
diff --git a/plugin/SFZero.jucer b/plugin/SFZero.jucer
index b34f437..ca6ee0b 100644
--- a/plugin/SFZero.jucer
+++ b/plugin/SFZero.jucer
@@ -1,116 +1,117 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugin/Source/SFZeroAudioProcessor.cpp b/plugin/Source/SFZeroAudioProcessor.cpp
index 4c7418b..5a7a999 100644
--- a/plugin/Source/SFZeroAudioProcessor.cpp
+++ b/plugin/Source/SFZeroAudioProcessor.cpp
@@ -1,13 +1,15 @@
#include "SFZeroAudioProcessor.h"
#include "SFZeroEditor.h"
+#include "SFZeroEditorList.h"
sfzero::SFZeroAudioProcessor::SFZeroAudioProcessor() : loadProgress(0.0), loadThread(this)
+//sfzero::SFZeroAudioProcessor::SFZeroAudioProcessor() : AudioProcessor (BusesProperties().withOutput ("Output", AudioChannelSet::stereo(), true)),loadProgress(0.0), loadThread(this)
{
formatManager.registerBasicFormats();
for (int i = 0; i < 128; ++i)
{
- synth.addVoice(new sfzero::Voice());
+ synth.addVoice(new sfzero::Voice(&formatManager, synth.GetCleaner()));
}
}
@@ -19,13 +21,13 @@ void sfzero::SFZeroAudioProcessor::setParameter(int /*index*/, float /*newValue*
const String sfzero::SFZeroAudioProcessor::getParameterName(int /*index*/) { return String::empty; }
const String sfzero::SFZeroAudioProcessor::getParameterText(int /*index*/) { return String::empty; }
-void sfzero::SFZeroAudioProcessor::setSfzFile(File *newSfzFile)
+void sfzero::SFZeroAudioProcessor::setSfzFile(const File *newSfzFile)
{
sfzFile = *newSfzFile;
loadSound();
}
-void sfzero::SFZeroAudioProcessor::setSfzFileThreaded(File *newSfzFile)
+void sfzero::SFZeroAudioProcessor::setSfzFileThreaded(const File *newSfzFile)
{
loadThread.stopThread(2000);
sfzFile = *newSfzFile;
@@ -36,7 +38,6 @@ bool sfzero::SFZeroAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
-
#else
return false;
#endif
@@ -46,7 +47,6 @@ bool sfzero::SFZeroAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
-
#else
return false;
#endif
@@ -84,7 +84,12 @@ bool sfzero::SFZeroAudioProcessor::hasEditor() const
return true; // (change this to false if you choose to not supply an editor)
}
-AudioProcessorEditor *sfzero::SFZeroAudioProcessor::createEditor() { return new SFZeroEditor(this); }
+AudioProcessorEditor *sfzero::SFZeroAudioProcessor::createEditor() {
+ if(SystemStats::isRunningInAppExtensionSandbox())
+ return new SFZeroEditorList(this);
+ else
+ return new SFZeroEditor(this);
+}
void sfzero::SFZeroAudioProcessor::getStateInformation(MemoryBlock &destData)
{
diff --git a/plugin/Source/SFZeroAudioProcessor.h b/plugin/Source/SFZeroAudioProcessor.h
index 7ec1f8a..8e7c8aa 100644
--- a/plugin/Source/SFZeroAudioProcessor.h
+++ b/plugin/Source/SFZeroAudioProcessor.h
@@ -32,8 +32,8 @@ class SFZeroAudioProcessor : public AudioProcessor
const String getParameterName(int index) override;
const String getParameterText(int index) override;
- void setSfzFile(File *newSfzFile);
- void setSfzFileThreaded(File *newSfzFile);
+ void setSfzFile(const File *newSfzFile);
+ void setSfzFileThreaded(const File *newSfzFile);
File getSfzFile() { return (sfzFile); }
bool acceptsMidi() const override;
@@ -54,6 +54,10 @@ class SFZeroAudioProcessor : public AudioProcessor
Sound *getSound();
int numVoicesUsed();
String voiceInfoString();
+ /*bool isBusesLayoutSupported (const BusesLayout& layouts) const override
+ {
+ return (layouts.getMainOutputChannels() == 2);
+ }*/
protected:
diff --git a/plugin/Source/SFZeroEditor.cpp b/plugin/Source/SFZeroEditor.cpp
index 8bb9949..15f3e92 100644
--- a/plugin/Source/SFZeroEditor.cpp
+++ b/plugin/Source/SFZeroEditor.cpp
@@ -1,75 +1,25 @@
#include "SFZeroEditor.h"
#include "SFZeroAudioProcessor.h"
+#include "SFZeroFolders.h"
-enum
-{
- hMargin = 12,
- vMargin = 12,
- labelHeight = 25,
- progressBarHeight = 30,
- keyboardHeight = 54,
-};
-
-sfzero::SFZeroEditor::SFZeroEditor(SFZeroAudioProcessor *ownerFilter)
- : AudioProcessorEditor(ownerFilter), fileLabel(String::empty, "File... (click here to choose)"), pathLabel(String::empty),
- showingInfo(showingSoundInfo), midiKeyboard(ownerFilter->keyboardState, MidiKeyboardComponent::horizontalKeyboard),
- progressBar(nullptr)
-{
- setSize(500, 300);
-
-#ifdef JUCE_MAC
- Font fileFont("Helvetica", 22.0, Font::bold);
- Font labelFont("Helvetica", 15.0, Font::plain);
-#else
- Font fileFont("Ariel", 22.0, Font::bold);
- Font labelFont("Ariel", 15.0, Font::plain);
-#endif
-
- addAndMakeVisible(&fileLabel);
- fileLabel.setFont(fileFont);
- fileLabel.setColour(Label::textColourId, Colours::grey);
- fileLabel.addClickListener(this);
-
- addAndMakeVisible(&pathLabel);
- pathLabel.setFont(labelFont);
- pathLabel.setColour(Label::textColourId, Colours::grey);
- pathLabel.addClickListener(this);
-
+sfzero::SFZeroEditor::SFZeroEditor(SFZeroAudioProcessor *ownerFilter) : SFZeroEditorBase(ownerFilter){
addAndMakeVisible(&viewport);
viewport.setScrollBarsShown(true, true);
viewport.setViewedComponent(&infoLabel, false);
infoLabel.setFont(labelFont);
infoLabel.setJustificationType(Justification::topLeft);
infoLabel.addClickListener(this);
-
- addAndMakeVisible(&midiKeyboard);
- midiKeyboard.setOctaveForMiddleC(4);
-
- startTimer(200);
-
- File sfzFile = ownerFilter->getSfzFile();
- if (sfzFile != File::nonexistent)
- {
- updateFile(&sfzFile);
- showSoundInfo();
- auto sound = ownerFilter->getSound();
- if (sound && (sound->numSubsounds() > 1))
- {
- showSubsound();
- }
- }
- else
- {
- showVersion();
- }
+ setSize(500, 300);
}
-sfzero::SFZeroEditor::~SFZeroEditor() { delete progressBar; }
+sfzero::SFZeroEditor::~SFZeroEditor(){
+}
-void sfzero::SFZeroEditor::paint(Graphics &g) { g.fillAll(Colours::white); }
+void sfzero::SFZeroEditor::paint(Graphics &g){
+ g.fillAll(Colours::white);
+}
-void sfzero::SFZeroEditor::resized()
-{
+void sfzero::SFZeroEditor::resized(){
int marginedWidth = getWidth() - 2 * hMargin;
fileLabel.setBounds(hMargin, vMargin, marginedWidth, labelHeight);
@@ -81,215 +31,3 @@ void sfzero::SFZeroEditor::resized()
infoLabel.setBounds(0, 0, marginedWidth, infoLabelHeight * 10);
midiKeyboard.setBounds(hMargin, keyboardTop, marginedWidth, keyboardHeight);
}
-
-void sfzero::SFZeroEditor::labelClicked(Label *clickedLabel)
-{
- if (clickedLabel == &fileLabel)
- {
- chooseFile();
- }
- else if (clickedLabel == &pathLabel)
- {
- if (showing == showingSubsound)
- {
- auto processor = getProcessor();
- auto sound = processor->getSound();
- if (sound)
- {
- PopupMenu menu;
- int selectedSubsound = sound->selectedSubsound();
- int numSubsounds = sound->numSubsounds();
- for (int i = 0; i < numSubsounds; ++i)
- {
- menu.addItem(i + 1, sound->subsoundName(i), true, (i == selectedSubsound));
- }
- int result = menu.show();
- if (result != 0)
- {
- sound->useSubsound(result - 1);
- showSubsound();
- }
- }
- }
- else if (showing == showingVersion)
- {
- showPath();
- }
- else
- {
- showVersion();
- }
- }
- else if (clickedLabel == &infoLabel)
- {
- if (showingInfo == showingSoundInfo)
- {
- showVoiceInfo();
- }
- else
- {
- showSoundInfo();
- }
- }
-}
-
-void sfzero::SFZeroEditor::timerCallback()
-{
- if (showing == showingProgress)
- {
- auto processor = getProcessor();
- if (processor->loadProgress >= 1.0)
- {
- auto sound = processor->getSound();
- if (sound && (sound->numSubsounds() > 1))
- {
- showSubsound();
- }
- else
- {
- showPath();
- }
- showSoundInfo();
- }
- }
-
- if (showingInfo == showingVoiceInfo)
- {
- showVoiceInfo();
- }
-}
-
-void sfzero::SFZeroEditor::chooseFile()
-{
- FileChooser chooser("Select an SFZ file...", File::nonexistent, "*.sfz;*.SFZ;*.sf2;*.SF2");
-
- if (chooser.browseForFileToOpen())
- {
- File sfzFile(chooser.getResult());
- setFile(&sfzFile);
- }
-}
-
-void sfzero::SFZeroEditor::setFile(File *newFile)
-{
- auto processor = getProcessor();
-
- processor->setSfzFileThreaded(newFile);
-
- updateFile(newFile);
- showProgress();
-}
-
-void sfzero::SFZeroEditor::updateFile(File *file)
-{
- fileLabel.setText(file->getFileName(), dontSendNotification);
- fileLabel.setColour(Label::textColourId, Colours::black);
- showPath();
-}
-
-void sfzero::SFZeroEditor::showSoundInfo()
-{
- auto processor = getProcessor();
- auto sound = processor->getSound();
-
- if (sound)
- {
- String info;
- auto& errors = sound->getErrors();
- if (errors.size() > 0)
- {
- info << errors.size() << " errors: \n";
- info << errors.joinIntoString("\n");
- info << "\n";
- }
- else
- {
- info << "no errors.\n\n";
- }
- auto& warnings = sound->getWarnings();
- if (warnings.size() > 0)
- {
- info << warnings.size() << " warnings: \n";
- info << warnings.joinIntoString("\n");
- }
- else
- {
- info << "no warnings.\n";
- }
- infoLabel.setText(info, dontSendNotification);
- }
- showingInfo = showingSoundInfo;
-}
-
-void sfzero::SFZeroEditor::showVoiceInfo()
-{
- auto processor = getProcessor();
-
- infoLabel.setText(processor->voiceInfoString(), dontSendNotification);
- showingInfo = showingVoiceInfo;
-}
-
-void sfzero::SFZeroEditor::showVersion()
-{
- auto date = Time::getCompilationDate();
- auto str = String::formatted("SFZero beta %d.%d.%d", date.getYear(), date.getMonth(), date.getDayOfMonth());
- pathLabel.setText(str, dontSendNotification);
- pathLabel.setColour(Label::textColourId, Colours::grey);
- hideProgress();
- showing = showingVersion;
-}
-
-void sfzero::SFZeroEditor::showPath()
-{
- auto processor = getProcessor();
- File file = processor->getSfzFile();
-
- pathLabel.setText(file.getParentDirectory().getFullPathName(), dontSendNotification);
- pathLabel.setColour(Label::textColourId, Colours::grey);
- hideProgress();
- showing = showingPath;
-}
-
-void sfzero::SFZeroEditor::showSubsound()
-{
- auto processor = getProcessor();
- auto sound = processor->getSound();
-
- if (sound == nullptr)
- {
- return;
- }
-
- pathLabel.setText(sound->subsoundName(sound->selectedSubsound()), dontSendNotification);
- pathLabel.setColour(Label::textColourId, Colours::black);
- hideProgress();
- showing = showingSubsound;
-}
-
-void sfzero::SFZeroEditor::showProgress()
-{
- auto processor = getProcessor();
-
- pathLabel.setVisible(false);
- infoLabel.setVisible(false);
- progressBar = new ProgressBar(processor->loadProgress);
- addAndMakeVisible(progressBar);
- int marginedWidth = getWidth() - 2 * hMargin;
- progressBar->setBounds(hMargin, vMargin + labelHeight, marginedWidth, progressBarHeight);
- showing = showingProgress;
-}
-
-void sfzero::SFZeroEditor::hideProgress()
-{
- if (progressBar == nullptr)
- {
- return;
- }
-
- removeChildComponent(progressBar);
- delete progressBar;
- progressBar = nullptr;
-
- pathLabel.setVisible(true);
- infoLabel.setVisible(true);
-}
diff --git a/plugin/Source/SFZeroEditor.h b/plugin/Source/SFZeroEditor.h
index c06f885..a20c8e7 100644
--- a/plugin/Source/SFZeroEditor.h
+++ b/plugin/Source/SFZeroEditor.h
@@ -4,59 +4,22 @@
#include "JuceHeader.h"
#include "ClickableLabel.h"
#include "SFZeroAudioProcessor.h"
+#include "SFZeroEditorBase.h"
namespace sfzero
{
-
-class SFZeroEditor : public AudioProcessorEditor, public Timer, public ClickableLabel::ClickListener
-{
-public:
- SFZeroEditor(SFZeroAudioProcessor *ownerFilter);
- ~SFZeroEditor();
-
- void paint(Graphics &g) override;
- void resized() override;
- void labelClicked(Label *clickedLabel) override;
- void timerCallback() override;
-
-protected:
- // pathLabel options.
- enum
- {
- showingVersion,
- showingPath,
- showingProgress,
- showingSubsound,
- };
-
- // infoLabel options.
- enum
+ class SFZeroEditor : public SFZeroEditorBase
{
- showingSoundInfo,
- showingVoiceInfo,
- };
+ public:
+ SFZeroEditor(SFZeroAudioProcessor *ownerFilter);
+ ~SFZeroEditor();
- ClickableLabel fileLabel;
- ClickableLabel pathLabel;
- ClickableLabel infoLabel;
- Viewport viewport;
- int showing, showingInfo;
- MidiKeyboardComponent midiKeyboard;
- ProgressBar *progressBar;
+ void paint(Graphics &g) override;
+ void resized() override;
- SFZeroAudioProcessor *getProcessor() const { return static_cast(getAudioProcessor()); }
- void chooseFile();
- void setFile(File *newFile);
- void updateFile(File *file);
- void showSoundInfo();
- void showVoiceInfo();
- void showVersion();
- void showPath();
- void showProgress();
- void hideProgress();
- void showSubsound();
-};
+ protected:
+ Viewport viewport;
+ };
}
-
#endif // INCLUDED_SFZEROEDITOR_H
diff --git a/plugin/Source/SFZeroEditorBase.cpp b/plugin/Source/SFZeroEditorBase.cpp
new file mode 100644
index 0000000..1632e6c
--- /dev/null
+++ b/plugin/Source/SFZeroEditorBase.cpp
@@ -0,0 +1,289 @@
+#include "SFZeroEditorBase.h"
+#include "SFZeroAudioProcessor.h"
+#include "SFZeroFolders.h"
+
+sfzero::SFZeroEditorBase::SFZeroEditorBase(SFZeroAudioProcessor *ownerFilter)
+: AudioProcessorEditor(ownerFilter), fileLabel(String::empty, "File... (click here to choose)"), pathLabel(String::empty),
+showingInfo(showingSoundInfo), midiKeyboard(ownerFilter->keyboardState, MidiKeyboardComponent::horizontalKeyboard),
+progressBar(nullptr)
+{
+ isAU = SystemStats::isRunningInAppExtensionSandbox();
+ groupFolder = SFZeroFolders::GetGroupFolder();
+
+ fileFont.setHeight(22.0);
+ fileFont.setStyleFlags(Font::bold);
+ labelFont.setHeight(15.0);
+ labelFont.setStyleFlags(Font::plain);
+#ifdef JUCE_MAC
+ fileFont.setTypefaceName("Helvetica");
+ labelFont.setTypefaceName("Helvetica");
+#else
+ fileFont.setTypefaceName("Ariel");
+ labelFont.setTypefaceName("Ariel");
+#endif
+
+ addAndMakeVisible(&midiKeyboard);
+ midiKeyboard.setOctaveForMiddleC(4);
+
+ addAndMakeVisible(&fileLabel);
+ fileLabel.setFont(fileFont);
+ fileLabel.setColour(Label::textColourId, Colours::grey);
+ fileLabel.addClickListener(this);
+
+ addAndMakeVisible(&pathLabel);
+ pathLabel.setFont(labelFont);
+ pathLabel.setColour(Label::textColourId, Colours::grey);
+ pathLabel.addClickListener(this);
+
+ startTimer(200);
+ auto processor = getProcessor();
+ File sfzFile = processor->getSfzFile();
+ if (sfzFile != File::nonexistent)
+ {
+ updateFile(&sfzFile);
+ showSoundInfo();
+ auto sound = processor->getSound();
+ if (sound && (sound->numSubsounds() > 1))
+ {
+ showSubsound();
+ }
+ }
+ else
+ {
+ showVersion();
+ }
+}
+
+sfzero::SFZeroEditorBase::~SFZeroEditorBase() {
+ delete progressBar;
+}
+
+void sfzero::SFZeroEditorBase::labelClicked(Label *clickedLabel)
+{
+ if (clickedLabel == &fileLabel)
+ {
+ chooseFile();
+ }
+ else if (clickedLabel == &pathLabel)
+ {
+ if (showing == showingSubsound)
+ {
+ auto processor = getProcessor();
+ auto sound = processor->getSound();
+ if (sound)
+ {
+ PopupMenu menu;
+ int selectedSubsound = sound->selectedSubsound();
+ int numSubsounds = sound->numSubsounds();
+ for (int i = 0; i < numSubsounds; ++i)
+ {
+ menu.addItem(i + 1, sound->subsoundName(i), true, (i == selectedSubsound));
+ }
+ int result = menu.show();
+ if (result != 0)
+ {
+ sound->useSubsound(result - 1);
+ showSubsound();
+ }
+ }
+ }
+ else if (showing == showingVersion)
+ {
+ showPath();
+ }
+ else
+ {
+ showVersion();
+ }
+ }
+ else if (clickedLabel == &infoLabel)
+ {
+ if (showingInfo == showingSoundInfo)
+ {
+ showVoiceInfo();
+ }
+ else
+ {
+ showSoundInfo();
+ }
+ }
+}
+
+void sfzero::SFZeroEditorBase::timerCallback()
+{
+ if (showing == showingProgress)
+ {
+ auto processor = getProcessor();
+ if (processor->loadProgress >= 1.0)
+ {
+ auto sound = processor->getSound();
+ if (sound && (sound->numSubsounds() > 1))
+ {
+ showSubsound();
+ }
+ else
+ {
+ showPath();
+ }
+ showSoundInfo();
+ }
+ }
+
+ if (showingInfo == showingVoiceInfo)
+ {
+ showVoiceInfo();
+ }
+}
+
+void sfzero::SFZeroEditorBase::chooseFile()
+{
+#ifdef JUCE_IOS
+ FileChooser chooser("Select an SFZ file...", File::getSpecialLocation (File::userDocumentsDirectory), "*.sfz;*.SFZ;*.sf2;*.SF2");
+#else
+ FileChooser chooser("Select an SFZ file...", File::nonexistent, "*.sfz;*.SFZ;*.sf2;*.SF2");
+#endif
+ if (chooser.browseForFileToOpen())
+ {
+ File sfzFile(chooser.getResult());
+ setFile(&sfzFile);
+ }
+}
+
+void sfzero::SFZeroEditorBase::setFile(const File *newFile)
+{
+#ifdef JUCE_IOS
+ bool result=false;
+ if(!isAU){
+ if(true){
+ File parentDir = newFile->getParentDirectory();
+ juce::String dest=groupFolder.getFullPathName()+"/"+parentDir.getFileName();
+ result=parentDir.copyDirectoryTo(dest);
+ }
+ else{
+ juce::String dest=groupFolder.getFullPathName()+"/"+newFile->getFileName();
+ result=newFile->copyFileTo(File(dest));
+ }
+ }
+#endif
+
+ auto processor = getProcessor();
+
+ processor->setSfzFileThreaded(newFile);
+
+ updateFile(newFile);
+ showProgress();
+}
+
+void sfzero::SFZeroEditorBase::updateFile(const File *file)
+{
+ fileLabel.setText(file->getFileName(), dontSendNotification);
+ fileLabel.setColour(Label::textColourId, Colours::black);
+ showPath();
+}
+
+void sfzero::SFZeroEditorBase::showSoundInfo()
+{
+ auto processor = getProcessor();
+ auto sound = processor->getSound();
+
+ if (sound)
+ {
+ String info;
+ auto& errors = sound->getErrors();
+ if (errors.size() > 0)
+ {
+ info << errors.size() << " errors: \n";
+ info << errors.joinIntoString("\n");
+ info << "\n";
+ }
+ else
+ {
+ info << "no errors.\n\n";
+ }
+ auto& warnings = sound->getWarnings();
+ if (warnings.size() > 0)
+ {
+ info << warnings.size() << " warnings: \n";
+ info << warnings.joinIntoString("\n");
+ }
+ else
+ {
+ info << "no warnings.\n";
+ }
+ infoLabel.setText(info, dontSendNotification);
+ }
+ showingInfo = showingSoundInfo;
+}
+
+void sfzero::SFZeroEditorBase::showVoiceInfo()
+{
+ auto processor = getProcessor();
+
+ infoLabel.setText(processor->voiceInfoString(), dontSendNotification);
+ showingInfo = showingVoiceInfo;
+}
+
+void sfzero::SFZeroEditorBase::showVersion()
+{
+ auto date = Time::getCompilationDate();
+ auto str = String::formatted("SFZero beta %d.%d.%d", date.getYear(), date.getMonth(), date.getDayOfMonth());
+ pathLabel.setText(str, dontSendNotification);
+ pathLabel.setColour(Label::textColourId, Colours::grey);
+ hideProgress();
+ showing = showingVersion;
+}
+
+void sfzero::SFZeroEditorBase::showPath()
+{
+ auto processor = getProcessor();
+ File file = processor->getSfzFile();
+
+ pathLabel.setText(file.getParentDirectory().getFullPathName(), dontSendNotification);
+ pathLabel.setColour(Label::textColourId, Colours::grey);
+ hideProgress();
+ showing = showingPath;
+}
+
+void sfzero::SFZeroEditorBase::showSubsound()
+{
+ auto processor = getProcessor();
+ auto sound = processor->getSound();
+
+ if (sound == nullptr)
+ {
+ return;
+ }
+
+ pathLabel.setText(sound->subsoundName(sound->selectedSubsound()), dontSendNotification);
+ pathLabel.setColour(Label::textColourId, Colours::black);
+ hideProgress();
+ showing = showingSubsound;
+}
+
+void sfzero::SFZeroEditorBase::showProgress()
+{
+ auto processor = getProcessor();
+
+ pathLabel.setVisible(false);
+ infoLabel.setVisible(false);
+ progressBar = new ProgressBar(processor->loadProgress);
+ addAndMakeVisible(progressBar);
+ int marginedWidth = getWidth() - 2 * hMargin;
+ progressBar->setBounds(hMargin, vMargin + labelHeight, marginedWidth, progressBarHeight);
+ showing = showingProgress;
+}
+
+void sfzero::SFZeroEditorBase::hideProgress()
+{
+ if (progressBar == nullptr)
+ {
+ return;
+ }
+
+ removeChildComponent(progressBar);
+ delete progressBar;
+ progressBar = nullptr;
+
+ pathLabel.setVisible(true);
+ infoLabel.setVisible(true);
+}
diff --git a/plugin/Source/SFZeroEditorBase.h b/plugin/Source/SFZeroEditorBase.h
new file mode 100644
index 0000000..3864ba6
--- /dev/null
+++ b/plugin/Source/SFZeroEditorBase.h
@@ -0,0 +1,73 @@
+#ifndef INCLUDED_SFZEROEDITORBASE_H
+#define INCLUDED_SFZEROEDITORBASE_H
+
+#include "JuceHeader.h"
+#include "ClickableLabel.h"
+#include "SFZeroAudioProcessor.h"
+
+namespace sfzero
+{
+ class SFZeroEditorBase : public AudioProcessorEditor, public Timer, public ClickableLabel::ClickListener
+ {
+ public:
+ SFZeroEditorBase(SFZeroAudioProcessor *ownerFilter);
+ ~SFZeroEditorBase();
+
+ void labelClicked(Label *clickedLabel) override;
+ void timerCallback() override;
+
+ protected:
+ // layout parameters
+ enum
+ {
+ hMargin = 12,
+ vMargin = 12,
+ labelHeight = 25,
+ progressBarHeight = 30,
+ keyboardHeight = 54,
+ };
+
+ // pathLabel options.
+ enum
+ {
+ showingVersion,
+ showingPath,
+ showingProgress,
+ showingSubsound,
+ };
+
+ // infoLabel options.
+ enum
+ {
+ showingSoundInfo,
+ showingVoiceInfo,
+ };
+
+ Font fileFont;
+ Font labelFont;
+ ClickableLabel fileLabel;
+ ClickableLabel pathLabel;
+ ClickableLabel infoLabel;
+ Viewport viewport;
+ int showing, showingInfo;
+ MidiKeyboardComponent midiKeyboard;
+ ProgressBar *progressBar;
+ bool isAU;
+ File groupFolder;
+
+ SFZeroAudioProcessor *getProcessor() const { return static_cast(getAudioProcessor()); }
+ void chooseFile();
+ void setFile(const File *newFile);
+ void updateFile(const File *file);
+ void showSoundInfo();
+ void showVoiceInfo();
+ void showVersion();
+ void showPath();
+ void showProgress();
+ void hideProgress();
+ void showSubsound();
+ };
+}
+
+
+#endif // INCLUDED_SFZEROEDITORBASE_H
diff --git a/plugin/Source/SFZeroEditorList.cpp b/plugin/Source/SFZeroEditorList.cpp
new file mode 100644
index 0000000..792c6bd
--- /dev/null
+++ b/plugin/Source/SFZeroEditorList.cpp
@@ -0,0 +1,83 @@
+#include "SFZeroEditorList.h"
+#include "SFZeroFolders.h"
+#include "SFZeroAudioProcessor.h"
+
+sfzero::SFZeroEditorList::SFZeroEditorList(SFZeroAudioProcessor *ownerFilter) : SFZeroEditorBase(ownerFilter){
+ File localFolder (File::getSpecialLocation (File::userDocumentsDirectory));
+ //File folder = getSharedResourceFolder().getParentDirectory().getChildFile("Documents");
+ if(isAU)
+ browseFolder = groupFolder;
+ else
+ browseFolder = localFolder;
+ fileFilter=new WildcardFileFilter("*.sf2;*.sfz;*.SF2;*.SFZ", "*", "Soundfonts");
+ filelistThread = new TimeSliceThread("File List");
+ directoryList = new DirectoryContentsList (fileFilter, *filelistThread);
+ directoryList->setDirectory(browseFolder, true, true);
+ filelistThread->startThread (3);
+ fileTree = new FileTreeComponent(*directoryList);
+ fileTree->setLookAndFeel(&lookAndFeel);
+ //fileTree->setRootItemVisible(true);
+ addAndMakeVisible(fileTree);
+ fileTree->addListener(this);
+
+ addAndMakeVisible(&infoLabel);
+ infoLabel.setFont(labelFont);
+ infoLabel.setJustificationType(Justification::topLeft);
+ infoLabel.addClickListener(this);
+ setSize(500, 300);
+}
+
+sfzero::SFZeroEditorList::~SFZeroEditorList(){
+ filelistThread->stopThread(1000);
+ delete filelistThread;
+ delete directoryList;
+ delete fileTree;
+ delete fileFilter;
+}
+
+void sfzero::SFZeroEditorList::paint(Graphics &g){
+ g.fillAll(Colours::grey);
+}
+
+void sfzero::SFZeroEditorList::resized()
+{
+ Rectangle area (getLocalBounds());
+ area.removeFromTop(vMargin);
+ area.removeFromBottom(vMargin);
+ area.removeFromLeft(hMargin);
+ area.removeFromRight(hMargin);
+ fileLabel.setBounds(area.removeFromTop(labelHeight));
+ pathLabel.setBounds(area.removeFromTop(labelHeight));
+ infoLabel.setBounds(area.removeFromTop(labelHeight));
+ midiKeyboard.setBounds (area.removeFromBottom (keyboardHeight));
+ fileTree->setBounds(area);
+}
+
+File sfzero::SFZeroEditorList::getSharedResourceFolder()
+{
+ File bundle = File::getSpecialLocation (File::invokedExecutableFile).getParentDirectory();
+
+ // macOS uses Contents/MacOS structrue, iOS bundle structure is flat
+#if JUCE_MAC
+ bundle = bundle.getParentDirectory().getParentDirectory();
+#endif
+
+ // appex is in a PlugIns folder inside the parent bundle
+ if (SystemStats::isRunningInAppExtensionSandbox())
+ bundle = bundle.getParentDirectory().getParentDirectory();
+
+#if JUCE_MAC
+ bundle = bundle.getChildFile ("Resources");
+#endif
+
+ return bundle;
+}
+
+void sfzero::SFZeroEditorList::selectionChanged(){}
+void sfzero::SFZeroEditorList::fileClicked (const File& file, const MouseEvent& e){}
+void sfzero::SFZeroEditorList::fileDoubleClicked (const File& file){
+ String ext = file.getFileExtension();
+ if(ext==".sf2" || ext==".SF2" || ext==".sfz" || ext==".SFZ")
+ setFile(&file);
+}
+void sfzero::SFZeroEditorList::browserRootChanged (const File& newRoot){}
diff --git a/plugin/Source/SFZeroEditorList.h b/plugin/Source/SFZeroEditorList.h
new file mode 100644
index 0000000..819de0b
--- /dev/null
+++ b/plugin/Source/SFZeroEditorList.h
@@ -0,0 +1,43 @@
+#ifndef INCLUDED_SFZEROEDITORLIST_H
+#define INCLUDED_SFZEROEDITORLIST_H
+
+#include "JuceHeader.h"
+#include "ClickableLabel.h"
+#include "SFZeroAudioProcessor.h"
+#include "SFZeroFileBrowserLookAndFeel.h"
+#include "SFZeroEditorBase.h"
+
+namespace sfzero
+{
+
+ class SFZeroEditorList : public SFZeroEditorBase, public FileBrowserListener
+ {
+ public:
+ SFZeroEditorList(SFZeroAudioProcessor *ownerFilter);
+ ~SFZeroEditorList();
+
+ void paint(Graphics &g) override;
+ void resized() override;
+ /** Callback when the user selects a different file in the browser. */
+ void selectionChanged() override;
+ /** Callback when the user clicks on a file in the browser. */
+ void fileClicked (const File& file, const MouseEvent& e) override;
+ /** Callback when the user double-clicks on a file in the browser. */
+ void fileDoubleClicked (const File& file) override;
+ /** Callback when the browser's root folder changes. */
+ void browserRootChanged (const File& newRoot) override;
+
+ protected:
+ DirectoryContentsList *directoryList;
+ TimeSliceThread *filelistThread;
+ FileTreeComponent *fileTree;
+ SFZeroFileBrowserLookAndFeel lookAndFeel;
+ File getSharedResourceFolder();
+ File browseFolder;
+ WildcardFileFilter* fileFilter;
+
+ };
+}
+
+
+#endif // INCLUDED_SFZEROEDITORLIST_H
diff --git a/plugin/Source/SFZeroFileBrowserLookAndFeel.cpp b/plugin/Source/SFZeroFileBrowserLookAndFeel.cpp
new file mode 100644
index 0000000..4800ac0
--- /dev/null
+++ b/plugin/Source/SFZeroFileBrowserLookAndFeel.cpp
@@ -0,0 +1,30 @@
+/*
+ ==============================================================================
+
+ SFZeroFileBrowserLookAndFeel.cpp
+ Created: 28 Nov 2017 7:47:28pm
+ Author: malcolm
+
+ ==============================================================================
+*/
+
+#include "SFZeroFileBrowserLookAndFeel.h"
+sfzero::SFZeroFileBrowserLookAndFeel::SFZeroFileBrowserLookAndFeel(){
+}
+
+sfzero::SFZeroFileBrowserLookAndFeel::~SFZeroFileBrowserLookAndFeel(){
+}
+
+void sfzero::SFZeroFileBrowserLookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height,
+ const File& file, const String& filename, Image* icon,
+ const String& fileSizeDescription,
+ const String& fileTimeDescription,
+ bool isDirectory, bool isItemSelected,
+ int itemIndex, DirectoryContentsDisplayComponent& dcc){
+ LookAndFeel_V4::drawFileBrowserRow (g, width, height,
+ file, filename, icon,
+ "",
+ "",
+ isDirectory, isItemSelected,
+ itemIndex, dcc);
+}
diff --git a/plugin/Source/SFZeroFileBrowserLookAndFeel.h b/plugin/Source/SFZeroFileBrowserLookAndFeel.h
new file mode 100644
index 0000000..6d50a97
--- /dev/null
+++ b/plugin/Source/SFZeroFileBrowserLookAndFeel.h
@@ -0,0 +1,27 @@
+/*
+ ==============================================================================
+
+ SFZeroFileBrowserLookAndFeel.h
+ Created: 28 Nov 2017 7:47:28pm
+ Author: malcolm
+
+ ==============================================================================
+*/
+
+#pragma once
+#include "JuceHeader.h"
+namespace sfzero
+{
+
+ class SFZeroFileBrowserLookAndFeel : public LookAndFeel_V4
+ {
+ public:
+ SFZeroFileBrowserLookAndFeel();
+ ~SFZeroFileBrowserLookAndFeel();
+ void drawFileBrowserRow (Graphics&, int width, int height,
+ const File& file, const String& filename, Image* icon,
+ const String& fileSizeDescription, const String& fileTimeDescription,
+ bool isDirectory, bool isItemSelected, int itemIndex,
+ DirectoryContentsDisplayComponent&) override;
+ };
+}
diff --git a/plugin/Source/SFZeroFolders.h b/plugin/Source/SFZeroFolders.h
new file mode 100644
index 0000000..23761c9
--- /dev/null
+++ b/plugin/Source/SFZeroFolders.h
@@ -0,0 +1,16 @@
+#pragma once
+#include "JuceHeader.h"
+
+namespace sfzero
+{
+
+ class SFZeroFolders
+ {
+ public:
+ SFZeroFolders();
+ ~SFZeroFolders();
+ static File GetGroupFolder();
+ protected:
+ };
+}
+
diff --git a/plugin/Source/SFZeroFolders.mm b/plugin/Source/SFZeroFolders.mm
new file mode 100644
index 0000000..8d978ee
--- /dev/null
+++ b/plugin/Source/SFZeroFolders.mm
@@ -0,0 +1,17 @@
+#include "SFZeroFolders.h"
+#include "Foundation/NSFileManager.h"
+#include "Foundation/NSString.h"
+
+sfzero::SFZeroFolders::SFZeroFolders(){
+};
+
+sfzero::SFZeroFolders::~SFZeroFolders(){
+}
+
+ File sfzero::SFZeroFolders::GetGroupFolder(){
+ NSFileManager* fm = [NSFileManager defaultManager];
+ NSURL *containerURL = [fm containerURLForSecurityApplicationGroupIdentifier:@"group.com.vsamp.SFZero"];
+ String tmp = ([containerURL.relativeString UTF8String]);
+ File startDir(tmp.substring(7));
+ return(startDir);
+}