-
Notifications
You must be signed in to change notification settings - Fork 73
/
ofxMidi.h
executable file
·73 lines (58 loc) · 1.98 KB
/
ofxMidi.h
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
/*
* Copyright (c) 2013 Dan Wilcox <danomatika@gmail.com>
*
* BSD Simplified License.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
*
* See https://github.com/danomatika/ofxMidi for documentation
*
*/
#pragma once
#include "ofxMidiIn.h"
#include "ofxMidiOut.h"
#include "ofxMidiClock.h"
#include "ofxMidiTimecode.h"
/// receives iOS MIDI device (dis)connection events,
/// currently does nothing on desktop
class ofxMidiConnectionListener {
public:
ofxMidiConnectionListener() {}
virtual ~ofxMidiConnectionListener() {}
virtual void midiInputAdded(std::string name, bool isNetwork=false);
virtual void midiInputRemoved(std::string name, bool isNetwork=false);
virtual void midiOutputAdded(std::string nam, bool isNetwork=false);
virtual void midiOutputRemoved(std::string name, bool isNetwork=false);
};
// global access
namespace ofxMidi {
/// \section Util
/// convert MIDI note to frequency in Hz
/// ala the [mtof] object in Max & Pure Data
float mtof(float note);
/// convert a frequency in Hz to a MIDI note
/// ala the [ftom] object in Max & Pure Data
float ftom(float frequency);
/// convert raw MIDI bytes to a printable string, ex. "F0 0C 33"
std::string bytesToString(std::vector<unsigned char> &bytes);
/// \section iOS Specific
/// set a listener to receive iOS device (dis)connection events
///
/// don't forget to clear before the listener is deallocated!
///
/// note: these are noops on Mac, Win, & Linux
///
void setConnectionListener(ofxMidiConnectionListener *listener);
/// clear iOS device event receiver
void clearConnectionListener();
/// enables the network MIDI session between iOS and macOS on a
/// local wifi network
///
/// in ofxMidi: open the input/outport network ports named "Session 1"
///
/// on OSX: use the Audio MIDI Setup Utility to connect to the iOS device
///
/// note: this is a noop on Mac, Win, & Linux
///
void enableNetworking();
};