public FileEncodeTask(IEncoderFactory encoderFactory, Func<IAudioSource> audioSourceLazy, string targetFilename, AudioFileTag tag) { this.EncoderFactory = encoderFactory; this.AudioSourceLazy = audioSourceLazy; this.TargetFilename = targetFilename; this.Tag = tag; }
public RemoteMp3VbrEncoder(IPAddress remoteAddress, IAudioSource audioSource, string targetFilename, AudioFileTag tags, int vbrQuality, TrackGain trackGain, DrMeter drMeter) : base(audioSource, targetFilename, tags, trackGain, drMeter) { this.AudioDest = new RemoteMp3VbrWriter(remoteAddress, targetFilename, audioSource.PCM) { CompressionLevel = vbrQuality }; }
public RemoteFlacEncoder(IPAddress remoteAddress, IAudioSource audioSource, string targetFilename, AudioFileTag tags, int compressionLevel, TrackGain trackGain, DrMeter drMeter) : base(audioSource, targetFilename, tags, trackGain, drMeter) { this.AudioDest = new RemoteFlacWriter(remoteAddress, targetFilename, audioSource.PCM) { CompressionLevel = compressionLevel }; }
public LocalMp3Encoder(IAudioSource audioSource, string targetFilename, AudioFileTag tags, int vbrQuality, TrackGain trackGain, DrMeter drMeter) : base(audioSource, targetFilename, tags, trackGain, drMeter) { this.AudioDest = new LameWriter(targetFilename, audioSource.PCM) { Settings = LameWriterSettings.CreateVbr(vbrQuality) }; }
public CueToolsFlacEncoder(IAudioSource audioSource, string targetFilename, AudioFileTag tags, int compressionLevel, TrackGain trackGain, DrMeter drMeter) : base(audioSource, targetFilename, tags, trackGain, drMeter) { this.AudioDest = new FLACWriter(targetFilename, audioSource.PCM) { CompressionLevel = compressionLevel }; }
public FileEncoderBase(IAudioSource audioSource, string targetFilename, AudioFileTag tags, TrackGain trackGain, DrMeter drMeter) { if (audioSource == null) { throw new SkipEncodingItemException("Unsupported audio source."); } this.targetFilename = targetFilename; this.audioSource = audioSource; Directory.CreateDirectory(Path.GetDirectoryName(this.targetFilename)); this.tags = tags; this.trackGain = trackGain; this.drMeter = drMeter; }
private void btnSync_Click(object sender, System.Windows.RoutedEventArgs e) { bool successfullyDeletedFiles = true; foreach (string fileToDelete in this.scanResult.FilesToDelete) { successfullyDeletedFiles = Utility.TryDeleteFile(fileToDelete) && successfullyDeletedFiles; successfullyDeletedFiles = Utility.TryDeleteEmptyFoldersToTheRoot(Path.GetDirectoryName(fileToDelete)) && successfullyDeletedFiles; } if (!successfullyDeletedFiles) { Dialogs.Inform("Some files or folders were not successfully deleted. Please unlock them and rerun the sync."); } if (this.scanResult.ReleasesToEncode.Count > 0) { int localConcurrencyLevel = this.SettingsManager.Settings.ActualLocalConcurrencyLevel; IEncoderFactory encoderFactory; if (this.CollectionManager.Settings.NetworkEncoding) { encoderFactory = new RemoteMp3EncoderFactory(this.networkBox.Servers, this.encodingTarget.Mp3Settings.VbrQuality, localConcurrencyLevel, false, false); } else { encoderFactory = new LocalMp3EncoderFactory(this.encodingTarget.Mp3Settings.VbrQuality, localConcurrencyLevel, false, false); } IEncoderFactory replayGainFactory = new DspEncoderFactory(this.SettingsManager.Settings.ActualLocalConcurrencyLevel, false, false); List<IParallelTask> tasks = new List<IParallelTask>(); foreach (var release in this.scanResult.ReleasesToEncode) { var rgTask = new ReplayGainTask(replayGainFactory, release, false, false, false); if (!release.Tracklist.All(t => AudioHelper.IsSupportedAudioSource(t.RelativeFilename))) { continue; } foreach (Track track in release.Tracklist) { string sourceFilename = Path.Combine(this.CollectionManager.Settings.MusicDirectory, track.RelativeFilename); string targetRelativeFilename = FilenameGenerator.PatternToFilename(this.encodingTarget.FileNamingPattern, release, track) + this.encodingTarget.Extension; string targetFilename = Path.Combine(this.encodingTarget.TargetDirectory, targetRelativeFilename); AudioFileTag tag = new AudioFileTag(release, track); FileEncodeTask encodeTask = new FileEncodeTask( encoderFactory, () => AudioHelper.GetAudioSourceForFile(sourceFilename), targetFilename, tag ); encodeTask.ProgressChanged += (_sender, _e) => { if (encodeTask.Status == EncodeTaskStatus.Completed) { FileInfo originalFileInfo = new FileInfo(sourceFilename); File.SetCreationTime(targetFilename, originalFileInfo.CreationTime); File.SetLastWriteTime(targetFilename, originalFileInfo.LastWriteTime); File.SetLastAccessTime(targetFilename, originalFileInfo.LastAccessTime); } }; tasks.Add(encodeTask); rgTask.AddItem(track, encodeTask); } tasks.Add(rgTask); } int concurrency = Math.Max(encoderFactory.ThreadCount, replayGainFactory.ThreadCount); EncoderController controller = new EncoderController(tasks.ToArray(), concurrency); controller.DeleteSuccessfullyEncodedItemsIfFailure = false; EncodingWindow window = new EncodingWindow(controller); window.ShowDialog(this); } this.Close(); }
private void OKCancelBox_OKClicked(object sender, EventArgs e) { this.release.DateAudioModified = DateTime.Now; IEncoderFactory encoderFactory; if (this.CollectionManager.Settings.NetworkEncoding) { encoderFactory = new RemoteFlacEncoderFactory(this.networkBox.Servers, 8, this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true); } else { encoderFactory = new NativeFlacEncoderFactory(8, this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true); } IEncoderFactory replayGainFactory = new DspEncoderFactory(this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true); ReplayGainTask rgTask = new ReplayGainTask(replayGainFactory, this.release, true, true, true); List<IParallelTask> tasks = new List<IParallelTask>(); for (int i = 0; i < this.items.Count; ++i) { Track track = this.release.Tracklist[i]; IImportSourceItem importSourceItem = this.items[i]; track.RelativeFilename = FilenameGenerator.PatternToFilename( this.CollectionManager.Settings.FileNamingPattern, this.release, track) + ".flac"; AudioFileTag tag = new AudioFileTag(this.release, track); string filename = Path.Combine(this.CollectionManager.Settings.MusicDirectory, track.RelativeFilename); var task = new FileEncodeTask( encoderFactory, () => importSourceItem.GetAudioSource(), filename, tag ); tasks.Add(task); rgTask.AddItem(track, task); } tasks.Add(rgTask); int concurrency = Math.Max(encoderFactory.ThreadCount, replayGainFactory.ThreadCount); EncoderController controller = new EncoderController(tasks.ToArray(), concurrency); EncodingWindow window = new EncodingWindow(controller); if (window.ShowDialog(this) == true) { this.release.UpdateDynamicProperties(); this.CollectionManager.Save(this.release); this.Close(); } CollectionManagerGlobal.OnCollectionChanged(); }
private void OKCancelBox_OKClicked(object sender, System.EventArgs e) { this.UpdateRelease(); IEncoderFactory encoderFactory; if (this.CollectionManager.Settings.NetworkEncoding) { encoderFactory = new RemoteFlacEncoderFactory(this.networkBox.Servers, 8, this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true); } else { encoderFactory = new NativeFlacEncoderFactory(8, this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true); } IEncoderFactory replayGainFactory = new DspEncoderFactory(this.SettingsManager.Settings.ActualLocalConcurrencyLevel, true, true); ReplayGainTask rgTask = new ReplayGainTask(replayGainFactory, this.DatabaseRelease, true, true, true); List<IParallelTask> tasks = new List<IParallelTask>(); foreach (Track track in this.DatabaseRelease.Tracklist) { track.RelativeFilename = FilenameGenerator.PatternToFilename( this.CollectionManager.Settings.FileNamingPattern, this.DatabaseRelease, track) + ".flac"; AudioFileTag tag = new AudioFileTag(this.DatabaseRelease, track); IImportSourceItem sourceItem = this.Release.Discs[track.Disc - 1][track.Position - 1].SourceItem; string filename = Path.Combine(this.CollectionManager.Settings.MusicDirectory, track.RelativeFilename); var task = new FileEncodeTask( encoderFactory, () => sourceItem.GetAudioSource(), filename, tag ); tasks.Add(task); rgTask.AddItem(track, task); } tasks.Add(rgTask); int concurrency = Math.Max(encoderFactory.ThreadCount, replayGainFactory.ThreadCount); EncoderController controller = new EncoderController(tasks.ToArray(), concurrency); EncodingWindow window = new EncodingWindow(controller); if (window.ShowDialog(this) == true) { this.DatabaseRelease.UpdateDynamicProperties(); this.CollectionManager.Save(this.DatabaseRelease); this.InsertedReleaseId = this.DatabaseRelease.Id; this.imagesEditor.WriteFiles(); CollectionManagerGlobal.OnCollectionChanged(); this.completed = true; this.DialogResult = true; } }
public void WriteTags(Release release, IProgress<double> progress = null) { string musicDirectory = this.collectionManager.Settings.MusicDirectory; int tracksFinished = 0; foreach (Track track in release.Tracklist) { AudioFileTag tag = new AudioFileTag(release, track); string filename = Path.Combine(musicDirectory, track.RelativeFilename); tag.WriteToFile(filename); File.SetLastWriteTime(filename, release.DateModified); ++tracksFinished; if (progress != null) { progress.Report((double)tracksFinished / release.Tracklist.Count); } } }