public void SetupForProcessor(IWaveInManagerProcessor processor) { if (processor == null) { return; } int iDevNum = GetDeviceNumFromName(processor.WaveInName); if (iDevNum < 0) { return; } lock (_lockObj) { try { if (!_waveInDevices.ContainsKey(iDevNum)) { _waveInDevices.Add(iDevNum, new WaveInManagerDevice(processor.WaveInName)); } _waveInDevices[iDevNum].UpdateProcessor(processor); } catch (Exception ex) { Common.DebugHelper.WriteExceptionToLog("WaveInManager.SetupForProcessor", ex, false, string.Format("{0} [{1}]", processor.WaveInName, processor.WaveInChannelIndex)); } } }
void waveIn_RecordingStopped(object sender, StoppedEventArgs e) { _running = false; for (int i = 0; i < processors.Count; i++) { IWaveInManagerProcessor proc = processors[i]; proc.WaveInStopped(); } }
public void UnregisterProcessor(IWaveInManagerProcessor processor) { if (processors == null || processor == null || !processors.Contains(processor)) { return; } processors.Remove(processor); StopIfNeeded(); }
public void RegisterProcessor(IWaveInManagerProcessor processor) { if (processor == null || processors.Contains(processor) || processor.WaveInChannelIndex >= _numberOfChannels || processor.WaveInChannelIndex < 0) { return; } processors.Add(processor); StartIfNeeded(); }
public void TeardownForProcessor(IWaveInManagerProcessor processor) { if (processor == null) return; int iDevNum = GetDeviceNumFromName(processor.WaveInName); if (iDevNum < 0) return; lock (_lockObj) { if (_waveInDevices.ContainsKey(iDevNum)) { _waveInDevices[iDevNum].UnregisterProcessor(processor); } } }
public void UpdateProcessor(IWaveInManagerProcessor processor) { if (processor == null) { return; } if (string.Equals(processor.WaveInName, _waveInDeviceName, StringComparison.InvariantCultureIgnoreCase)) { RegisterProcessor(processor); } else { UnregisterProcessor(processor); } }
void waveIn_DataAvailable(object sender, WaveInEventArgs e) { if (processors == null || processors.Count <= 0) { return; } byte[][] sampleBytes = AudioProcessingGlobals.BytesToSampleBytes(e.Buffer, e.BytesRecorded, AudioProcessingGlobals.DEFAULT_BYTES_PER_SAMPLE, AudioProcessingGlobals.DEFAULT_ENCODING, _numberOfChannels); if (sampleBytes == null) { return; } for (int i = 0; i < processors.Count; i++) { IWaveInManagerProcessor proc = processors[i]; proc.ProcessSamples(sampleBytes[proc.WaveInChannelIndex]); } }
public void TeardownForProcessor(IWaveInManagerProcessor processor) { if (processor == null) { return; } int iDevNum = GetDeviceNumFromName(processor.WaveInName); if (iDevNum < 0) { return; } lock (_lockObj) { if (_waveInDevices.ContainsKey(iDevNum)) { _waveInDevices[iDevNum].UnregisterProcessor(processor); } } }
public void SetupForProcessor(IWaveInManagerProcessor processor) { if (processor == null) return; int iDevNum = GetDeviceNumFromName(processor.WaveInName); if (iDevNum < 0) return; lock (_lockObj) { try { if (!_waveInDevices.ContainsKey(iDevNum)) { _waveInDevices.Add(iDevNum, new WaveInManagerDevice(processor.WaveInName)); } _waveInDevices[iDevNum].UpdateProcessor(processor); } catch (Exception ex) { Common.DebugHelper.WriteExceptionToLog("WaveInManager.SetupForProcessor", ex, false, string.Format("{0} [{1}]", processor.WaveInName, processor.WaveInChannelIndex)); } } }
public void UnregisterProcessor(IWaveInManagerProcessor processor) { if (processors == null || processor == null || !processors.Contains(processor)) return; processors.Remove(processor); StopIfNeeded(); }
public void RegisterProcessor(IWaveInManagerProcessor processor) { if (processor == null || processors.Contains(processor) || processor.WaveInChannelIndex >= _numberOfChannels || processor.WaveInChannelIndex < 0) return; processors.Add(processor); StartIfNeeded(); }
public void UpdateProcessor(IWaveInManagerProcessor processor) { if (processor == null) return; if (string.Equals(processor.WaveInName, _waveInDeviceName, StringComparison.InvariantCultureIgnoreCase)) RegisterProcessor(processor); else UnregisterProcessor(processor); }