Example #1
0
__author__ = 'tpellegrini'

from utils import load_y_to_dict

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig, ax = plt.subplots()

nb_points_to_plot = 3
x = np.arange(0, nb_points_to_plot, 1)  # x-array
gtdir = 'train/'
arousal, valence, song_id, nb_of_songs = load_y_to_dict(gtdir)
# print arousal.keys()

song = '1284'
duration = len(arousal[song])
print duration

ar = np.array(arousal[song])
val = np.array(valence[song])

line, = ax.plot(x, ar[x], 'go-', linewidth=5)
line_val, = ax.plot(x, val[x], 'ro-', linewidth=5)
plt.ylim([-1., 1.])


def animate(i):
    #    print i, x+i
    line.set_ydata(ar[x + i])  # update the data
Example #2
0
    num = n * sxy - sx * sy
    sx2 = np.dot(temps, temps.T)
    den = n*sx2 - sx*sx
    slope = num / den
    intercept = (sy - slope * sx) / (1. * n)
    return slope, intercept

annotator = '/home/thomas/software/sonic-annotator-1.1/sonic-annotator'
plugin='vamp:mtg-melodia:melodia:melody'
feature_dir='/baie/corpus/emoMusic/train/vamp_features'
melody_dir = feature_dir + '/melody'
DATADIR = '/baie/corpus/emoMusic/train/'

data = dict()
arousal, valence, song_ids, nb_of_songs = load_y_to_dict(DATADIR)

wts = np.ones(47)*1./48
wts = np.hstack((np.array([1./96]), wts, np.array([1./96])))
delay = (wts.shape[0]-1) / 2

# wts_slopes = np.array([1/4., 1/2., 1/4.])
wts_slopes = np.ones(9) * 1/8.
wts_slopes[4] = 1/4.
delay_slopes = (wts_slopes.shape[0]-1) / 2
# delay_slopes = 0

# song_id=250
for song_id in song_ids:
# for song_id in [3, 4]:
    # file='/home/thomas/software/sonic-annotator-1.1/250_vamp_mtg-melodia_melodia_melody.csv'
Example #3
0
__author__ = "tpellegrini"

from utils import load_y_to_dict

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig, ax = plt.subplots()

nb_points_to_plot = 3
x = np.arange(0, nb_points_to_plot, 1)  # x-array
gtdir = "train/"
arousal, valence, song_id, nb_of_songs = load_y_to_dict(gtdir)
# print arousal.keys()

song = "1284"
duration = len(arousal[song])
print duration

ar = np.array(arousal[song])
val = np.array(valence[song])

line, = ax.plot(x, ar[x], "go-", linewidth=5)
line_val, = ax.plot(x, val[x], "ro-", linewidth=5)
plt.ylim([-1.0, 1.0])


def animate(i):
    #    print i, x+i
    line.set_ydata(ar[x + i])  # update the data