Beispiel #1
0
 public void AddFilesToWrite(List<Song> filesToWrite)
 {
     _writeList.AddRange(filesToWrite);
     if (_firstWrite)
     {
         _exampleSong = _writeList.First();
         _exampleSegmentStat = _exampleSong.SegmentStats;
         _exampleAggregate = _exampleSegmentStat.LoudnessMax;
     }
 }
Beispiel #2
0
 public static SegmentStats AggregateSegments(IEnumerable<Segment> segments)
 {
     var enumerable = segments as Segment[] ?? segments.ToArray();
     var confidenceMean = enumerable.Average(s => s.Confidence);
     var loudnessStart = Aggregate(enumerable.Select(s => s.LoudnessStart));
     var loudnessmax = Aggregate(enumerable.Select(s => s.LoudnessMax));
     var loudnessMaxTime = Aggregate(enumerable.Select(s => s.LoudnessMaxTime));
     var duration = Aggregate(enumerable.Select(s => s.Duration));
     var pitch = Aggregate(enumerable.Select(s => s.Pitches));
     var timbre = Aggregate(enumerable.Select(s => s.Timbre));
     var result = new SegmentStats(confidenceMean, loudnessStart, loudnessMaxTime, loudnessmax, duration, pitch,
         timbre);
     return result;
 }
Beispiel #3
0
        Song ParseRow(string row_data)
        {
            var song_builder = new SongBuilder();
            string[] fields = row_data.Split('\t');

            //0 -> id; ignore
            int ptr = 1;
            //Segment stats
            //1-8 -> LoudnessStart
            var loudness_start = ReadAggregate(fields, ref ptr);
            //9-16 -> LoudnessMax
            var loudness_max = ReadAggregate(fields, ref ptr);
            //17-24 -> LoudnessMaxTime
            var loudness_max_time = ReadAggregate(fields, ref ptr);
            //25-32 -> Duration
            var seg_duration = ReadAggregate(fields, ref ptr);
            //Segment stats: Pitches
            var pitches = ReadAggregates(fields, ref ptr, 12);
            //Segment stats: Timbre
            var timbre = ReadAggregates(fields, ref ptr, 12);
            var segment_stats = new SegmentStats(0d, loudness_start, loudness_max_time, loudness_max, seg_duration, pitches, timbre);
            //Sections stats
            //?? -> Count
            var sec_count = ReadIntField(fields, ref ptr);
            //??+7 -> Duration
            var sec_duration = ReadAggregate(fields, ref ptr);
            var sections_stats = new SectionStats(0d, sec_duration, sec_count);

            //Single attrs
            //?? -> ArtistLatitude
            var artist_latitude = ReadDoubleField(fields, ref ptr);
            //?? -> ArtistLongitude
            var artist_longitude = ReadDoubleField(fields, ref ptr);
            //?? -> Danceability
            var danceability = ReadDoubleField(fields, ref ptr);
            //?? -> Duration
            var duration = ReadDoubleField(fields, ref ptr);
            //?? -> Energy
            var energy = ReadDoubleField(fields, ref ptr);
            //?? -> Tempo
            var tempo = ReadDoubleField(fields, ref ptr);
            //?? -> ArtistName
            var artist_name = ReadField(fields, ref ptr);
            //?? -> Genre
            var genre = ReadField(fields, ref ptr);
            //?? -> TrackName
            var track_name = ReadField(fields, ref ptr);

            return new Song(artist_name, track_name, segment_stats, sections_stats, 0d, 0d, artist_longitude, artist_latitude, danceability, duration, energy, tempo, Key.AflatMaj, new TimeSignature(), genre);
        }
Beispiel #4
0
 public Song(string artistName, string trackName, SegmentStats segmentStats, SectionStats sectionsStats, 
     double familiarity, double hotttnesss, double artistLongtitude, double artistLatitude,
     double danceability, double duration, double energy, double tempo, Key key, TimeSignature timeSignature, String genre = null)
 {
     ArtistName = artistName;
     TrackName = trackName;
     SegmentStats = segmentStats;
     SectionsStats = sectionsStats;
     Familiarity = familiarity;
     Hotttnesss = hotttnesss;
     ArtistLongtitude = artistLongtitude;
     ArtistLatitude = artistLatitude;
     Danceability = danceability;
     Duration = duration;
     Energy = energy;
     Tempo = tempo;
     Key = key;
     TimeSignature = timeSignature;
     Genre = genre;
 }
Beispiel #5
0
        private void WriteSegmentStats(SegmentStats example)
        {
            // TODO fix Hardcoded aggregate count
            const int aggregateCount = 4;
            for (int i = 0; i < aggregateCount; i++)
            {
                WriteAggregate(_columnPrefix++);
            }

            WriteAggregateArray(_columnPrefix++, example.Pitches.Length);
            WriteAggregateArray(_columnPrefix++, example.Timbre.Length);
        }