public AudioRecorder(string streamSourceName, Common.SignalRecordingType recordingType, int recordingKickTime, WaveFormat sourceWaveFormat, WaveFormat fileWaveFormat, bool recordingEnabled) { _recordingType = recordingType; switch (_recordingType) { case SignalRecordingType.Fixed: { RecordingKickTimeTicks = TimeSpan.FromMinutes(recordingKickTime).Ticks; break; } default: { RecordingKickTimeTicks = TimeSpan.FromSeconds(recordingKickTime).Ticks; break; } } RecordingPrefix = RadioSignalLogger.MakeSourceFilePrefix(streamSourceName); _sourceWaveFormat = sourceWaveFormat; if (fileWaveFormat == null) _fileWaveFormat = sourceWaveFormat; else _fileWaveFormat = fileWaveFormat; _recordingEnabled = recordingEnabled; if (_sourceWaveFormat.Equals(_fileWaveFormat)) { _resampleStream = null; _useResampler = false; } else { _resampleStream = new NAudio.Wave.Compression.AcmStream(_sourceWaveFormat, _fileWaveFormat); _useResampler = true; } }
public ProcessorWaveProvider(string sourceName, IWaveProvider sourceWaveProvider, string waveFilePath, WaveFormat outFormat, Common.ProcessRadioSignalingItemDelegate sigDelegate, Action<bool> hasPropertyChanged, bool recordEnabled, Common.SignalRecordingType recordType, int recordKickTime, Common.NoiseFloor noiseFloor, int customNoiseFloor,bool removeNoise, bool decodeMDC1200, bool decodeGEStar, bool decodeFleetSync, bool decodeP25) : base(sourceWaveProvider, waveFilePath) { LastValidStreamTitle = string.Empty; _sourceName = sourceName; _sourceFormat = sourceWaveProvider.WaveFormat; _outFormat = outFormat; _hasPropertyChanged = hasPropertyChanged; _silenceHelper = new SilenceHelper(outFormat.AverageBytesPerSecond / (outFormat.BitsPerSample / 8), noiseFloor, removeNoise, customNoiseFloor); if (outFormat.Equals(sourceWaveProvider.WaveFormat)) { _resampleStream = null; _useResampler = false; } else { if (Common.AppSettings.Instance.DiagnosticMode) { Common.ConsoleHelper.ColorWriteLine(ConsoleColor.Magenta, "{0}: Source Format <> Out Format [{1}] <> [{2}]", sourceName, sourceWaveProvider.WaveFormat, outFormat); } _resampleStream = new NAudio.Wave.Compression.AcmStream(sourceWaveProvider.WaveFormat, outFormat); _useResampler = true; } if (decodeMDC1200) { _mdc = new Decoders.MDC1200(outFormat.SampleRate, ProcessMDC1200, sourceName); } else { _mdc = null; } if (decodeGEStar) { _star = new Decoders.STAR(outFormat.SampleRate, ProcessSTAR, Decoders.STAR.star_format.star_format_1_16383, sourceName); } else { _star = null; } _rootDecoder = new Decoders.RootDecoder(outFormat.SampleRate, decodeFleetSync, decodeP25, ProcessRootDecoder); _recorder = new AudioRecorder(sourceName, recordType, recordKickTime, outFormat, AudioProcessingGlobals.DefaultSaveFileWaveFormat, recordEnabled); _bytesPerSample = outFormat.BitsPerSample / 8; _encoding = outFormat.Encoding; _sigDelegate = sigDelegate; }