public void OnClickMute() { buttonClickSound.Play(); buttonClickSound.mute = !buttonClickSound.mute; AudioSource songAudioSource = song.GetAudioSource(); songAudioSource.mute = !songAudioSource.mute; }
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(); } }