Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified plugin/Builds/Linux/Makefile
100644 → 100755
Empty file.
Empty file modified plugin/Builds/MacOSX/Info.plist
100644 → 100755
Empty file.
Empty file modified plugin/Builds/MacOSX/RecentFilesMenuTemplate.nib
100644 → 100755
Empty file.
Empty file modified plugin/Builds/MacOSX/SFZero.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file modified plugin/Builds/VisualStudio2015/SFZero.sln
100644 → 100755
Empty file.
Empty file modified plugin/Builds/VisualStudio2015/SFZero.vcxproj
100644 → 100755
Empty file.
Empty file modified plugin/Builds/VisualStudio2015/SFZero.vcxproj.filters
100644 → 100755
Empty file.
Empty file modified plugin/Builds/VisualStudio2015/SFZero.vcxproj.user
100644 → 100755
Empty file.
Empty file modified plugin/Builds/VisualStudio2015/resources.rc
100644 → 100755
Empty file.
Binary file added plugin/Builds/iOS/build/Debug/.DS_Store
Binary file not shown.
Binary file added plugin/Builds/iOS/build/Release/.DS_Store
Binary file not shown.
Empty file modified plugin/JuceLibraryCode/AppConfig.h
100644 → 100755
Empty file.
Empty file modified plugin/JuceLibraryCode/JuceHeader.h
100644 → 100755
Empty file.
Empty file modified plugin/JuceLibraryCode/ReadMe.txt
100644 → 100755
Empty file.
Empty file modified plugin/JuceLibraryCode/modules/SFZero/SFZero.h
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified plugin/JuceLibraryCode/modules/juce_core/juce_core.h
100644 → 100755
Empty file.
Empty file.
Empty file modified plugin/JuceLibraryCode/modules/juce_events/juce_events.h
100644 → 100755
Empty file.
Empty file modified plugin/JuceLibraryCode/modules/juce_graphics/juce_graphics.h
100644 → 100755
Empty file.
Empty file.
Empty file modified plugin/JuceLibraryCode/modules/juce_gui_extra/juce_gui_extra.h
100644 → 100755
Empty file.
233 changes: 117 additions & 116 deletions plugin/SFZero.jucer

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions plugin/Source/SFZeroAudioProcessor.cpp
Original file line number Diff line number Diff line change
@@ -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()));
}
}

Expand All @@ -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;
Expand All @@ -36,7 +38,6 @@ bool sfzero::SFZeroAudioProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;

#else
return false;
#endif
Expand All @@ -46,7 +47,6 @@ bool sfzero::SFZeroAudioProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;

#else
return false;
#endif
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 6 additions & 2 deletions plugin/Source/SFZeroAudioProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:

Expand Down
280 changes: 9 additions & 271 deletions plugin/Source/SFZeroEditor.cpp
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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);
}
Loading