Exemple #1
0
        void PrepareAudioQueue(MonoTouch.CoreFoundation.CFUrl url)
        {
            AudioStreamBasicDescription audioFormat = new AudioStreamBasicDescription()
            {
                SampleRate       = _samplingRate,
                Format           = AudioFormatType.LinearPCM,
                FormatFlags      = AudioFormatFlags.LinearPCMIsSignedInteger | AudioFormatFlags.LinearPCMIsBigEndian | AudioFormatFlags.LinearPCMIsPacked,
                FramesPerPacket  = 1,
                ChannelsPerFrame = 1,  // monoral
                BitsPerChannel   = 16, // 16-bit
                BytesPerPacket   = 2,
                BytesPerFrame    = 2,
                Reserved         = 0
            };

            _audioFile = AudioFile.Create(url, AudioFileType.AIFF, audioFormat, AudioFileFlags.EraseFlags);

            _queue = new InputAudioQueue(audioFormat);
            _queue.InputCompleted += new EventHandler <InputCompletedEventArgs>(_queue_InputCompleted);

            _startingPacketCount = 0;
            _numPacketsToWrite   = 1024;
            _bufferByteSize      = (int)(_numPacketsToWrite * audioFormat.BytesPerPacket);

            // preparing queue buffer
            IntPtr bufferPtr;

            for (int index = 0; index < 3; index++)
            {
                //_queue.AllocateBuffer(_bufferByteSize, out bufferPtr);
                _queue.AllocateBufferWithPacketDescriptors(_bufferByteSize, _numPacketsToWrite, out bufferPtr);
                _queue.EnqueueBuffer(bufferPtr, _bufferByteSize, null);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
     
            /*
            var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            path = System.IO.Path.Combine(path, "loop_stereo.aif"); // loop_mono.wav
            if (!System.IO.File.Exists(path))
                throw new ArgumentException("file not found; " + path);*/

            _url = MonoTouch.CoreFoundation.CFUrl.FromFile("output.aif");
            _player = new RemoteIOPlayThrough();
            
            _playButton.TouchDown += new EventHandler(_playButton_TouchDown);
            _stopButton.TouchDown += new EventHandler(_stopButton_TouchDown);

            _player.Play();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            /*
             * var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
             * path = System.IO.Path.Combine(path, "loop_stereo.aif"); // loop_mono.wav
             * if (!System.IO.File.Exists(path))
             *  throw new ArgumentException("file not found; " + path);*/

            _url    = MonoTouch.CoreFoundation.CFUrl.FromFile("output.aif");
            _player = new RemoteIOPlayThrough();

            _playButton.TouchDown += new EventHandler(_playButton_TouchDown);
            _stopButton.TouchDown += new EventHandler(_stopButton_TouchDown);

            _player.Play();
        }
Exemple #4
0
        public static ExtAudioFile OpenURL(MonoTouch.CoreFoundation.CFUrl url)
        {
            int    err;
            IntPtr ptr = new IntPtr();

            unsafe {
                err = ExtAudioFileOpenURL(url.Handle, (IntPtr)(&ptr));
            }
            if (err != 0)
            {
                throw new ArgumentException(String.Format("Error code:{0}", err));
            }
            if (ptr == IntPtr.Zero)
            {
                throw new InvalidOperationException("Can not get object instance");
            }

            return(new ExtAudioFile(ptr));
        }
Exemple #5
0
        public static ExtAudioFile CreateWithURL(MonoTouch.CoreFoundation.CFUrl url,
                                                 AudioFileType fileType,
                                                 AudioStreamBasicDescription inStreamDesc,
                                                 //AudioChannelLayout channelLayout,
                                                 AudioFileFlags flag)
        {
            int    err;
            IntPtr ptr = new IntPtr();

            unsafe {
                err = ExtAudioFileCreateWithURL(url.Handle, fileType, ref inStreamDesc, IntPtr.Zero, (uint)flag,
                                                (IntPtr)(&ptr));
            }
            if (err != 0)
            {
                throw new ArgumentException(String.Format("Error code:{0}", err));
            }
            if (ptr == IntPtr.Zero)
            {
                throw new InvalidOperationException("Can not get object instance");
            }

            return(new ExtAudioFile(ptr));
        }
Exemple #6
0
 public AudioQueueRecorder(MonoTouch.CoreFoundation.CFUrl url)
 {
     _isRecording = false;
     PrepareAudioQueue(url);
 }