OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
mapping.hpp
1#pragma once
2#include <ossia/detail/config.hpp>
3
4#include <ossia/dataflow/graph_node.hpp>
5#include <ossia/dataflow/port.hpp>
6#include <ossia/detail/optional.hpp>
8#include <ossia/editor/mapper/detail/mapper_visitor.hpp>
12
13namespace ossia::nodes
14{
22
23class mapping final : public ossia::nonowning_graph_node
24{
25public:
26 mapping()
27 {
28 m_inlets.push_back(&value_in);
29 m_outlets.push_back(&value_out);
30 }
31
32 [[nodiscard]] std::string label() const noexcept override { return "mapping"; }
33
34 ~mapping() override = default;
35
36 void set_behavior(const ossia::behavior& b) { m_drive = b; }
37
40 void swap_behavior(ossia::behavior& b) noexcept { std::swap(m_drive, b); }
41
42private:
43 void run(const ossia::token_request& t, ossia::exec_state_facade e) noexcept override
44 {
45 if(!m_drive)
46 return;
47
48 const ossia::value_port& ip = *value_in;
49 ossia::value_port& op = *value_out;
50
51 // TODO use correct unit / whatever ?
52 for(auto& tv : ip.get_data())
53 {
54 if(tv.value.valid())
55 try
56 {
57 auto v = ossia::apply(
58 ossia::detail::mapper_compute_visitor{}, tv.value, m_drive.v);
59
60 op.write_value(std::move(v), tv.timestamp);
61 }
62 catch(...)
63 {
64 }
65 }
66 }
67
68 ossia::behavior m_drive;
69 ossia::value_inlet value_in;
70 ossia::value_outlet value_out;
71};
72}
void swap_behavior(ossia::behavior &b) noexcept
Hands the previous behavior back instead of destroying it here: on the audio thread,...
Definition mapping.hpp:40