In [1]:
import numpy as np
import random
import matplotlib.pyplot as plt
%matplotlib inline
from music_transcription.onset_detection.cnn_onset_detection import CnnOnsetDetector
from music_transcription.read_data import get_wav_and_truth_files
from music_transcription.tempo_detection.aubio_tempo_detection import AubioTempoDetector
from music_transcription.tempo_detection.simple_tempo_detection import SimpleTempoDetector


Using Theano backend.

In [2]:
# CONFIG
DATA_DIR = r'..\data'

onset_detector = CnnOnsetDetector.from_zip(
    '../models/onset_detection/20170627-3-channels_ds1-4_80-perc_adjusted-labels_with_config_thresh-0.05.zip')

aubio_tempo_detector = AubioTempoDetector()
simple_tempo_detector = SimpleTempoDetector()

In [3]:
active_datasets = {4}
wav_file_paths, truth_dataset_format_tuples = get_wav_and_truth_files(active_datasets)


D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Career SG\fast\country_folk\audio\country_1_150BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Career SG\fast\metal\audio\metal_3_135BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Career SG\fast\rock_blues\audio\rock_1_120BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Career SG\fast\rock_blues\audio\rock_2_115BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\classical\audio\classical_8_100BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\jazz\audio\jazz_1_160BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\jazz\audio\jazz_2_170BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\jazz\audio\jazz_3_120BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\jazz\audio\jazz_4_70BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\jazz\audio\jazz_5_80BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\jazz\audio\jazz_6_150BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\jazz\audio\jazz_7_140BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\jazz\audio\jazz_8_110BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\reggae_ska\audio\reggae_2_100BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')
D:\documents\FHNW\IP-6bb Verarbeitung von Instrumentaufnahmen\music-transcription\music_transcription\read_data.py:158: UserWarning: Skipping ..\data\IDMT-SMT-GUITAR_V2\dataset4\Ibanez 2820\slow\rock_blues\audio\rock_5_100BPM.wav, no truth csv found.
  warn('Skipping ' + path_to_wav + ', no truth csv found.')

In [4]:
triples = []
for wav_path in wav_file_paths:
    filename = wav_path.split('\\').pop().split('BPM.')[0]
    bpmstr = filename.split('_').pop()
    bpm_truth = int(bpmstr)

    onset_times_seconds = onset_detector.predict_onsets(wav_path)

    bpm_aubio = aubio_tempo_detector.predict(wav_path, onset_times_seconds)
    bpm_onset_times = simple_tempo_detector.predict(wav_path, onset_times_seconds)
    triples.append((bpm_truth, bpm_aubio, bpm_onset_times))

triples.sort()
bpm_gt = []
bpm_a = []
bpm_o = []
for gt, a, o in triples:
    bpm_gt.append(gt)
    bpm_a.append(a)
    bpm_o.append(o)

In [5]:
print(bpm_gt)
print('')
print(bpm_a)
print('')
print(bpm_o)
print('')
gt = np.array(bpm_gt)
diff_a = np.array(bpm_a) - gt
diff_o = np.array(bpm_o) - gt
print(diff_a)
print('')
print(diff_o)
print('')
fact_a = np.array(bpm_a) / gt
fact_o = np.array(bpm_o) / gt
print(fact_a)
print('')
print(fact_o)
print('')


[50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 75, 75, 75, 75, 75, 75, 78, 78, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 85, 85, 88, 88, 90, 90, 90, 90, 95, 95, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 115, 115, 115, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 125, 125, 125, 125, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 135, 140, 140, 140, 140, 140, 140, 140, 140, 140, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 170, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 200, 200, 200]

