plotter.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:tomato 作者: sertansenturk 项目源码 文件源码
def _get_relative_note_occurences(note_models, pitch_distribution):
        max_rel_occur = 0
        for note_symbol, note in iteritems(note_models):
            try:
                # get the relative occurrence of each note from the pitch
                # distribution
                dists = np.array([abs(note['stable_pitch']['value'] - dist_bin)
                                  for dist_bin in pitch_distribution.bins])
            except TypeError:
                logging.info(u'The stable pitch for {0:s} is not computed'
                             .format(note_symbol))
                # use the max peak even if it's weak, far from theoretical etc.
                peak_idx, heights = note['distribution'].detect_peaks()
                max_peak_ind = peak_idx[np.argmax(heights)]
                max_bin = note['distribution'].bins[max_peak_ind]
                dists = np.array([abs(max_bin - dist_bin)
                                  for dist_bin in pitch_distribution.bins])

            peak_ind = np.argmin(dists)
            note['rel_occur'] = pitch_distribution.vals[peak_ind]
            max_rel_occur = max([max_rel_occur, note['rel_occur']])

        return max_rel_occur
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号