Beispiel #1
0
        public void StartLibZPlay()
        {
            _stopPlayer = false;

            // open file
            var fileName =
                "wavein://src=microphone;volume=50;";
            // @"C:\Users\david_000\Music\my best remixes\10 vibromatic.mp3";

            FixedSizedQueue <FFTData> fftDatas = new FixedSizedQueue <FFTData>();

            fftDatas.Limit = 5000;

            if (!_player.OpenFile(fileName, TStreamFormat.sfAutodetect))
            {
                return;
            }
            _player.StartPlayback();
            Pause();
            while (_continue && !_stopPlayer)
            {
                FFTData fftData = new FFTData();
                _player.GetFFTData(512, TFFTWindow.fwRectangular, ref fftData.HarmonicNumber, ref fftData.HarmonicFreq, ref fftData.LeftAmplitude, ref fftData.RightAmplitude, ref fftData.LeftPhase, ref fftData.RightPhase);
                fftDatas.Enqueue(fftData);
                if (change(fftDatas))
                {
                    _display = true;
                }

                System.Threading.Thread.Sleep(1);
            }

            _player.Close();

            if (_continue)
            {
                StartLibZPlay();
            }
        }
Beispiel #2
0
        Boolean change(FixedSizedQueue <FFTData> fftDatas)
        {
            if (fftDatas.q.Count > fftDatas.Limit / 2)
            {
                List <int> bass = new List <int>();
                fftDatas.q.ToList().ForEach(f => bass.Add(getBassIntensity(f)));
                _bassSmoothed = smooth(bass);

                var averageBassIntesity = _bassSmoothed.Average();
                if (averageBassIntesity < 10000)
                {
                    return(false);
                }

                var averageMaxBassIntesity = _bassSmoothed.Where(b => b > averageBassIntesity).Average();
                if (_bassSmoothed.Last() > averageMaxBassIntesity)
                {
                    return(true);
                }
            }
            return(false);
        }