private void AddSample() { var sampleName = UserInputHelper.GetUserInput("Sample Name", "", this); if (sampleName == "") { return; } var sampleKey = ""; for (var i = 0; i < 2000; i++) { sampleKey = "Sample" + (i + 1); if (!CurrentSamples.Exists(s => s.Key == sampleKey)) { break; } } var trackSample = new TrackSample { Description = sampleName, Key = sampleKey }; CurrentSamples.Add(trackSample); CurrentSample = trackSample; BindSamples(); BindSample(); }
private void LoadSample(Track track, TrackSample trackSample) { var sampleId = track.Description + " - " + trackSample.Key; var filename = trackSample.IsExternalLoop ? Path.Combine(LoopFolder, trackSample.Key) : track.Filename; if (!File.Exists(filename)) { return; } var sample = (Sample)_audioPlayer.Load(sampleId, filename); sample.LinkedTrackDescription = track.Description; sample.Gain = trackSample.IsExternalLoop ? 0 : track.Gain; sample.SampleKey = trackSample.Key; sample.IsLooped = trackSample.IsExternalLoop || trackSample.IsLooped; sample.Bpm = trackSample.CalculateBpm(track); sample.Description = trackSample.Description; _audioPlayer.AddSection(sampleId, sampleId, start: trackSample.Start, length: trackSample.Length, bpm: sample.Bpm, loopIndefinitely: trackSample.IsLooped); _audioPlayer.QueueSection(sampleId, sampleId); }