Skip to content
Browse files

Make endianness configurable

  • Loading branch information...
1 parent a611885 commit 52186d2e40ef1a1d13a15736b92157a3d1eeef09 @marek-safar marek-safar committed Nov 23, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/AudioToolbox/AudioType.cs
View
6 src/AudioToolbox/AudioType.cs
@@ -127,15 +127,17 @@ public AudioStreamBasicDescription (AudioFormatType formatType)
Format = formatType;
}
- public static AudioStreamBasicDescription CreateLinearPCM (double sampleRate = 441000, uint channelsPerFrame = 2, uint bitsPerChannel = 16)
+ public static AudioStreamBasicDescription CreateLinearPCM (double sampleRate = 441000, uint channelsPerFrame = 2, uint bitsPerChannel = 16, bool bigEndian = false)
{
var desc = new AudioStreamBasicDescription (AudioFormatType.LinearPCM);
desc.SampleRate = sampleRate;
desc.ChannelsPerFrame = (int) channelsPerFrame;
desc.BitsPerChannel = (int) bitsPerChannel;
desc.BytesPerPacket = desc.BytesPerFrame = (int) channelsPerFrame * sizeof (Int16);
desc.FramesPerPacket = 1;
- desc.FormatFlags = AudioFormatFlags.IsBigEndian | AudioFormatFlags.IsSignedInteger | AudioFormatFlags.IsPacked;
+ desc.FormatFlags = AudioFormatFlags.IsSignedInteger | AudioFormatFlags.IsPacked;
+ if (bigEndian)
+ desc.FormatFlags |= AudioFormatFlags.IsBigEndian;
return desc;
}

0 comments on commit 52186d2

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