Ejemplo n.º 1
0
        void SetPlayerFile(NSUrl fileUrl)
        {
            NSError error;

            file = new AVAudioFile(fileUrl, out error);
            if (error != null)
            {
                throw new NSErrorException(error);
            }

            engine.Connect(player, engine.MainMixerNode, file.ProcessingFormat);
        }
Ejemplo n.º 2
0
        ///<Summary>
        /// Load wave or mp3 audio file from the Android assets folder
        ///</Summary>
        public bool Load(string fileName)
        {
            DeletePlayer();

            NSError error = new NSError();

            if (!String.IsNullOrWhiteSpace(fileName))
            {
                string directory = Path.GetDirectoryName(fileName);
                string filename  = Path.GetFileNameWithoutExtension(fileName);
                string extension = Path.GetExtension(fileName).Substring(1);
                NSUrl  url       = NSBundle.MainBundle.GetUrlForResource(filename, extension, directory);
                audioFile = new AVAudioFile(url, out error);
            }

            if (audioFile != null)
            {
                componentDescription = new AudioComponentDescription();
                componentDescription.ComponentType    = AudioComponentType.FormatConverter;
                componentDescription.ComponentSubType = (int)AudioUnitSubType.Varispeed;

                engine = new AVAudioEngine();
                player = new AVAudioPlayerNode();
                pitch  = new AVAudioUnitTimePitch(componentDescription);


                engine.AttachNode(player);
                engine.AttachNode(pitch);

                engine.Connect(player, pitch, audioFile.ProcessingFormat);
                engine.Connect(pitch, engine.MainMixerNode, audioFile.ProcessingFormat);

                engine.Prepare();
                NSError startError = new NSError();
                engine.StartAndReturnError(out startError);
            }

            return(true);
        }
Ejemplo n.º 3
0
		void SetPlayerFile (NSUrl fileUrl)
		{
			NSError error;
			file = new AVAudioFile (fileUrl, out error);
			if (error != null)
				throw new NSErrorException (error);

			engine.Connect (player, engine.MainMixerNode, file.ProcessingFormat);
		}