Ejemplo n.º 1
0
        public AudioQueueStatus SetOfflineRenderFormat(AudioStreamBasicDescription desc, AudioChannelLayout layout)
        {
            int size;
            var h = layout == null ? IntPtr.Zero : AudioChannelLayout.ToBlock(layout, out size);

            try {
                return(AudioQueueSetOfflineRenderFormat(handle, ref desc, h));
            } finally {
                Marshal.FreeHGlobal(h);
            }
        }
Ejemplo n.º 2
0
        public unsafe static float[,] GetMatrixMixMap(AudioChannelLayout inputLayout, AudioChannelLayout outputLayout)
        {
            if (inputLayout == null)
            {
                throw new ArgumentNullException("inputLayout");
            }
            if (outputLayout == null)
            {
                throw new ArgumentNullException("outputLayout");
            }

            var channels_count_output = GetNumberOfChannels(outputLayout);

            if (channels_count_output == null)
            {
                throw new ArgumentException("outputLayout");
            }

            var channels_count_input = GetNumberOfChannels(inputLayout);

            if (channels_count_input == null)
            {
                throw new ArgumentException("inputLayout");
            }

            int ptr_size;
            var input_ptr  = inputLayout.ToBlock(out ptr_size);
            var output_ptr = outputLayout.ToBlock(out ptr_size);
            var array      = new IntPtr[] { input_ptr, output_ptr };

            ptr_size = sizeof(IntPtr) * array.Length;

            float[,] value;
            AudioFormatError res;

            fixed(IntPtr *ptr = &array[0])
            {
                value = new float[channels_count_input.Value, channels_count_output.Value];
                var size = sizeof(float) * channels_count_input.Value * channels_count_output.Value;

                fixed(float *value_ptr = &value[0, 0])
                {
                    res = AudioFormatPropertyNative.AudioFormatGetProperty(AudioFormatProperty.MatrixMixMap, ptr_size, ptr, ref size, value_ptr);
                }
            }

            Marshal.FreeHGlobal(input_ptr);
            Marshal.FreeHGlobal(output_ptr);

            return(res == 0 ? value : null);
        }
Ejemplo n.º 3
0
        public static AudioFormatError Validate(AudioChannelLayout layout)
        {
            if (layout == null)
            {
                throw new ArgumentNullException("layout");
            }

            int ptr_size;
            var ptr = layout.ToBlock(out ptr_size);

            var res = AudioFormatPropertyNative.AudioFormatGetProperty(AudioFormatProperty.ValidateChannelLayout, ptr_size, ptr, IntPtr.Zero, IntPtr.Zero);

            Marshal.FreeHGlobal(ptr);
            return(res);
        }
Ejemplo n.º 4
0
        public static int?GetNumberOfChannels(AudioChannelLayout layout)
        {
            if (layout == null)
            {
                throw new ArgumentNullException("layout");
            }

            int ptr_size;
            var ptr  = layout.ToBlock(out ptr_size);
            int size = sizeof(int);
            int value;

            var res = AudioFormatPropertyNative.AudioFormatGetProperty(AudioFormatProperty.NumberOfChannelsForLayout, ptr_size, ptr, ref size, out value);

            Marshal.FreeHGlobal(ptr);
            return(res != 0 ? null : (int?)value);
        }
Ejemplo n.º 5
0
		public static AudioChannelLayoutTag? GetTagForChannelLayout (AudioChannelLayout layout)
		{
			if (layout == null)
				throw new ArgumentNullException ("layout");

			int ptr_size;
			var ptr = layout.ToBlock (out ptr_size);
			int size = sizeof (AudioChannelLayoutTag);
			int value;

			var res = AudioFormatPropertyNative.AudioFormatGetProperty (AudioFormatProperty.TagForChannelLayout, ptr_size, ptr, ref size, out value);
			Marshal.FreeHGlobal (ptr);
			return res != 0 ? null : (AudioChannelLayoutTag?) value;
		}
Ejemplo n.º 6
0
		public unsafe static float[,] GetMatrixMixMap (AudioChannelLayout inputLayout, AudioChannelLayout outputLayout)
		{
			if (inputLayout == null)
				throw new ArgumentNullException ("inputLayout");
			if (outputLayout == null)
				throw new ArgumentNullException ("outputLayout");

			var channels_count_output = GetNumberOfChannels (outputLayout);
			if (channels_count_output == null)
				throw new ArgumentException ("outputLayout");

			var channels_count_input = GetNumberOfChannels (inputLayout);
			if (channels_count_input == null)
				throw new ArgumentException ("inputLayout");

			int ptr_size;
			var input_ptr = inputLayout.ToBlock (out ptr_size);
			var output_ptr = outputLayout.ToBlock (out ptr_size);
			var array = new IntPtr[] { input_ptr, output_ptr };
			ptr_size = sizeof (IntPtr) * array.Length;

			float[,] value;
			AudioFormatError res;

			fixed (IntPtr* ptr = &array[0]) {
				value = new float[channels_count_input.Value, channels_count_output.Value];
				var size = sizeof (float) * channels_count_input.Value * channels_count_output.Value;
				fixed (float* value_ptr = &value[0, 0]) {
					res = AudioFormatPropertyNative.AudioFormatGetProperty (AudioFormatProperty.MatrixMixMap, ptr_size, ptr, ref size, value_ptr);
				}
			}

			Marshal.FreeHGlobal (input_ptr);
			Marshal.FreeHGlobal (output_ptr);

			return res == 0 ? value : null;
		}
Ejemplo n.º 7
0
		public static AudioFormatError Validate (AudioChannelLayout layout)
		{
			if (layout == null)
				throw new ArgumentNullException ("layout");

			int ptr_size;
			var ptr = layout.ToBlock (out ptr_size);

			var res = AudioFormatPropertyNative.AudioFormatGetProperty (AudioFormatProperty.ValidateChannelLayout, ptr_size, ptr, IntPtr.Zero, IntPtr.Zero);
			Marshal.FreeHGlobal (ptr);
			return res;
		}