示例#1
0
        public BassMicrophoneHandler(IAudioProcessingConfig config)
        {
            _samples = new float[config.FrequencyResolution];

            PrintDebugInfo();

            SamplesStream = Observable.EveryUpdate()
                            .Where(_ => _recordingHandle != Bass.FALSE)
                            .Select(_ => ProcessRecordedData());

            StartRecording();
        }
示例#2
0
        public NoteDetector(IAudioProcessingConfig config)
        {
            _config = config;

            Debug.Log($"[NoteDetector] Initializing. DetectionInterval {_config.NoteDetectionInterval}");

            FillNoteTable();

            DetectedNotes = Observable.Interval(_config.NoteDetectionInterval)
                            .Where(_ => _notesForInterval.Any())
                            .Select(_ =>
            {
                var mostCommonNote = FindMostCommonNote();
                _notesForInterval.Clear();
                return(mostCommonNote);
            });
        }
示例#3
0
        public UnityMicrophoneHandler(IAudioProcessingConfig config)
        {
            _samples       = new float[config.FrequencyResolution];
            _primaryDevice = Microphone.devices.First();
            _source        = new GameObject("MicrophoneHandlerSource").AddComponent <AudioSource>();

            SamplesStream = Observable.EveryUpdate()
                            .Where(_ => _source.clip != null)
                            .Select(
                _ =>
            {
                _source.GetSpectrumData(_samples, 0, FFTWindow.BlackmanHarris);

                return(_samples);
            }
                );

            StartListening();
        }