sfizz/vst/SfizzVstEditor.h

79 lines
2.4 KiB
C
Raw Normal View History

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"
2020-08-29 04:54:18 +02:00
#include "editor/EditorController.h"
2020-03-05 11:16:47 +01:00
#include "public.sdk/source/vst/vstguieditor.h"
2020-11-24 07:24:24 +01:00
#include <mutex>
2020-08-29 04:54:18 +02:00
class Editor;
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;
2020-10-19 02:58:01 +02:00
class SfizzVstEditor : public Vst::VSTGUIEditor,
public EditorController {
2020-03-05 11:16:47 +01:00
public:
2020-11-24 07:24:24 +01:00
explicit SfizzVstEditor(SfizzVstController* controller);
2020-03-05 11:16:47 +01:00
~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-12 00:41:35 +01:00
// VSTGUIEditor
CMessageResult notify(CBaseObject* sender, const char* message) override;
2020-11-24 07:24:24 +01:00
//
void updateState(const SfizzVstState& state);
void updateUiState(const SfizzUiState& uiState);
void updatePlayState(const SfizzPlayState& playState);
SfizzUiState getCurrentUiState() const;
void receiveMessage(const void* data, uint32_t size);
2020-10-19 02:58:01 +02:00
2020-08-29 04:54:18 +02:00
protected:
// EditorController
void uiSendValue(EditId id, const EditValue& v) override;
void uiBeginSend(EditId id) override;
void uiEndSend(EditId id) override;
2020-10-14 20:04:59 +02:00
void uiSendMIDI(const uint8_t* data, uint32_t len) override;
2020-10-19 02:58:01 +02:00
void uiSendMessage(const char* path, const char* sig, const sfizz_arg_t* args) override;
2020-08-29 04:54:18 +02:00
2020-03-05 11:16:47 +01:00
private:
void loadSfzFile(const std::string& filePath);
2020-06-20 05:49:00 +02:00
void loadScalaFile(const std::string& filePath);
2020-03-05 11:16:47 +01:00
void updateStateDisplay();
2020-08-29 04:54:18 +02:00
Vst::ParamID parameterOfEditId(EditId id);
2020-03-12 00:41:35 +01:00
2020-08-29 04:54:18 +02:00
std::unique_ptr<Editor> editor_;
2020-08-12 19:23:50 +02:00
2020-03-12 00:41:35 +01:00
#if !defined(__APPLE__) && !defined(_WIN32)
SharedPointer<RunLoop> _runLoop;
#endif
2020-10-19 02:58:01 +02:00
// messaging
std::unique_ptr<uint8[]> oscTemp_;
2020-11-24 07:24:24 +01:00
// editor state
// note: might be updated from a non-UI thread
mutable std::recursive_mutex stateMutex_;
SfizzVstState state_;
SfizzUiState uiState_;
SfizzPlayState playState_;
volatile bool mustRedisplayState_ = false;
volatile bool mustRedisplayUiState_ = false;
volatile bool mustRedisplayPlayState_ = false;
2020-03-05 11:16:47 +01:00
};