Пример #1
0
 public void AddFilesToWrite(List<Song> filesToWrite)
 {
     _writeList.AddRange(filesToWrite);
     if (_firstWrite)
     {
         _exampleSong = _writeList.First();
         _exampleSegmentStat = _exampleSong.SegmentStats;
         _exampleAggregate = _exampleSegmentStat.LoudnessMax;
     }
 }
Пример #2
0
        private SongReader(string filename)
        {
            _f = new File(filename);
            _builder = new SongBuilder();

            ReadMetaData();
            ReadAnalysisData();

            SongInfo = _builder.Build();

            _f.Dispose();
        }
Пример #3
0
        public static List<Song> FindKBestMatches(Song[] songs, List<int> dataSet, Song source, int k)
        {
            var pq = new SortedList<double, int>();
            List<Song> returnList = new List<Song>();

            foreach (var dataInt in dataSet)
            {
                double dist = EuclideanDistance.Distance(source, songs[dataInt]);
                pq.Add(dist, dataInt);
            }

            foreach (var demInts in pq.Values.Take(k).ToList())
            {
                returnList.Add(songs[demInts]);
            }

            return returnList;
        }
Пример #4
0
 public static double Distance(Song x, Song y)
 {
     return Distance(x.DistanceArray(), y.DistanceArray());
 }
Пример #5
0
        private String GenerateRowLine(Song song)
        {
            StringBuilder row = new StringBuilder();
            row.Append(_currentID++ + "" + TABCHAR);
            // Write segmentstats
            foreach (var aggregate in song.SegmentStats.AggregatesList)
            {
                AppendAggregateValues(row, aggregate);
            }

            // Write section stats
            row.Append(song.SectionsStats.Count + "" + TABCHAR);
            AppendAggregateValues(row, song.SectionsStats.Duration);

            // Write lone attributes
            var map = song.GetESOMAttributeMap();
            foreach (var key in map.Keys)
            {
                string plusRow = "";
                if (map[key] == null) plusRow += "NaN";
                else plusRow += map[key].ToString();
                row.Append(plusRow + TABCHAR);
            }

            //var map1 = song.GetIgnoredAttributeMap();
            //foreach (var key in map1.Keys)
            //{
            //    string plusRow = "";
            //    if (map1[key] == null) plusRow += "NaN";
            //    else plusRow += map1[key].ToString();
            //    row.Append(plusRow + TABCHAR);
            //}

            return row.ToString();
        }
Пример #6
0
        private String GenerateRowLine(Song song)
        {
            StringBuilder row = new StringBuilder();
            row.Append(_currentID++ + "" + TABCHAR);

            var dick = song.GetIgnoredAttributeMap();

            row.Append("\"");
            row.Append(dick["ArtistName"] + " , " + dick["TrackName"]);
            row.Append("\"" + TABCHAR);
            row.Append(dick["Genre"]);
            row.Append("\"");
            return row.ToString();
        }