[102.0, 102.0, 103.0, 105.0, 153.0, 153.0, 119.0, 121.0, 121.0, 122.0, 122.0, 123.0, 123.0, 123.0, 123.0, 123.0, 123.0, 184.0, 71.0, 142.0, 142.0, 143.0, 143.0, 78.0, 101.0, 148.0, 153.0, 154.0, 154.0, 104.0, 106.0, 82.0, 82.0, 83.0, 85.0, 96.0, 108.0, 109.0, 133.0, 163.0, 163.0, 164.0, 117.0, 117.0, 89.0, 89.0, 92.0, 112.0, 122.0, 186.0, 96.0, 96.0, 100.0, 100.0, 100.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 102.0, 102.0, 102.0, 102.0, 102.0, 102.0, 102.0, 102.0, 102.0, 102.0, 102.0, 103.0, 103.0, 103.0, 104.0, 108.0, 110.0, 110.0, 120.0, 135.0, 135.0, 135.0, 136.0, 148.0, 150.0, 153.0, 84.0, 106.0, 111.0, 111.0, 111.0, 111.0, 111.0, 112.0, 112.0, 112.0, 112.0, 112.0, 113.0, 117.0, 117.0, 117.0, 91.0, 91.0, 94.0, 118.0, 120.0, 120.0, 121.0, 121.0, 121.0, 121.0, 121.0, 121.0, 121.0, 121.0, 121.0, 122.0, 122.0, 122.0, 122.0, 122.0, 122.0, 122.0, 122.0, 122.0, 122.0, 122.0, 122.0, 123.0, 123.0, 123.0, 123.0, 123.0, 184.0, 126.0, 126.0, 126.0, 127.0, 100.0, 132.0, 132.0, 132.0, 132.0, 132.0, 132.0, 132.0, 132.0, 132.0, 132.0, 132.0, 132.0, 133.0, 137.0, 104.0, 106.0, 111.0, 142.0, 142.0, 143.0, 143.0, 143.0, 144.0, 115.0, 116.0, 152.0, 152.0, 152.0, 152.0, 152.0, 152.0, 152.0, 152.0, 152.0, 152.0, 152.0, 153.0, 153.0, 153.0, 153.0, 153.0, 153.0, 154.0, 80.0, 83.0, 109.0, 109.0, 122.0, 123.0, 162.0, 162.0, 162.0, 164.0, 165.0, 130.0, 91.0, 91.0, 91.0, 91.0, 91.0, 91.0, 91.0, 92.0, 93.0, 95.0, 110.0, 111.0, 118.0, 121.0, 121.0, 122.0, 137.0, 144.0, 148.0, 182.0, 183.0, 183.0, 184.0, 184.0, 184.0, 185.0, 133.0, 153.0, 154.0]

[98.0, 200.0, 200.0, 98.0, 150.0, 150.0, 182.0, 118.0, 122.0, 118.0, 231.0, 118.0, 120.0, 120.0, 222.0, 240.0, 240.0, 176.0, 70.0, 133.0, 135.0, 273.0, 273.0, 300.0, 300.0, 77.0, 78.0, 286.0, 300.0, 107.0, 107.0, 167.0, 316.0, 162.0, 316.0, 162.0, 162.0, 316.0, 300.0, 158.0, 162.0, 162.0, 113.0, 120.0, 88.0, 88.0, 187.0, 122.0, 122.0, 182.0, 48.0, 48.0, 101.0, 102.0, 333.0, 98.0, 98.0, 100.0, 100.0, 103.0, 107.0, 171.0, 176.0, 176.0, 188.0, 194.0, 194.0, 194.0, 200.0, 261.0, 261.0, 333.0, 98.0, 100.0, 158.0, 162.0, 171.0, 182.0, 207.0, 214.0, 325.0, 375.0, 400.0, 103.0, 200.0, 375.0, 98.0, 100.0, 98.0, 400.0, 122.0, 136.0, 400.0, 400.0, 136.0, 78.0, 100.0, 77.0, 107.0, 214.0, 207.0, 214.0, 214.0, 222.0, 222.0, 194.0, 200.0, 207.0, 207.0, 218.0, 200.0, 113.0, 115.0, 222.0, 86.0, 118.0, 115.0, 94.0, 118.0, 118.0, 61.0, 61.0, 97.0, 120.0, 120.0, 122.0, 132.0, 231.0, 333.0, 118.0, 120.0, 120.0, 120.0, 120.0, 143.0, 207.0, 207.0, 218.0, 222.0, 231.0, 316.0, 118.0, 187.0, 187.0, 214.0, 222.0, 122.0, 231.0, 240.0, 375.0, 429.0, 92.0, 91.0, 136.0, 136.0, 140.0, 187.0, 240.0, 250.0, 250.0, 250.0, 250.0, 462.0, 500.0, 187.0, 273.0, 95.0, 90.0, 143.0, 143.0, 250.0, 150.0, 162.0, 250.0, 143.0, 111.0, 111.0, 154.0, 154.0, 154.0, 273.0, 273.0, 300.0, 300.0, 300.0, 300.0, 545.0, 573.0, 143.0, 158.0, 250.0, 273.0, 300.0, 300.0, 261.0, 316.0, 316.0, 113.0, 162.0, 103.0, 113.0, 167.0, 171.0, 176.0, 300.0, 300.0, 113.0, 187.0, 187.0, 261.0, 353.0, 353.0, 545.0, 600.0, 353.0, 167.0, 118.0, 194.0, 187.0, 667.0, 125.0, 353.0, 122.0, 115.0, 185.0, 187.0, 353.0, 182.0, 187.0, 353.0, 353.0, 353.0, 750.0, 207.0, 128.0, 133.0]

