新增mixer_track ui_buffer用于绘制混音台轨道音量
新增默认插件窗口位置 新增portaudio启用默认asio输出设备 修复circular_audio_buffer编译错误
This commit is contained in:
parent
e8d341df18
commit
0acf109ef2
@ -51,6 +51,8 @@ GLFWwindow* window_manager::create_plugin_host_window(plugin_host* host) {
|
||||
if (host_window_pos_map_.contains(host)) {
|
||||
auto pos = host_window_pos_map_[host];
|
||||
glfwSetWindowPos(new_window, pos.x, pos.y);
|
||||
}else {
|
||||
glfwSetWindowPos(new_window, 100, 100);
|
||||
}
|
||||
host_window_map_[host] = new_window;
|
||||
glfwShowWindow(new_window);
|
||||
|
@ -37,7 +37,9 @@ void port_audio_device::stop() {
|
||||
|
||||
void port_audio_device::start() {
|
||||
try {
|
||||
open_stream(-1, Pa_GetDefaultOutputDevice(), sample_rate(), buffer_size());
|
||||
auto host_api_info = Pa_GetHostApiInfo(Pa_HostApiTypeIdToHostApiIndex(paASIO));
|
||||
auto device_info = Pa_GetDeviceInfo(host_api_info->defaultOutputDevice);
|
||||
open_stream(-1, host_api_info->defaultOutputDevice, sample_rate(), buffer_size());
|
||||
} catch (const std::exception& e) {
|
||||
spdlog::error("Init failed: {}", e.what());
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ private:
|
||||
void render_thread();
|
||||
std::thread render_thread_;
|
||||
circular_audio_buffer<float> render_buffer_;
|
||||
uint32_t render_buffer_size_ = 2048;
|
||||
uint32_t render_buffer_size_ = 512;
|
||||
std::atomic_bool render_thread_running_ = false;
|
||||
#pragma endregion
|
||||
|
||||
|
@ -30,8 +30,8 @@ public:
|
||||
circular_audio_buffer& operator=(const circular_audio_buffer& InOther) {
|
||||
InternalBuffer = InOther.InternalBuffer;
|
||||
Capacity = InOther.Capacity;
|
||||
ReadCounter = InOther.ReadCounter;
|
||||
WriteCounter = InOther.WriteCounter;
|
||||
ReadCounter.store(InOther.ReadCounter);
|
||||
WriteCounter.store(InOther.WriteCounter);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ mixer_track::~mixer_track() {
|
||||
void mixer_track::init() {
|
||||
const uint32_t channel_count = g_audio_device_manager.get_output_channel_count();
|
||||
buffer.resize(channel_count, g_audio_device_manager.get_buffer_size());
|
||||
for (int i = 0; i < buffer.get_num_channels(); ++i) {
|
||||
ui_buffers.emplace_back(g_audio_device_manager.get_buffer_size() * 2);
|
||||
}
|
||||
|
||||
channel_interface_ = new mixer_channel_interface(this);
|
||||
}
|
||||
@ -39,6 +42,9 @@ void mixer_track::process(uint32_t in_frames) {
|
||||
effect->process(in_frames);
|
||||
buffer.multiple(volume);
|
||||
on_processed.broadcast(this);
|
||||
for (int i = 0; i < buffer.get_num_channels(); ++i) {
|
||||
ui_buffers[i].Push(buffer.get_headers()[i], in_frames);
|
||||
}
|
||||
}
|
||||
|
||||
void instrument_track::rename(const std::string& in_name) {
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
[[nodiscard]] channel_interface* get_channel_interface() const { return channel_interface_; }
|
||||
|
||||
audio_buffer buffer;
|
||||
std::vector<circular_audio_buffer<float>> ui_buffers;
|
||||
std::atomic<float> volume = 1.0f;
|
||||
std::vector<plugin_host*> effects{};
|
||||
std::vector<mixer_track_link> children{};
|
||||
|
@ -5,12 +5,13 @@
|
||||
|
||||
plugin_host::~plugin_host() {
|
||||
delete channel;
|
||||
g_window_manager.destroy_plugin_host_window(this);
|
||||
}
|
||||
|
||||
void plugin_host::try_open_editor() {
|
||||
if (!has_editor())
|
||||
return;
|
||||
if (editor_opened)
|
||||
return;
|
||||
editor_window = g_window_manager.create_plugin_host_window(this);
|
||||
open_editor(editor_window);
|
||||
editor_opened = true;
|
||||
@ -19,6 +20,8 @@ void plugin_host::try_open_editor() {
|
||||
void plugin_host::try_close_editor() {
|
||||
if (!has_editor())
|
||||
return;
|
||||
if (editor_opened == false)
|
||||
return;
|
||||
close_editor();
|
||||
editor_opened = false;
|
||||
g_window_manager.destroy_plugin_host_window(this);
|
||||
|
@ -134,6 +134,7 @@ vst2_plugin_host::vst2_plugin_host() {
|
||||
|
||||
vst2_plugin_host::~vst2_plugin_host() {
|
||||
spdlog::info("vst2 plugin {} destroyed", name);
|
||||
try_close_editor();
|
||||
if (effect_) {
|
||||
dispatch(effClose);
|
||||
}
|
||||
|
2
third_party/imgui/imgui
vendored
2
third_party/imgui/imgui
vendored
@ -1 +1 @@
|
||||
Subproject commit 77dff5a735afd821fea1ac54dda63ef5d8bded96
|
||||
Subproject commit 8048b52498a9bf2a9f87b080d43b0bfd7a5d51d8
|
Loading…
x
Reference in New Issue
Block a user