public AudioGraphEventArgs(AudioUnitRenderActionFlags actionFlags,
				       MonoMac.AudioToolbox.AudioTimeStamp timeStamp,
				       int busNumber,
				       int numberFrames,
				       AudioBufferList data)
		    : base(actionFlags, timeStamp, busNumber, numberFrames, data)
	    {
	    }
Exemplo n.º 2
0
 public _AudioConverterEventArgs(
     uint _NumberDataPackets,
     AudioBufferList _Data,
     MonoMac.AudioToolbox.AudioStreamPacketDescription[] _DataPacketDescription)
 {
     NumberDataPackets = _NumberDataPackets;
     Data = _Data;
     DataPacketDescription = _DataPacketDescription;
 }
Exemplo n.º 3
0
        public AudioUnitEventArgs(AudioUnitRenderActionFlags actionFlags,
				  MonoMac.AudioToolbox.AudioTimeStamp timestamp,
				  int busNumber,
				  int frames,
				  AudioBufferList data)
        {
            ActionFlags = actionFlags;
            this.TimeStamp = timestamp;
            BusNumber = busNumber;
            NumberFrames = frames;
            Data = data;
        }
Exemplo n.º 4
0
        static int complexInputDataProc(
            IntPtr inAudioConverrter,
            ref uint ioNumberDataPackets,
            AudioBufferList ioData,
            ref AudioStreamPacketDescription[] outDataPacketDescription, //AudioStreamPacketDescription**
            IntPtr inUserData
            )
        {
            // getting audiounit instance
            var handler = GCHandle.FromIntPtr(inUserData);
            var inst = (_AudioConverter)handler.Target;

            // evoke event handler with an argument
            if (inst.EncoderCallback != null)
            {
                var args = new _AudioConverterEventArgs(
                    ioNumberDataPackets,
                    ioData,
                    outDataPacketDescription);
                inst.EncoderCallback(inst, args);
            }

            return 0; // noerror
        }
Exemplo n.º 5
0
        public void WriteAsync(int numberFrames, AudioBufferList data)
        {
            IntPtr buffer = data == null ? IntPtr.Zero : data.ToPointer ();
            int err = ExtAudioFileWriteAsync(_extAudioFile, numberFrames, buffer);

            // Try not to leak unmanaged pointer buffer
            if (last_async_write_buffer_ptr != IntPtr.Zero) {
                Marshal.FreeHGlobal (last_async_write_buffer_ptr);
                last_async_write_buffer_ptr = IntPtr.Zero;
            }

            if (err != 0) {
                if (buffer != IntPtr.Zero)
                    Marshal.FreeHGlobal (buffer);
                throw new ArgumentException(String.Format("Error code:{0}", err));
            }

            if (buffer != IntPtr.Zero) {
                last_async_write_buffer_ptr = buffer;
            }
        }
Exemplo n.º 6
0
        public int Read(int numberFrames, AudioBufferList data)
        {
            if (data == null)
                throw new ArgumentNullException ("data");

            var ptr = data.ToPointer ();
            int err = ExtAudioFileRead(_extAudioFile, ref numberFrames, ptr);
            Marshal.FreeHGlobal (ptr);
            if (err != 0)
            {
                throw new ArgumentException(String.Format("Error code:{0}", err));
            }

            return numberFrames;
        }
Exemplo n.º 7
0
		static extern int AudioUnitRender(IntPtr inUnit,
						  ref AudioUnitRenderActionFlags ioActionFlags,
						  ref AudioTimeStamp inTimeStamp,
						  int inOutputBusNumber,
						  int inNumberFrames,
						  AudioBufferList ioData);
Exemplo n.º 8
0
		public AudioUnitStatus TryRender(AudioUnitRenderActionFlags flags,
						AudioTimeStamp timeStamp,
						int outputBusnumber,
						int numberFrames, AudioBufferList data)
		{
			return (AudioUnitStatus) AudioUnitRender(handle,
								ref flags,
								ref timeStamp,
								outputBusnumber,
								numberFrames,
								data);
		}
Exemplo n.º 9
0
		public void Render(AudioUnitRenderActionFlags flags,
				   AudioTimeStamp timeStamp,
				   int outputBusnumber,
				   int numberFrames, AudioBufferList data)
		{
			int err = AudioUnitRender(handle,
						  ref flags,
						  ref timeStamp,
						  outputBusnumber,
						  numberFrames,
						  data);
			if (err != 0)
				throw new AudioUnitException (err);
		}
Exemplo n.º 10
0
		static int renderCallback(IntPtr inRefCon, ref AudioUnitRenderActionFlags _ioActionFlags,
					  ref AudioTimeStamp _inTimeStamp,
					  int _inBusNumber,
					  int _inNumberFrames,
					  AudioBufferList _ioData)
		{
			// getting audiounit instance
			var handler = GCHandle.FromIntPtr(inRefCon);
			var inst = (AudioUnit)handler.Target;
			
			// evoke event handler with an argument
			if (inst.RenderCallback != null)  { 
				var args = new AudioUnitEventArgs(
					_ioActionFlags,
					_inTimeStamp,
					_inBusNumber,
					_inNumberFrames,
					_ioData);
				inst.RenderCallback(inst, args);
			}
			
			return 0; // noerror
		}
Exemplo n.º 11
0
 static extern int ExtAudioFileWriteAsync(IntPtr inExtAudioFile, uint inNumberFrames, AudioBufferList ioData);
Exemplo n.º 12
0
 static extern int ExtAudioFileRead(IntPtr  inExtAudioFile, ref uint ioNumberFrames, AudioBufferList ioData);
Exemplo n.º 13
0
 public void WriteAsync(uint numberFrames, AudioBufferList data)
 {
     int err = ExtAudioFileWriteAsync(_extAudioFile, numberFrames, data);
     if (err != 0)
         throw new ArgumentException(String.Format("Error code:{0}", err));
 }
Exemplo n.º 14
0
        public uint Read(uint numberFrames, AudioBufferList data)
        {
            int err = ExtAudioFileRead(_extAudioFile, ref numberFrames, data);
            if (err != 0)
            {
                throw new ArgumentException(String.Format("Error code:{0}", err));
            }

            return numberFrames;
        }
Exemplo n.º 15
0
 static extern int AudioConverterFillComplexBuffer(
     IntPtr 		inAudioConverter,
     AudioConverterComplexInputDataProc	inInputDataProc,
     IntPtr inInputDataProcUserData,
     ref uint ioOutputDataPacketSize,
     AudioBufferList outOutputData,
     AudioStreamPacketDescription[] outPacketDescription);
Exemplo n.º 16
0
 public void FillBuffer(AudioBufferList data, uint numberFrames, AudioStreamPacketDescription[] packetDescs)
 {
     uint numPackets = numberFrames;
     int err =AudioConverterFillComplexBuffer(                
         _audioConverter,
         complexInputDataProc,
         GCHandle.ToIntPtr(_handle),
         ref numPackets,
         data,
         packetDescs);
     if(err != 0 || numPackets == 0) {
         throw new InvalidOperationException(String.Format("Error code:{0}", err));
     }            
 }