Exemplo n.º 1
0
        public void Load()
        {
            Artist = _xmlWrapper.GetAttribute(EntryNode.Attributes["ARTIST"]);
            Title  = _xmlWrapper.GetAttribute(EntryNode.Attributes["TITLE"]);
            var locationNode = EntryNode.SelectSingleNode("LOCATION");

            Playlist = GetPlayList(locationNode);
            Path     = GetPath(locationNode);
            var infoNode = EntryNode.SelectSingleNode("INFO");

            PlayTime             = GetPlayTime(_xmlWrapper.GetAttribute(infoNode.Attributes["PLAYTIME"]));
            LeadingTempo         = GetTempo(EntryNode.SelectSingleNode("TEMPO"), Path);
            TrailingTempo        = GetTempo(EntryNode.SelectSingleNode("TEMPO"), Path, false);
            TempoText            = GetTempoText(LeadingTempo, TrailingTempo);
            RoundedTrailingTempo = GetRoundedTrailingTempo(TrailingTempo);
            var comment = _xmlWrapper.GetAttribute(infoNode.Attributes["COMMENT"]).Trim();

            Intensity           = GetIntensity(comment);
            LeadingHarmonicKey  = GetLeadingHarmonicKey(comment);
            TrailingHarmonicKey = GetTrailingHarmonicKey(comment, LeadingHarmonicKey);
            HarmonicKeyText     = GetHarmonicKeyText(LeadingHarmonicKey, TrailingHarmonicKey);
            IsCharting          = GetIsCharting();
            IsChartingText      = GetIsChartingText(IsCharting);
            FullNameText        = GetFullNameText(Artist, Title, TempoText, HarmonicKeyText, Intensity, Playlist);
            TempoRange.Load(TrailingTempo, 3); // menu item control the range value to be added later
            HarmonicKeyRange.Load(LeadingHarmonicKey);
            IntensityRange.Load(Intensity);
        }
Exemplo n.º 2
0
        public void GetBestMatch_MatchOnHarmonicKey_Test()
        {
            // Arrange
            IXmlWrapper       xmlWrapper1       = new XmlWrapper();
            ITempoRange       tempoRange1       = new TempoRange();
            IHarmonicKeyRange harmonicKeyRange1 = new HarmonicKeyRange();
            IIntensityRange   intensityRange1   = new IntensityRange();
            ISong             song1             = new Song(xmlWrapper1, tempoRange1, harmonicKeyRange1, intensityRange1)
            {
                Artist              = "Song 1",
                PlayTime            = 100,
                TrailingTempo       = 128.000,
                TrailingHarmonicKey = "8A"
            };

            IXmlWrapper xmlWrapper2 = new XmlWrapper();
            ITempoRange tempoRange2 = new TempoRange();

            tempoRange2.Load(128, 3);
            IHarmonicKeyRange harmonicKeyRange2 = new HarmonicKeyRange();

            harmonicKeyRange2.Load("8A");
            IIntensityRange intensityRange2 = new IntensityRange();
            ISong           song2           = new Song(xmlWrapper2, tempoRange2, harmonicKeyRange2, intensityRange2)
            {
                Artist   = "Song 2",
                PlayTime = 100
            };

            var baseTrackList = new List <ISong>
            {
                song1
            };

            var playlistTracks = new List <ISong>
            {
                song2
            };

            var intensityStyle = "Random";
            var minPlaytime    = 200;
            var mixLength      = 0;

            IMixDisc mixDisc = new MixDisc
            {
                BaseTrackList  = baseTrackList,
                PlaylistTracks = playlistTracks,
                IntensityStyle = intensityStyle,
                MinPlaytime    = minPlaytime,
                MixLength      = mixLength
            };

            // Act
            var result = mixDisc.GetBestMatch();

            // Assert
            Assert.IsTrue(result.Count == 2);
        }
Exemplo n.º 3
0
        public void GetBestMatch_SongAlreadyInMixableTrackCombination_Test()
        {
            // Arrange
            IXmlWrapper       xmlWrapper1       = new XmlWrapper();
            ITempoRange       tempoRange1       = new TempoRange();
            IHarmonicKeyRange harmonicKeyRange1 = new HarmonicKeyRange();
            IIntensityRange   intensityRange1   = new IntensityRange();
            ISong             song1             = new Song(xmlWrapper1, tempoRange1, harmonicKeyRange1, intensityRange1)
            {
                Artist   = "Song 1",
                PlayTime = 100
            };

            IXmlWrapper       xmlWrapper2       = new XmlWrapper();
            ITempoRange       tempoRange2       = new TempoRange();
            IHarmonicKeyRange harmonicKeyRange2 = new HarmonicKeyRange();
            IIntensityRange   intensityRange2   = new IntensityRange();
            ISong             song2             = new Song(xmlWrapper2, tempoRange2, harmonicKeyRange2, intensityRange2)
            {
                Artist   = "Song 2",
                PlayTime = 100
            };

            var baseTrackList = new List <ISong>
            {
                song2,
                song1
            };

            var playlistTracks = new List <ISong>
            {
                song2
            };

            var intensityStyle = "Random";
            var minPlaytime    = 300;
            var mixLength      = 0;

            IMixDisc mixDisc = new MixDisc
            {
                BaseTrackList  = baseTrackList,
                PlaylistTracks = playlistTracks,
                IntensityStyle = intensityStyle,
                MinPlaytime    = minPlaytime,
                MixLength      = mixLength
            };

            // Act
            var result = mixDisc.GetBestMatch();

            // Assert
            Assert.IsTrue(result.Count == 0);
        }
