public IEncoder CreateEncoder(int threadNumber, IParallelTask _task) { if (_task is ReplayGainTask) { ReplayGainTask task = (ReplayGainTask)_task; return(new ReplayGainTagEncoder(task)); } else if (_task is FileEncodeTask) { FileEncodeTask task = (FileEncodeTask)_task; IAudioSource audioSource = task.AudioSourceLazy(); if (audioSource == null) { throw new SkipEncodingItemException("Unsupported audio format."); } if (this.CalculateReplayGain) { task.TrackGain = DspHelper.CreateTrackGain(audioSource); } if (this.CalculateDynamicRange) { task.DrMeter = DspHelper.CreateDrMeter(audioSource); } return(new DspCalculatorEncoder(audioSource, task.TrackGain, task.DrMeter)); } throw new NotSupportedException(); }
protected IAudioSource SetupTask(FileEncodeTask task) { IAudioSource audioSource = task.AudioSourceLazy(); if (audioSource == null) { throw new SkipEncodingItemException("Audio source is not supported."); } if (this.CalculateRg) { task.TrackGain = DspHelper.CreateTrackGain(audioSource); } if (this.CalculateDr) { task.DrMeter = DspHelper.CreateDrMeter(audioSource); } return audioSource; }
protected IAudioSource SetupTask(FileEncodeTask task) { IAudioSource audioSource = task.AudioSourceLazy(); if (audioSource == null) { throw new SkipEncodingItemException("Audio source is not supported."); } if (this.CalculateRg) { task.TrackGain = DspHelper.CreateTrackGain(audioSource); } if (this.CalculateDr) { task.DrMeter = DspHelper.CreateDrMeter(audioSource); } return(audioSource); }