コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        indexToProcess = thresholdWindowSize / 2;

        if (spectrumGenerator == null)
        {
            spectrumGenerator = GetComponent <SpectrumGenerator>();
        }
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        indexToProcess      = thresholdWindowSize / 2;
        Time.fixedDeltaTime = (1f / (bpm / 60)) / 64;

        if (spectrumGenerator == null)
        {
            spectrumGenerator = GetComponent <SpectrumGenerator>();
        }
    }
コード例 #3
0
        public void Open(string filename)
        {
            if (output != null)
            {
                output.Stop();

                while (output.PlaybackState != PlaybackState.Stopped)
                {
                    Thread.Sleep(10);
                }
            }

            if (spectrum != null)
            {
                spectrum.SpectrumReady -= Spectrum_SpectrumReady;
                spectrum = null;
            }

            output?.Dispose();

            reader?.Close();
            reader?.Dispose();
            reader = null;

            output   = outputFactory();
            reader   = new AudioFileReader2(filename);
            spectrum = new SpectrumGenerator(reader);
            spectrum.SpectrumReady += Spectrum_SpectrumReady;
            output.Init(spectrum);
            TracksPlayed++;
            InvokePlayerStart(filename);

            // write out filter parameter names to our shader directory so that shaders can reference things by name instead of index.
            if (!paramsWritten)
            {
                int i = 0;
                File.WriteAllLines("Res/Shaders/Common/filterParameters.glsl", spectrum.FilterOutputNames.Select(s => $"#define A_{s} {i++}"));
                paramsWritten = true;
            }
        }