gaindb node
This commit is contained in:
@@ -114,6 +114,7 @@ endif()
|
||||
|
||||
add_subdirectory(nodes/videoin)
|
||||
add_subdirectory(nodes/pip)
|
||||
add_subdirectory(nodes/gaindb)
|
||||
|
||||
# ── Asio standalone (needed by Crow; no Boost) ───────────────────────────────
|
||||
FetchContent_Declare(asio_fc
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"nodes": [
|
||||
{ "id": "testpattern", "type": "testpattern", "params": { "pattern": "bars" } },
|
||||
{ "id": "gaindb", "type": "gaindb", "params": {} },
|
||||
{ "id": "ndiout", "type": "ndiout", "params": {} }
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"from": "testpattern", "from_port": "video_flow_id",
|
||||
"to": "ndiout", "to_port": "video_flow_id",
|
||||
"format": { "kind": "video", "width": 1920, "height": 1080, "fps_num": 25, "fps_den": 1 }
|
||||
},
|
||||
{
|
||||
"from": "testpattern", "from_port": "audio_flow_id",
|
||||
"to": "gaindb", "to_port": "audio_in_flow_id",
|
||||
"format": { "kind": "audio", "sample_rate": 48000, "channels": 2, "bit_depth": 32 }
|
||||
},
|
||||
{
|
||||
"from": "gaindb", "from_port": "audio_out_flow_id",
|
||||
"to": "ndiout", "to_port": "audio_flow_id",
|
||||
"format": { "kind": "audio", "sample_rate": 48000, "channels": 2, "bit_depth": 32 }
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
add_executable(dmf-node-gaindb main.cpp)
|
||||
target_compile_features(dmf-node-gaindb PRIVATE cxx_std_20)
|
||||
target_link_libraries(dmf-node-gaindb PRIVATE dmf-shared)
|
||||
install(TARGETS dmf-node-gaindb RUNTIME DESTINATION bin)
|
||||
@@ -0,0 +1,58 @@
|
||||
#include <string>
|
||||
#include "NodeBase.hpp"
|
||||
#include "FlowDef.hpp"
|
||||
#include <mxl/flow.h>
|
||||
#include <mxl/time.h>
|
||||
|
||||
namespace dmf {
|
||||
class GainDbNode: public dmf::NodeBase {
|
||||
void run() override {
|
||||
if (!config().contains("audio_in_flow_id") || !config().contains("audio_out_flow_id")) {
|
||||
log("no audio connected to in or out");
|
||||
return;
|
||||
}
|
||||
const std::string in_flow_id = config().at("audio_in_flow_id").at("id").get<std::string>();
|
||||
dmf::AudioFlowInfo in_flow_info = dmf::read_audio_flow_info(domain(), in_flow_id);
|
||||
int gain = 0;
|
||||
if (config().contains("gain")) {
|
||||
gain = config().at("gain").get<int>();
|
||||
}
|
||||
// create writer
|
||||
int sample_rate = in_flow_info.sample_rate;
|
||||
const std::string out_flow_id = config().at("audio_out_flow_id").at("id").get<std::string>();
|
||||
std::string flow_def = dmf::make_audio_flow_def(
|
||||
out_flow_id,
|
||||
node_id(),
|
||||
sample_rate,
|
||||
in_flow_info.channels,
|
||||
32,
|
||||
sample_rate,
|
||||
in_flow_info.samples_per_grain
|
||||
);
|
||||
mxlFlowWriter writer{};
|
||||
mxlFlowConfigInfo cfg{};
|
||||
bool created = false;
|
||||
mxlStatus st = mxlCreateFlowWriter(instance(), flow_def.c_str(), nullptr, &writer, &cfg, &created);
|
||||
if (st != MXL_STATUS_OK) {
|
||||
log("audio mxlCreateFlowWriter failed (%s) — continuing without audio", dmf::mxl_status_str(st));
|
||||
} else {
|
||||
log("audio channels=%u buffer=%u samples",
|
||||
cfg.continuous.channelCount, cfg.continuous.bufferLength);
|
||||
}
|
||||
|
||||
const mxlRational rate = {sample_rate, 1};
|
||||
uint64_t index = mxlGetCurrentIndex(&rate);
|
||||
while (dmf::g_running.load(std::memory_order_relaxed)) {
|
||||
mxlMutableBufferSlice slice{};
|
||||
uint8_t* buf = nullptr;
|
||||
|
||||
}
|
||||
mxlReleaseFlowWriter(instance(), writer);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main() {
|
||||
dmf::GainDbNode node;
|
||||
return node.execute();
|
||||
}
|
||||
Reference in New Issue
Block a user