Exemplo n.º 4
0
        public ISong GetSong(XmlNode entryNode)
        {
            ITempoRange       tempoRange       = new TempoRange();
            IHarmonicKeyRange harmonicKeyRange = new HarmonicKeyRange();
            IIntensityRange   intensityRange   = new IntensityRange();
            ISong             song             = new Song(_xmlWrapper, tempoRange, harmonicKeyRange, intensityRange)
            {
                EntryNode = entryNode
            };

            song.Load();

            return(song);
        }
Exemplo n.º 5
0
        public void Load_AtEnd_Test()
        {
            // Arrange
            IHarmonicKeyRange harmonicKeyRange = new HarmonicKeyRange();

            // Act
            harmonicKeyRange.Load("12B");

            // Assert
            Assert.AreEqual("12A", harmonicKeyRange.InnerCircleHarmonicKey);
            Assert.AreEqual("12B", harmonicKeyRange.OuterCircleHarmonicKey);
            Assert.AreEqual("11B", harmonicKeyRange.MinusOneHarmonicKey);
            Assert.AreEqual("1B", harmonicKeyRange.PlusOneHarmonicKey);
        }
Exemplo n.º 6
0
        public void IsInTempoRange_AboveFastestDoubleAndSlowestDoubleTempo_Test()
        {
            // Arrange
            IXmlWrapper xmlWrapper = new XmlWrapper();
            ITempoRange tempoRange = new TempoRange();

            tempoRange.Load(62.499, 3);
            IHarmonicKeyRange harmonicKeyRange = new HarmonicKeyRange();
            IIntensityRange   intensityRange   = new IntensityRange();
            ISong             song             = new Song(xmlWrapper, tempoRange, harmonicKeyRange, intensityRange)
            {
                Artist = "Song 1",
            };

            var trailingTempo = 128;

            // Act
            var result = song.IsInTempoRange(trailingTempo);

            // Assert
            Assert.IsFalse(result);
        }
Exemplo n.º 7
0
        public void IsInHarmonicKeyRange_MinusOneAndOppositeCircle_Test()
        {
            // Arrange
            IXmlWrapper       xmlWrapper       = new XmlWrapper();
            ITempoRange       tempoRange       = new TempoRange();
            IHarmonicKeyRange harmonicKeyRange = new HarmonicKeyRange();

            harmonicKeyRange.Load("7B");
            IIntensityRange intensityRange = new IntensityRange();
            ISong           song           = new Song(xmlWrapper, tempoRange, harmonicKeyRange, intensityRange)
            {
                Artist = "Song 1",
            };

            var trailingHarmonicKey = "8A";

            // Act
            var result = song.IsInHarmonicKeyRange(trailingHarmonicKey);

            // Assert
            Assert.IsFalse(result);
        }
Exemplo n.º 8
0
        public void GetBestMatch_SongsAreSame_Test()
        {
            // Arrange
            IXmlWrapper       xmlWrapper1       = new XmlWrapper();
            ITempoRange       tempoRange1       = new TempoRange();
            IHarmonicKeyRange harmonicKeyRange1 = new HarmonicKeyRange();
            IIntensityRange   intensityRange1   = new IntensityRange();
            ISong             song1             = new Song(xmlWrapper1, tempoRange1, harmonicKeyRange1, intensityRange1);

            var baseTrackList = new List <ISong>
            {
                song1
            };

            var playlistTracks = new List <ISong>
            {
                song1
            };

            var intensityStyle = "Random";
            var minPlaytime    = 200;
            var mixLength      = 0;

            IMixDisc mixDisc = new MixDisc
            {
                BaseTrackList  = baseTrackList,
                PlaylistTracks = playlistTracks,
                IntensityStyle = intensityStyle,
                MinPlaytime    = minPlaytime,
                MixLength      = mixLength
            };

            // Act
            var result = mixDisc.GetBestMatch();

            // Assert
            Assert.IsTrue(result.Count == 0);
        }
Exemplo n.º 9
0
        public void IsInIntensityRange_AbovePlusOne_Test()
        {
            // Arrange
            IXmlWrapper       xmlWrapper       = new XmlWrapper();
            ITempoRange       tempoRange       = new TempoRange();
            IHarmonicKeyRange harmonicKeyRange = new HarmonicKeyRange();
            IIntensityRange   intensityRange   = new IntensityRange();

            intensityRange.Load(9);
            ISong song = new Song(xmlWrapper, tempoRange, harmonicKeyRange, intensityRange)
            {
                Artist    = "Song 1",
                Intensity = 9
            };

            var trailingIntensity = 7;

            // Act
            var result = song.IsInIntensityRange(trailingIntensity);

            // Assert
            Assert.IsFalse(result);
        }