-
Notifications
You must be signed in to change notification settings - Fork 1
/
audioUi.cpp
119 lines (96 loc) · 2.94 KB
/
audioUi.cpp
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
111
112
113
114
115
116
117
118
119
/*
Copyright (C) 2020 Marcel Smit
https://www.facebook.com/marcel.smit981
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
#include "audioGraphManager.h"
#include "audioUi.h"
#include "StringEx.h"
#include "ui.h"
bool doAudioGraphSelect(AudioGraphManager_RTE & audioGraphMgr)
{
bool result = false;
for (auto & fileItr : audioGraphMgr.files)
{
auto & filename = fileItr.first;
if (doButton(filename.c_str()))
{
audioGraphMgr.selectFile(filename.c_str());
result = true;
}
}
return result;
}
bool doAudioGraphInstanceSelect(AudioGraphManager_RTE & audioGraphMgr, std::string & activeInstanceName, const bool forSelectedFileOnly)
{
bool result = true;
for (auto & fileItr : audioGraphMgr.files)
{
auto & filename = fileItr.first;
auto file = fileItr.second;
if (forSelectedFileOnly && file != audioGraphMgr.selectedFile)
continue;
for (auto instance : file->instanceList)
{
std::string name = String::FormatC("%s: %p", filename.c_str(), instance->audioGraph);
if (doButton(name.c_str()))
{
if (name != activeInstanceName)
{
activeInstanceName = name;
audioGraphMgr.selectInstance(instance);
result = true;
}
}
}
}
return result;
}
//
#include "audioNodeBase.h"
#include "framework.h"
void drawFilterResponse(const AudioNodeBase * node, const float sx, const float sy)
{
const int kNumSteps = 256;
float response[kNumSteps];
if (node->getFilterResponse(response, kNumSteps))
{
hqBegin(HQ_FILLED_ROUNDED_RECTS);
{
setColorf(0, 0, 0, .8f);
hqFillRoundedRect(0, 0, sx, sy, 4.f);
}
hqEnd();
setColor(colorWhite);
hqBegin(HQ_LINES);
{
for (int i = 0; i < kNumSteps - 1; ++i)
{
const float x1 = sx * (i + 0) / kNumSteps;
const float x2 = sx * (i + 1) / kNumSteps;
const float y1 = (1.f - response[i + 0]) * sy;
const float y2 = (1.f - response[i + 1]) * sy;
hqLine(x1, y1, 3.f, x2, y2, 3.f);
}
}
hqEnd();
}
}