-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
138 lines (106 loc) · 4.35 KB
/
main.cc
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include <tracktion_engine/tracktion_engine.h>
namespace te = tracktion;
using namespace std::literals;
using namespace te::literals;
static void addNoteToClip(
te::MidiClip *midiClip,
int noteNumber,
int velocity,
te::BeatPosition start,
te::BeatDuration duration)
{
midiClip->getSequence().addNote(
noteNumber,
start,
duration,
velocity,
0,
nullptr);
}
void setupAudioDevice(te::Engine& engine, const std::string& backendType){
auto& deviceManager = engine.getDeviceManager();
// Shut down the current audio device
deviceManager.closeDevices();
// Set the desired backend type
// Initialize the default audio device with the selected backend
deviceManager.initialise();
// Optionally, handle specific device settings or customizations here
}
int main()
{
// Create the engine
te::Engine engine{"Tracktion Hello World"};
// Create an edit
te::Edit edit{
engine,
te::createEmptyEdit(engine),
te::Edit::forEditing,
nullptr,
0};
// Create a track
edit.ensureNumberOfAudioTracks(1);
auto track = te::getAudioTracks(edit)[0];
// Get length of 1 bar
const tracktion::TimeRange oneBarTimeRange(
0s,
edit.tempoSequence.toTime({1, tracktion::BeatDuration()}));
// Insert a 1 bar long Midi clip
auto clip = track->insertNewClip(
te::TrackItem::Type::midi,
"Midi Clip",
oneBarTimeRange,
nullptr);
auto midiClip = static_cast<te::MidiClip *>(clip);
// Add a 4-note C-E-G-C sequence to the clip
// Note the use of Tracktion's beat position/duration literals
addNoteToClip(midiClip, 60, 100, 0_bp, 0.5_bd);
addNoteToClip(midiClip, 64, 100, 1_bp, 0.5_bd);
addNoteToClip(midiClip, 67, 100, 2_bp, 0.5_bd);
addNoteToClip(midiClip, 72, 100, 3_bp, 0.5_bd);
// Create a built-in synth plugin instance to play the sequence on
auto plugin = edit.getPluginCache().createNewPlugin(te::FourOscPlugin::xmlTypeName, {}).get();
auto fourOscPlugin = static_cast<te::FourOscPlugin *>(plugin);
auto plugin2 = edit.getPluginCache().createNewPlugin(te::FourOscPlugin::xmlTypeName, {}).get();
auto fourOscPlugin2 = static_cast<te::FourOscPlugin *>(plugin2);
auto plugin3 = edit.getPluginCache().createNewPlugin(te::DelayPlugin::xmlTypeName, {}).get();
auto delayPlugin = static_cast<te::DelayPlugin *>(plugin3);
auto plugin4 = edit.getPluginCache().createNewPlugin(te::PhaserPlugin::xmlTypeName, {}).get();
auto phaserPlugin = static_cast<te::PhaserPlugin *>(plugin4);
// Insert the plugin to the track
// track->pluginList.insertPlugin(*fourOscPlugin, 0, nullptr);
// track->pluginList.insertPlugin(*delayPlugin, 1, nullptr);
// for (int i = 0; i < fourOscPlugin->oscParams.size(); i++) {
// fourOscPlugin->oscParams[i]->waveShapeValue.setValue(0, nullptr);
// }
fourOscPlugin->chorusOnValue.setValue(true, nullptr);
fourOscPlugin->chorusMixValue.setValue(1000, nullptr);
fourOscPlugin->distortionOnValue.setValue(true, nullptr);
fourOscPlugin->distortionValue.setValue(100, nullptr);
std::cout << fourOscPlugin->chorusOnValue << std::endl;
std::cout << fourOscPlugin->chorusMixValue << std::endl;
track->pluginList.insertPlugin(*fourOscPlugin, 0, nullptr);
track->pluginList.insertPlugin(*delayPlugin, 1, nullptr);
// track->pluginList.insertPlugin(*phaserPlugin, 2, nullptr);
// USE setParameter() TO CONTROL PLUGIN PARAMS!!!
std::cout << delayPlugin->lengthMs << std::endl;
delayPlugin->mixProportion->setParameter(2.0, juce::dontSendNotification);
// delayPlugin->feedbackValue = -1;
delayPlugin->feedbackDb->setParameter(-1, juce::dontSendNotification);
// delayPlugin->lengthMs = 10;
std::cout << delayPlugin->mixProportion->getCurrentValue() << std::endl;
std::cout << delayPlugin->feedbackValue << std::endl;
std::cout << delayPlugin->lengthMs << std::endl;
// Get the transport & set it to the start of the edit
auto &transport = edit.getTransport();
transport.setPosition(0s);
// Set the transport to loop our clip
transport.setLoopRange(clip->getEditTimeRange());
transport.looping = true;
// Begin playback
transport.play(false);
// Dance while the record spins
while (true)
{
}
return 0;
}