-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwitchbridge-av.hpp
110 lines (91 loc) · 2.03 KB
/
witchbridge-av.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#pragma once
#include "custom.hpp"
#include <halp/meta.hpp>
#include <halp/audio.hpp>
#include <halp/texture.hpp>
#include <cmath>
#include <memory>
#include <iostream>
namespace wb
{
template<std::size_t N>
struct Audio
{
struct
{
halp::fixed_audio_bus<"In", float, N> audio;
} inputs;
struct
{
} outputs;
std::shared_ptr<Streamer> streamer;
void prepare(halp::setup t)
{
config c;
c.rate = t.rate;
c.frames = t.frames;
streamer = make_streamer(c);
}
void operator()(int frames)
{
using namespace std;
switch(N) {
case 1:
push_audio(*streamer, {.audio = {inputs.audio.samples[0]}, .channels = N, .frames = frames});
break;
case 2:
push_audio(*streamer, {.audio = {
inputs.audio.samples[0],
inputs.audio.samples[1],
},
.channels = N, .frames = frames});
break;
}
}
};
struct AudioMono : Audio<1>
{
halp_meta(name, "Witchbridge Audio (mono)")
halp_meta(c_name, "wb_audio_1ch")
halp_meta(uuid, "119d7020-6b7b-4dc9-af7d-ecfb23c5994d")
};
struct AudioStereo : Audio<2>
{
halp_meta(name, "Witchbridge Audio (stereo)")
halp_meta(c_name, "wb_audio_2ch")
halp_meta(uuid, "58b9924c-b405-4bad-a1d0-60159dafd019")
};
struct Texture
{
halp_meta(name, "Witchbridge Video")
halp_meta(c_name, "wb_video")
halp_meta(uuid, "942ce751-6791-4209-9625-af0e189afd78")
struct
{
halp::texture_input<"In"> image;
} inputs;
struct
{
halp::texture_output<"Out"> image;
} outputs;
std::shared_ptr<Streamer> streamer;
Texture()
{
config c;
c.rate = 1;
c.frames = 1;
streamer = make_streamer(c);
outputs.image.create(1, 1);
outputs.image.upload();
}
void operator()()
{
using namespace std;
push_video(*streamer,
{.bytes= inputs.image.texture.bytes
, .width = inputs.image.texture.width
, .height = inputs.image.texture.height
});
}
};
}