Пример #1
0
    void Update()
    {
        if (AudioHelper.currentPlaybackSource != null && AudioHelper.currentPlaybackSource.isPlaying)
        {
            //first get input for this frame
            for (int i = 0; i < players.Length; ++i)
            {
                players[i].GetInput();
            }
            frameIndex++;
            time = (AudioHelper.currentPlaybackSource.time * 1000f);
            float millisecondsPassed = time - previousTime;
            AudioHelper.setAllAudioTime(AudioHelper.currentPlaybackSource.time);

            Sync(millisecondsPassed);
            smoothBpm  = smoothing.SmoothBPM(bpm);
            smoothTick = smoothing.SmoothTick(tick, (uint)song.data.info.resolution);
            bool playGuitarMusic = false;
            for (int i = 0; i < players.Length; ++i)
            {
                players[i].SpawnObjects(tick, beatsPerSecond);
                players[i].UpdateObjects(smoothTick, noteRenderer, frameIndex);
                players[i].CreateBar(tick);
                players[i].UpdateActiveBars(smoothTick);
                players[i].RegisterAndRemove(smoothTick);
                playGuitarMusic |= players[i].lastNoteHit;
            }

            if (AudioHelper.GetCertainAudio("guitar") != null)
            {
                AudioHelper.GetCertainAudio("guitar").volume = playGuitarMusic ? 1 : 0;
            }

            previousTime = time;
        }
        else
        {
            if (playing)
            {
                AudioHelper.playAllAudio(0);
            }
        }
    }
Пример #2
0
    void Update()
    {
        if (songSource != null && songSource.isPlaying)
        {
            //first get input for this frame
            for (int i = 0; i < players.Length; ++i)
            {
                players[i].GetInput();
            }
            frameIndex++;
            time = (songSource.time * 1000f);
            float millisecondsPassed = time - previousTime;
            rhythmSource.time = songSource.time;
            guitarSource.time = songSource.time;

            Sync(millisecondsPassed);
            smoothBpm  = smoothing.SmoothBPM(bpm);
            smoothTick = smoothing.SmoothTick(tick, song.data.info.resolution);
            bool playGuitarMusic = false;
            for (int i = 0; i < players.Length; ++i)
            {
                players[i].SpawnObjects(tick, beatsPerSecond);
                players[i].UpdateObjects(smoothTick, noteRenderer, frameIndex);
                players[i].CreateBar(tick);
                players[i].UpdateActiveBars(smoothTick);
                players[i].RegisterAndRemove(smoothTick);
                playGuitarMusic |= players[i].lastNoteHit;
            }
            guitarSource.volume = playGuitarMusic ? 1 : 0;

            previousTime = time;
        }
        else
        {
            if (playing)
            {
                guitarSource.Play();
                rhythmSource.Play();
                songSource.Play();
            }
        }
    }