[  52.   52.   53.   55.  103.  103.   59.   61.   61.   62.   62.   63.
   63.   63.   63.   63.   63.  124.    1.   72.   72.   73.   73.    3.
   26.   73.   78.   79.   79.   26.   28.    2.    2.    3.    5.   16.
   28.   29.   53.   83.   83.   84.   32.   32.    1.    1.    2.   22.
   32.   96.    1.    1.    0.    0.    0.    1.    1.    1.    1.    1.
    1.    1.    1.    1.    1.    1.    1.    1.    1.    1.    1.    1.
    2.    2.    2.    2.    2.    2.    2.    2.    2.    2.    2.    3.
    3.    3.    4.    8.   10.   10.   20.   35.   35.   35.   36.   48.
   50.   53.  -26.   -4.    1.    1.    1.    1.    1.    2.    2.    2.
    2.    2.    3.    2.    2.    2.  -29.  -29.  -26.   -2.    0.    0.
    1.    1.    1.    1.    1.    1.    1.    1.    1.    2.    2.    2.
    2.    2.    2.    2.    2.    2.    2.    2.    2.    3.    3.    3.
    3.    3.   64.    1.    1.    1.    2.  -30.    2.    2.    2.    2.
    2.    2.    2.    2.    2.    2.    2.    2.    3.    2.  -36.  -34.
  -29.    2.    2.    3.    3.    3.    4.  -35.  -34.    2.    2.    2.
    2.    2.    2.    2.    2.    2.    2.    2.    3.    3.    3.    3.
    3.    3.    4.  -80.  -77.  -51.  -51.  -38.  -37.    2.    2.    2.
    4.    5.  -40.  -89.  -89.  -89.  -89.  -89.  -89.  -89.  -88.  -87.
  -85.  -70.  -69.  -62.  -59.  -59.  -58.  -43.  -36.  -32.    2.    3.
    3.    4.    4.    4.    5.  -67.  -47.  -46.]

[  48.  150.  150.   48.  100.  100.  122.   58.   62.   58.  171.   58.
   60.   60.  162.  180.  180.  116.    0.   63.   65.  203.  203.  225.
  225.    2.    3.  211.  225.   29.   29.   87.  236.   82.  236.   82.
   82.  236.  220.   78.   82.   82.   28.   35.    0.    0.   97.   32.
   32.   92.  -47.  -47.    1.    2.  233.   -2.   -2.    0.    0.    3.
    7.   71.   76.   76.   88.   94.   94.   94.  100.  161.  161.  233.
   -2.    0.   58.   62.   71.   82.  107.  114.  225.  275.  300.    3.
  100.  275.   -2.    0.   -2.  300.   22.   36.  300.  300.   36.  -22.
    0.  -23.   -3.  104.   97.  104.  104.  112.  112.   84.   90.   97.
   97.  108.   90.   -2.    0.  107.  -34.   -2.   -5.  -26.   -2.   -2.
  -59.  -59.  -23.    0.    0.    2.   12.  111.  213.   -2.    0.    0.
    0.    0.   23.   87.   87.   98.  102.  111.  196.   -2.   67.   67.
   94.  102.    2.  106.  115.  250.  304.  -38.  -39.    6.    6.   10.
   57.  110.  120.  120.  120.  120.  332.  370.   57.  138.  -45.  -50.
    3.    3.  110.   10.   22.  110.    3.  -39.  -39.    4.    4.    4.
  123.  123.  150.  150.  150.  150.  395.  423.   -7.    8.  100.  123.
  150.  150.  111.  156.  156.  -47.    2.  -57.  -47.    7.   11.   16.
  140.  140.  -57.    7.    7.   81.  173.  173.  365.  420.  173.  -13.
  -62.   14.    7.  487.  -55.  173.  -58.  -65.    5.    7.  173.    2.
    7.  173.  173.  173.  570.    7.  -72.  -67.]

