コード例 #1
0
ファイル: SoundScript.cs プロジェクト: romanchom/Luna
        public override void Run()
        {
            capture.ReadPackets();
            int c = 0;

            foreach (var channel in capture.Channels)
            {
                vizualizers[c].Process(channel);
                ++c;
            }
            spectrumViz.amplitudes = aggregator.Tones;



            float[] arr = new float[1024];
            foreach (var channel in capture.Channels)
            {
                for (int i = 0; i < 1024; ++i)
                {
                    arr[i] += channel[i];
                }
            }
            sfftProcessor.Process(arr);
            for (int i = 0; i < 1024; ++i)
            {
                sfftProcessor.Magnitudes[i] += 1e-10f;
            }
            sfftAggregator.Aggregate(sfftProcessor.Magnitudes);
            beatDetector.Feed(sfftAggregator.Result);
            float isBeat = beatDetector.IsBeat;

            isBeat        = Math.Max(isBeat, beatIntensity);
            beatIntensity = Math.Max(0.0f, isBeat * 0.93f);

            for (c = 0; c < 2; ++c)
            {
                for (int i = 0; i < LunaConnectionBase.ledCount; ++i)
                {
                    luna.pixels[c][i] = (float)Math.Pow(holdFilters[c].Values[i], 2.2f) * (1 + beatIntensity * 3) * colors.Colors[i];
                }
            }

            luna.whiteLeft = luna.whiteRight = beatIntensity * 0.05f;
        }