public static AudioFormatError GetFormatInfo(ref AudioStreamBasicDescription format) { unsafe { var size = sizeof(AudioStreamBasicDescription); return(AudioFormatPropertyNative.AudioFormatGetProperty(AudioFormatProperty.FormatInfo, 0, IntPtr.Zero, ref size, ref format)); } }
public static AudioStreamBasicDescription[] GetAvailableStreamDescriptions(AudioFileType fileType, AudioFormatType formatType) { AudioFileTypeAndFormatID input; input.FileType = fileType; input.FormatType = formatType; uint size; if (AudioFileGetGlobalInfoSize(AudioFileGlobalProperty.AvailableStreamDescriptionsForFormat, (uint)sizeof(AudioFileTypeAndFormatID), ref input, out size) != 0) { return(null); } var data = new AudioStreamBasicDescription[size / sizeof(AudioStreamBasicDescription)]; fixed(AudioStreamBasicDescription *ptr = data) { var res = AudioFileGetGlobalInfo(AudioFileGlobalProperty.AvailableStreamDescriptionsForFormat, (uint)sizeof(AudioFileTypeAndFormatID), ref input, ref size, ptr); if (res != 0) { return(null); } return(data); } }
public static AudioConverter Create(AudioStreamBasicDescription sourceFormat, AudioStreamBasicDescription destinationFormat, out AudioConverterError error) { IntPtr ptr = new IntPtr(); error = AudioConverterNew(ref sourceFormat, ref destinationFormat, ref ptr); if (error != AudioConverterError.None) { return(null); } return(new AudioConverter(ptr, true)); }
public static AudioStreamBasicDescription CreateLinearPCM(double sampleRate = 44100, 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.IsSignedInteger | AudioFormatFlags.IsPacked; if (bigEndian) desc.FormatFlags |= AudioFormatFlags.IsBigEndian; return desc; }
public static unsafe int[] GetAvailableEncodeNumberChannels(AudioStreamBasicDescription format) { uint size; if (AudioFormatPropertyNative.AudioFormatGetPropertyInfo (AudioFormatProperty.AvailableEncodeNumberChannels, sizeof (AudioStreamBasicDescription), ref format, out size) != 0) return null; var data = new int[size / sizeof (int)]; fixed (int* ptr = data) { var res = AudioFormatPropertyNative.AudioFormatGetProperty (AudioFormatProperty.AvailableEncodeNumberChannels, sizeof (AudioStreamBasicDescription), ref format, ref size, ptr); if (res != 0) return null; return data; } }
public static AudioConverter Create(AudioStreamBasicDescription sourceFormat, AudioStreamBasicDescription destinationFormat, AudioClassDescription[] descriptions) { if (descriptions == null) { throw new ArgumentNullException("descriptions"); } IntPtr ptr = new IntPtr(); var res = AudioConverterNewSpecific(ref sourceFormat, ref destinationFormat, descriptions.Length, ref descriptions, ref ptr); if (res != AudioConverterError.None) { return(null); } return(new AudioConverter(ptr, true)); }
public unsafe static AudioChannelLayoutTag[] GetAvailableEncodeChannelLayoutTags(AudioStreamBasicDescription format) { var type_size = sizeof(AudioStreamBasicDescription); uint size; if (AudioFormatPropertyNative.AudioFormatGetPropertyInfo(AudioFormatProperty.AvailableEncodeChannelLayoutTags, type_size, ref format, out size) != 0) { return(null); } var data = new AudioChannelLayoutTag[size / sizeof(AudioChannelLayoutTag)]; fixed(AudioChannelLayoutTag *ptr = data) { var res = AudioFormatPropertyNative.AudioFormatGetProperty(AudioFormatProperty.AvailableEncodeChannelLayoutTags, type_size, ref format, ref size, (int *)ptr); if (res != 0) { return(null); } return(data); } }
static extern AudioConverterError AudioConverterNewSpecific(ref AudioStreamBasicDescription inSourceFormat, ref AudioStreamBasicDescription inDestinationFormat, int inNumberClassDescriptions, ref AudioClassDescription[] inClassDescriptions, ref IntPtr outAudioConverter);
static extern AudioConverterError AudioConverterNew(ref AudioStreamBasicDescription inSourceFormat, ref AudioStreamBasicDescription inDestinationFormat, ref IntPtr outAudioConverter);
public static AudioConverter Create(AudioStreamBasicDescription sourceFormat, AudioStreamBasicDescription destinationFormat) { AudioConverterError res; return(Create(sourceFormat, destinationFormat, out res)); }