[ 2.04        2.04        2.06        2.1         3.06        3.06
  1.98333333  2.01666667  2.01666667  2.03333333  2.03333333  2.05        2.05
  2.05        2.05        2.05        2.05        3.06666667  1.01428571
  2.02857143  2.02857143  2.04285714  2.04285714  1.04        1.34666667
  1.97333333  2.04        2.05333333  2.05333333  1.33333333  1.35897436
  1.025       1.025       1.0375      1.0625      1.2         1.35        1.3625
  1.6625      2.0375      2.0375      2.05        1.37647059  1.37647059
  1.01136364  1.01136364  1.02222222  1.24444444  1.35555556  2.06666667
  1.01052632  1.01052632  1.          1.          1.          1.01        1.01
  1.01        1.01        1.01        1.01        1.01        1.01        1.01
  1.01        1.01        1.01        1.01        1.01        1.01        1.01
  1.01        1.02        1.02        1.02        1.02        1.02        1.02
  1.02        1.02        1.02        1.02        1.02        1.03        1.03
  1.03        1.04        1.08        1.1         1.1         1.2         1.35
  1.35        1.35        1.36        1.48        1.5         1.53
  0.76363636  0.96363636  1.00909091  1.00909091  1.00909091  1.00909091
  1.00909091  1.01818182  1.01818182  1.01818182  1.01818182  1.01818182
  1.02727273  1.0173913   1.0173913   1.0173913   0.75833333  0.75833333
  0.78333333  0.98333333  1.          1.          1.00833333  1.00833333
  1.00833333  1.00833333  1.00833333  1.00833333  1.00833333  1.00833333
  1.00833333  1.01666667  1.01666667  1.01666667  1.01666667  1.01666667
  1.01666667  1.01666667  1.01666667  1.01666667  1.01666667  1.01666667
  1.01666667  1.025       1.025       1.025       1.025       1.025
  1.53333333  1.008       1.008       1.008       1.016       0.76923077
  1.01538462  1.01538462  1.01538462  1.01538462  1.01538462  1.01538462
  1.01538462  1.01538462  1.01538462  1.01538462  1.01538462  1.01538462
  1.02307692  1.01481481  0.74285714  0.75714286  0.79285714  1.01428571
  1.01428571  1.02142857  1.02142857  1.02142857  1.02857143  0.76666667
  0.77333333  1.01333333  1.01333333  1.01333333  1.01333333  1.01333333
  1.01333333  1.01333333  1.01333333  1.01333333  1.01333333  1.01333333
  1.02        1.02        1.02        1.02        1.02        1.02
  1.02666667  0.5         0.51875     0.68125     0.68125     0.7625
  0.76875     1.0125      1.0125      1.0125      1.025       1.03125
  0.76470588  0.50555556  0.50555556  0.50555556  0.50555556  0.50555556
  0.50555556  0.50555556  0.51111111  0.51666667  0.52777778  0.61111111
  0.61666667  0.65555556  0.67222222  0.67222222  0.67777778  0.76111111
  0.8         0.82222222  1.01111111  1.01666667  1.01666667  1.02222222
  1.02222222  1.02222222  1.02777778  0.665       0.765       0.77      ]

