public BassMicrophoneHandler(IAudioProcessingConfig config) { _samples = new float[config.FrequencyResolution]; PrintDebugInfo(); SamplesStream = Observable.EveryUpdate() .Where(_ => _recordingHandle != Bass.FALSE) .Select(_ => ProcessRecordedData()); StartRecording(); }
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); }); }
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(); }