From e9d9e3ec81a14cd92205210671de9a595002553f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 2 Jan 2025 13:21:30 -0500 Subject: [PATCH] recorder: use the local path logic. Fix #1655 --- 3rdparty/libossia | 2 +- .../AvndProcesses/AudioRecorder.hpp | 25 +++++++++++++++---- .../score-plugin-avnd/Crousti/Executor.hpp | 1 + 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/3rdparty/libossia b/3rdparty/libossia index a76be25e9a..8b29d06643 160000 --- a/3rdparty/libossia +++ b/3rdparty/libossia @@ -1 +1 @@ -Subproject commit a76be25e9a41aea62413f0db5b21f028e7b9fe4c +Subproject commit 8b29d06643de5ebc29c0db7d84641ec71c208a91 diff --git a/src/plugins/score-plugin-avnd/AvndProcesses/AudioRecorder.hpp b/src/plugins/score-plugin-avnd/AvndProcesses/AudioRecorder.hpp index a7361c63eb..ba48a93dac 100644 --- a/src/plugins/score-plugin-avnd/AvndProcesses/AudioRecorder.hpp +++ b/src/plugins/score-plugin-avnd/AvndProcesses/AudioRecorder.hpp @@ -31,6 +31,11 @@ struct AudioRecorder // Threaded worker struct recorder_thread { + explicit recorder_thread(const score::DocumentContext& context) + : context{context} + { + } + const score::DocumentContext& context; ossia::drwav_write_handle f; std::string filename; std::string actual_filename; @@ -43,8 +48,10 @@ struct AudioRecorder if(must_record) { // Open the file with the correct substitutions - auto fname = QByteArray::fromStdString(this->filename); - fname.replace("%t", QDateTime::currentDateTimeUtc().toString().toUtf8()); + auto fname = QString::fromStdString(this->filename); + + fname.replace("%t", QDateTime::currentDateTimeUtc().toString()); + fname = score::locateFilePath(fname, context); actual_filename = fname.toStdString(); f.open(actual_filename, channels, rate, 16); return false; @@ -83,7 +90,7 @@ struct AudioRecorder f.write_pcm_frames(frames, arr); } }; - std::shared_ptr impl = std::make_shared(); + std::shared_ptr impl; struct reset_message { @@ -163,12 +170,20 @@ struct AudioRecorder halp::callback<"Filename", std::string> finished; } outputs; + const score::DocumentContext* ossia_document_context{}; int current_rate = 0; - void prepare(halp::setup s) { current_rate = s.rate; } + void prepare(halp::setup s) + { + current_rate = s.rate; + SCORE_ASSERT(ossia_document_context); + impl = std::make_shared(*ossia_document_context); + update(); + } void update() { - worker.request(impl, reset_message{inputs.filename, current_rate, inputs.record}); + if(impl) + worker.request(impl, reset_message{inputs.filename, current_rate, inputs.record}); } void operator()(int frames) diff --git a/src/plugins/score-plugin-avnd/Crousti/Executor.hpp b/src/plugins/score-plugin-avnd/Crousti/Executor.hpp index 2bebebdd57..c85fa8e967 100644 --- a/src/plugins/score-plugin-avnd/Crousti/Executor.hpp +++ b/src/plugins/score-plugin-avnd/Crousti/Executor.hpp @@ -166,6 +166,7 @@ class Executor final if_possible(node->impl.effect.ossia_state = st); if_possible(node->impl.effect.io_context = &net_ctx.context); + if_possible(node->impl.effect.ossia_document_context = &ctx.doc); ptr.reset(node); this->node = ptr;