/// <summary> /// Gets all preferred tracks for the specified track /// </summary> /// <param name="track">The track.</param> /// <param name="mixLevels">The mix levels.</param> /// <returns> /// A list of tracks from the available tracks the specified track should prefer to mix with /// </returns> public List <Track> GetMixableFromTracks(Track track, List <int> mixLevels) { var tracks = new List <Track>(); if (track == null) { return(tracks); } if (mixLevels == null || mixLevels.Count == 0) { return(tracks); } if (mixLevels.Contains(1)) { tracks.AddRange(GetUnrankedFromTracks(track)); } if (mixLevels.Count == 1 && mixLevels[0] == 1) { return(tracks); } var mixes = GetFromMixes(track.Description) .Where(t => mixLevels.Contains(t.MixLevel)) .ToList(); tracks.AddRange(GetDistinctFromTracksFromMixes(mixes)); return(tracks); }
/// <summary> /// Gets the mix level for mixing track 1 into track 1 /// </summary> /// <param name="track1">The track 1.</param> /// <param name="track2">The track 2.</param> /// <returns>A mix level from 0 to 5</returns> public string GetExtendedMixDescription(Track track1, Track track2) { var description = GetRankDescription(GetMixLevel(track1, track2)); return(HasExtendedMix(track1, track2) ? description + "*" : description); }
public int GetKeyMixedInCount(Track track) { var inTracks = GetMixableFromTracks(track, new List <int> { 5, 4, 3 }); return(inTracks.Count(t => KeyHelper.GetKeyMixRank(t.Key, track.Key) >= 3)); }
public int GetKeyMixedOutCount(Track track) { var outTracks = GetMixableToTracks(track, new List <int> { 5, 4, 3 }); return(outTracks.Count(t => KeyHelper.GetKeyMixRank(track.Key, t.Key) >= 3)); }
/// <summary> /// Loads the shuffler details for a track /// </summary> /// <param name="track">The track.</param> public static Dictionary<string, string> LoadShufflerDetails(Track track) { var shufflerAttribuesFile = GetShufflerAttributeFile(track.Description); track.IsShufflerTrack = File.Exists(shufflerAttribuesFile); if (!track.IsShufflerTrack) return null; track.ShufflerAttribuesFile = shufflerAttribuesFile; track.ShufflerMixesFile = GetShufflerMixesFile(track); var attributes = AudioEngine.Helpers.PlaylistHelper.GetShufflerAttributes(track.ShufflerAttribuesFile); if (attributes.ContainsKey("StartBPM")) track.StartBpm = BpmHelper.NormaliseBpm(ConversionHelper.ToDecimal(attributes["StartBPM"], track.Bpm)); if (attributes.ContainsKey("EndBPM")) track.EndBpm = BpmHelper.NormaliseBpm(ConversionHelper.ToDecimal(attributes["EndBPM"], track.Bpm)); if (attributes.ContainsKey("Rank")) track.Rank = ConversionHelper.ToInt(attributes["Rank"], 1); decimal start = 0; if (attributes.ContainsKey("FadeIn")) start = ConversionHelper.ToDecimal(attributes["FadeIn"], start); var end = track.Length; if (attributes.ContainsKey("FadeOut")) end = ConversionHelper.ToDecimal(attributes["FadeOut"], end); var length = end - start; var inLoopCount = 0; if (attributes.ContainsKey("StartLoopCount")) inLoopCount = ConversionHelper.ToInt(attributes["StartLoopCount"], inLoopCount); decimal inLoopLength = 0; if (attributes.ContainsKey("FadeInLengthInSeconds")) inLoopLength = ConversionHelper.ToDecimal(attributes["FadeInLengthInSeconds"]); if (inLoopLength > 0) track.StartBpm = BpmHelper.GetBpmFromLoopLength(Convert.ToDouble(inLoopLength)); inLoopCount = inLoopCount - 1; if (inLoopCount > 0) length = length + (inLoopCount*inLoopLength); decimal skipLength = 0; if (attributes.ContainsKey("SkipLengthInSeconds")) skipLength = ConversionHelper.ToDecimal(attributes["SkipLengthInSeconds"]); if (skipLength > 0) length = length - skipLength; track.PowerDown = false; if (attributes.ContainsKey("PowerDown")) track.PowerDown = ConversionHelper.ToBoolean(attributes["PowerDown"]); if (attributes.ContainsKey("Key")) track.Key = attributes["Key"]; decimal outLoopLength = 0; if (attributes.ContainsKey("FadeOutLengthInSeconds")) outLoopLength = ConversionHelper.ToDecimal(attributes["FadeOutLengthInSeconds"], 0); if (outLoopLength > 0) track.EndBpm = BpmHelper.GetBpmFromLoopLength(Convert.ToDouble(outLoopLength)); track.Length = length; return attributes; }
/// <summary> /// Flags track 2 as a mix track for track 1 /// </summary> /// <param name="fromTrack">From track.</param> /// <param name="toTrack">To track.</param> /// <param name="mixLevel">The mix level.</param> public void SetMixLevel(Track fromTrack, Track toTrack, int mixLevel) { if (fromTrack == null || toTrack == null) { return; } SetMixLevel(fromTrack.Description, toTrack.Description, mixLevel); //SaveMixRankings(fromTrack.Description); SaveMixRankings(); }
/// <summary> /// Determines whether track 1 has extended mix details with track 2 /// </summary> /// <param name="track1">The track1.</param> /// <param name="track2">The track2.</param> /// <returns> /// True if track 1 has extended mix details with track 2; otherwise, false. /// </returns> public bool HasExtendedMix(Track track1, Track track2) { if (track1 == null || track2 == null) { return(false); } var attributes = GetExtendedMixAttributes(track1.Description, track2.Description); return(attributes != null); }
/// <summary> /// Gets all preferred tracks for the specified track /// </summary> /// <param name="track">The track.</param> /// <returns>A list of tracks that specified track should prefer to mix from</returns> private IEnumerable <Track> GetFromTracksInRange(Track track) { if (track == null) { return(new List <Track>()); } var tracksInRange = GetTracksInEndBpmRange(track.StartBpm, 5M, AvailableTracks); return(tracksInRange .Where(t => t.Description != track.Description) .ToList()); }
public int GetMixInCount(Track track, int minimumLevel) { if (!track.IsShufflerTrack) { return(0); } var mixes = GetFromMixes(track.Description) .Where(mt => mt.MixLevel >= minimumLevel) .ToList(); return(GetDistinctFromTracksFromMixes(mixes).Count()); }
/// <summary> /// Gets the mix level for mixing track 1 into track 1 /// </summary> /// <param name="track1">The track 1.</param> /// <param name="track2">The track 2.</param> /// <returns>A mix level from 0 to 5</returns> public double GetExtendedMixLevel(Track track1, Track track2) { double mixLevel = GetMixLevel(track1, track2); if (HasExtendedMix(track1, track2)) { mixLevel += 0.5; } else if (track1.PowerDown) { mixLevel += 0.25; } return(mixLevel); }
/// <summary> /// Gets the mix level for mixing track 1 into track 1 /// </summary> /// <param name="track1">The track 1.</param> /// <param name="track2">The track 2.</param> /// <returns>A mix level from 0 to 5</returns> public int GetMixLevel(Track track1, Track track2) { if (track1 == null || track2 == null) { return(0); } var mixRank = GetMixRank(track1.Description, track2.Description); if (mixRank != null) { return(mixRank.MixLevel); } return(BpmHelper.IsBpmInRange(track1.EndBpm, track2.StartBpm, 5M) ? 1 : 0); }
public List <Track> GetUnrankedFromTracks(Track track) { // excluded all ranked tracks and current track var fromMixes = GetFromMixes(track.Description); var excludeTracks = GetFromTracksFromMixes(fromMixes).Select(t => t.Description).ToList(); excludeTracks.Add(track.Description); // find tracks in range var tracksInRange = GetFromTracksInRange(track); // return tracks in range, except ranked tracks and current track return(tracksInRange .Where(t => !excludeTracks.Contains(t.Description)) .ToList()); }
/// <summary> /// Updates the Shuffler files after a track has been changed. /// Assumes the OriginalDescription is the old description, /// and that the ShufflerAttribuesFile/ShufflerMixesFile properties /// point to the old files /// </summary> /// <param name="track">The track.</param> public static void RenameShufferFiles(Track track) { try { var newAttributesFile = GetShufflerAttributeFile(track.Description); var newMixesFile = GetShufflerMixesFile(track); File.Move(track.ShufflerAttribuesFile, newAttributesFile); File.Move(track.ShufflerMixesFile, newMixesFile); track.ShufflerAttribuesFile = newAttributesFile; track.ShufflerMixesFile = newMixesFile; var replacer = new TextReplacer(track.OriginalDescription + ",", track.Description + ",", false, false, false, false); replacer.Replace(ShufflerFolder, "*.Mixes.txt", false); } catch { // ignored } }
public int GetCurrentMixRank() { if (BassPlayer.CurrentTrack == null) { return(1); } Track currentTrack = null; if (BassPlayer.CurrentTrack != null) { currentTrack = Library.GetTrackByFilename(BassPlayer.CurrentTrack.Filename); } var prevTrack = PlaylistControl.GetPreviousTrack(); if (prevTrack == null) { return(1); } return(MixLibrary.GetMixLevel(prevTrack, currentTrack)); }
public void SetCurrentMixRank(int mixRank) { if (BassPlayer.CurrentTrack == null) { return; } Track currentTrack = null; if (BassPlayer.CurrentTrack != null) { currentTrack = Library.GetTrackByFilename(BassPlayer.CurrentTrack.Filename); } var prevTrack = PlaylistControl.GetPreviousTrack(); if (prevTrack == null) { return; } MixLibrary.SetMixLevel(prevTrack, currentTrack, mixRank); }
/// <summary> /// Gets the preferred tracks to mix with the supplied track /// </summary> /// <param name="track">The track.</param> /// <returns>The preferred tracks to mix with the supplied track</returns> public List <Track> GetBearableTracks(Track track) { var ranks = new[] { 2 }.ToList(); return(GetMixableToTracks(track, ranks)); }
/// <summary> /// Gets the preferred tracks to mix with the supplied track /// </summary> /// <param name="track">The track.</param> /// <returns>The preferred tracks to mix with the supplied track</returns> public List <Track> GetGoodTracks(Track track) { var ranks = new[] { 5, 4, 3 }.ToList(); return(GetMixableToTracks(track, ranks)); }
/// <summary> /// Gets the preferred tracks to mix with the supplied track /// </summary> /// <param name="track">The track.</param> /// <returns>The preferred tracks to mix with the supplied track</returns> public List<Track> GetGoodTracks(Track track) { var ranks = new[] {5, 4, 3}.ToList(); return GetMixableToTracks(track, ranks); }
public int GetUnrankedToCount(Track track) { return GetUnrankedToTracks(track).Count(); }
public int GetMixInCount(Track track, int minimumLevel) { if (!track.IsShufflerTrack) return 0; var mixes = GetFromMixes(track.Description) .Where(mt => mt.MixLevel >= minimumLevel) .ToList(); return GetDistinctFromTracksFromMixes(mixes).Count(); }
/// <summary> /// Gets the forbidden tracks for a particular track /// </summary> /// <param name="track">The track.</param> /// <returns>The tracks forbidden to mix with the supplied track</returns> public List<Track> GetForbiddenTracks(Track track) { var ranks = new[] {0}.ToList(); return GetMixableToTracks(track, ranks); }
/// <summary> /// Gets all preferred tracks for the specified track /// </summary> /// <param name="track">The track.</param> /// <param name="mixLevels">The mix levels.</param> /// <returns> /// A list of tracks from the available tracks the specified track should prefer to mix with /// </returns> public List<Track> GetMixableFromTracks(Track track, List<int> mixLevels) { var tracks = new List<Track>(); if (track == null) return tracks; if (mixLevels == null || mixLevels.Count == 0) return tracks; if (mixLevels.Contains(1)) tracks.AddRange(GetUnrankedFromTracks(track)); if (mixLevels.Count == 1 && mixLevels[0] == 1) return tracks; var mixes = GetFromMixes(track.Description) .Where(t => mixLevels.Contains(t.MixLevel)) .ToList(); tracks.AddRange(GetDistinctFromTracksFromMixes(mixes)); return tracks; }
public List <Track> GetRankedTracks(Track track) { var toMixes = GetToMixes(track.Description); return(GetDistinctToTracksFromMixes(toMixes)); }
public List<Track> GetUnrankedFromTracks(Track track) { // excluded all ranked tracks and current track var fromMixes = GetFromMixes(track.Description); var excludeTracks = GetFromTracksFromMixes(fromMixes).Select(t => t.Description).ToList(); excludeTracks.Add(track.Description); // find tracks in range var tracksInRange = GetFromTracksInRange(track); // return tracks in range, except ranked tracks and current track return tracksInRange .Where(t => !excludeTracks.Contains(t.Description)) .ToList(); }
/// <summary> /// Gets the mix level for mixing track 1 into track 1 /// </summary> /// <param name="track1">The track 1.</param> /// <param name="track2">The track 2.</param> /// <returns>A mix level from 0 to 5</returns> public string GetExtendedMixDescription(Track track1, Track track2) { var description = GetRankDescription(GetMixLevel(track1, track2)); return HasExtendedMix(track1, track2) ? description + "*" : description; }
/// <summary> /// Gets the mix level for mixing track 1 into track 1 /// </summary> /// <param name="track1">The track 1.</param> /// <param name="track2">The track 2.</param> /// <returns>A mix level from 0 to 5</returns> public double GetExtendedMixLevel(Track track1, Track track2) { double mixLevel = GetMixLevel(track1, track2); if (HasExtendedMix(track1, track2)) mixLevel += 0.5; else if (track1.PowerDown) mixLevel += 0.25; return mixLevel; }
/// <summary> /// Flags track 2 as a mix track for track 1 /// </summary> /// <param name="fromTrack">From track.</param> /// <param name="toTrack">To track.</param> /// <param name="mixLevel">The mix level.</param> public void SetMixLevel(Track fromTrack, Track toTrack, int mixLevel) { if (fromTrack == null || toTrack == null) return; SetMixLevel(fromTrack.Description, toTrack.Description, mixLevel); SaveMixRankings(fromTrack.Description); }
/// <summary> /// Gets the forbidden tracks for a particular track /// </summary> /// <param name="track">The track.</param> /// <returns>The tracks forbidden to mix with the supplied track</returns> public List <Track> GetForbiddenTracks(Track track) { var ranks = new[] { 0 }.ToList(); return(GetMixableToTracks(track, ranks)); }
/// <summary> /// Displays the current track details. /// </summary> public void DisplayCurrentTrackDetails() { Track track = null; if (BassPlayer.CurrentTrack != null) { track = Library.GetTrackByFilename(BassPlayer.CurrentTrack.Filename); } if (BassPlayer.PlayState == PlayState.Playing) { if (!btnPause.Visible) { btnPause.Visible = true; } if (btnPlay.Visible) { btnPlay.Visible = false; } } if (BassPlayer.PlayState != PlayState.Playing) { if (btnPause.Visible) { btnPause.Visible = false; } if (!btnPlay.Visible) { btnPlay.Visible = true; } } if (track != null) { lblCurrentTrackDescription.Text = track.Description.Replace("&", "&&"); var details = $"{track.Album} - {track.Genre} - {track.LengthFormatted}"; if (track.Bpm != 0) { details += $" - {track.Bpm:0.00} BPM"; } if (track.Key != "") { details += $" - {KeyHelper.GetDisplayKey(track.Key)}"; } details += $" - {track.Bitrate:00} KPS";; lblCurrentTrackDetails.Text = details; picCover.Image = Library.GetAlbumCover(track.Album); } else { lblCurrentTrackDescription.Text = ""; lblCurrentTrackDetails.Text = ""; picCover.Image = null; } var mainForm = (BaseMinimizeToTrayForm)ParentForm; if (mainForm == null) { return; } if (track != null) { var text = track.Description.Replace("&", "&&"); if (text.Length > 63) { text = text.Substring(0, 63); } mainForm.NotifyIcon.Text = text; } else { mainForm.NotifyIcon.Text = ""; } }
public List<Track> GetRankedTracks(Track track) { var toMixes = GetToMixes(track.Description); return GetDistinctToTracksFromMixes(toMixes); }
/// <summary> /// Gets the preferred tracks to mix with the supplied track /// </summary> /// <param name="track">The track.</param> /// <returns>The preferred tracks to mix with the supplied track</returns> public List<Track> GetPreferredTracks(Track track) { var ranks = new[] {5, 4, 3, 2}.ToList(); return GetMixableToTracks(track, ranks); }
public int GetMixInCount(Track track) { return GetMixInCount(track, 3); }
/// <summary> /// Gets the shuffler mixes file for a track /// </summary> /// <param name="track">The track.</param> /// <returns> /// The shuffler mixes file /// </returns> public static string GetShufflerMixesFile(Track track) { var filename = $"{track.Description}.Mixes.txt"; filename = FileSystemHelper.StripInvalidFileNameChars(filename); filename = Path.Combine(ShufflerFolder, filename); return filename; }
/// <summary> /// Gets the preferred tracks to mix with the supplied track /// </summary> /// <param name="track">The track.</param> /// <returns>The preferred tracks to mix with the supplied track</returns> public List<Track> GetBearableTracks(Track track) { var ranks = new[] {2}.ToList(); return GetMixableToTracks(track, ranks); }
/// <summary> /// Determines whether track 1 has extended mix details with track 2 /// </summary> /// <param name="track1">The track1.</param> /// <param name="track2">The track2.</param> /// <returns> /// True if track 1 has extended mix details with track 2; otherwise, false. /// </returns> public bool HasExtendedMix(Track track1, Track track2) { if (track1 == null || track2 == null) return false; var attributes = GetExtendedMixAttributes(track1.Description, track2.Description); return attributes != null; }
/// <summary> /// Gets all preferred tracks for the specified track /// </summary> /// <param name="track">The track.</param> /// <returns>A list of tracks that specified track should prefer to mix from</returns> private IEnumerable<Track> GetFromTracksInRange(Track track) { if (track == null) return new List<Track>(); var tracksInRange = GetTracksInEndBpmRange(track.StartBpm, 5M, AvailableTracks); return tracksInRange .Where(t => t.Description != track.Description) .ToList(); }
/// <summary> /// Gets the mix level for mixing track 1 into track 1 /// </summary> /// <param name="track1">The track 1.</param> /// <param name="track2">The track 2.</param> /// <returns>A mix level from 0 to 5</returns> public int GetMixLevel(Track track1, Track track2) { if (track1 == null || track2 == null) return 0; var mixRank = GetMixRank(track1.Description, track2.Description); if (mixRank != null) return mixRank.MixLevel; return BpmHelper.IsBpmInRange(track1.EndBpm, track2.StartBpm, 5M) ? 1 : 0; }
public int GetKeyMixedOutCount(Track track) { var outTracks = GetMixableToTracks(track, new List<int> {5, 4, 3}); return outTracks.Count(t => KeyHelper.GetKeyMixRank(track.Key, t.Key) >= 3); }
public int GetMixInCount(Track track) { return(GetMixInCount(track, 3)); }
public int GetKeyMixedInCount(Track track) { var inTracks = GetMixableFromTracks(track, new List<int> {5, 4, 3}); return inTracks.Count(t => KeyHelper.GetKeyMixRank(t.Key, track.Key) >= 3); }
public int GetUnrankedToCount(Track track) { return(GetUnrankedToTracks(track).Count()); }
public static void SaveShufflerAttributes(Track track, Dictionary<string, string> attributes) { ExtenedAttributesHelper.SaveExtendedAttributes(attributes, GetShufflerAttributeFile(track.Description)); }