diff scripts/load_features.py @ 6:a35bd818d8e9 branch-tests

notebook to test music segments
author Maria Panteli <m.x.panteli@gmail.com>
date Mon, 11 Sep 2017 14:22:17 +0100
parents e50c63cf96be
children 56cbf155680a 852d4377f6ca
line wrap: on
line diff
--- a/scripts/load_features.py	Mon Sep 11 12:01:28 2017 +0100
+++ b/scripts/load_features.py	Mon Sep 11 14:22:17 2017 +0100
@@ -80,12 +80,12 @@
             duration_in_frames = np.round(np.array(bounds[:, 1], dtype=float) * sr)
             for music_bound in music_bounds:
                 lower_bound = np.max([0, bounds_in_frames[music_bound] - half_win_hop])
-                upper_bound = lower_bound + duration_in_frames[music_bound] - half_win_hop
+                upper_bound = bounds_in_frames[music_bound] + duration_in_frames[music_bound] - half_win_hop
                 music_idx.append(np.arange(lower_bound, upper_bound, dtype=int))
             if len(music_idx)>0:
                 music_idx = np.sort(np.concatenate(music_idx))  # it should be sorted, but just in case segments overlap -- remove duplicates if segments overlap
         return music_idx
-    
+
     
     def get_music_idx_for_file(self, segmenter_file=None):
         music_idx = []
@@ -255,33 +255,3 @@
             pbihist = (pbihist - np.nanmean(pbihist)) / np.nanstd(pbihist)
         return pbihist
         
-        
-#    def get_pb_chroma_for_file(self, chroma_file=None, scale=True):
-#        ch = []
-#        pb = []
-#        if not os.path.exists(chroma_file):
-#            return ch, pb
-#        songframes = pd.read_csv(chroma_file, engine="c", header=None)
-#        songframes.iloc[np.where(np.isnan(songframes))] = 0
-#        songframes = songframes.iloc[0:min(len(songframes), 18000), :]  # only first 1.5 minutes
-#        chroma = songframes.get_values().T
-#        ch = self.get_ave_chroma(chroma)
-#        pb = self.get_pbihist_from_chroma(chroma)
-#        if scale:
-#            # scale all frames by mean and std of recording
-#            ch = (ch - np.nanmean(ch)) / np.nanstd(ch)                        
-#            pb = (pb - np.nanmean(pb)) / np.nanstd(pb)
-#        return ch, pb
-
-
-#    def get_pbihist_from_chroma(self, chroma, alignchroma=True, nmfpb=True):
-#        pb = pbi.PitchBihist(win2sec=self.win2sec)        
-#        chroma[np.where(np.isnan(chroma))] = 0
-#        if alignchroma:
-#            maxind = np.argmax(np.sum(chroma, axis=1))
-#            chroma = np.roll(chroma, -maxind, axis=0)
-#        pbihist = pb.get_pitchbihist_from_chroma(chroma=chroma, chromasr=self.framessr)
-#        if nmfpb is True:
-#            pbihist = self.nmfpitchbihist(pbihist)
-#        pbihist = pd.DataFrame(pbihist.T)
-#        return pbihist
\ No newline at end of file