OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
raw_stretcher.hpp
1#pragma once
2#include <ossia/dataflow/audio_port.hpp>
3#include <ossia/dataflow/graph_node.hpp>
4#include <ossia/dataflow/nodes/media.hpp>
5#include <ossia/dataflow/token_request.hpp>
6
7namespace ossia
8{
9
10struct raw_stretcher
11{
12 int64_t next_sample_to_read{};
13 raw_stretcher() noexcept = default;
14 raw_stretcher(const raw_stretcher&) noexcept = default;
15 raw_stretcher(raw_stretcher&&) noexcept = default;
16 raw_stretcher& operator=(const raw_stretcher&) noexcept = default;
17 raw_stretcher& operator=(raw_stretcher&&) noexcept = default;
18 raw_stretcher(int64_t pos) noexcept
19 : next_sample_to_read{pos}
20 {
21 }
22
23 void transport(int64_t date) { next_sample_to_read = date; }
24
25 template <typename T>
26 void
27 run(T& audio_fetcher, const ossia::token_request& t, const ossia::exec_state_facade e,
28 double tempo_ratio, const std::size_t chan, const int64_t len,
29 const int64_t samples_to_read, const int64_t samples_to_write,
30 const int64_t samples_offset, const ossia::mutable_audio_span<double>& ap) noexcept
31 {
32 if(t.forward())
33 {
34 double** output = (double**)alloca(sizeof(double*) * chan);
35 for(std::size_t i = 0; i < chan; i++)
36 output[i] = ap[i].data() + samples_offset;
37
38 audio_fetcher.fetch_audio(next_sample_to_read, samples_to_write, output);
39 next_sample_to_read += samples_to_write;
40 }
41 else
42 {
43 // TODO
44 }
45 }
46};
47
48}
Definition git_info.h:7