コード例 #1
0
    bool PlayStream(AudioStream audioStream, AudioStream syncStream)
    {
        if (audioStream != null && audioStream.isValid)
        {
            audioStream.Play(syncStream.CurrentPositionInSeconds());
            Debug.Log("Playing stream at " + syncStream.CurrentPositionInSeconds());

            return(true);
        }

        return(false);
    }
コード例 #2
0
    void LateUpdate()
    {
        ChartEditor editor = ChartEditor.Instance;

        if (editor.currentState == ChartEditor.State.Playing && tick)
        {
            SongAudioManager songAudioManager = editor.currentSongAudio;
            visibleAudioTime = editor.services.currentAudioTime;

            AudioStream stream = null;

            foreach (Song.AudioInstrument audio in audioInstrumentEnumVals)
            {
                if (AudioManager.StreamIsValid(songAudioManager.GetAudioStream(audio)))
                {
                    stream = songAudioManager.GetAudioStream(audio);
                    break;
                }
            }

            audioPosition = AudioManager.StreamIsValid(stream) ? stream.CurrentPositionInSeconds() : 0;

            tick = false;
        }

        dt += Time.deltaTime;

        if (dt > tickFrequency)
        {
            dt  -= tickFrequency;
            tick = true;
        }
    }
コード例 #3
0
    public void PlayAudio(float playPoint)
    {
        SetStreamProperties(currentSong.GetAudioStream(Song.AudioInstrument.Song), GameSettings.gameSpeed, GameSettings.vol_song);
        SetStreamProperties(currentSong.GetAudioStream(Song.AudioInstrument.Guitar), GameSettings.gameSpeed, GameSettings.vol_guitar);
        SetStreamProperties(currentSong.GetAudioStream(Song.AudioInstrument.Bass), GameSettings.gameSpeed, GameSettings.vol_bass);
        SetStreamProperties(currentSong.GetAudioStream(Song.AudioInstrument.Rhythm), GameSettings.gameSpeed, GameSettings.vol_rhythm);
        SetStreamProperties(currentSong.GetAudioStream(Song.AudioInstrument.Drum), GameSettings.gameSpeed, GameSettings.vol_drum);

        AudioStream primaryStream = null;

        foreach (var bassStream in currentSong.bassAudioStreams)
        {
            if (primaryStream != null)
            {
                playPoint = primaryStream.CurrentPositionInSeconds();
            }

            if (primaryStream != null)
            {
                PlayStream(bassStream, primaryStream);
            }
            else if (PlayStream(bassStream, playPoint))
            {
                primaryStream = bassStream;
            }
        }
    }
コード例 #4
0
    public void PlayAudio(float playPoint)
    {
        SongAudioManager songAudioManager = currentSongAudio;

        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Song), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_song);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Guitar), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_guitar);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Bass), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_bass);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Rhythm), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_rhythm);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Keys), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_keys);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drum), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_2), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_3), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Drums_4), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_drums);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Vocals), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_vocals);
        SetStreamProperties(songAudioManager.GetAudioStream(Song.AudioInstrument.Crowd), Globals.gameSettings.gameSpeed, Globals.gameSettings.vol_crowd);

        AudioStream primaryStream = null;

        foreach (var bassStream in songAudioManager.bassAudioStreams)
        {
            if (primaryStream != null)
            {
                playPoint = primaryStream.CurrentPositionInSeconds();
            }

            if (primaryStream != null)
            {
                PlayStream(bassStream, primaryStream);
            }
            else if (PlayStream(bassStream, playPoint))
            {
                primaryStream = bassStream;
            }
        }
    }
コード例 #5
0
    public void PlayingMovement()
    {
        float   speed          = Globals.gameSettings.hyperspeed;
        Vector3 pos            = transform.position;
        float   deltaTime      = Time.deltaTime;
        float   positionOffset = initPos.y;

        {
            float timeBeforeMovement = ChartEditor.WorldYPositionToTime(pos.y - positionOffset);
            float timeAfterMovement  = timeBeforeMovement + deltaTime * Globals.gameSettings.gameSpeed;

            // Make sure we're staying in sync with the audio
            {
                SongAudioManager songAudioManager = editor.currentSongAudio;

                AudioStream stream = null;

                for (int i = 0; i < EnumX <Song.AudioInstrument> .Count; ++i)
                {
                    Song.AudioInstrument audio = (Song.AudioInstrument)i;
                    if (AudioManager.StreamIsValid(songAudioManager.GetAudioStream(audio)))
                    {
                        stream = songAudioManager.GetAudioStream(audio);
                        break;
                    }
                }

                if (AudioManager.StreamIsValid(stream) && stream.IsPlaying())
                {
                    float audioTimePosition = stream.CurrentPositionInSeconds() - editor.services.totalSongAudioOffset;
                    float desyncAmount      = audioTimePosition - timeAfterMovement;

                    if (Mathf.Abs(desyncAmount) > DESYNCLENIENCE)
                    {
                        timeAfterMovement += desyncAmount;
                    }
                }
            }

            float maxChangeInTimeAllowed = Application.targetFrameRate > 0 ? 2.0f / Application.targetFrameRate : 1.0f / 120.0f;

            float totalChangeInTime = timeAfterMovement - timeBeforeMovement;

            float newTimePosition = ChartEditor.TimeToWorldYPosition(timeBeforeMovement + totalChangeInTime);
            pos.y = newTimePosition + positionOffset;
        }

        selfTransform.position = pos;
        explicitChartPos       = null;

        lastUpdatedRealTime = Time.time;
    }