public CueSourceItem(string targetFilename, CueSheet cueSheet, int trackIndex) { this.targetFilename = targetFilename; this.cueSheet = cueSheet; this.trackIndex = trackIndex; this.Tag = new AudioFileTag() { AlbumArtists = this.cueSheet.Performer, Artists = this.cueSheet.Tracks[this.trackIndex].Performer ?? this.cueSheet.Performer, Title = this.cueSheet.Tracks[this.trackIndex].Title, Album = this.cueSheet.Title, Track = this.trackIndex + 1, TrackCount = this.cueSheet.Tracks.Length }; }
private void AddCue(string file) { CueSheet sheet; try { sheet = new CueSheet(file); } catch (Exception e) { Utility.WriteToErrorLog(e.ToString()); Dialogs.Error("Error reading cue file. Invalid format."); return; } bool isOriginal; string targetFilename = sheet.DiscoverTarget(out isOriginal); if (targetFilename == null) { Dialogs.Error("Cue target was not found!"); return; } else if (!isOriginal) { Dialogs.Inform("Cue target was not found, but successfully discovered."); } if (!AudioHelper.IsSupportedAudioSource(targetFilename)) { Dialogs.Error("Unsupported audio source!"); return; } for (int i = 0; i < sheet.Tracks.Length; ++i) { CueSourceItem item = new CueSourceItem(targetFilename, sheet, i); this.AddItem(item); } }
private void WorkerTask() { while (true) { string item; if (this.shouldCancel || !this.tasks.TryTake(out item, -1)) { break; } try { if (AudioHelper.IsSupportedAudioSource(item)) { this.ProcessAudio(AudioHelper.GetAudioSourceForFile(item), Path.GetDirectoryName(item), Path.GetFileName(item)); } else if (item.ToLower().EndsWith(".cue")) { CueSheet sheet = new CueSheet(item); bool isOriginal; string target = sheet.DiscoverTarget(out isOriginal); if (target == null) { Dialogs.Error("Cue target not found."); continue; } for (int i = 0; i < sheet.Tracks.Length; ++i) { IAudioSource fullFileSource = AudioHelper.GetAudioSourceForFile(target); AudioSourcePart sourcePart = new AudioSourcePart(fullFileSource); sourcePart.SetLengthFrames( sheet.GetTrackStartFrame(i), sheet.GetTrackEndFrame(i)); this.ProcessAudio(sourcePart, target, (i + 1).ToString("00") + ". " + sheet.Tracks[i].Title); } } } catch (Exception e) { Utility.WriteToErrorLog(e.ToString()); Dialogs.Error("Error processing file " + item + ": " + e.Message); } } }