Ejemplo n.º 1
0
        private void PerceivedEmotion_Load(object sender, EventArgs e)
        {
            CenterToScreen();

            //Create log file for Data
            _logger = new Logging(_experimentData.NameOfParticipant + "_PEResults.txt", ",");

            string path = Directory.GetCurrentDirectory();

            path = path + "\\EmotionFiles.txt";

            List <String> audioFiles = new List <string>();

            try
            {
                using (var sr = new StreamReader(path))
                {
                    var reader = new CsvReader(sr);

                    while (true)
                    {
                        reader.Configuration.HasHeaderRecord = false;
                        var row = reader.Read();
                        if (reader.CurrentRecord == null)
                        {
                            break;
                        }
                        audioFiles.Add(reader.CurrentRecord[0]);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                throw;
            }

            int songIndex = 0;

            foreach (var pathAudio in audioFiles)
            {
                ExperimentData expdata     = new ExperimentData();
                string[]       fileEntries = Directory.GetFiles(pathAudio, "*.wav");

                foreach (string fileName in fileEntries)
                {
                    _experimentData.Songs[songIndex].Add(fileName);
                }

                songIndex++;
            }

            //Randomise Everyting for the experiment
            var rnd = new Random();

            _experimentData.Song1Mixes = _experimentData.Song1Mixes.OrderBy(x => rnd.Next()).ToList();
            rnd = new Random();
            _experimentData.Song2Mixes = _experimentData.Song2Mixes.OrderBy(x => rnd.Next()).ToList();
            rnd = new Random();
            _experimentData.Song3Mixes = _experimentData.Song3Mixes.OrderBy(x => rnd.Next()).ToList();
            rnd = new Random();
            _experimentData.Song4Mixes = _experimentData.Song4Mixes.OrderBy(x => rnd.Next()).ToList();
            rnd = new Random();
            _experimentData.Song5Mixes = _experimentData.Song5Mixes.OrderBy(x => rnd.Next()).ToList();

            rnd = new Random();
            _experimentData.Songs = _experimentData.Songs.OrderBy(x => rnd.Next()).ToList();

            int songNum = _testNumber + 1;

            this.Text = "Perceived Emotion Experiment - Song " + songNum;

            AssignSliders();

            _stopWatchListenToSong.Reset();
            _stopWatchListenToSong.Start();
        }
        private void ListenToAudio_Load(object sender, EventArgs e)
        {
            this.CenterToScreen();

            Name   nameDialog  = new Name();
            String currentUser = String.Empty;
            String testType    = String.Empty;

            this.Hide();
            nameDialog.ShowDialog(this);

            if (nameDialog.radioButtonTestA.Checked)
            {
                testType = "A";
                textBoxTestInstructions.Text = "Please rate the mixes in terms of your own overall preference.";
            }
            else if (nameDialog.radioButtonTestB.Checked)
            {
                testType = "B";
                textBoxTestInstructions.Text = "Please rate the mixes in terms of the ability to distinguish the sources (i.e. the lack of masking).";
            }

            nameDialog.ShowDialog(this);

            _experimentData.NameOfParticipant = nameDialog.tbName.Text;

            nameDialog.ShowDialog(this);

            //Create log file for Data
            _logger = new Logging(testType + "_" + _experimentData.NameOfParticipant + "_LTResults.txt", ",");


            string path = Directory.GetCurrentDirectory();

            path = path + "\\Files.txt";

            List <String> audioFiles = new List <string>();

            try
            {
                using (var sr = new StreamReader(path))
                {
                    var reader = new CsvReader(sr);

                    while (true)
                    {
                        reader.Configuration.HasHeaderRecord = false;
                        var row = reader.Read();
                        if (reader.CurrentRecord == null)
                        {
                            break;
                        }
                        audioFiles.Add(reader.CurrentRecord[0]);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                throw;
            }

            int songIndex = 0;

            foreach (var pathAudio in audioFiles)
            {
                ExperimentData expdata     = new ExperimentData();
                string []      fileEntries = Directory.GetFiles(pathAudio, "*.wav");

                foreach (string fileName in fileEntries)
                {
                    _experimentData.Songs[songIndex].Add(fileName);
                }

                songIndex++;
            }


            //Randomise Everyting for the experiment
            var rnd = new Random();

            _experimentData.Song1Mixes = _experimentData.Song1Mixes.OrderBy(x => rnd.Next()).ToList();
            rnd = new Random();
            _experimentData.Song2Mixes = _experimentData.Song2Mixes.OrderBy(x => rnd.Next()).ToList();
            rnd = new Random();
            _experimentData.Song3Mixes = _experimentData.Song3Mixes.OrderBy(x => rnd.Next()).ToList();
            rnd = new Random();
            _experimentData.Song4Mixes = _experimentData.Song4Mixes.OrderBy(x => rnd.Next()).ToList();
            rnd = new Random();
            _experimentData.Song5Mixes = _experimentData.Song5Mixes.OrderBy(x => rnd.Next()).ToList();

            rnd = new Random();
            _experimentData.Songs = _experimentData.Songs.OrderBy(x => rnd.Next()).ToList();

            int songNum = _testNumber + 1;

            this.Text = "Experiment - Song " + songNum.ToString();

            AssignSliders();

            _stopWatchListenToSong.Reset();
            _stopWatchListenToSong.Start();
        }