diff --git a/EZAudio/EZAudioUtilities.h b/EZAudio/EZAudioUtilities.h index 1ae97451..158e61d3 100644 --- a/EZAudio/EZAudioUtilities.h +++ b/EZAudio/EZAudioUtilities.h @@ -231,6 +231,15 @@ typedef NSRect EZRect; //------------------------------------------------------------------------------ +/** + Creates a two-channel, packed, signed integer-based AudioStreamBasicDescription. + @param sampleRate A float representing the sample rate. + @return A new AudioStreamBasicDescription with the specified format. + */ ++ (AudioStreamBasicDescription)stereoSignedIntegerPackedFormatWithSampleRate:(float)sampleRate; + +//------------------------------------------------------------------------------ + /** Creates a two-channel, non-interleaved, float-based AudioStreamBasicDescription. @param sampleRate A float representing the sample rate. diff --git a/EZAudio/EZAudioUtilities.m b/EZAudio/EZAudioUtilities.m index 82402dad..6f3e76e6 100644 --- a/EZAudio/EZAudioUtilities.m +++ b/EZAudio/EZAudioUtilities.m @@ -302,6 +302,24 @@ + (AudioStreamBasicDescription)stereoFloatInterleavedFormatWithSampleRate:(float //------------------------------------------------------------------------------ ++ (AudioStreamBasicDescription)stereoSignedIntegerPackedFormatWithSampleRate:(float)sampleRate +{ + AudioStreamBasicDescription asbd; + UInt32 floatByteSize = sizeof(float); + asbd.mChannelsPerFrame = 2; + asbd.mBitsPerChannel = 4 * floatByteSize; + asbd.mBytesPerFrame = asbd.mChannelsPerFrame * floatByteSize; + asbd.mFramesPerPacket = 1; + asbd.mBytesPerPacket = asbd.mFramesPerPacket * asbd.mBytesPerFrame; + asbd.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; + asbd.mFormatID = kAudioFormatLinearPCM; + asbd.mSampleRate = sampleRate; + asbd.mReserved = 0; + return asbd; +} + +//------------------------------------------------------------------------------ + + (AudioStreamBasicDescription)stereoFloatNonInterleavedFormatWithSampleRate:(float)sampleRate { AudioStreamBasicDescription asbd; diff --git a/EZAudio/EZRecorder.m b/EZAudio/EZRecorder.m index 0b61b987..70ff0865 100644 --- a/EZAudio/EZRecorder.m +++ b/EZAudio/EZRecorder.m @@ -233,7 +233,7 @@ + (AudioStreamBasicDescription)formatForFileType:(EZRecorderFileType)fileType break; case EZRecorderFileTypeWAV: - asbd = [EZAudioUtilities stereoFloatInterleavedFormatWithSampleRate:sourceFormat.mSampleRate]; + asbd = [EZAudioUtilities stereoSignedIntegerPackedFormatWithSampleRate:sourceFormat.mSampleRate]; break; default: