Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        m_stampWidth = new int[m_enemyParam.Length];
        int spec_len = JAudioAnalysis_smooth.Instance().SampleSpectrum.Length;

        m_maxX = Mathf.Log(spec_len);
    }
Ejemplo n.º 2
0
    void Awake()
    {
        m_instance = this;

        for (int idx = 0; idx != m_sampleSpectrumSmoother.Length; ++idx)
        {
            m_sampleSpectrumSmoother[idx] = new WAudioAnalysis.CacheAndSmooth(m_sampleSpectrumSmoothCount);
        }
    }
Ejemplo n.º 3
0
    private void DebugDrawSpectrum()
    {
        float[] spec           = JAudioAnalysis_smooth.Instance().SampleSpectrum;
        int     draw_enemy_idx = 0;

        for (int i = 1; i < spec.Length - 1; i++)
        {
            float log_i = Mathf.Log(i + 1);
            Color color = Color.red;
            while (m_enemyParam[draw_enemy_idx].width < log_i / m_maxX)
            {
                ++draw_enemy_idx;
                color = Color.green;
            }

            float x = 1.5f;
            Debug.DrawLine(new Vector3(Mathf.Log(i - 1) * x, spec[i - 1] - 5, -2), new Vector3(Mathf.Log(i) * x, spec[i] - 5, -2), color);
        }
    }
Ejemplo n.º 4
0
    private void SpawnBySplitedMaxAmp()
    {
        float[] enemy_max     = new float[m_enemyParam.Length];
        int[]   enemy_max_idx = new int[m_enemyParam.Length];
        int     cur_enemy_idx = 0;

        float[] spec = JAudioAnalysis_smooth.Instance().SampleSpectrum;

        int allmax_idx = 0;

        for (int idx = 0; idx < spec.Length; ++idx)
        {
            float x = Mathf.Log(idx + 1);
            while (m_enemyParam[cur_enemy_idx].width < x / m_maxX)
            {
                ++cur_enemy_idx;
                enemy_max[cur_enemy_idx] = 0;
            }
            if (spec[idx] > spec[allmax_idx])
            {
                allmax_idx = idx;
            }

            if (spec[idx] > enemy_max[cur_enemy_idx])
            {
                enemy_max[cur_enemy_idx]     = spec[idx];
                enemy_max_idx[cur_enemy_idx] = idx;
            }
        }

        for (int idx = 0; idx < enemy_max.Length; ++idx)
        {
            if (enemy_max[idx] < m_minSpawnAmp)
            {
                continue;
            }

            InstantiateEnemy(idx, enemy_max[idx] > m_maxSpawnAmp, Mathf.Log(enemy_max_idx[idx] + 1) / m_maxX);
        }
    }