public void StopRecording() { if (!(PlayingState == PlayingStateType.Recording)) { return; } int endPos = Microphone.GetPosition(Microphone.devices[0]); Microphone.End(Microphone.devices[0]); Recorder.Stop(); vp.Pause(); Player.Pause(); PlayingState = PlayingStateType.Pausing; Recorder.mute = false; reviewer.StartReviewing(this, vp, Recorder, MasterSound, startTime, endPos, Player); double length = vp.time - startTime; //copy recorded sound from temp to master /* * float[] rec = new float[endPos * TemporarySound.channels]; * TemporarySound.GetData(rec, 0); * int startPos = MasterSound.channels * Mathf.FloorToInt(MasterSound.samples * ((float)startTime / MasterSound.length)); * MasterSound.SetData(rec, startPos); * Player.clip = MasterSound; * Recorder.Stop(); * Microphone.End(Microphone.devices[0]); * TemporarySound = Microphone.Start(Microphone.devices[0], true, Mathf.CeilToInt((float)vp.clip.length), 44100); * Recorder.clip = TemporarySound; * Recorder.Play(); * Player.Pause();*/ BG.color = new Color(0, 0, 0); }
public void Pause() { if (PlayingState == PlayingStateType.Recording) { StopRecording(); } RecordButton.interactable = true; vp.Pause(); Player.Pause(); PlayingState = PlayingStateType.Pausing; }
public void Stop() { if (PlayingState == PlayingStateType.Recording) { StopRecording(); } RecordButton.interactable = false; vp.Stop(); Player.Stop(); PlayingState = PlayingStateType.None; }
public void Play() { if (PlayingState == PlayingStateType.Recording) { StopRecording(); } RecordButton.interactable = false; vp.Play(); Player.Play(); PlayingState = PlayingStateType.Playing; }
public void StartRecording() { if (!(PlayingState == PlayingStateType.Pausing)) { return; } Recorder.Stop(); Microphone.End(Microphone.devices[0]); TemporarySound = Microphone.Start(Microphone.devices[0], false, Mathf.CeilToInt(lengthSec), 44100); Recorder.clip = TemporarySound; Recorder.Play(); vp.Play(); startTime = vp.time; PlayingState = PlayingStateType.Recording; BG.color = new Color(1, 0.4f, 0.5f); }