コード例 #1
0
    public void CheckAudioAndStartSingScene()
    {
        if (playerSelectOverlayContainer.IsVisibleByDisplay())
        {
            StartSingScene(SelectedSong);
        }
        else if (SelectedSong.VoiceNames.Count <= 1 &&
                 playerListControl.PlayerEntryControlControls.Count == 1 &&
                 micListControl.MicEntryControls.Count == 1)
        {
            // There is one mic for only one player and only one voice to sing.
            // Thus, there is no choice to make and the song can be started immediately.
            playerListControl.PlayerEntryControlControls[0].MicProfile = micListControl.MicEntryControls[0].MicProfile;
            playerListControl.PlayerEntryControlControls[0].SetSelected(true);
            StartSingScene(SelectedSong);
        }
        else
        {
            if (SelectedSong == null)
            {
                return;
            }

            // Check that the audio file exists
            if (!WebRequestUtils.IsHttpOrHttpsUri(SelectedSong.Mp3))
            {
                string audioUri = SongMetaUtils.GetAudioUri(SelectedSong);
                if (!WebRequestUtils.ResourceExists(audioUri))
                {
                    string message = "Audio file resource does not exist: " + audioUri;
                    Debug.Log(message);
                    uiManager.CreateNotificationVisualElement(message);
                    return;
                }
            }

            // Check that the used audio format can be loaded.
            songAudioPlayer.Init(SelectedSong);
            if (!songAudioPlayer.HasAudioClip)
            {
                string message = $"Audio file '{SelectedSong.Mp3}' could not be loaded.\nPlease use a supported format.";
                Debug.Log(message);
                uiManager.CreateNotificationVisualElement(message);
                return;
            }

            ShowPlayerSelectOverlay();
        }
    }
コード例 #2
0
    public void UpdateAudioWaveForm()
    {
        if (!songAudioPlayer.HasAudioClip ||
            songAudioPlayer.AudioClip.samples <= 0)
        {
            return;
        }

        if (audioWaveFormVisualization == null)
        {
            audioWaveFormVisualization = new AudioWaveFormVisualization(songEditorSceneControl.gameObject, overviewAreaWaveform)
            {
                // Waveform color is same as text color
                WaveformColor = overviewAreaLabel.resolvedStyle.color
            };
        }

        using (new DisposableStopwatch($"Created audio waveform in <millis> ms"))
        {
            // For drawing the waveform, the AudioClip must not be streamed. All data must have been fully loaded.
            AudioClip audioClip = audioManager.LoadAudioClipFromUri(SongMetaUtils.GetAudioUri(songMeta), false);
            audioWaveFormVisualization.DrawWaveFormMinAndMaxValues(audioClip);
        }
    }