void Update() { if (Input.GetKeyDown(KeyCode.R) && mic == MicState.Off) { startRecording(); } else if (mic == MicState.Recording) { timeRecorded += Time.deltaTime; if (timeRecorded >= recordingTime) { stopRecording(); } } if (mic == MicState.Playback) { if (source.isPlaying) { float updateVol = 0; float updatePitch = 0; AnalyseAudio(out updateVol, out updatePitch); volume += updateVol; pitch += updatePitch; frameCounter++; } else { volume = volume / frameCounter; pitch = pitch / frameCounter; Debug.Log("volume: " + volume + ", pitch: " + pitch); mic = MicState.Off; move(); } } }
public void FindRange() { inpt.StartRecording(); listening = true; longTimer.Start(); MC = MicState.BottomNote; Console.WriteLine("Please sing your lowest note\n"); }
protected void startRecording() { Debug.Log("Started Recording"); mic = MicState.Recording; recordingUI.SetActive(true); source.clip = Microphone.Start(Microphone.devices [0], true, recordingTime, osr); timeRecorded = 0.0f; }
public void startMicIfNeeded() { if (startMic & (micState != MicState.UPDATED)) { Debug.Log("in start update micro"); micI.StartMicrophone(); micState = MicState.UPDATED; startMic = false; } }
protected void stopRecording() { Debug.Log("Stopped Recording"); mic = MicState.Playback; recordingUI.SetActive(false); pitch = 0.0f; volume = 0.0f; frameCounter = 0; source.Play(); }
// Update is called once per frame void Update() { if (target == null) { Sudoku(); return; } switch (state) { case MicState.rotating: transform.Rotate(0, 0, startRotateSpeed * Time.deltaTime); startRotateSpeed = Mathf.MoveTowards(startRotateSpeed, 0, rotationDecay * Time.deltaTime); if (startRotateSpeed == 0) { state = MicState.tracking; } break; case MicState.tracking: timeTracker += Time.deltaTime; if (timeTracker >= trackTime) { state = MicState.launched; } if (target == null) { return; } Vector3 dir = ((target.transform.position + Vector3.up * 0.5f) - transform.position).normalized; transform.up = Vector3.Slerp(transform.up, dir, timeTracker / trackTime + 0.15f); break; case MicState.launched: if (target == null) { return; } transform.up = ((target.transform.position + Vector3.up * 0.5f) - transform.position).normalized; transform.position += transform.up * velocity * Time.deltaTime; break; } }
// Use this for initialization void Start() { redBalloon = GameObject.Find("RedBalloonWrapper"); blueBalloon = GameObject.Find("BlueBalloonWrapper"); greenBalloon = GameObject.Find("GreenBalloonWrapper"); previewCube = GameObject.Find("previewCube"); redLabel = GameObject.Find("RedcolorVal"); greenLabel = GameObject.Find("GreenColorVal"); blueLabel = GameObject.Find("BlueColorVal"); selectedBalloon = Balloon.NONE; viz = micI.GetComponent <AudioVisualizer1> (); Debug.Log("viz is null " + (viz == null)); redSize = blueSize = greenSize = (int)((redBalloon.transform.localScale.x - 0.5) * 255); previewCube.GetComponent <Renderer>().material.color = new Color((float)(redSize / 255f), (float)(greenSize / 255f), (float)(blueSize / 255f)); updateLabels(); micI.InitMircophone(); micState = MicState.INIT; this.startMicIfNeeded(); }
private static async void TestMicSettings() { string botURL = globalSettings["botURL"].Value <string>(); if (string.IsNullOrEmpty(botURL)) { return; } botURL = botURL.Trim(); if (botURL.EndsWith("/")) { botURL = botURL.Substring(0, botURL.Length - 1); } RestRequest request = new RestRequest(Method.GET); RestClient restClient = new RestClient(botURL + "/TASagentBotAPI/Mic/Effect"); IRestResponse response = await restClient.ExecuteAsync(request); MicState newMicState = ExtractMicState(response); if (newMicState != micState) { micState = newMicState; foreach (string uuid in micTesters.ToList()) { try { await connection.SetImageAsync(CurrentMicImage, uuid, SDKTarget.HardwareAndSoftware, null); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Mic SetImage Exception: {ex}"); } } } }
private void OnTimedEvent(object source, ElapsedEventArgs e) { switch (MC) { case MicState.TopNote: MC = MicState.Silence; longTimer.Stop(); Console.WriteLine( "High Note: " + getTopNote() ); Console.WriteLine( "Low Note: " + getBottomNote() ); listening = false; break; case MicState.BottomNote: Console.Out.WriteLine("Please sing your highest note\n"); MC = MicState.TopNote; break; default: Console.Out.WriteLine("Something Broke"); break; } }
public void StopRecording() { listening = false; MC = MicState.Silence; inpt.StopRecording(); }
public void StartRecording() { listening = true; MC = MicState.Listening; inpt.StartRecording(); }
//-2.8 void Start() { state = MicState.rotating; rotationDecay = startRotateSpeed / rotationTime; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); //get controls from layout btnConnect = FindViewById <Button>(Resource.Id.btnConnect); btnSpeak = FindViewById <Button>(Resource.Id.btnSpeak); rbMic = FindViewById <RadioButton>(Resource.Id.rbMic); webSocket = new WebSocket("ws://10.92.84.183:80", ""); //client socket connected webSocket.Opened += (s, e) => { RunOnUiThread(() => { Toast.MakeText(this, "Connected.", ToastLength.Short).Show(); btnConnect.Enabled = false; btnConnect.Text = "Connected."; btnSpeak.Enabled = true; }); }; //client socket disconnected webSocket.Closed += (s, e) => { RunOnUiThread(() => { Toast.MakeText(this, "Disconnected.", ToastLength.Short).Show(); btnConnect.Enabled = true; btnConnect.Text = "Connect"; micState = MicState.Off; btnSpeak.Enabled = false; }); }; //client socket received a message webSocket.MessageReceived += (s, e) => { RootObject root = JsonConvert.DeserializeObject <RootObject>(e.Message); //deserialize json message into obj switch (root.Data.Type) { case "ping": RunOnUiThread(() => { Toast.MakeText(this, root.Data.Message, ToastLength.Short).Show(); }); break; case "mic": RunOnUiThread(() => { if (root.Data.On == true) { Toast.MakeText(this, root.Data.Message, ToastLength.Short).Show(); micState = MicState.On; } else { Toast.MakeText(this, root.Data.Message, ToastLength.Short).Show(); micState = MicState.Off; } }); break; } }; //connect to websocket sv btnConnect.Click += (s, e) => { if (webSocket.State == WebSocketState.Closed || webSocket.State == WebSocketState.None) { webSocket.Open(); } }; //send request to sv to speak/turn mic on btnSpeak.Click += (s, e) => { micState = MicState.Requesitng; RootObject root = new RootObject(); root.Data.Type = "request"; string json = JsonConvert.SerializeObject(root); webSocket.Send(json); }; }