示例#1
0
		private void getSettings()
		{

			var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
			var library = System.IO.Path.Combine (documents, "..", "Library");
			var urlpath = System.IO.Path.Combine (library, "audioRecording.wav");

			session = AVAudioSession.SharedInstance ();
			session.SetCategory (AVAudioSessionCategory.PlayAndRecord);

			url = new NSUrl (urlpath, false);


			NSFileManager manager = new NSFileManager ();
			NSError error = new NSError (new NSString ("world"), 1);

			//if there is a file at the save location, delete it so we can save there
			if (manager.FileExists (urlpath)) {
				Console.WriteLine ("Deleting File");
				manager.Remove (urlpath, out error);
				Console.WriteLine ("Deleted File");
			}

			NSObject[] values = new NSObject[]
			{
				NSNumber.FromFloat (44100.0f), //Sample Rate
				NSNumber.FromInt32 ((int)MonoTouch.AudioToolbox.AudioFormatType.LinearPCM), //AVFormat
				NSNumber.FromInt32 (2), //Channels
				NSNumber.FromInt32 (16), //PCMBitDepth
				NSNumber.FromBoolean (false), //IsBigEndianKey
				NSNumber.FromBoolean (false) //IsFloatKey
			};

			NSObject[] keys = new NSObject[] {
				AVAudioSettings.AVSampleRateKey,
				AVAudioSettings.AVFormatIDKey,
				AVAudioSettings.AVNumberOfChannelsKey,
				AVAudioSettings.AVLinearPCMBitDepthKey,
				AVAudioSettings.AVLinearPCMIsBigEndianKey,
				AVAudioSettings.AVLinearPCMIsFloatKey
			};

			settings = NSDictionary.FromObjectsAndKeys (values, keys);

			recorder = AVAudioRecorder.ToUrl (url, settings, out error);


		}
示例#2
0
        /// <summary>
        /// Opens and parses the BVH file at the specifie path.
        /// </summary>
        public BVH(string path)
        {
            var fm = new NSFileManager();

            if (path == null || !fm.FileExists(path))
            {
                throw new Exception($"Could not find file '{Path.GetFileName(path)}'.");
            }
            var data     = fm.Contents(path);
            var contents = new NSString(data, NSStringEncoding.UTF8).ToString();
            var lines    = contents.Split(new[] { Environment.NewLine, "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);

            var lineCounter = 1;             // start with first line of hierarchy, which should be ROOT

            while (true)
            {
                Roots.Add(ParseNode(lines, ref lineCounter));
                lineCounter++;
                if (!lines[lineCounter].TrimStart(' ').StartsWith("ROOT", StringComparison.InvariantCulture))
                {
                    break;
                }
            }

            if (!string.Equals(lines[lineCounter], "MOTION"))
            {
                throw new Exception($"Expected MOTION but encountered invalid line: {lines[lineCounter]}");
            }

            lineCounter  += 2;            // skip the "Frames: x" line and get "Frame Time: y"
            FrameTimeSecs = double.Parse(lines[lineCounter].Split('\t')[1]);

            lineCounter++;
            for (; lineCounter < lines.Length; lineCounter++)
            {
                var motions = lines[lineCounter]
                              .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                              .Select(double.Parse).ToList();
                for (var i = 0; i < motions.Count; i++)
                {
                    _channels.ElementAt(i).Key.Motions.Add(motions[i]);
                }
            }
        }
		void convertAudio ()
		{    
			var success = DoConvertFile (sourceURL, destinationURL, outputFormat, sampleRate);
		
			BeginInvokeOnMainThread (delegate {
				activityIndicator.StopAnimating ();
			});

			if (!success) {
				var fm = new NSFileManager ();
				if (fm.FileExists (destinationFilePath)) {
					NSError error;
					fm.Remove (destinationFilePath, out error);
				}
				BeginInvokeOnMainThread (updateUI);
			} else {
				BeginInvokeOnMainThread (playAudio);
			}
		}
示例#4
0
        void startStopPushed(object sender, EventArgs ea)
        {
            if (!weAreRecording) {

                var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
                var library = System.IO.Path.Combine (documents, "..", "Library");
                var urlpath = System.IO.Path.Combine (library, "sweetMovieFilm.mov");

                NSUrl url = new NSUrl (urlpath, false);

                NSFileManager manager = new NSFileManager ();
                NSError error = new NSError ();

                if (manager.FileExists (urlpath)) {
                    Console.WriteLine ("Deleting File");
                    manager.Remove (urlpath, out error);
                    Console.WriteLine ("Deleted File");
                }

                AVCaptureFileOutputRecordingDelegate avDel= new AVCaptureFileOutputRecordingDelegate ();
                output.StartRecordingToOutputFile(url, avDel);
                Console.WriteLine (urlpath);
                weAreRecording = true;

                btnStartRecording.SetTitle("Stop Recording", UIControlState.Normal);
            }
            //we were already recording.  Stop recording
            else {

                output.StopRecording ();

                Console.WriteLine ("stopped recording");

                weAreRecording = false;

                btnStartRecording.SetTitle("Start Recording", UIControlState.Normal);

            }
        }
		public static void deleteVideo(string vidToDelete)
		{
			NSFileManager manager = new NSFileManager ();
			NSError error = new NSError ();

			//delete the file if it is already there
			if (manager.FileExists (vidToDelete)) {
				manager.Remove (vidToDelete, out error);
			}
		}
		public static Boolean vidExists(string vidCheck)
		{
			NSFileManager mgr = new NSFileManager ();
			if (mgr.FileExists (vidCheck)) {
				return true;
			} 

			return false;


		}