Beispiel #1
0
 public void Resume()
 {
     pauseButton.interactable = true;
     pauseMenu.SetActive(false);
     Time.timeScale = 1f;
     song.PlayAudio();
 }
Beispiel #2
0
    void Start()
    {
        SongObjectScript song = findSong();

        audioSource = song.GetAudioSource();
        Debug.Log(song.GetBPM());
        song.PlayAudio();

        // Process audio as it plays
        if (realTimeSamples)
        {
            realTimeSpectrum             = new float[1024];
            realTimeSpectralFluxAnalyzer = new SpectralFluxAnalyzer();
            realTimePlotController       = GameObject.Find("RealtimePlot").GetComponent <NoteGenerator> ();

            this.sampleRate = AudioSettings.outputSampleRate;
        }

        // Preprocess entire audio file upfront
        if (preProcessSamples)
        {
            preProcessedSpectralFluxAnalyzer = new SpectralFluxAnalyzer();
            preProcessedPlotController       = GameObject.Find("PreprocessedPlot").GetComponent <NoteGenerator>();

            // Need all audio samples.  If in stereo, samples will return with left and right channels interweaved
            // [L,R,L,R,L,R]
            multiChannelSamples = new float[audioSource.clip.samples * audioSource.clip.channels];
            numChannels         = audioSource.clip.channels;
            numTotalSamples     = audioSource.clip.samples;
            clipLength          = audioSource.clip.length;

            // We are not evaluating the audio as it is being played by Unity, so we need the clip's sampling rate
            this.sampleRate = audioSource.clip.frequency;

            audioSource.clip.GetData(multiChannelSamples, 0);
            Debug.Log("GetData done");

            Thread bgThread = new Thread(this.getFullSpectrumThreaded);

            Debug.Log("Starting Background Thread");
            bgThread.Start();
        }
    }
Beispiel #3
0
 // Start is called before the first frame update
 void Start()
 {
     try
     {
         song = findSong();
         BPM  = song.GetBPM();               // Gets selected Song's BPM
         Debug.Log(BPM);
         songLength = song.GetAudioLength(); // Gets the song's length in seconds
         Debug.Log(songLength);
         secsPerBeat          = 60f / BPM;   // Calculates Seconds per Beat
         noteSpawnPositions   = new Vector3[] { noteOneSpawn, noteTwoSpawn, noteThreeSpawn };
         startDelay           = song.GetStartDelay();
         difficultyMultiplier = song.GetDifficultyMultiplier();
         song.PlayAudio();
         StartCoroutine(SpawnNote()); // Starts spawning Method
     } catch (Exception e) {          // Catch for when song doesn't load, spawn objects with no sound (testing purposes only)
         BPM                  = 60f;
         songLength           = 60f;
         secsPerBeat          = 60f / BPM; // Calculates Seconds per Beat
         noteSpawnPositions   = new Vector3[] { noteOneSpawn, noteTwoSpawn, noteThreeSpawn };
         difficultyMultiplier = 4;
         StartCoroutine(SpawnNote()); // Starts spawning Method
     }
 }