示例#1
0
        public bool ProcessAndShowBlockReadyness()
        {
            var block = _inStream.GetBlock(_bandWidth);
            var level = SpectralAnalyzer.AverageLevelAnalysis(block);

            if (_lastLevel != 0)
            {
                LastAttack = level / _lastLevel;
            }

            if (level > _decay && LastAttack > _attack)
            {
                _lastLevel = level;
                if (_isBlockRecording)
                {
                    lock (_preparedBlocks)
                        _preparedBlocks.AddLast(_block);
                    _block = block;
                    return(true);
                }
                else
                {
                    _block            = block;
                    _isBlockRecording = true;
                    return(false);
                }
            }

            _lastLevel = level;
            if (_isBlockRecording)
            {
                Array.Resize(ref _block, _block.Length + block.Length);
                Array.Copy(block, 0, _block, _block.Length - block.Length, block.Length);
            }

            if (_block.Length > _maxSamples)
            {
                _isBlockRecording = false;
                lock (_preparedBlocks)
                    _preparedBlocks.AddLast(_block);
                _block = new short[0];
                return(true);
            }

            if (_isBlockRecording && level < _decay)
            {
                _isBlockRecording = false;

                lock (_preparedBlocks)
                    _preparedBlocks.AddLast(_block);
                _block = new short[0];
                return(true);
            }
            return(false);
        }
示例#2
0
 public BlockAnalyzer(int blockSize, int discr)
 {
     _analyzer = new SpectralAnalyzer(blockSize, discr);
     _size     = blockSize;
 }