CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Test_Audio.cpp
Go to the documentation of this file.
1 //
2 // Test_Audio.cpp -- Streaming audio IO tests
3 //
4 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
5 //
6
7 #ifdef USE_JUCE
8 #include "Test_Support.h"
9 #include "../JuceLibraryCode/JuceHeader.h"
10 #else
11 #define USE_TEST_MAIN // use the main() function in test_support.h
12 #include "Test_Support.cpp" // include all of CSL core and the test support functions
13 #endif
14
15 using namespace csl;
16
17 extern juce::AudioDeviceManager * gAudioDeviceManager; // global JUCE audio device mgr
18
19
20 // dump io port-type & device names
21
22 void audio_dump() {
23 for (unsigned i = 0; i < gAudioDeviceManager->getAvailableDeviceTypes().size(); i++) {
24 logMsg(" AudioIODeviceType %s",
25 gAudioDeviceManager->getAvailableDeviceTypes().getUnchecked(i)->getTypeName().toUTF8());
26 StringArray devs = gAudioDeviceManager->getAvailableDeviceTypes().getUnchecked(i)->getDeviceNames();
27 for (unsigned j = 0; j < devs.size(); j++) {
28 logMsg(" Device %s", devs[j].toUTF8() );
29 }
30 }
31 AudioIODevice * adm = gAudioDeviceManager->getCurrentAudioDevice();
32 logMsg("Current AudioIODevice = %s : %s", adm->getTypeName().toUTF8(), adm->getName().toUTF8());
33 }
34
35 // echo mic back using an InOut
36
37 void mic_test() {
38 // CGestalt::setNumInChannels(2);
39 // set up InOut UGen to copy input to effect
40 InOut mio(theIO, 2, 2); // stereo i/o
41 logMsg("playing mic in unaltered...");
42 runTest(mio, 10); // 10 sec
43 logMsg("done.\n");
44 }
45
46 // Apply a BPF to the input
47
48 void filt_test() {
49 InOut mio(theIO, 2, 1); // mono input
50 Butter bpf(mio, BW_BAND_PASS, 1000.f, 100.f);
51 logMsg("playing filter on mic in...");
52 runTest(bpf, 10); // 10 sec
53 logMsg("done.\n");
54 }
55
56 // Add echo to the input
57
58 void echo_test() {
59 InOut mio(theIO, 2, 2); // stereo i/o
60 Stereoverb mReverb(mio); // stereo reverb
61 mReverb.setRoomSize(0.988); // long reverb time
62 logMsg("playing echo on mic in...");
63 runTest(mReverb, 10); // 10 sec
64 logMsg("done.\n");
65 }
66
67 // pan the input
68
69 void panner_test() {
70 InOut mio(theIO, 2, 1); // mono input
71 Osc lfo(0.5, 1, 0, CSL_PI); // position LFO
72 Panner pan(mio, lfo); // panner
73 logMsg("playing panner on mic in...");
74 runTest(pan, 10); // 10 sec
75 logMsg("done.\n");
76 }
77
78 //////////////////////////////////////////////////////////////////////////////
79
80 // make an Audio listener class -- implement update() and store in-coming audio
81
82 //class AudioListener : public Observer {
83 //public:
84 // // update message prints to the log
85 // void update(void * arg) {
86 // }
87 // // constructor
88 // AudioListener(MIDIIn * in) : mIn(in) { };
89 // // data member for the input
90 // AudioListener * mIn;
91 //
92 //};
93 //
94 ///// Create a MIDI in and attach a filtering listener to it
95 //
96 void listener_test() {
97 // MIDIIn in;
98 // in.open(DEFAULT_MIDI_IN);
99 // MIDIListener lst(&in); // create a listener
100 //// lst.mPeriod = 0.25;
101 // lst.mKey = kNoteOn; // filter noteOn events
102 // in.attachObserver(&lst); // attach observer to input
103 // logMsg("Start MIDI listener");
104 // in.start();
105 //
106 // sleepSec(10);
107 //
108 // logMsg("done.");
109 // in.stop();
110 // in.close();
111 }
112
113 // test list for Juce GUI
114
115 testStruct audioTestList[] = {
116 "Dump audio ports", audio_dump, "Dump list of audio ports to stdout",
117 "Echo audio in", mic_test, "Play the microphone input back the output",
118 "Filter input", filt_test, "Apply a band-pass filter to the live input",
119 "Echo input", echo_test, "Add echo to the live input",
120 "Input panner", panner_test, "Stereo panner on the live input",
121 "Input listener", listener_test, "Demonstrate recording input listener",
122 NULL, NULL, NULL
123 };