amuse/VST/VSTBackend.hpp

72 lines
2.4 KiB
C++
Raw Normal View History

2018-10-06 20:40:25 -07:00
#pragma once
2016-06-09 14:33:26 -07:00
2016-06-10 17:47:02 -07:00
#include "audioeffectx.h"
2016-06-09 14:33:26 -07:00
#include "VSTEditor.hpp"
#include <memory>
2019-06-11 19:02:52 -07:00
#include <optional>
2016-06-09 14:33:26 -07:00
#include "amuse/BooBackend.hpp"
#include "amuse/Engine.hpp"
#include "amuse/IBackendVoice.hpp"
#include "amuse/IBackendSubmix.hpp"
#include "amuse/IBackendVoiceAllocator.hpp"
#include "AudioGroupFilePresenter.hpp"
2016-06-09 14:33:26 -07:00
2018-12-07 21:20:09 -08:00
namespace amuse {
2016-06-09 14:33:26 -07:00
class VSTBackend;
/** Backend voice allocator implementation for AudioUnit mixer */
2018-12-07 21:20:09 -08:00
class VSTBackendVoiceAllocator : public BooBackendVoiceAllocator {
2016-06-09 14:33:26 -07:00
public:
2018-12-07 21:20:09 -08:00
VSTBackendVoiceAllocator(boo::IAudioVoiceEngine& booEngine) : BooBackendVoiceAllocator(booEngine) {}
2016-06-09 14:33:26 -07:00
};
/** Actual plugin implementation class */
2018-12-07 21:20:09 -08:00
class VSTBackend : public AudioEffectX {
std::mutex m_lock;
std::unique_ptr<boo::IAudioVoiceEngine> m_booBackend;
2019-06-11 19:02:52 -07:00
std::optional<amuse::VSTBackendVoiceAllocator> m_voxAlloc;
std::optional<amuse::Engine> m_engine;
2018-12-07 21:20:09 -08:00
std::shared_ptr<amuse::Sequencer> m_curSeq;
int m_reqGroup = -1;
int m_curGroup = -1;
const AudioGroupDataCollection* m_curData = nullptr;
size_t m_curFrame = 0;
std::wstring m_userDir;
int m_routeChannel = -1;
AudioGroupFilePresenter m_filePresenter;
VSTEditor m_editor;
2016-07-13 21:54:46 -07:00
2016-06-09 14:33:26 -07:00
public:
2018-12-07 21:20:09 -08:00
VSTBackend(audioMasterCallback cb);
~VSTBackend();
AEffEditor* getEditor();
VstInt32 processEvents(VstEvents* events);
void processReplacing(float** inputs, float** outputs, VstInt32 sampleFrames);
VstInt32 canDo(char* text);
VstPlugCategory getPlugCategory();
bool getEffectName(char* text);
bool getProductString(char* text);
bool getVendorString(char* text);
bool getProgramNameIndexed(VstInt32 category, VstInt32 index, char* text);
bool getOutputProperties(VstInt32 index, VstPinProperties* properties);
VstInt32 getNumMidiInputChannels();
void setSampleRate(float sampleRate);
void setBlockSize(VstInt32 blockSize);
2018-12-07 21:20:09 -08:00
amuse::Engine& getAmuseEngine() { return *m_engine; }
std::wstring_view getUserDir() const { return m_userDir; }
AudioGroupFilePresenter& getFilePresenter() { return m_filePresenter; }
2018-12-07 21:20:09 -08:00
void loadGroupFile(int collectionIdx, int fileIdx);
void setGroup(int groupIdx, bool immediate);
void _setNormalProgram(int programNo);
void setNormalProgram(int programNo);
void _setDrumProgram(int programNo);
void setDrumProgram(int programNo);
2016-06-14 01:04:37 -07:00
2018-12-07 21:20:09 -08:00
VstInt32 getChunk(void** data, bool isPreset);
VstInt32 setChunk(void* data, VstInt32 byteSize, bool isPreset);
2016-06-09 14:33:26 -07:00
};
2018-12-07 21:20:09 -08:00
} // namespace amuse