Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (44 sloc) 1.801 kb
86a3973 @oatmealandcoffee Initial commit to GitHub
authored
1 //
2 // coreaudio_helper.cpp
3 // Bridge
4 //
5 // Created by Philip Regan on 12/7/11.
6 // Copyright (c) 2011 __MyCompanyName__. All rights reserved.
7 //
8
9 #include <CoreServices/CoreServices.h>
10 #include <AudioUnit/AudioUnit.h>
11 #include <AudioToolbox/AudioToolbox.h> //for AUGraph
12 #include <unistd.h> // used for usleep...
13
14 AUGraph graph = 0;
15 AudioUnit synthUnit;
16 OSStatus result;
17
18 UInt8 midiChannelInUse = 0; //we're using midi channel 1...
19
20
21 // This call creates the Graph and the Synth unit...
22 OSStatus
23 CreateAUGraph (AUGraph &outGraph, AudioUnit &outSynth)
24 {
25 OSStatus result;
26 //create the nodes of the graph
27 AUNode synthNode, limiterNode, outNode;
28
29 AudioComponentDescription cd;
30 cd.componentManufacturer = kAudioUnitManufacturer_Apple;
31 cd.componentFlags = 0;
32 cd.componentFlagsMask = 0;
33
34 require_noerr (result = NewAUGraph (&outGraph), home);
35
36 cd.componentType = kAudioUnitType_MusicDevice;
37 cd.componentSubType = kAudioUnitSubType_DLSSynth;
38
39 require_noerr (result = AUGraphAddNode (outGraph, &cd, &synthNode), home);
40
41 cd.componentType = kAudioUnitType_Effect;
42 cd.componentSubType = kAudioUnitSubType_PeakLimiter;
43
44 require_noerr (result = AUGraphAddNode (outGraph, &cd, &limiterNode), home);
45
46 cd.componentType = kAudioUnitType_Output;
47 cd.componentSubType = kAudioUnitSubType_DefaultOutput;
48 require_noerr (result = AUGraphAddNode (outGraph, &cd, &outNode), home);
49
50 require_noerr (result = AUGraphOpen (outGraph), home);
51
52 require_noerr (result = AUGraphConnectNodeInput (outGraph, synthNode, 0, limiterNode, 0), home);
53 require_noerr (result = AUGraphConnectNodeInput (outGraph, limiterNode, 0, outNode, 0), home);
54
55 // ok we're good to go - get the Synth Unit...
56 require_noerr (result = AUGraphNodeInfo(outGraph, synthNode, 0, &outSynth), home);
57
58 home:
59 return result;
60 }
Something went wrong with that request. Please try again.