コード例 #1
0
def get_tempo_info(file_number):
    # get data
    d = BallroomData()

    # wav name
    wav_name = d.file_name(file_number)
    # ground truth
    aaagt_bpm = d.get_gt_bpm(file_number)
    # load file for librosa
    y, sr = d[file_number]

    onset_env = librosa.onset.onset_strength(y, sr=sr)
    # Static tempo
    aaatempo = librosa.beat.tempo(onset_envelope=onset_env, sr=sr)

    # Dynamic tempo
    dtempo = librosa.beat.tempo(onset_envelope=onset_env, sr=sr, aggregate=None)
    # Dynamic tempo distribution
    zapple = get_tempo_distribu(dtempo)
    aaatempo_list = zapple[0]
    aaatempo_cnt = zapple[1]

    # # --- print info ---
    # print("filename = ", wav_name)
    # print("gt = ", aaagt_bpm)
    # print("static = ", aaatempo[0])
    # print("----- guess ------ ------")
    # dis_lan = len(aaatempo_cnt)
    # for i in range(dis_lan):
    #     print("%18.14f" % aaatempo_list[i], "%6d" % aaatempo_cnt[i])
    #     # print(str(aaatempo_list[i]), str(aaatempo_cnt[i]))
    # print("----- ----- ------ ------\n\n")
    # # --- ----- ---- ---

    return aaagt_bpm, aaatempo, aaatempo_list, aaatempo_cnt
コード例 #2
0
def get_tempo_info(file_number):
    # get data
    d = BallroomData()

    # wav name
    wav_name = d.file_name(file_number)
    # ground truth
    aaagt_bpm = d.get_gt_bpm(file_number)
    # load file for librosa
    y, sr = d[file_number]

    onset_env = librosa.onset.onset_strength(y, sr=sr)
    # Static tempo
    aaatempo = librosa.beat.tempo(onset_envelope=onset_env, sr=sr)

    # Dynamic tempo
    dtempo = librosa.beat.tempo(onset_envelope=onset_env, sr=sr, aggregate=None)
    # Dynamic tempo distribution
    zapple = get_tempo_distribu(dtempo)
    aaatempo_list = zapple[0]
    aaatempo_cnt = zapple[1]

    return aaagt_bpm, aaatempo, aaatempo_list, aaatempo_cnt
コード例 #3
0
    d = BallroomData()

    for target_tempo in range(119, 123, 1):

        t_zapple = [], []
        total = 0
        print("target tempo = ", target_tempo)

        for file_number in range(len(d) - 1):
            # ground truth

            aaagt_bpm = d.get_gt_bpm(file_number)
            if aaagt_bpm == target_tempo:
                # wav name
                wav_name = d.file_name(file_number)
                # ground truth
                aaagt_bpm = d.get_gt_bpm(file_number)
                # load file for librosa
                y, sr = d[file_number]

                onset_env = librosa.onset.onset_strength(y, sr=sr)
                # Static tempo
                aaatempo = librosa.beat.tempo(onset_envelope=onset_env, sr=sr)

                # Dynamic tempo
                dtempo = librosa.beat.tempo(onset_envelope=onset_env,
                                            sr=sr,
                                            aggregate=None)
                # Dynamic tempo distribution
                zapple = get_tempo_distribu(dtempo)