Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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