Skip to content

Commit

Permalink
another merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dantrueman committed Nov 15, 2024
2 parents cbd7266 + fcf3619 commit 4775fb2
Show file tree
Hide file tree
Showing 15 changed files with 155 additions and 73 deletions.
7 changes: 6 additions & 1 deletion source/common/Identifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace IDs
DECLARE_ID (INPUT)
DECLARE_ID (OUTPUT)
DECLARE_ID (PIANO)

DECLARE_ID (GLOBALPIANOSAMPLES)
DECLARE_ID (PREPARATIONS)

DECLARE_ID (name)
Expand Down Expand Up @@ -51,6 +51,11 @@ namespace IDs
DECLARE_ID (midiDeviceId)
DECLARE_ID(active)
DECLARE_ID(midiPrefs)
DECLARE_ID(mainSampleSet)
DECLARE_ID(hammerSampleSet)
DECLARE_ID(releaseResonanceSampleSet)
DECLARE_ID(pedalSampleSet)

}

#undef DECLARE_ID
Expand Down
2 changes: 2 additions & 0 deletions source/common/synth_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ SynthBase::SynthBase(juce::AudioDeviceManager * deviceManager) : expired_(false)

Startup::doStartupChecks();
tree = juce::ValueTree(IDs::GALLERY);
tree.setProperty(IDs::mainSampleSet,"Piano (Default)",nullptr);
tree.addListener(this);
}

Expand Down Expand Up @@ -161,6 +162,7 @@ bool SynthBase::loadFromValueTree(const juce::ValueTree& state)
pauseProcessing(true);
engine_->allSoundsOff();
tree.copyPropertiesAndChildrenFrom(state, nullptr);

pauseProcessing(false);
DBG("unpause processing");
if (tree.isValid())
Expand Down
5 changes: 4 additions & 1 deletion source/common/synth_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class SynthBase : public MidiManager::Listener, public juce::ValueTree::Listener

SynthBase(juce::AudioDeviceManager* ={});
virtual ~SynthBase();

// void updateMainSoundSets( juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>* s, // main samples
// juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>* h, // hammer samples
// juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>* r, // release samples
// juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>* p);

void valueChanged(const std::string& name, bitklavier::mono_float value);
void valueChangedThroughMidi(const std::string& name, bitklavier::mono_float value) override;
Expand Down
10 changes: 7 additions & 3 deletions source/common/synth_gui_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SynthGuiData::SynthGuiData(SynthBase* synth_base) : synth(synth_base),
{
//tree = mainSynth->getValueTree();
// um = synth_base->getUndoManager();
//sampleLoadManager->loadSamples(0, true);
}
#if HEADLESS

Expand Down Expand Up @@ -64,7 +65,7 @@ SynthGuiInterface::SynthGuiInterface(SynthBase* synth, bool use_gui) : synth_(sy
gui_ = std::make_unique<FullInterface>(&synth_data);
}
sampleLoadManager->preferences = userPreferences->userPreferences.get();

//sampleLoadManager->loadSamples(0, true);
}

