Permalink
Browse files

Update all demos to support changes

  • Loading branch information...
1 parent 1ae786b commit ca4d47b1cebbb886c361cdfe675a7a0abdb47f4f @ndonald2 ndonald2 committed Jun 10, 2013
Showing with 42 additions and 42 deletions.
  1. +42 −42 Novocaine iOS Example/ViewController.mm
@@ -45,27 +45,29 @@ - (void)viewDidUnload
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
+
+ __weak ViewController * wself = self;
self.ringBuffer = new RingBuffer(32768, 2);
self.audioManager = [Novocaine audioManager];
// Basic playthru example
-// [audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
+// [self.audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
// float volume = 0.5;
// vDSP_vsmul(data, 1, &volume, data, 1, numFrames*numChannels);
-// ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
+// wself.ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
// }];
//
//
-// [audioManager setOutputBlock:^(float *outData, UInt32 numFrames, UInt32 numChannels) {
-// ringBuffer->FetchInterleavedData(outData, numFrames, numChannels);
+// [self.audioManager setOutputBlock:^(float *outData, UInt32 numFrames, UInt32 numChannels) {
+// wself.ringBuffer->FetchInterleavedData(outData, numFrames, numChannels);
// }];
// MAKE SOME NOOOOO OIIIISSSEEE
// ==================================================
-// [audioManager setOutputBlock:^(float *newdata, UInt32 numFrames, UInt32 thisNumChannels)
+// [self.audioManager setOutputBlock:^(float *newdata, UInt32 numFrames, UInt32 thisNumChannels)
// {
// for (int i = 0; i < numFrames * thisNumChannels; i++) {
// newdata[i] = (rand() % 100) / 100.0f / 2;
@@ -76,7 +78,7 @@ - (void)viewWillAppear:(BOOL)animated
// MEASURE SOME DECIBELS!
// ==================================================
// __block float dbVal = 0.0;
-// [audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
+// [self.audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) {
//
// vDSP_vsq(data, 1, data, 1, numFrames*numChannels);
// float meanVal = 0.0;
@@ -92,10 +94,10 @@ - (void)viewWillAppear:(BOOL)animated
// SIGNAL GENERATOR!
// __block float frequency = 40.0;
// __block float phase = 0.0;
-// [audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
+// [self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
// {
//
-// float samplingRate = audioManager.samplingRate;
+// float samplingRate = wself.audioManager.samplingRate;
// for (int i=0; i < numFrames; ++i)
// {
// for (int iChannel = 0; iChannel < numChannels; ++iChannel)
@@ -112,18 +114,18 @@ - (void)viewWillAppear:(BOOL)animated
// DALEK VOICE!
// (aka Ring Modulator)
-// [audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
+// [self.audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
// {
-// ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
+// wself.ringBuffer->AddNewInterleavedFloatData(data, numFrames, numChannels);
// }];
//
// __block float frequency = 100.0;
// __block float phase = 0.0;
-// [audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
+// [self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
// {
-// ringBuffer->FetchInterleavedData(data, numFrames, numChannels);
+// wself.ringBuffer->FetchInterleavedData(data, numFrames, numChannels);
//
-// float samplingRate = audioManager.samplingRate;
+// float samplingRate = wself.audioManager.samplingRate;
// for (int i=0; i < numFrames; ++i)
// {
// for (int iChannel = 0; iChannel < numChannels; ++iChannel)
@@ -135,23 +137,23 @@ - (void)viewWillAppear:(BOOL)animated
// if (phase > 1.0) phase = -1;
// }
// }];
-
+//
// VOICE-MODULATED OSCILLATOR
// __block float magnitude = 0.0;
-// [audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
+// [self.audioManager setInputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
// {
// vDSP_rmsqv(data, 1, &magnitude, numFrames*numChannels);
// }];
//
// __block float frequency = 100.0;
// __block float phase = 0.0;
-// [audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
+// [self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
// {
//
// printf("Magnitude: %f\n", magnitude);
-// float samplingRate = audioManager.samplingRate;
+// float samplingRate = wself.audioManager.samplingRate;
// for (int i=0; i < numFrames; ++i)
// {
// for (int iChannel = 0; iChannel < numChannels; ++iChannel)
@@ -167,23 +169,22 @@ - (void)viewWillAppear:(BOOL)animated
// AUDIO FILE READING OHHH YEAHHHH
// ========================================
- NSURL *inputFileURL = [[NSBundle mainBundle] URLForResource:@"TLC" withExtension:@"mp3"];
-
- self.fileReader = [[AudioFileReader alloc]
- initWithAudioFileURL:inputFileURL
- samplingRate:self.audioManager.samplingRate
- numChannels:self.audioManager.numOutputChannels];
-
- [self.fileReader play];
- self.fileReader.currentTime = 30.0;
-
-
- __weak ViewController * wself = self;
- [self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
- {
- [wself.fileReader retrieveFreshAudio:data numFrames:numFrames numChannels:numChannels];
- NSLog(@"Time: %f", wself.fileReader.currentTime);
- }];
+// NSURL *inputFileURL = [[NSBundle mainBundle] URLForResource:@"TLC" withExtension:@"mp3"];
+//
+// self.fileReader = [[AudioFileReader alloc]
+// initWithAudioFileURL:inputFileURL
+// samplingRate:self.audioManager.samplingRate
+// numChannels:self.audioManager.numOutputChannels];
+//
+// [self.fileReader play];
+// self.fileReader.currentTime = 30.0;
+//
+//
+// [self.audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
+// {
+// [wself.fileReader retrieveFreshAudio:data numFrames:numFrames numChannels:numChannels];
+// NSLog(@"Time: %f", wself.fileReader.currentTime);
+// }];
// AUDIO FILE WRITING YEAH!
@@ -195,19 +196,18 @@ - (void)viewWillAppear:(BOOL)animated
// NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
// NSLog(@"URL: %@", outputFileURL);
//
-// fileWriter = [[AudioFileWriter alloc]
-// initWithAudioFileURL:outputFileURL
-// samplingRate:audioManager.samplingRate
-// numChannels:audioManager.numInputChannels];
+// self.fileWriter = [[AudioFileWriter alloc]
+// initWithAudioFileURL:outputFileURL
+// samplingRate:self.audioManager.samplingRate
+// numChannels:self.audioManager.numInputChannels];
//
//
// __block int counter = 0;
-// audioManager.inputBlock = ^(float *data, UInt32 numFrames, UInt32 numChannels) {
-// [fileWriter writeNewAudio:data numFrames:numFrames numChannels:numChannels];
+// self.audioManager.inputBlock = ^(float *data, UInt32 numFrames, UInt32 numChannels) {
+// [wself.fileWriter writeNewAudio:data numFrames:numFrames numChannels:numChannels];
// counter += 1;
// if (counter > 400) { // roughly 5 seconds of audio
-// audioManager.inputBlock = nil;
-// [fileWriter release];
+// wself.audioManager.inputBlock = nil;
// }
// };

0 comments on commit ca4d47b

Please sign in to comment.