Beispiel #1
0
    private void StopNocieCalc()
    {
        voiceUsedAt = VoiceUsed.None;
        float sum = 0;

        _rmsInTime.ForEach(o => sum += o);
        noiceRMS = (sum / _rmsInTime.Count);
        _rmsInTime.Clear();
    }
Beispiel #2
0
    void OnGUI()
    {
        guiX      = guiY = padding = 8;
        hbuttons  = 4;
        vbuttons  = 15;
        guiwidth  = (short)((Screen.width - ((hbuttons + 2) * padding)) / hbuttons);
        guiheight = (short)((Screen.height - ((vbuttons + 2) * padding)) / vbuttons);

        guiX = guiY = padding;
        if (voiceUsedAt.Equals(VoiceUsed.None))
        {
            if (GUI.Button(new Rect(guiX, guiY, guiwidth, guiheight), "Calc Noice"))
            {
                StartNoiceCalc();
            }
            guiY += padding + guiheight;
        }
        if (voiceUsedAt.Equals(VoiceUsed.None) && !noiceRMS.Equals(0f))
        {
            if (GUI.Button(new Rect(guiX, guiY, guiwidth, guiheight), "Play"))
            {
                voiceUsedAt = VoiceUsed.Command;
            }
            guiY += padding + guiheight;
        }
        if (voiceUsedAt.Equals(VoiceUsed.Command))
        {
            GUI.Label(new Rect(guiX, guiY, guiwidth, guiheight), "CVol: " + micInfo.rmsVolume.ToString("f4"));
            guiX += padding + guiwidth;
            GUI.Label(new Rect(guiX, guiY, guiwidth, guiheight), "Noice: " + noiceRMS.ToString("f4"));
            guiX    += padding + guiwidth;
            noiceRMS = GUI.HorizontalSlider(new Rect(guiX, guiY, Screen.width - padding - guiX, guiheight), noiceRMS, -1f, 1f);

            //guiX = padding;
            //moveVal = (noiceRMS + moveRMSDif);
            //guiY += padding + (guiheight );
            //GUI.Label(new Rect(guiX, guiY, guiwidth, guiheight), "Move: " + moveVal.ToString("f4"));
            //guiX += padding + guiwidth;
            //moveRMSDif = GUI.HorizontalSlider(new Rect(guiX, guiY, Screen.width - padding - guiX, guiheight), moveRMSDif, 0f, 0.5f);

            jumpVal = (noiceRMS + moveRMSDif + jumpRMSDif);
            guiX    = padding;
            guiY   += padding + (guiheight);
            GUI.Label(new Rect(guiX, guiY, guiwidth, guiheight), "Jump: " + jumpVal.ToString("f4"));
            guiX      += padding + guiwidth;
            jumpRMSDif = GUI.HorizontalSlider(new Rect(guiX, guiY, Screen.width - padding - guiX, guiheight), jumpRMSDif, 0f, 0.5f);

            guiX  = padding;
            guiY += padding + (guiheight);
            if (GUI.Button(new Rect(guiX, guiY, guiwidth, guiheight), "Stop"))
            {
                voiceUsedAt = VoiceUsed.None;
                CreateClip();
            }
        }
        if (!voiceUsedAt.Equals(VoiceUsed.Command) && c != null)
        {
            guiX  = padding;
            guiY += padding + (guiheight);
            if (GUI.Button(new Rect(guiX, guiY, guiwidth, guiheight), "Play Recroded Audio"))
            {
                _audio.clip = c;
                _audio.Play();
            }
            guiX  = padding;
            guiY += padding + (guiheight);
            if (GUI.Button(new Rect(guiX, guiY, guiwidth, guiheight), "Stop Audio"))
            {
                _audio.Stop();
            }
        }
    }
Beispiel #3
0
 private void Play()
 {
     voiceUsedAt = VoiceUsed.Command;
 }
Beispiel #4
0
 private void StartNoiceCalc()
 {
     _rmsInTime         = new List <float>();
     _timeUsedNoiceCalc = 0f;
     voiceUsedAt        = VoiceUsed.NoiceCalculation;
 }