OSSIA
Open Scenario System for Interactive Application
sound_ref.hpp
1 #pragma once
2 #include <ossia/dataflow/graph_node.hpp>
3 #include <ossia/dataflow/nodes/sound.hpp>
4 #include <ossia/dataflow/nodes/sound_sampler.hpp>
5 #include <ossia/dataflow/nodes/sound_utils.hpp>
6 
7 namespace ossia::nodes
8 {
9 class sound_ref final : public ossia::sound_node
10 {
11 public:
12  sound_ref() { m_outlets.push_back(&audio_out); }
13 
14  ~sound_ref() = default;
15 
16  [[nodiscard]] std::string label() const noexcept override { return "sound_ref"; }
17 
18  void transport(time_value date) override { m_sampler.transport(date); }
19 
20  void set_start(std::size_t v) { m_sampler.set_start(v); }
21 
22  void set_upmix(std::size_t v) { m_sampler.set_upmix(v); }
23 
24  // Used for testing only
25  void set_sound(audio_array data) { m_sampler.set_sound(std::move(data)); }
26 
27  void set_sound(const audio_handle& hdl, int channels, int sampleRate)
28  {
29  m_sampler.set_sound(hdl, channels, sampleRate);
30  }
31 
32  void run(const ossia::token_request& t, ossia::exec_state_facade e) noexcept override
33  {
34  return m_sampler.run(t, e);
35  }
36 
37  ossia::audio_outlet audio_out;
38  sound_sampler m_sampler{this, &audio_out.data};
39 };
40 }