10 #define USE_TEST_MAIN // use the main() function in test_support.h
14 #ifdef USE_JMIDI // new way with JUCE midi
39 logMsg(
"Default MIDI in = %d", juce::MidiInput::getDefaultDeviceIndex());
40 logMsg(
"Default MIDI out = %d", juce::MidiOutput::getDefaultDeviceIndex());
68 ADSR env(1.0, 0.05, 0.1, 0.7, 0.6);
70 osc.setFrequency(1017.0f);
72 rev.setRoomSize(0.92);
75 logMsg(
"testing MIDIIn playback");
79 if(in.
mMsg.isNoteOn()) {
80 logMsg(
"MIDI note %d vel. %d", in.
mMsg.getNote(), in.
mMsg.getVelocity());
81 osc.setFrequency(in.
mMsg.getFrequency());
82 env.scaleValues(in.
mMsg.getVelocityFloat() / 2.0f );
85 if(in.
mMsg.isNoteOff()) {
107 class MIDIListener :
public Observer {
110 void update(
void * arg) {
116 MIDIListener(
MIDIIn * in) : mIn(in) { };
124 void testListener() {
127 MIDIListener lst(&in);
131 logMsg(
"Start MIDI listener");
146 void testMIDIFile() {
150 logMsg(
"Setting up instrument library");
151 for (
unsigned i = 0; i < 16; i++) {
153 lib[i].push_back(in);
160 rev.setRoomSize(0.8);
162 logMsg(
"Load MIDI score");
165 logMsg(
"Start MIDI player");
184 #ifdef USE_LOSC // liblo for OSC
191 void testOSCServer() {
193 logMsg(
"Setting up instrument library");
196 for (
unsigned i = 0; i < 16; i++) {
202 rev.setRoomSize(0.8);
215 logMsg(
"OSC server waiting for input\n");
226 void testOSCClientServer() {
228 logMsg(
"Setting up instrument library");
231 for (
unsigned i = 0; i < 16; i++) {
237 rev.setRoomSize(0.8);
256 lo_address ad = lo_address_new(NULL, pNam);
257 logMsg(
"Sending OSC note cmds");
263 for (
unsigned i = 0; i < 64; i++) {
264 sprintf(pNam,
"/i%d/pn", (i % 16)+1);
265 float dur =
fRandM(0.15f, 1.5f);
266 float ampl =
fRandM(0.2, 0.8);
267 float freq =
fRandM(60, 500);
269 if (lo_send(ad, pNam,
"ffff", dur, ampl, freq, pos) == -1) {
270 logMsg(
kLogError,
"OSC error2 %d: %s\n", lo_address_errno(ad), lo_address_errstr(ad));
276 logMsg(
"Sending OSC quit");
277 if (lo_send(ad,
"/q", NULL) == -1) {
278 logMsg(
kLogError,
"OSC error3 %d: %s\n", lo_address_errno(ad), lo_address_errstr(ad));
291 "Dump ports", IO_test,
"Dump list of MIDI ports to stdout",
292 "Dump input", input_test,
"Dump MIDI input from default device",
293 "MIDI notes", play_test,
"Play MIDI notes (reads MIDI kbd)",
294 "MIDI output", output_test,
"Test sending MIDI output",
295 "MIDI listener", testListener,
"Start the MIDI listener object",
296 "MIDI file player", testMIDIFile,
"Play a MIDI file on an instrument library",
297 #ifdef USE_LOSC // liblo for OSC
298 "OSC client/server", testOSCClientServer,
"OSC client/server on a library",
299 "OSC server", testOSCServer,
"Start OSC server on a library",
static void dumpDevices()
printing device info for all devices.
void logMsg(const char *format,...)
These are the public logging messages.
#define kFrequency
Enum for SumOfSines description formats.
The PThreads CSL Thread class.
virtual void clear()
stop MIDI stream
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
CSL Observer/Dependent/Monitor class – instances receive update() messages from "models" and handle ...
MIDIIn class is-a MidiInputCallback too, and an "input-ready" flag.
void mainOSCLoop(int port)
struct used for the JUCE pop-up menu of tests (see the test files)
virtual void stop()
stop MIDI stream
void setupOSCInstrLibrary(std::vector< Instrument * > library)
void dumpMessage()
print current msg
float fRandM(float minV, float maxV)
min - max (min/max)
juce::AudioDeviceManager * gAudioDeviceManager
CSL port of the public domain Freeverb reverberator.
ADSR = 4-segment attack/decay/sustain/release envelope class.
std::vector< Instrument * > InstrumentVector
Players hold onto Instrument vectors/maps.
bool poll()
poll returns a bool (really quickly)
#define CSL_WORD_LEN
default short string length
virtual int createThread(VoidFcnPtr *func, void *args)=0
void attachObserver(Observer *)
(possibly notify obersvers on my death)
static CThread * MakeThread()
factory method
virtual void close()
open/close start/stop methods
void setRoot(UnitGenerator &root)
set/clear my graph root generator
Mixer – The n-input m-channel mixer class.
CMIDIMessage class (mapped to juce::MidiMessage)
CMIDIMessageType message
event type
virtual void open(int deviceID)
open a device
virtual void close()
closing MIDI stream
static unsigned outPort()
the default RemoteIO output port
float fRand1(void)
-1 - 1 (one)
virtual void start()
start MIDI stream
std::map< int, InstrumentVector > InstrumentLibrary
Base class of CSL exceptions (written upper-case). Has a string message.
static std::string dataFolder()
the default directory for test data