[ 1.96        4.          4.          1.96        3.          3.
  3.03333333  1.96666667  2.03333333  1.96666667  3.85        1.96666667
  2.          2.          3.7         4.          4.          2.93333333
  1.          1.9         1.92857143  3.9         3.9         4.          4.
  1.02666667  1.04        3.81333333  4.          1.37179487  1.37179487
  2.0875      3.95        2.025       3.95        2.025       2.025       3.95
  3.75        1.975       2.025       2.025       1.32941176  1.41176471
  1.          1.          2.07777778  1.35555556  1.35555556  2.02222222
  0.50526316  0.50526316  1.01        1.02        3.33        0.98        0.98
  1.          1.          1.03        1.07        1.71        1.76        1.76
  1.88        1.94        1.94        1.94        2.          2.61        2.61
  3.33        0.98        1.          1.58        1.62        1.71        1.82
  2.07        2.14        3.25        3.75        4.          1.03        2.
  3.75        0.98        1.          0.98        4.          1.22        1.36
  4.          4.          1.36        0.78        1.          0.77
  0.97272727  1.94545455  1.88181818  1.94545455  1.94545455  2.01818182
  2.01818182  1.76363636  1.81818182  1.88181818  1.88181818  1.98181818
  1.81818182  0.9826087   1.          1.93043478  0.71666667  0.98333333
  0.95833333  0.78333333  0.98333333  0.98333333  0.50833333  0.50833333
  0.80833333  1.          1.          1.01666667  1.1         1.925       2.775
  0.98333333  1.          1.          1.          1.          1.19166667
  1.725       1.725       1.81666667  1.85        1.925       2.63333333
  0.98333333  1.55833333  1.55833333  1.78333333  1.85        1.01666667
  1.848       1.92        3.          3.432       0.70769231  0.7
  1.04615385  1.04615385  1.07692308  1.43846154  1.84615385  1.92307692
  1.92307692  1.92307692  1.92307692  3.55384615  3.84615385  1.43846154
  2.02222222  0.67857143  0.64285714  1.02142857  1.02142857  1.78571429
  1.07142857  1.15714286  1.78571429  1.02142857  0.74        0.74
  1.02666667  1.02666667  1.02666667  1.82        1.82        2.          2.
  2.          2.          3.63333333  3.82        0.95333333  1.05333333
  1.66666667  1.82        2.          2.          1.74        1.975       1.975
  0.70625     1.0125      0.64375     0.70625     1.04375     1.06875     1.1
  1.875       1.875       0.66470588  1.03888889  1.03888889  1.45
  1.96111111  1.96111111  3.02777778  3.33333333  1.96111111  0.92777778
  0.65555556  1.07777778  1.03888889  3.70555556  0.69444444  1.96111111
  0.67777778  0.63888889  1.02777778  1.03888889  1.96111111  1.01111111
  1.03888889  1.96111111  1.96111111  1.96111111  4.16666667  1.035       0.64
  0.665     ]


In [6]:
x_ax = range(len(bpm_gt))
plt.plot(x_ax, bpm_gt, '-g', x_ax, bpm_a, '-r', x_ax, bpm_o, '-b')
plt.show()



In [7]:
diff_a.sort()
diff_o.sort()

plt.figure()
plt.scatter(x_ax, diff_a, c='red', alpha=0.5)
plt.scatter(range(1000, 1000+len(bpm_gt)), diff_o, c='blue', alpha=0.5)
plt.show()



In [8]:
fact_a.sort()
fact_o.sort()

plt.figure()
plt.scatter(x_ax, fact_a, c='red', alpha=0.5)
plt.scatter(range(1000, 1000+len(bpm_gt)), fact_o, c='blue', alpha=0.5)
plt.show()



In [15]:
random.shuffle(diff_a)

In [16]:
plt.figure()
plt.scatter(x_ax, diff_a, c='black', alpha=0.25)
plt.axis([-10, 250, -100, 150])
plt.show()



In [18]:
random.shuffle(fact_a)

In [76]:
from math import log2
print(log2(1), log2(2), log2(4), log2(8))
log2(3)%1


0.0 1.0 2.0 3.0
Out[76]:
0.5849625007211561

In [77]:
clrs = []
for x in fact_a:
    r2x = round(2*x)
    f = 2*x / r2x
    
    no_multiple = (r2x > 1 and r2x%2 == 1) or log2(r2x)%1 != 0
    clrs.append('r' if f <= 0.95 or f >= 1.05 or no_multiple else 'g' if round(2*x) == 2 else 'y')
print(clrs.count('g'), clrs.count('y'),  clrs.count('r'))


143 37 56

In [86]:
plt.figure(figsize=(10,5))
plt.plot([-3, 239], [2.1, 2.1], '--k', alpha=0.5)
plt.plot([-3, 239], [1.9, 1.9], '--k', alpha=0.5)
plt.plot([-3, 239], [1.05, 1.05], '--k', alpha=0.5)
plt.plot([-3, 239], [0.95, 0.95], '--k', alpha=0.5)
plt.plot([-3, 239], [0.525, 0.525], '--k', alpha=0.5)
plt.plot([-3, 239], [0.475, 0.475], '--k', alpha=0.5)
plt.scatter(x_ax, fact_a, c=clrs, alpha=0.33)
plt.axis([-5, 241, 0.2, 3.3])
plt.show()



In [ ]: