forked from notahat/simplesynth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AudioSystem.h
65 lines (52 loc) · 1.8 KB
/
AudioSystem.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
#import <Foundation/Foundation.h>
#include <CoreServices/CoreServices.h>
#include <CoreAudio/CoreAudio.h>
#include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AUGraph.h>
#include <CoreMIDI/MIDIServices.h>
#import <PYMIDI/PYMIDI.h>
typedef struct {
unsigned char bankSelectMSB;
unsigned char bankSelectLSB;
unsigned char programChange;
} MIDIInstrument;
/*!
@class AudioSystem
This class handles all the hard work of controlling the audio
and MIDI components of the system.
*/
@interface AudioSystem : NSObject {
// Audio related
AUGraph graph;
AUNode synthNode;
AUNode filterNode;
AUNode outputNode;
MusicDeviceInstrumentID channelInstrument[16];
// MIDI related
PYMIDIEndpoint* currentMIDIEndpoint;
}
- (id)init;
// Audio related
- (void)setUpAudio;
- (BOOL)openFile:(NSString*)filename;
- (void)restoreAppleSounds;
- (UInt32)instrumentCount;
- (MusicDeviceInstrumentID)instrumentIDAtIndex:(UInt32)index;
- (UInt32)indexOfInstrumentID:(MusicDeviceInstrumentID)instrumentID;
- (NSString*)nameOfInstrument:(MusicDeviceInstrumentID)instrumentID;
+ (MIDIInstrument)instrumentIDToInstrument:(MusicDeviceInstrumentID)instrumentID;
+ (MusicDeviceInstrumentID)instrumentToInstrumentID:(MIDIInstrument)instrument;
- (MusicDeviceInstrumentID)currentInstrumentOnChannel:(int)channel;
- (void)setInstrument:(MusicDeviceInstrumentID)instrumentID forChannel:(int)channel;
- (float)getFilterCutoffMin;
- (float)getFilterCutoffMax;
- (float)getFilterCutoff;
- (void)setFilterCutoff:(float)value;
- (float)getCPULoad;
// MIDI related
- (void)setUpMIDI;
- (PYMIDIEndpoint*)midiInput;
- (void)setMIDIInput:(PYMIDIEndpoint*)endpoint;
- (void)processMIDIPacketList:(const MIDIPacketList*)packets sender:(id)sender;
- (void)handleMIDIMessage:(Byte*)message ofSize:(int)size;
@end