-
Notifications
You must be signed in to change notification settings - Fork 33
/
RIOInterface.h
executable file
·89 lines (69 loc) · 2.17 KB
/
RIOInterface.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// RIOInterface.h
// SafeSound
//
// Created by Demetri Miller on 10/22/1010
// Copyright 2010 Demetri Miller. All rights reserved.
//
/*
* This class is a singleton providing globally accessible methods
* and properties that may be needed by multiple classes.
*/
#import <Foundation/Foundation.h>
#import <AudioUnit/AudioUnit.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <Accelerate/Accelerate.h>
#include <stdlib.h>
@class ListenerViewController;
/**
* This is a singleton class that manages all the low level CoreAudio/RemoteIO
* elements. A singleton is used since we should never be instantiating more
* than one instance of this class per application lifecycle.
*/
#define kInputBus 1
#define kOutputBus 0
#define kBufferSize 1024
#define kBufferCount 1
#define N 10
@interface RIOInterface : NSObject {
UIViewController *selectedViewController;
ListenerViewController *listener;
AUGraph processingGraph;
AudioUnit ioUnit;
AudioBufferList* bufferList;
AudioStreamBasicDescription streamFormat;
FFTSetup fftSetup;
COMPLEX_SPLIT A;
int log2n, n, nOver2;
void *dataBuffer;
float *outputBuffer;
size_t bufferCapacity; // In samples
size_t index; // In samples
float sampleRate;
float frequency;
}
@property(nonatomic, assign) id<AVAudioPlayerDelegate> audioPlayerDelegate;
@property(nonatomic, assign) id<AVAudioSessionDelegate> audioSessionDelegate;
@property(nonatomic, assign) ListenerViewController *listener;
@property(assign) float sampleRate;
@property(assign) float frequency;
#pragma mark Lifecycle
#pragma mark Audio Session/Graph Setup
- (void)initializeAudioSession;
- (void)createAUProcessingGraph;
- (size_t)ASBDForSoundMode;
#pragma mark Playback Controls
- (void)startPlayback;
- (void)startPlaybackFromEncodedArray:(NSArray *)encodedArray;
- (void)stopPlayback;
- (void)printASBD:(AudioStreamBasicDescription)asbd;
#pragma mark Listener Controls
- (void)startListening:(ListenerViewController*)aListener;
- (void)stopListening;
#pragma mark Generic Audio Controls
- (void)initializeAndStartProcessingGraph;
- (void)stopProcessingGraph;
#pragma mark Singleton Methods
+ (RIOInterface *)sharedInstance;
@end