Exemplo n.º 1
0
        public List<int> CreatePlaylist(EmotionVector curEmo, char goalEmo, List<string> prefGenres)
        {
            float startVal, startAr, goalVal, goalAr;

            EmotionVector goalEmotion;
            switch (goalEmo)
            {
                case 'H':
                    goalEmotion = GlobalVariables.Happy;
                    break;
                case 'A':
                    goalEmotion = GlobalVariables.Anger;
                    break;
                case 'S':
                    goalEmotion = GlobalVariables.Sad;
                    break;
                case 'F':
                    goalEmotion = GlobalVariables.Fear;
                    break;
                default:
                    goalEmotion = GlobalVariables.Neutral;
                    break;
            }

            startAr = (float)curEmo.Arousal;
            startVal = (float)curEmo.Valence;
            goalAr = (float)goalEmotion.Arousal;
            goalVal = (float)goalEmotion.Valence;

            float midStartGoalAr = (startAr + goalAr) / 2;
            float midStartGoalVal = (startVal + goalVal) / 2;
            float sumMids = midStartGoalAr + midStartGoalVal;

            string query = "SELECT song_id FROM db WHERE (genre IN (";
            bool first = true;
            foreach (string s in prefGenres)
            {
                if (first)
                {
                    query += "\"" + s + "\"";
                    first = false;
                }
                else
                {
                    query += ", " + "\"" + s + "\"";
                }
            }
            query += ")) ORDER BY (abs(mean_arousal + mean_valence - " + sumMids.ToString().Replace(',','.') + ")) LIMIT 5;";
            dbConnection.Open();
            sql = new SQLiteCommand(query, dbConnection);
            SQLiteDataReader sqlr = sql.ExecuteReader();
            List<int> songIDs = new List<int>();
            while(sqlr.Read())
            {
                songIDs.Add(sqlr.GetInt32(0));
            }
            dbConnection.Close();
            return songIDs;
        }
Exemplo n.º 2
0
        public void OutputIteration(int song, EmotionAnalysis analysis, EmotionVector vector)
        {
            using (StreamWriter sw = new StreamWriter(file, true))
            {
                sw.WriteLine(iterations + ";" + song + ";" + analysis.Emotion + ";" + analysis.Happy + ";" + analysis.Sad + ";" + analysis.Anger + ";" + analysis.Fear + ";" + analysis.Neutral + ";" + vector.Arousal + ";" + vector.Valence);
            }

            iterations++;
        }
Exemplo n.º 3
0
        private void stopRecordingButton_Click(object sender, EventArgs e)
        {
            currentAnalysis = dbm.SearchDatabaseForEmotion(windows);
            currentVector = ec.CalculateVector(currentAnalysis);

            try
            {
                waveIn.StopRecording();
                waveIn.Dispose();
                waveIn = null;
                waveChart.Series[0].Points.Clear();
            }
            catch { }

            stopRecordingButton.Enabled = false;
            startRecordingButton.Enabled = true;

            this.musicPlayer = new MusicPlayer(db.CreatePlaylist(currentVector, settings.GoalEmotion, settings.GenrePreferences));
        }