2020-03-05 11:16:47 +01:00
|
|
|
// SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
|
|
|
|
|
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
|
|
|
|
// license. You should have receive a LICENSE.md file along with the code.
|
|
|
|
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
#include "SfizzVstController.h"
|
|
|
|
|
#include "public.sdk/source/vst/vstguieditor.h"
|
2020-03-12 00:41:35 +01:00
|
|
|
#if !defined(__APPLE__) && !defined(_WIN32)
|
|
|
|
|
namespace VSTGUI { class RunLoop; }
|
|
|
|
|
#endif
|
2020-03-05 11:16:47 +01:00
|
|
|
|
|
|
|
|
using namespace Steinberg;
|
|
|
|
|
using namespace VSTGUI;
|
|
|
|
|
|
|
|
|
|
class SfizzVstEditor : public Vst::VSTGUIEditor, public IControlListener, public SfizzVstController::StateListener {
|
|
|
|
|
public:
|
|
|
|
|
explicit SfizzVstEditor(void *controller);
|
|
|
|
|
~SfizzVstEditor();
|
|
|
|
|
|
|
|
|
|
bool PLUGIN_API open(void* parent, const VSTGUI::PlatformType& platformType = VSTGUI::kDefaultNative) override;
|
|
|
|
|
void PLUGIN_API close() override;
|
|
|
|
|
|
2020-03-05 18:21:46 +01:00
|
|
|
SfizzVstController* getController() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<SfizzVstController*>(Vst::VSTGUIEditor::getController());
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-05 11:16:47 +01:00
|
|
|
// IControlListener
|
|
|
|
|
void valueChanged(CControl* ctl) override;
|
2020-03-05 18:21:46 +01:00
|
|
|
void enterOrLeaveEdit(CControl* ctl, bool enter);
|
|
|
|
|
void controlBeginEdit(CControl* ctl) override;
|
|
|
|
|
void controlEndEdit(CControl* ctl) override;
|
2020-03-05 11:16:47 +01:00
|
|
|
|
2020-03-12 00:41:35 +01:00
|
|
|
// VSTGUIEditor
|
|
|
|
|
CMessageResult notify(CBaseObject* sender, const char* message) override;
|
|
|
|
|
|
2020-03-05 11:16:47 +01:00
|
|
|
// SfizzVstController::StateListener
|
|
|
|
|
void onStateChanged() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void chooseSfzFile();
|
|
|
|
|
void loadSfzFile(const std::string& filePath);
|
|
|
|
|
|
|
|
|
|
void createFrameContents();
|
|
|
|
|
void updateStateDisplay();
|
2020-03-05 16:41:59 +01:00
|
|
|
void setActivePanel(unsigned panelId);
|
|
|
|
|
|
2020-03-05 18:21:46 +01:00
|
|
|
template <class Control>
|
|
|
|
|
void adjustMinMaxToRangeParam(Control* c, Vst::ParamID id)
|
|
|
|
|
{
|
|
|
|
|
auto* p = static_cast<Vst::RangeParameter*>(getController()->getParameterObject(id));
|
|
|
|
|
c->setMin(p->getMin());
|
|
|
|
|
c->setMax(p->getMax());
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-05 16:41:59 +01:00
|
|
|
enum {
|
|
|
|
|
kPanelGeneral,
|
|
|
|
|
// kPanelControls,
|
|
|
|
|
kPanelSettings,
|
|
|
|
|
kNumPanels,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
unsigned _activePanel = 0;
|
|
|
|
|
CViewContainer* _subPanels[kNumPanels] = {};
|
2020-03-05 11:16:47 +01:00
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
kTagLoadSfzFile,
|
2020-03-05 18:21:46 +01:00
|
|
|
kTagSetVolume,
|
2020-03-06 11:46:49 +01:00
|
|
|
kTagSetNumVoices,
|
2020-03-06 11:55:52 +01:00
|
|
|
kTagSetOversampling,
|
2020-03-06 13:15:32 +01:00
|
|
|
kTagSetPreloadSize,
|
2020-03-05 16:41:59 +01:00
|
|
|
kTagFirstChangePanel,
|
|
|
|
|
kTagLastChangePanel = kTagFirstChangePanel + kNumPanels - 1,
|
2020-03-05 11:16:47 +01:00
|
|
|
};
|
|
|
|
|
|
2020-03-05 15:53:01 +01:00
|
|
|
CBitmap _logo;
|
2020-03-05 11:16:47 +01:00
|
|
|
CTextLabel* _fileLabel = nullptr;
|
2020-03-05 18:21:46 +01:00
|
|
|
CSliderBase *_volumeSlider = nullptr;
|
2020-03-06 11:46:49 +01:00
|
|
|
CSliderBase *_numVoicesSlider = nullptr;
|
2020-03-06 11:55:52 +01:00
|
|
|
CSliderBase *_oversamplingSlider = nullptr;
|
2020-03-06 13:15:32 +01:00
|
|
|
CSliderBase *_preloadSizeSlider = nullptr;
|
2020-03-12 00:41:35 +01:00
|
|
|
|
|
|
|
|
#if !defined(__APPLE__) && !defined(_WIN32)
|
|
|
|
|
SharedPointer<RunLoop> _runLoop;
|
|
|
|
|
#endif
|
2020-03-05 11:16:47 +01:00
|
|
|
};
|