コード例 #1
0
        //CREATE AND LABEL AUDIO EMOTION OBJECTS
        public AudioEmotion GetEmotion(Song song)
        {
            var songE = new AudioEmotion();

            songE.songName   = song.name;
            songE.artistName = song.artist;
            songE.albumName  = song.album;
            songE.albumYear  = song.year;
            songE.preview    = song.previewUrl;

            var arr = GetEmotionValues(song);

            songE.emotionValue = arr.Max();
            var indexOfMax = arr.ToList().IndexOf(arr.Max());

            if (indexOfMax == 0)
            {
                songE.emotionName = "Angry";
            }
            if (indexOfMax == 1)
            {
                songE.emotionName = "Joyful";
            }
            if (indexOfMax == 2)
            {
                songE.emotionName = "Sad";
            }
            if (indexOfMax == 3)
            {
                songE.emotionName = "Peaceful";
            }

            return(songE);
        }
コード例 #2
0
        //CATEGORIZE AND ORDER AUDIO EMOTION OBJECTS INTO PROPER LISTS
        public void SortSong()
        {
            var audioItems = LoadJson();

            foreach (var item in audioItems)
            {
                var songAudioEmotion = new AudioEmotion();
                songAudioEmotion = GetEmotion(item);
                if (songAudioEmotion.emotionName == "Angry")
                {
                    angrySongs.Add(songAudioEmotion);
                }

                if (songAudioEmotion.emotionName == "Joyful")
                {
                    joyfulSongs.Add(songAudioEmotion);
                }

                if (songAudioEmotion.emotionName == "Sad")
                {
                    sadSongs.Add(songAudioEmotion);
                }

                if (songAudioEmotion.emotionName == "Peaceful")
                {
                    peacefulSongs.Add(songAudioEmotion);
                }
            }
            angrySongs    = angrySongs.OrderByDescending(x => x.emotionValue).ToList();
            joyfulSongs   = joyfulSongs.OrderByDescending(x => x.emotionValue).ToList();
            sadSongs      = sadSongs.OrderByDescending(x => x.emotionValue).ToList();
            peacefulSongs = peacefulSongs.OrderByDescending(x => x.emotionValue).ToList();
        }