Пример #1
0
        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));
                }
            }
        }
Пример #2
0
 void waveIn_RecordingStopped(object sender, StoppedEventArgs e)
 {
     _running = false;
     for (int i = 0; i < processors.Count; i++)
     {
         IWaveInManagerProcessor proc = processors[i];
         proc.WaveInStopped();
     }
 }
Пример #3
0
 public void UnregisterProcessor(IWaveInManagerProcessor processor)
 {
     if (processors == null || processor == null || !processors.Contains(processor))
     {
         return;
     }
     processors.Remove(processor);
     StopIfNeeded();
 }
Пример #4
0
 public void RegisterProcessor(IWaveInManagerProcessor processor)
 {
     if (processor == null || processors.Contains(processor) || processor.WaveInChannelIndex >= _numberOfChannels || processor.WaveInChannelIndex < 0)
     {
         return;
     }
     processors.Add(processor);
     StartIfNeeded();
 }
Пример #5
0
 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);
         }
     }
 }
Пример #6
0
 public void UpdateProcessor(IWaveInManagerProcessor processor)
 {
     if (processor == null)
     {
         return;
     }
     if (string.Equals(processor.WaveInName, _waveInDeviceName, StringComparison.InvariantCultureIgnoreCase))
     {
         RegisterProcessor(processor);
     }
     else
     {
         UnregisterProcessor(processor);
     }
 }
Пример #7
0
 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]);
     }
 }
Пример #8
0
        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);
                }
            }
        }
Пример #9
0
 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));
         }
     }
 }
Пример #10
0
 public void UnregisterProcessor(IWaveInManagerProcessor processor)
 {
     if (processors == null || processor == null || !processors.Contains(processor))
         return;
     processors.Remove(processor);
     StopIfNeeded();
 }
Пример #11
0
 public void RegisterProcessor(IWaveInManagerProcessor processor)
 {
     if (processor == null || processors.Contains(processor) || processor.WaveInChannelIndex >= _numberOfChannels || processor.WaveInChannelIndex < 0)
         return;
     processors.Add(processor);
     StartIfNeeded();
 }
Пример #12
0
 public void UpdateProcessor(IWaveInManagerProcessor processor)
 {
     if (processor == null)
         return;
     if (string.Equals(processor.WaveInName, _waveInDeviceName, StringComparison.InvariantCultureIgnoreCase))
         RegisterProcessor(processor);
     else
         UnregisterProcessor(processor);
 }