private void RefreshSamples() { if (!_samplePlayer.HaveTracksChanged(CurrentTrack, NextTrack)) { return; } Task.Run(() => { _samplePlayer.LoadSamples(CurrentTrack, NextTrack); OnTrackSamplesChanged?.Invoke(this, EventArgs.Empty); }); }
public void LinkLoopSampleToTrack(string loopKey, Track track) { var filename = Path.Combine(LoopFolder, loopKey); if (!File.Exists(filename) || track == null) { return; } var length = AudioStreamHelper.GetLength(filename); var attributes = AutomationAttributesHelper.GetAutomationAttributes(track.Description); var description = Path.GetFileNameWithoutExtension(filename) .Replace("_", " ") .Replace("-", " ") .Replace(".", " "); attributes.LoopSamples.Add(new TrackSample { Description = description, IsExternalLoop = true, Key = loopKey, Length = length, IsLooped = true, Start = 0 }); AutomationAttributesHelper.SaveAutomationAttributes(track.Description, attributes); if (track == CurrentTrack || track == NextTrack) { Task.Run(() => { _samplePlayer.LoadSamples(CurrentTrack, NextTrack); OnTrackSamplesChanged?.Invoke(this, EventArgs.Empty); }); } }