private void LoadCurrentSamples() { lock (_player) { _player.Pause(); var samples = GetSelectedSamples(); if (samples == null || samples.Count == 0) { return; } _player.UnloadAll(); foreach (var sample in samples) { var track = SampleLibrary.GetTrackFromSample(sample); var filename = (track == null) ? sample.Filename : track.Filename; if (!File.Exists(filename)) { continue; } _player.AddSample(GetSampleKey(sample), filename, sample.Start, sample.Length, sample.Offset); } } }
private void EditSample() { var trackSampleLibrary = (TrackSampleLibrary)SampleLibrary; if (trackSampleLibrary == null) { return; } var sample = GetSelectedSample(); if (sample == null) { return; } var track = SampleLibrary.GetTrackFromSample(sample); if (track == null) { return; } StopSamples(); var initialSample = sample.Description; var form = new FrmEditTrackSamples { BassPlayer = BassPlayer, Filename = track.Filename, TrackSampleLibrary = trackSampleLibrary, Library = trackSampleLibrary.TrackLibrary, InitialSample = initialSample }; var result = form.ShowDialog(); if (result == DialogResult.OK) { BindData(); } form.Dispose(); }
private void ExportSamples(List <Sample> samples) { StopSamples(); Cursor = Cursors.WaitCursor; var folder = FileDialogHelper.OpenFolder(); if (folder == "") { return; } ParallelHelper.ForEach(samples, sample => { var track = SampleLibrary.GetTrackFromSample(sample); if (track == null) { return; } var outPath = Path.Combine(folder, track.Genre); if (!Directory.Exists(outPath)) { Directory.CreateDirectory(outPath); } var outFile = FileSystemHelper.StripInvalidFileNameChars($"{sample.Bpm:000.00} - {sample.TrackArtist} - {sample.TrackTitle} - {sample.Description}.wav"); outPath = Path.Combine(outPath, outFile); if (File.Exists(outPath)) { File.Delete(outPath); } AudioExportHelper.SavePartialAsWave(track.Filename, outPath, sample.Start, sample.Length, sample.Offset, sample.Gain); }); Cursor = Cursors.Default; }
private string GetSampleKey(Sample sample) { var track = SampleLibrary.GetTrackFromSample(sample); return((track == null) ? sample.Filename : track.Description + " - " + sample.Description); }