-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathExamplesMain.cpp
More file actions
executable file
·88 lines (79 loc) · 3.82 KB
/
ExamplesMain.cpp
File metadata and controls
executable file
·88 lines (79 loc) · 3.82 KB
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
// SPDX-License-Identifier: BSD-2-Clause
// Copyright (C) 2015+, The LabSound Authors. All rights reserved.
#define USE_LIVE
#include "Examples.hpp"
/*
Note for Airpods ~ airpods only present a mono output if the
default input device is set to airpods
- if you change the input device to the mac book internal microphone,
then the airpods work in stereo; strange behavior.
https://discussions.apple.com/thread/252088121
*/
int main(int argc, char *argv[]) try
{
enum Passing { pass, fail };
enum Skip { yes, no };
struct Example {
Passing passing;
Skip skip;
labsound_example* example;
};
AudioStreamConfig _inputConfig;
AudioStreamConfig _outputConfig;
auto config = GetDefaultAudioDeviceConfiguration(true);
_inputConfig = config.first;
_outputConfig = config.second;
std::shared_ptr<lab::AudioDevice_RtAudio> device(new lab::AudioDevice_RtAudio(_inputConfig, _outputConfig));
auto context = std::make_shared<lab::AudioContext>(false, true);
auto destinationNode = std::make_shared<lab::AudioDestinationNode>(*context.get(), device);
device->setDestinationNode(destinationNode);
context->setDestinationNode(destinationNode);
const bool NoInput = false;
const bool UseInput = true;
Example examples[] = {
{ Passing::pass, Skip::yes, new ex_devices(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_play_file(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_simple(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_osc_pop(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_playback_events(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_offline_rendering(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_tremolo(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_frequency_modulation(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_runtime_graph_update(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_microphone_loopback(context, UseInput) },
{ Passing::pass, Skip::yes, new ex_microphone_reverb(context, UseInput) },
{ Passing::pass, Skip::yes, new ex_peak_compressor(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_stereo_panning(context, NoInput) },
{ Passing::pass, Skip::no, new ex_hrtf_spatialization(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_convolution_reverb(context, NoInput) }, // note: exhibits severe popping
{ Passing::pass, Skip::yes, new ex_misc(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_dalek_filter(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_redalert_synthesis(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_wavepot_dsp(context, NoInput) },
{ Passing::pass, Skip::yes, new ex_granulation_node(context, NoInput) }, // note: node is under development
{ Passing::pass, Skip::yes, new ex_poly_blep(context, NoInput) },
{ Passing::fail, Skip::yes, new ex_split_merge(context, NoInput) },
{ Passing::fail, Skip::yes, new ex_waveshaper(context, NoInput)},
};
static constexpr int iterations = 1;
for (int i = 0; i < iterations; ++i)
{
for (auto& example : examples)
if (example.skip == Skip::no) {
example.example->play(argc, argv);
}
}
for (auto& example : examples) {
delete example.example;
}
// device, context, and rendernode are circularly referenced, so break the cycle manually.
destinationNode.reset();
device->setDestinationNode(destinationNode);
context->setDestinationNode(destinationNode);
return EXIT_SUCCESS;
}
catch (const std::exception & e)
{
std::cerr << "unhandled fatal exception: " << e.what() << std::endl;
return EXIT_FAILURE;
}