Skip to content

Commit

Permalink
fix issue #243
Browse files Browse the repository at this point in the history
  • Loading branch information
thuydx55 committed Dec 30, 2015
1 parent f27e299 commit 086d627
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions EZAudio/EZAudioUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions EZAudio/EZAudioUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion EZAudio/EZRecorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ + (AudioStreamBasicDescription)formatForFileType:(EZRecorderFileType)fileType
break;

case EZRecorderFileTypeWAV:
asbd = [EZAudioUtilities stereoFloatInterleavedFormatWithSampleRate:sourceFormat.mSampleRate];
asbd = [EZAudioUtilities stereoSignedIntegerPackedFormatWithSampleRate:sourceFormat.mSampleRate];
break;

default:
Expand Down

0 comments on commit 086d627

Please sign in to comment.