SynthGuiInterface::~SynthGuiInterface() { }
Expand Down Expand Up @@ -102,14 +103,17 @@ void SynthGuiInterface::updateGuiControl(const std::string& name, bitklavier::mo
//}

//void SynthGuiInterface::connectModulation(bitklavier::ModulationConnection* connection) {
// synth_->connectModulation(connection);
// synth_->connecotModulation(connection);
// notifyModulationsChanged();
//}





bool SynthGuiInterface::loadFromFile(juce::File preset, std::string &error) {
return getSynth()->loadFromFile(preset,error);
//sampleLoadManager->loadSamples()
}


void SynthGuiInterface::setFocus() {
Expand Down
1 change: 1 addition & 0 deletions source/common/synth_gui_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class SynthGuiInterface {
void openSaveDialog();
void externalPresetLoaded(juce::File preset);
void setGuiSize(float scale);
bool loadFromFile(juce::File preset, std::string& error);
FullInterface* getGui() { return gui_.get(); }
OpenGlWrapper* getOpenGlWrapper();
std::shared_ptr<UserPreferencesWrapper> userPreferences;
Expand Down
19 changes: 14 additions & 5 deletions source/interface/ConstructionSite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,17 @@ PreparationSection* ConstructionSite::createNewObject (const juce::ValueTree& v)
s->setSizeRatio (size_ratio_);
s->setCentrePosition (s->x, s->y);
s->setSize (s->width, s->height);
s->addSoundSet (
parent->sampleLoadManager->globalSoundset,
parent->sampleLoadManager->globalHammersSoundset,
parent->sampleLoadManager->globalReleaseResonanceSoundset,
parent->sampleLoadManager->globalPedalsSoundset);


s->addSoundSet(&parent->sampleLoadManager->samplerSoundset);
if(!parent->sampleLoadManager->samplerSoundset.empty())
{
s->addSoundSet (
&parent->sampleLoadManager->samplerSoundset[parent->sampleLoadManager->globalSoundset_name],
&parent->sampleLoadManager->samplerSoundset[parent->sampleLoadManager->globalHammersSoundset_name],
&parent->sampleLoadManager->samplerSoundset[parent->sampleLoadManager->globalReleaseResonanceSoundset_name],
&parent->sampleLoadManager->samplerSoundset[parent->sampleLoadManager->globalPedalsSoundset_name]);
}
s->selectedSet = &(preparationSelector.getLassoSelection());
preparationSelector.getLassoSelection().addChangeListener (s);
s->addListener (&cableView);
Expand Down Expand Up @@ -125,7 +131,10 @@ void ConstructionSite::newObjectAdded (PreparationSection* object)
SynthGuiInterface* parent = findParentComponentOfClass<SynthGuiInterface>();
parent->getSynth()->processorInitQueue.try_enqueue ([this, object] {
SynthGuiInterface* _parent = findParentComponentOfClass<SynthGuiInterface>();
if(auto listener = dynamic_cast<juce::ValueTree::Listener*>(object->getProcessor()))
_parent->sampleLoadManager->t.addListener(listener);
object->setNodeInfo (_parent->getSynth()->addProcessor (std::move (object->getProcessorPtr()), object->pluginID));

//changelistener callback is causing timing errors here.

//last_proc.reset();
Expand Down
2 changes: 1 addition & 1 deletion source/interface/Preparations/DirectPreparation.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class DirectPreparation : public PreparationSection
// }
// Public function definitions for the DirectPreparation class, which override functions
// in the PreparationSection base class
void addSoundSet(juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>* s) override
void addSoundSet(std::map<juce::String, juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>>* s) override
{
proc.addSoundSet(s);
}
Expand Down
2 changes: 1 addition & 1 deletion source/interface/Preparations/PreparationSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class PreparationSection : public SynthSection, public BKItem::Listener, public
// Destructor Declaration
~PreparationSection();

virtual void addSoundSet(juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>* s) {}
virtual void addSoundSet(std::map<juce::String, juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>>* s) {}
virtual void addSoundSet(
juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>* s,
juce::ReferenceCountedArray<BKSamplerSound<juce::AudioFormatReader>>* h,
Expand Down
31 changes: 17 additions & 14 deletions source/interface/header_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ LogoSection::LogoSection() : SynthSection("logo_section") {

setSkinOverride(Skin::kLogo);
}
namespace string_constants{

// i think the sample library menu should be autopopulated by subfolders in the samples folder
// and also by whatever other folders the user specifies in preferences for storing samples
// including SoundFonts
static const std::vector<std::string> cBKSampleLoadTypes = {
"Piano (Default)",
"Library 2",
"Library 3",
"Library 4"
};

};

void LogoSection::resized() {
int logo_padding_y = kLogoPaddingY * size_ratio_;
Expand Down Expand Up @@ -71,10 +84,12 @@ HeaderSection::HeaderSection() : SynthSection("header_section"), tab_offset_(0),
sampleSelector->addListener(this);
sampleSelector->setTriggeredOnMouseDown(true);
sampleSelector->setShape(juce::Path(), true, true, true);

// sampleSelector->triggerClick();
currentSampleType = 0;
sampleSelectText = std::make_shared<PlainTextComponent>("Sample Select Text", "---");
addOpenGlComponent(sampleSelectText);
//parent->sampleLoadManager->loadSamples(selection, true);
sampleSelectText->setText(string_constants::cBKSampleLoadTypes[currentSampleType]);

saveButton = std::make_unique<OpenGlTextButton>("header_save");
addOpenGlComponent(saveButton->getGlComponent());
Expand Down Expand Up @@ -256,19 +271,7 @@ void HeaderSection::reset() {
//// oscilloscope_->setVisible(!view_spectrogram);
//// spectrogram_->setVisible(view_spectrogram);
//}
namespace string_constants{

// i think the sample library menu should be autopopulated by subfolders in the samples folder
// and also by whatever other folders the user specifies in preferences for storing samples
// including SoundFonts
static const std::vector<std::string> cBKSampleLoadTypes = {
"Piano (Default)",
"Library 2",
"Library 3",
"Library 4"
};

};
void HeaderSection::buttonClicked(juce::Button* clicked_button) {
if (clicked_button == exit_temporary_button_.get()) {
// for (Listener* listener : listeners_)
Expand Down Expand Up @@ -316,7 +319,7 @@ void HeaderSection::buttonClicked(juce::Button* clicked_button) {
SynthGuiInterface* _parent = findParentComponentOfClass<SynthGuiInterface>();
std::string error;
juce::File choice = fc.getResult();
if (!_parent->getSynth()->loadFromFile(choice, error)) {
if (!_parent->loadFromFile(choice, error)) {
// std::string name = ProjectInfo::projectName;
// error = "There was an error open the preset. " + error;
//juce::AlertWindow::showMessageBoxAsync(MessageBoxIconType::WarningIcon, "PRESET ERROR, ""Error opening preset", error);
Expand Down
Loading

0 comments on commit 4775fb2

Please sign in to comment.