Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            TogglePause();
        }
        else if (isPaused)
        {
            return;
        }
        if (since_stimulation == 0.01)     //continuous stimulation framework
        {
            last_update = Time.deltaTime;
            //double[] voltage_data = color_script.UpdateVoltage(0.000001);
            //graph_script.AddPoint(voltage_data, (float)(last_update * time_converter));
            since_stimulation += Time.deltaTime;
        }
        else
        {
            last_update = Time.deltaTime;
            double total_time = since_stimulation + last_update;

            double[] voltage_data = color_script.UpdateVoltage(total_time * time_scale);
            color_script.ColorBands(voltage_data);
            graph_script.AddPoint(voltage_data, (float)(last_update * time_converter));
            since_stimulation = total_time;

            double temp_volt = voltage_data[e_pos];

            if (audio_isPlaying && temp_volt < 0.02)
            {
                audio_obj.GetComponent <AudioSource>().Stop();
                audio_isPlaying = false;
            }
            else
            {
                if (rec_enabled)
                {
                    audio_script.PassData(temp_volt);
                }
                else
                {
                    audio_script.PassData(voltage_data[band_width]);
                }
            }
        }
    }