plugin host新增ui buffer, 将ui_buffer_type移到circular_audio_buffer.h中
This commit is contained in:
parent
191f90de6d
commit
62162fad92
@ -46,10 +46,22 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
circular_audio_buffer(uint32_t InCapacity) {
|
explicit circular_audio_buffer(uint32_t InCapacity) {
|
||||||
SetCapacity(InCapacity);
|
SetCapacity(InCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move
|
||||||
|
circular_audio_buffer(circular_audio_buffer&& InOther) noexcept {
|
||||||
|
InternalBuffer = std::move(InOther.InternalBuffer);
|
||||||
|
Capacity = InOther.Capacity;
|
||||||
|
ReadCounter.store(InOther.ReadCounter);
|
||||||
|
WriteCounter.store(InOther.WriteCounter);
|
||||||
|
|
||||||
|
InOther.Capacity = 0;
|
||||||
|
InOther.ReadCounter = 0;
|
||||||
|
InOther.WriteCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Reset(uint32_t InCapacity = 0) {
|
void Reset(uint32_t InCapacity = 0) {
|
||||||
SetCapacity(InCapacity);
|
SetCapacity(InCapacity);
|
||||||
}
|
}
|
||||||
@ -276,5 +288,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using ui_buffer_type = circular_audio_buffer<float>;
|
||||||
|
using ui_buffer_vector_type = std::vector<ui_buffer_type>;
|
||||||
|
|
||||||
#undef checkf
|
#undef checkf
|
||||||
#undef check
|
#undef check
|
@ -20,9 +20,6 @@ struct mixer_track_link {
|
|||||||
|
|
||||||
class mixer_track {
|
class mixer_track {
|
||||||
public:
|
public:
|
||||||
using ui_buffer_type = circular_audio_buffer<float>;
|
|
||||||
using ui_buffer_vector_type = std::vector<ui_buffer_type>;
|
|
||||||
|
|
||||||
explicit mixer_track(mixer_track_type in_type) : type_(in_type) {
|
explicit mixer_track(mixer_track_type in_type) : type_(in_type) {
|
||||||
ui_buffers = std::make_shared<ui_buffer_vector_type>();
|
ui_buffers = std::make_shared<ui_buffer_vector_type>();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,16 @@ plugin_host::~plugin_host() {
|
|||||||
delete channel;
|
delete channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void plugin_host::on_update_buffer_size(int buffer_size)
|
||||||
|
{
|
||||||
|
ui_buffers = std::make_shared<ui_buffer_vector_type>();
|
||||||
|
for (uint32_t i = 0; i < get_output_channels(); i++)
|
||||||
|
{
|
||||||
|
ui_buffer_type buffer(buffer_size * 3);
|
||||||
|
ui_buffers->emplace_back(std::move(buffer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void plugin_host::try_open_editor() {
|
void plugin_host::try_open_editor() {
|
||||||
if (!has_editor())
|
if (!has_editor())
|
||||||
return;
|
return;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
#include "audio/misc/circular_audio_buffer.h"
|
||||||
#include "misc/delegates.h"
|
#include "misc/delegates.h"
|
||||||
|
|
||||||
class mixer_track;
|
class mixer_track;
|
||||||
@ -19,7 +20,7 @@ public:
|
|||||||
[[nodiscard]] virtual bool is_enabled() const = 0;
|
[[nodiscard]] virtual bool is_enabled() const = 0;
|
||||||
|
|
||||||
virtual void on_update_sample_rate(double sample_rate) = 0;
|
virtual void on_update_sample_rate(double sample_rate) = 0;
|
||||||
virtual void on_update_buffer_size(int buffer_size) = 0;
|
virtual void on_update_buffer_size(int buffer_size);
|
||||||
[[nodiscard]] virtual uint32_t get_input_channels() const = 0;
|
[[nodiscard]] virtual uint32_t get_input_channels() const = 0;
|
||||||
[[nodiscard]] virtual uint32_t get_output_channels() const = 0;
|
[[nodiscard]] virtual uint32_t get_output_channels() const = 0;
|
||||||
virtual void update_channel_node_name() {}
|
virtual void update_channel_node_name() {}
|
||||||
@ -46,6 +47,7 @@ public:
|
|||||||
channel_interface* channel = nullptr;
|
channel_interface* channel = nullptr;
|
||||||
std::vector<mixer_track*> owner_tracks;
|
std::vector<mixer_track*> owner_tracks;
|
||||||
bool editor_opened = false;
|
bool editor_opened = false;
|
||||||
|
std::shared_ptr<ui_buffer_vector_type> ui_buffers;
|
||||||
protected:
|
protected:
|
||||||
void create_and_open_editor();
|
void create_and_open_editor();
|
||||||
void destroy_editor();
|
void destroy_editor();
|
||||||
|
@ -183,6 +183,7 @@ void vst2_plugin_host::on_update_sample_rate(double sample_rate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void vst2_plugin_host::on_update_buffer_size(int buffer_size) {
|
void vst2_plugin_host::on_update_buffer_size(int buffer_size) {
|
||||||
|
plugin_host::on_update_buffer_size(buffer_size);
|
||||||
dispatch(effSetBlockSize, 0, buffer_size);
|
dispatch(effSetBlockSize, 0, buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +218,10 @@ void vst2_plugin_host::update_channel_node_name() {
|
|||||||
void vst2_plugin_host::process(uint32_t frame_num) {
|
void vst2_plugin_host::process(uint32_t frame_num) {
|
||||||
// TODO send midi
|
// TODO send midi
|
||||||
effect_->processReplacing(effect_, channel->get_input_headers(), channel->get_output_headers(), frame_num);
|
effect_->processReplacing(effect_, channel->get_input_headers(), channel->get_output_headers(), frame_num);
|
||||||
|
for (int i = 0; i < ui_buffers->size(); ++i)
|
||||||
|
{
|
||||||
|
ui_buffers->at(i).Push(channel->get_output_headers()[i], frame_num);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vst2_plugin_host::idle_editor() {
|
void vst2_plugin_host::idle_editor() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user