/// <summary> /// Removes the previous track FX automation. /// </summary> public void RemovePreviousTrackFxTrigger() { if (CurrentTrack == null) { return; } var attributes = AutomationAttributesHelper.GetAutomationAttributes(CurrentTrack.Description); if (attributes.TrackFXTriggers.Count == 0) { return; } var trigger = GetPrevTrackFxTrigger(attributes); if (trigger == null) { return; } ClearTrackSyncPositions(CurrentTrack); attributes.TrackFXTriggers.Remove(trigger); AutomationAttributesHelper.SaveAutomationAttributes(CurrentTrack.Description, attributes); ResetTrackSyncPositions(); }
/// <summary> /// Removes the previous track FX automation. /// </summary> public void RemovePreviousSampleTrigger() { if (CurrentTrack == null) { return; } var attributes = AutomationAttributesHelper.GetAutomationAttributes(CurrentTrack.Description); var trigger = GetPrevSampleTrigger(attributes); if (trigger == null) { return; } ClearTrackSyncPositions(CurrentTrack); var nextTrackSampleTriggers = GetNextTrackSampleTriggers(attributes); if (attributes.SampleTriggers.Contains(trigger)) { attributes.SampleTriggers.Remove(trigger); } else if (nextTrackSampleTriggers.Contains(trigger)) { nextTrackSampleTriggers.Remove(trigger); } AutomationAttributesHelper.SaveAutomationAttributes(CurrentTrack.Description, attributes); ResetTrackSyncPositions(); }
/// <summary> /// Clears the track FX triggers for the specified track. /// </summary> public void ClearTrackFxTriggers(Track track) { if (track == null) { return; } var attributes = AutomationAttributesHelper.GetAutomationAttributes(track.Description); if (attributes.TrackFXTriggers.Count == 0) { return; } if (IsTrackInUse(track)) { ClearTrackSyncPositions(track); } attributes.TrackFXTriggers.Clear(); AutomationAttributesHelper.SaveAutomationAttributes(track.Description, attributes); if (IsTrackInUse(track)) { ResetTrackSyncPositions(); } }
/// <summary> /// Gets the extended mix attributes. /// </summary> /// <param name="fadeOutTrackDescription">The fade out track description.</param> /// <param name="fadeInTrackDescription">The fade in track description.</param> /// <returns>The extended mix attributes.</returns> private static ExtendedMixAttributes GetExtendedMixAttributes(string fadeOutTrackDescription, string fadeInTrackDescription) { var attributes = AutomationAttributesHelper.GetAutomationAttributes(fadeOutTrackDescription); return(attributes?.GetExtendedMixAttributes(fadeInTrackDescription)); }
public void SaveExtendedMix() { if (LastExtendedMixTrack == null || LastExtendedMixAttributes == null) { return; } var attributes = AutomationAttributesHelper.GetAutomationAttributes(LastExtendedMixTrack.Description); if (attributes == null) { return; } var existingMix = attributes.GetExtendedMixAttributes(LastExtendedMixAttributes.TrackDescription); if (existingMix != null) { LastExtendedMixAttributes.SampleTriggers.AddRange(existingMix.SampleTriggers); attributes.RemoveExtendedMixAttributes(LastExtendedMixAttributes.TrackDescription); } attributes.ExtendedMixes.Add(LastExtendedMixAttributes); AutomationAttributesHelper.SaveAutomationAttributes(LastExtendedMixTrack.Description, attributes); LastExtendedMixTrack = null; LastExtendedMixAttributes = null; }
/// <summary> /// Clears the automation sync positions. /// </summary> /// <param name="track">The track.</param> private void ClearAutomationSyncPositions(AudioStream track) { foreach (var trigger in AutomationAttributesHelper.GetAutomationAttributes(track.Description).TrackFXTriggers) { if (trigger.StartSyncId != int.MinValue) { BassMix.BASS_Mixer_ChannelRemoveSync(track.ChannelId, trigger.StartSyncId); trigger.StartSyncId = int.MinValue; } if (trigger.EndSyncId == int.MinValue) { continue; } BassMix.BASS_Mixer_ChannelRemoveSync(track.ChannelId, trigger.EndSyncId); trigger.EndSyncId = int.MinValue; } foreach (var trigger in GetCurrentSampleTriggers()) { if (trigger.StartSyncId != int.MinValue) { BassMix.BASS_Mixer_ChannelRemoveSync(track.ChannelId, trigger.StartSyncId); trigger.StartSyncId = int.MinValue; } if (trigger.EndSyncId == int.MinValue) { continue; } BassMix.BASS_Mixer_ChannelRemoveSync(track.ChannelId, trigger.EndSyncId); trigger.EndSyncId = int.MinValue; } }
/// <summary> /// Gets the current automated track FX. /// </summary> /// <returns>The current automated track FX.</returns> private SampleTrigger GetCurrentSampleTrigger(AutomationAttributes attributes = null) { if (CurrentTrack == null) { return(null); } if (attributes == null) { attributes = AutomationAttributesHelper.GetAutomationAttributes(CurrentTrack.Description); } var position = AudioStreamHelper.GetPosition(CurrentTrack); return(GetCurrentSampleTriggers(attributes) .OrderBy(t => Math.Abs(t.StartSample - position)) .FirstOrDefault()); }
private static IEnumerable <TrackSample> GetAdditionalTrackSamples(string trackDescription) { var additionalSamples = new List <TrackSample>(); var attributes = AutomationAttributesHelper.GetAutomationAttributes(trackDescription); if (attributes?.TrackSamples != null && attributes.TrackSamples.Count > 0) { additionalSamples.AddRange(attributes.TrackSamples.OrderBy(t => t.Description).ToList()); } if (attributes?.LoopSamples != null && attributes.LoopSamples.Count > 0) { additionalSamples.AddRange(attributes.LoopSamples.OrderBy(t => t.Description).ToList()); } return(additionalSamples); }
/// <summary> /// Saves the last track FX. /// </summary> public void SaveLastSampleTrigger() { if (LastSampleTriggerTrack == null || LastSampleTrigger == null) { return; } var attributes = AutomationAttributesHelper.GetAutomationAttributes(LastSampleTriggerTrack.Description); var sample = GetSampleBySampleId(LastSampleTrigger.SampleId); if (sample != null) { if (sample.LinkedTrackDescription != LastSampleTriggerPrevTrackDescription && sample.LinkedTrackDescription != LastSampleTriggerNextTrackDescription) { attributes.SampleTriggers.Add(LastSampleTrigger); } else if (sample.LinkedTrackDescription == LastSampleTriggerNextTrackDescription) { var mixDetails = attributes.GetExtendedMixAttributes(LastSampleTriggerNextTrackDescription); if (mixDetails == null) { mixDetails = new ExtendedMixAttributes { TrackDescription = LastSampleTriggerNextTrackDescription }; attributes.ExtendedMixes.Add(mixDetails); } mixDetails.SampleTriggers.Add(LastSampleTrigger); } AutomationAttributesHelper.SaveAutomationAttributes(LastSampleTriggerTrack.Description, attributes); if (IsTrackInUse(LastSampleTriggerTrack)) { ResetTrackSyncPositions(); } } LastSampleTriggerTrack = null; LastSampleTrigger = null; LastSampleTriggerPrevTrackDescription = ""; LastSampleTriggerNextTrackDescription = ""; }
private void Initialise() { trackWave.BassPlayer = BassPlayer; Track = trackWave.LoadTrack(Filename); AutomationAttributes = AutomationAttributesHelper.GetAutomationAttributes(Track.Description); cmbOutput.SelectedIndex = 0; CurrentSamples = new List <TrackSample>(); foreach (var trackSample in AutomationAttributes.TrackSamples) { CurrentSamples.Add(trackSample.Clone()); } trackWave.TrackSamples = CurrentSamples; SetControlStates(); BindData(); SetBpmValues(); PopulateTrackFxComboBox(); }
/// <summary> /// Clears the track FX triggers for the specified track. /// </summary> public void ClearSampleTriggers() { if (CurrentTrack == null) { return; } var attributes = AutomationAttributesHelper.GetAutomationAttributes(CurrentTrack.Description); ClearTrackSyncPositions(CurrentTrack); attributes.SampleTriggers.Clear(); var mixDetails = attributes.GetExtendedMixAttributes(NextTrack.Description); mixDetails?.SampleTriggers.Clear(); AutomationAttributesHelper.SaveAutomationAttributes(CurrentTrack.Description, attributes); ResetTrackSyncPositions(); }
/// <summary> /// Gets the current automated track FX. /// </summary> /// <returns>The current automated track FX.</returns> private TrackFXTrigger GetPrevTrackFxTrigger(AutomationAttributes attributes = null) { if (CurrentTrack == null) { return(null); } if (attributes == null) { attributes = AutomationAttributesHelper.GetAutomationAttributes(CurrentTrack.Description); } var position = AudioStreamHelper.GetPosition(CurrentTrack); return(attributes .TrackFXTriggers .Where(ta => ta.StartSample <= position) .OrderBy(ta => Math.Abs(ta.StartSample - position)) .FirstOrDefault()); }
/// <summary> /// Saves the last track FX. /// </summary> public void SaveLastTrackFxTrigger() { if (LastTrackFxTriggerTrack == null || LastTrackFxTrigger == null) { return; } var attributes = AutomationAttributesHelper.GetAutomationAttributes(LastTrackFxTriggerTrack.Description); attributes.TrackFXTriggers.Add(LastTrackFxTrigger); AutomationAttributesHelper.SaveAutomationAttributes(LastTrackFxTriggerTrack.Description, attributes); if (IsTrackInUse(LastTrackFxTriggerTrack)) { ResetTrackSyncPositions(); } LastTrackFxTriggerTrack = null; LastTrackFxTrigger = null; }
public void ClearExtendedMix() { if (CurrentTrack == null || PreviousTrack == null) { return; } var attributes = AutomationAttributesHelper.GetAutomationAttributes(PreviousTrack.Description); if (attributes == null) { return; } attributes.RemoveExtendedMixAttributes(CurrentTrack.Description); AutomationAttributesHelper.SaveAutomationAttributes(PreviousTrack.Description, attributes); LastExtendedMixTrack = null; LastExtendedMixAttributes = null; }
/// <summary> /// Gets the sample triggers from the next track for the current track. /// </summary> /// <returns>A list of the sample triggers</returns> private List <SampleTrigger> GetNextTrackSampleTriggers(AutomationAttributes attributes = null) { if (NextTrack == null) { return(new List <SampleTrigger>()); } if (attributes == null) { attributes = AutomationAttributesHelper.GetAutomationAttributes(CurrentTrack.Description); } if (attributes == null) { return(new List <SampleTrigger>()); } var mixDetails = attributes.GetExtendedMixAttributes(NextTrack.Description); return(mixDetails == null ? new List <SampleTrigger>() : mixDetails.SampleTriggers); }
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); }); } }
/// <summary> /// Gets the sample triggers for the current track, including ones specific to the next track /// </summary> /// <returns>A list of sample triggers, or an empty list if there are none</returns> private IEnumerable <SampleTrigger> GetCurrentSampleTriggers(AutomationAttributes attributes = null) { if (CurrentTrack == null) { return(new List <SampleTrigger>()); } if (attributes == null) { attributes = AutomationAttributesHelper.GetAutomationAttributes(CurrentTrack.Description); } if (attributes == null) { return(new List <SampleTrigger>()); } return(attributes .SampleTriggers .Union(GetNextTrackSampleTriggers()) .OrderBy(t => t.StartSample) .ToList()); }
/// <summary> /// Sets the automation sync positions. /// </summary> /// <param name="track">The track.</param> private void SetAutomationSyncPositions(Track track) { if (track != CurrentTrack) { return; } foreach (var trigger in AutomationAttributesHelper.GetAutomationAttributes(track.Description).TrackFXTriggers) { trigger.StartSample = track.SecondsToSamples(trigger.Start); trigger.EndSample = track.SecondsToSamples(trigger.Start + trigger.Length); trigger.StartSyncId = SetTrackSync(track, trigger.StartSample, SyncType.StartTrackFxTrigger); trigger.EndSyncId = SetTrackSync(track, trigger.EndSample, SyncType.EndTrackFxTrigger); } foreach (var trigger in GetCurrentSampleTriggers()) { trigger.StartSample = track.SecondsToSamples(trigger.Start); trigger.EndSample = track.SecondsToSamples(trigger.Start + trigger.Length); trigger.StartSyncId = SetTrackSync(track, trigger.StartSample, SyncType.StartSampleTrigger); trigger.EndSyncId = SetTrackSync(track, trigger.EndSample, SyncType.EndSampleTrigger); } }
private void SetShufflerMarkers() { if (Wave == null) { return; } Wave.RemoveMarker("PFI"); Wave.RemoveMarker("FIS"); Wave.RemoveMarker("FIE"); Wave.RemoveMarker("FOS"); Wave.RemoveMarker("FOE"); Wave.RemoveMarker("SKS"); Wave.RemoveMarker("SKE"); var attributes = AutomationAttributesHelper.GetAutomationAttributes(BassTrack.Description); foreach (var trigger in attributes.TrackFXTriggers) { Wave.RemoveMarker("TS" + attributes.TrackFXTriggers.IndexOf(trigger)); Wave.RemoveMarker("TE" + attributes.TrackFXTriggers.IndexOf(trigger)); } for (var i = 1; i <= 2000; i++) { Wave.RemoveMarker("S" + i + "S"); Wave.RemoveMarker("S" + i + "E"); } Wave.AddMarker("PFI", BassTrack.SamplesToSeconds(BassTrack.PreFadeInStart)); Wave.AddMarker("FIS", BassTrack.SamplesToSeconds(BassTrack.FadeInStart)); Wave.AddMarker("FIE", BassTrack.SamplesToSeconds(BassTrack.FadeInEnd)); Wave.AddMarker("FOS", BassTrack.SamplesToSeconds(BassTrack.FadeOutStart)); Wave.AddMarker("FOE", BassTrack.SamplesToSeconds(BassTrack.FadeOutEnd)); if (BassTrack.HasSkipSection) { Wave.AddMarker("SKS", BassTrack.SamplesToSeconds(BassTrack.SkipStart)); Wave.AddMarker("SKE", BassTrack.SamplesToSeconds(BassTrack.SkipEnd)); } if (TrackSamples != null) { for (var i = 1; i <= TrackSamples.Count; i++) { var trackSample = TrackSamples[i - 1]; if (trackSample.Start == 0 && trackSample.Length == 0) { continue; } Wave.AddMarker("S" + i + "S", trackSample.Start); Wave.AddMarker("S" + i + "E", trackSample.Start + trackSample.Length); } } if (!ShowTrackFx) { return; } foreach (var trackFx in attributes.TrackFXTriggers) { Wave.AddMarker("TS" + attributes.TrackFXTriggers.IndexOf(trackFx), trackFx.Start); Wave.AddMarker("TE" + attributes.TrackFXTriggers.IndexOf(trackFx), trackFx.Start + trackFx.Length); } }