Skip to content
Browse files

Cleaned up the code a bit. Removed a goto. :-)

Removed Apple's copyright notice from OpenALSupport, which is only required when you distribute unmodified sample code.
  • Loading branch information...
1 parent 5c42e18 commit f9b0376af63fc6f71892802cdb926bdb0cb02b5b @hollance committed Dec 22, 2012
View
24 Demo.xcodeproj/project.pbxproj
@@ -10,6 +10,7 @@
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
+ 7B254DE41685DD1300B21EF9 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7B254DE31685DD1300B21EF9 /* Default-568h@2x.png */; };
7BAA29921212690D00BF4296 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BAA29911212690D00BF4296 /* OpenAL.framework */; };
7BAA29961212691700BF4296 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BAA29951212691700BF4296 /* AudioToolbox.framework */; };
7BAA29DA12126BFA00BF4296 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BAA29D912126BFA00BF4296 /* QuartzCore.framework */; };
@@ -47,6 +48,7 @@
1D6058910D05DD3D006BFB54 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 7B254DE31685DD1300B21EF9 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
7BAA29911212690D00BF4296 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
7BAA29951212691700BF4296 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
7BAA29D912126BFA00BF4296 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
@@ -135,6 +137,17 @@
name = Frameworks;
sourceTree = "<group>";
};
+ 7B254DE01685DC2C00B21EF9 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 7B254DE31685DD1300B21EF9 /* Default-568h@2x.png */,
+ 7BF55AE71595F5CE00324B00 /* Demo-Info.plist */,
+ 7BF55AE81595F5CE00324B00 /* Demo_Prefix.pch */,
+ 7BF55AEE1595F5CE00324B00 /* main.m */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
7BACBAB91211DE8E005E8F00 /* Sounds */ = {
isa = PBXGroup;
children = (
@@ -177,14 +190,12 @@
7BF55AE61595F5CE00324B00 /* Demo */ = {
isa = PBXGroup;
children = (
- 7BF55AE71595F5CE00324B00 /* Demo-Info.plist */,
- 7BF55AE81595F5CE00324B00 /* Demo_Prefix.pch */,
7BF55AE91595F5CE00324B00 /* DemoAppDelegate.h */,
7BF55AEA1595F5CE00324B00 /* DemoAppDelegate.m */,
7BF55AEB1595F5CE00324B00 /* DemoViewController.h */,
7BF55AEC1595F5CE00324B00 /* DemoViewController.m */,
7BF55AED1595F5CE00324B00 /* DemoViewController.xib */,
- 7BF55AEE1595F5CE00324B00 /* main.m */,
+ 7B254DE01685DC2C00B21EF9 /* Supporting Files */,
);
path = Demo;
sourceTree = "<group>";
@@ -263,6 +274,7 @@
7BACBAE21211DE8E005E8F00 /* P200 Piano G#9.caf in Resources */,
7BACBAE31211DE8E005E8F00 /* Piano.plist in Resources */,
7BF55AF21595F5CE00324B00 /* DemoViewController.xib in Resources */,
+ 7B254DE41685DD1300B21EF9 /* Default-568h@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -296,7 +308,6 @@
GCC_PREFIX_HEADER = Demo/Demo_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "Demo/Demo-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = Demo;
RUN_CLANG_STATIC_ANALYZER = YES;
WARNING_CFLAGS = (
@@ -317,7 +328,6 @@
GCC_PREFIX_HEADER = Demo/Demo_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "Demo/Demo-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
PRODUCT_NAME = Demo;
RUN_CLANG_STATIC_ANALYZER = YES;
VALIDATE_PRODUCT = YES;
@@ -337,7 +347,7 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
SDKROOT = iphoneos;
};
name = Debug;
@@ -350,7 +360,7 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
};
View
BIN Demo/Default-568h@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3 Demo/DemoAppDelegate.m
@@ -4,9 +4,6 @@
@implementation DemoAppDelegate
-@synthesize window = _window;
-@synthesize viewController = _viewController;
-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
View
34 Demo/DemoViewController.m
@@ -2,7 +2,7 @@
// The sounds in this demo project were taken from Fluid R3 by Frank Wen,
// a freely distributable SoundFont.
-#import <QuartzCore/CABase.h>
+#import <QuartzCore/QuartzCore.h>
#import "DemoViewController.h"
#import "SoundBankPlayer.h"
@@ -13,8 +13,8 @@ @implementation DemoViewController
BOOL _playingArpeggio;
NSArray *_arpeggioNotes;
NSUInteger _arpeggioIndex;
- double _arpeggioStartTime;
- double _arpeggioDelay;
+ CFTimeInterval _arpeggioStartTime;
+ CFTimeInterval _arpeggioDelay;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
@@ -48,13 +48,7 @@ - (IBAction)strumCMajorChord
- (IBAction)arpeggiateCMajorChord
{
- NSArray *notes = [NSArray arrayWithObjects:
- [NSNumber numberWithInt:48],
- [NSNumber numberWithInt:55],
- [NSNumber numberWithInt:64],
- nil];
-
- [self playArpeggioWithNotes:notes delay:0.05];
+ [self playArpeggioWithNotes:@[@48, @55, @64] delay:0.05f];
}
- (IBAction)strumAMinorChord
@@ -68,18 +62,10 @@ - (IBAction)strumAMinorChord
- (IBAction)arpeggiateAMinorChord
{
- NSArray *notes = [NSArray arrayWithObjects:
- [NSNumber numberWithInt:33],
- [NSNumber numberWithInt:45],
- [NSNumber numberWithInt:52],
- [NSNumber numberWithInt:60],
- [NSNumber numberWithInt:67],
- nil];
-
- [self playArpeggioWithNotes:notes delay:0.1];
+ [self playArpeggioWithNotes:@[@33, @45, @52, @60, @67] delay:0.1f];
}
-- (void)playArpeggioWithNotes:(NSArray *)notes delay:(double)delay
+- (void)playArpeggioWithNotes:(NSArray *)notes delay:(CFTimeInterval)delay
{
if (!_playingArpeggio)
{
@@ -93,7 +79,7 @@ - (void)playArpeggioWithNotes:(NSArray *)notes delay:(double)delay
- (void)startTimer
{
- _timer = [NSTimer scheduledTimerWithTimeInterval:0.05 // 50 ms
+ _timer = [NSTimer scheduledTimerWithTimeInterval:0.05f // 50 ms
target:self
selector:@selector(handleTimer:)
userInfo:nil
@@ -114,13 +100,13 @@ - (void)handleTimer:(NSTimer *)timer
if (_playingArpeggio)
{
// Play each note of the arpeggio after "arpeggioDelay" seconds.
- double now = CACurrentMediaTime();
+ CFTimeInterval now = CACurrentMediaTime();
if (now - _arpeggioStartTime >= _arpeggioDelay)
{
- NSNumber *number = (NSNumber *)[_arpeggioNotes objectAtIndex:_arpeggioIndex];
+ NSNumber *number = _arpeggioNotes[_arpeggioIndex];
[_soundBankPlayer noteOn:[number intValue] gain:0.4f];
- ++_arpeggioIndex;
+ _arpeggioIndex += 1;
if (_arpeggioIndex == [_arpeggioNotes count])
{
_playingArpeggio = NO;
View
4 Demo/Demo_Prefix.pch
@@ -1,8 +1,8 @@
#import <Availability.h>
-#ifndef __IPHONE_4_0
-#warning "This project uses features only available in iOS SDK 4.0 and later."
+#ifndef __IPHONE_5_0
+#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
View
2 LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2008-2011 Matthijs Hollemans
+Copyright (c) 2008-2012 Matthijs Hollemans
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
2 README.md
@@ -3,5 +3,3 @@
This is a sample-based audio player that uses OpenAL. A "sound bank" can have multiple samples, each covering one or more notes. This allows you to implement a full instrument with only a few samples. It's like SoundFonts but simpler.
The sounds in this demo project were taken from Fluid R3 by Frank Wen, a freely distributable SoundFont.
-
-Requires Xcode 4.3 or better.
View
78 SoundBankPlayer/OpenALSupport.c
@@ -1,48 +1,3 @@
-/*
-
-(Modified from Apple's oalTouch sample code.)
-
-Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
-Inc. ("Apple") in consideration of your agreement to the following
-terms, and your use, installation, modification or redistribution of
-this Apple software constitutes acceptance of these terms. If you do
-not agree with these terms, please do not use, install, modify or
-redistribute this Apple software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, Apple grants you a personal, non-exclusive
-license, under Apple's copyrights in this original Apple software (the
-"Apple Software"), to use, reproduce, modify and redistribute the Apple
-Software, with or without modifications, in source and/or binary forms;
-provided that if you redistribute the Apple Software in its entirety and
-without modifications, you must retain this notice and the following
-text and disclaimers in all such redistributions of the Apple Software.
-Neither the name, trademarks, service marks or logos of Apple Inc. may
-be used to endorse or promote products derived from the Apple Software
-without specific prior written permission from Apple. Except as
-expressly stated in this notice, no other rights or licenses, express or
-implied, are granted by Apple herein, including but not limited to any
-patent rights that may be infringed by your derivative works or by other
-works in which the Apple Software may be incorporated.
-
-The Apple Software is provided by Apple on an "AS IS" basis. APPLE
-MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
-THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
-OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
-IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
-OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
-MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
-AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
-STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
-*/
#include "OpenALSupport.h"
@@ -71,14 +26,13 @@ ALvoid alcMacOSXMixerOutputRateProc(const ALdouble value)
void *GetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDataFormat, ALsizei *outSampleRate)
{
OSStatus err = noErr;
- void *theData = NULL;
ExtAudioFileRef extRef = NULL;
err = ExtAudioFileOpenURL(inFileURL, &extRef);
if (err != noErr)
{
printf("GetOpenALAudioData: ExtAudioFileOpenURL FAILED, Error = %ld\n", err);
- goto Exit;
+ return NULL;
}
AudioStreamBasicDescription theFileFormat;
@@ -87,13 +41,15 @@ void *GetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDa
if (err != noErr)
{
printf("GetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileDataFormat) FAILED, Error = %ld\n", err);
- goto Exit;
+ ExtAudioFileDispose(extRef);
+ return NULL;
}
if (theFileFormat.mChannelsPerFrame > 2)
{
printf("GetOpenALAudioData: Unsupported format, channel count is greater than stereo\n");
- goto Exit;
+ ExtAudioFileDispose(extRef);
+ return NULL;
}
// Set the output format to 16 bit signed integer (native-endian) data
@@ -112,7 +68,8 @@ void *GetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDa
if (err != noErr)
{
printf("GetOpenALAudioData: ExtAudioFileSetProperty(kExtAudioFileProperty_ClientDataFormat) FAILED, Error = %ld\n", err);
- goto Exit;
+ ExtAudioFileDispose(extRef);
+ return NULL;
}
SInt64 theFileLengthInFrames = 0;
@@ -121,15 +78,17 @@ void *GetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDa
if (err != noErr)
{
printf("GetOpenALAudioData: ExtAudioFileGetProperty(kExtAudioFileProperty_FileLengthFrames) FAILED, Error = %ld\n", err);
- goto Exit;
+ ExtAudioFileDispose(extRef);
+ return NULL;
}
UInt32 dataSize = theFileLengthInFrames * theOutputFormat.mBytesPerFrame;
- theData = malloc(dataSize);
+ void *theData = malloc(dataSize);
if (theData == NULL)
{
printf("GetOpenALAudioData: malloc FAILED\n");
- goto Exit;
+ ExtAudioFileDispose(extRef);
+ return NULL;
}
AudioBufferList theDataBuffer;
@@ -141,19 +100,16 @@ void *GetOpenALAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDa
err = ExtAudioFileRead(extRef, (UInt32 *)&theFileLengthInFrames, &theDataBuffer);
if (err != noErr)
{
- free(theData);
- theData = NULL; // make sure to return NULL
printf("GetOpenALAudioData: ExtAudioFileRead FAILED, Error = %ld\n", err);
- goto Exit;
- }
+ free(theData);
+ ExtAudioFileDispose(extRef);
+ return NULL;
+ }
*outDataSize = (ALsizei)dataSize;
*outDataFormat = (theOutputFormat.mChannelsPerFrame > 1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16;
*outSampleRate = (ALsizei)theOutputFormat.mSampleRate;
-Exit:
- if (extRef != NULL)
- ExtAudioFileDispose(extRef);
-
+ ExtAudioFileDispose(extRef);
return theData;
}
View
45 SoundBankPlayer/OpenALSupport.h
@@ -1,48 +1,5 @@
-/*
-(Modified from Apple's oalTouch sample code.)
-
-Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
-Inc. ("Apple") in consideration of your agreement to the following
-terms, and your use, installation, modification or redistribution of
-this Apple software constitutes acceptance of these terms. If you do
-not agree with these terms, please do not use, install, modify or
-redistribute this Apple software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, Apple grants you a personal, non-exclusive
-license, under Apple's copyrights in this original Apple software (the
-"Apple Software"), to use, reproduce, modify and redistribute the Apple
-Software, with or without modifications, in source and/or binary forms;
-provided that if you redistribute the Apple Software in its entirety and
-without modifications, you must retain this notice and the following
-text and disclaimers in all such redistributions of the Apple Software.
-Neither the name, trademarks, service marks or logos of Apple Inc. may
-be used to endorse or promote products derived from the Apple Software
-without specific prior written permission from Apple. Except as
-expressly stated in this notice, no other rights or licenses, express or
-implied, are granted by Apple herein, including but not limited to any
-patent rights that may be infringed by your derivative works or by other
-works in which the Apple Software may be incorporated.
-
-The Apple Software is provided by Apple on an "AS IS" basis. APPLE
-MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
-THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
-OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
-
-IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
-OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
-MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
-AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
-STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
- */
+// Modified from Apple's oalTouch sample code.
#import <AudioToolbox/AudioToolbox.h>
#import <AudioToolbox/ExtendedAudioFile.h>
View
22 SoundBankPlayer/SoundBankPlayer.h
@@ -1,6 +1,4 @@
-/*!
- * \file SoundBankPlayer.h
- *
+/*
* Copyright (c) 2008-2012 Matthijs Hollemans.
* With contributions from π.
* Licensed under the terms of the MIT license.
@@ -10,15 +8,15 @@
#import <OpenAL/al.h>
#import <OpenAL/alc.h>
-/*!
+/*
* How many OpenAL sources we will use. Each source plays a single buffer, so
* this effectively determines the maximum polyphony. There is an upper limit
* to the number of simultaneously playing sources that OpenAL supports.
* http://stackoverflow.com/questions/2871905/openal-determine-maximum-sources
*/
#define NUM_SOURCES 32
-/*!
+/*
* SoundBankPlayer is a sample-based audio player that uses OpenAL. It employs
* a "sound bank", which contains a set of samples that each cover one or more
* notes, allowing you to implement a full instrument with only a few samples.
@@ -33,7 +31,7 @@
*/
@interface SoundBankPlayer : NSObject
-/*!
+/*
* For continuous tone instruments (such as an organ sound) set this to YES.
*
* Make sure you provide raw sound fonts that wrap nicely, i.e. try to catch a
@@ -48,14 +46,14 @@
*/
@property (nonatomic, assign) BOOL loopNotes;
-/*!
+/*
* Sets the sound bank that the sounds will be loaded from.
*
* @param soundBankName the name of a PLIST file from the bundle
*/
- (void)setSoundBank:(NSString *)soundBankName;
-/*!
+/*
* Plays the note with the specified MIDI note number.
*
* If there are no free sources found (i.e. there are more than NUM_SOURCES
@@ -69,25 +67,25 @@
*/
- (void)noteOn:(int)midiNoteNumber gain:(float)gain;
-/*!
+/*
* To play a chord, performance will be better if you enqueue a bunch of notes
* and then play them all simultaneously.
*/
- (void)queueNote:(int)midiNoteNumber gain:(float)gain;
-/*!
+/*
* Plays the enqueued notes.
*/
- (void)playQueuedNotes;
-/*!
+/*
* Stops playing a particular note. This method is really only useful when
* loopNotes is set to YES. Turning a note off when it is not playing is okay,
* it just does nothing.
*/
- (void)noteOff:(int)midiNoteNumber;
-/*!
+/*
* Stops all playing notes.
*/
- (void)allNotesOff;
View
14 SoundBankPlayer/SoundBankPlayer.m
@@ -60,8 +60,6 @@ @implementation SoundBankPlayer
NSString *_soundBankName; // name of the current sound bank
}
-@synthesize loopNotes = _loopNotes;
-
- (id)init
{
if ((self = [super init]))
@@ -145,7 +143,7 @@ - (void)loadSoundBank:(NSString *)filename
return;
}
- _sampleRate = [(NSString *)[array objectAtIndex:0] intValue];
+ _sampleRate = [(NSString *)array[0] intValue];
_numBuffers = ([array count] - 1) / 3;
if (_numBuffers > MAX_BUFFERS)
@@ -154,9 +152,9 @@ - (void)loadSoundBank:(NSString *)filename
int midiStart = 0;
for (int t = 0; t < _numBuffers; ++t)
{
- _buffers[t].filename = CFBridgingRetain([array objectAtIndex:1 + t*3]);
- int midiEnd = [(NSString *)[array objectAtIndex:1 + t*3 + 1] intValue];
- int rootKey = [(NSString *)[array objectAtIndex:1 + t*3 + 2] intValue];
+ _buffers[t].filename = CFBridgingRetain(array[1 + t*3]);
+ int midiEnd = [(NSString *)array[1 + t*3 + 1] intValue];
+ int rootKey = [(NSString *)array[1 + t*3 + 2] intValue];
_buffers[t].pitch = _notes[rootKey].pitch;
if (t == _numBuffers - 1)
@@ -171,7 +169,7 @@ - (void)loadSoundBank:(NSString *)filename
#pragma mark - Audio Session
-static void interruptionListener(void *inClientData, UInt32 inInterruptionState)
+static void InterruptionListener(void *inClientData, UInt32 inInterruptionState)
{
SoundBankPlayer *player = (__bridge SoundBankPlayer *)inClientData;
if (inInterruptionState == kAudioSessionBeginInterruption)
@@ -188,7 +186,7 @@ - (void)registerAudioSessionCategory
- (void)setUpAudioSession
{
- AudioSessionInitialize(NULL, NULL, interruptionListener, (__bridge void *)self);
+ AudioSessionInitialize(NULL, NULL, InterruptionListener, (__bridge void *)self);
[self registerAudioSessionCategory];
AudioSessionSetActive(true);
}

0 comments on commit f9b0376

Please sign in to comment.
Something went wrong with that request. Please try again.