public static Track CreateRandomTrack(HarmonicKey key, double bpm) { return new Track(artist: String.Format("Artist-{0:N}", Guid.NewGuid()), title: String.Format("Title-{0:N}", Guid.NewGuid()), originalKey: key, fileName: String.Format("{0:N}.mp3", Guid.NewGuid()), originalBpm: bpm, duration: GetRandomDuration()) { Genre = String.Format("Genre-{0}", Random.Next()), Year = Random.Next(1980, 2013).ToString(), Label = String.Format("Label-{0}", Random.Next()) }; }
public QuickEditHarmonicKeyViewModel( Track track, SaveHarmonicKeyCommand saveBpmCommand, CloseWindowCommand closeCommand) { if (track == null) throw new ArgumentNullException("track"); if (saveBpmCommand == null) throw new ArgumentNullException("saveBpmCommand"); if (closeCommand == null) throw new ArgumentNullException("closeCommand"); AllHarmonicKeys = HarmonicKey.AllKeys; Track = track; SaveBpmCommand = saveBpmCommand; CloseCommand = closeCommand; harmonicKey = track.OriginalKey; }
public override bool IsCompatible(HarmonicKey firstKey, HarmonicKey secondKey) { return secondKey.Equals(firstKey); }
public override bool IsCompatible(HarmonicKey firstKey, HarmonicKey secondKey) { return firstKey.Pitch == secondKey.Pitch && firstKey.IsMinor() && secondKey.IsMajor(); }
public override bool IsCompatible(HarmonicKey firstKey, HarmonicKey secondKey) { return HarmonicKey.Unknown.Equals(firstKey) || HarmonicKey.Unknown.Equals(secondKey); }
public override bool IsCompatible(HarmonicKey firstKey, HarmonicKey secondKey) { return secondKey.HasSameScaleAs(firstKey) && secondKey.Equals(firstKey.Advance(increaseAmount)); }
public override bool IsCompatible(HarmonicKey firstKey, HarmonicKey secondKey) { return true; }
public override bool IsCompatible(HarmonicKey firstKey, HarmonicKey secondKey) { throw new InvalidOperationException("This strategy is only used to compare BPMs."); }
static IEnumerable<AutoMixEdge> GetPathSatisfyingOptionalStartAndEndKey( IEnumerable<IEnumerable<AutoMixEdge>> paths, HarmonicKey? optionalStartKey, HarmonicKey? optionalEndKey) { var validPaths = paths; if (optionalStartKey.HasValue) { Log.DebugFormat("Required start key: {0}", optionalStartKey); validPaths = validPaths.Where(p => p.First().Source.ContainsKey(optionalStartKey.Value)); } if (optionalEndKey.HasValue) { Log.DebugFormat("Required end key: {0}", optionalEndKey); validPaths = validPaths.Where(p => p.Last().Target.ContainsKey(optionalEndKey.Value)); } return validPaths .OrderBy(p => p.Sum(e => e.Cost)) .FirstOrDefault(); }
static IEnumerable<AutoMixingBucket> GetPreferredMix( IVertexListGraph<AutoMixingBucket, AutoMixEdge> graph, AutoMixingBucket optionalStartVertex, HarmonicKey? optionalEndKey, bool computeAll) { LongestPathAlgorithm<AutoMixingBucket, AutoMixEdge> algo; if (!computeAll && (optionalEndKey == null && optionalStartVertex == null)) algo = new LongestPathAlgorithm<AutoMixingBucket, AutoMixEdge>(graph); else algo = new AllLongestPathsAlgorithm<AutoMixingBucket, AutoMixEdge>(graph); HarmonicKey? optionalStartKey = null; if (optionalStartVertex != null) { algo.SetRootVertex(optionalStartVertex); optionalStartKey = optionalStartVertex.ActualKey; } var stopwatch = Stopwatch.StartNew(); algo.Compute(); stopwatch.Stop(); Log.DebugFormat("Found {0} paths in {1}.", algo.LongestPaths.Count(), stopwatch.Elapsed); if (!algo.LongestPaths.Any()) return null; LogPaths(algo.LongestPaths); IEnumerable<AutoMixEdge> bestPath = GetPathSatisfyingOptionalStartAndEndKey(algo.LongestPaths, optionalStartKey, optionalEndKey); if (bestPath == null) return null; Log.DebugFormat("Using path: {0}", FormatPath(bestPath)); return GetVertices(bestPath); }
static AutoMixingBucket AddPlaceholderVertexIfRequired( AdjacencyGraph<AutoMixingBucket, AutoMixEdge> graph, HarmonicKey? key) { if (!key.HasValue) return null; var vertex = new AutoMixingBucket(key.Value); graph.AddVertex(vertex); return vertex; }
public static Track CreateRandomTrack(HarmonicKey key) { return CreateRandomTrack(key, GetRandomBpm()); }
public static PlaybackSpeed Create(HarmonicKey key) { return new PlaybackSpeed(key, TestTracks.GetRandomBpm()); }