In [1]:
from essentia import standard
In [11]:
from IPython.lib.display import Audio
In [6]:
import numpy
from matplotlib import *
%matplotlib inline
In [3]:
Maker = standard.AudioOnsetsMarker()
In [54]:
pas = 44100
In [67]:
l = [sin(i*2*3.14/pas) for i in range(pas)]
l_h = [sin(i*2*3.14/pas) + 0.8*sin(i*4*3.14/pas) + 0.6*sin(i*8*3.14/pas) for i in range(pas)]
In [68]:
subplot(2,1,1)
plot(l)
subplot(2,1,2)
plot(l_h)
Out[68]:
In [65]:
n = numpy.array(l, dtype=float32)
s = Maker(n)
In [66]:
Audio(s, rate = pas)
Out[66]:
In [70]:
def append(s1,s2):
r = []
for i in s1:
r.append(i)
for j in s2:
r.append(j)
return numpy.array(r, dtype=float32)
In [71]:
l_l_h = append(l, l_h)
In [72]:
plot(l_l_h)
Out[72]:
In [73]:
a = Maker(l_l_h)
In [74]:
Audio(a, rate = pas)
Out[74]:
LA 55 110 220 440 880 1760 3520 7040
In [75]:
LA = [55, 110, 220, 440, 880, 1760, 3520, 7040]
In [81]:
l_LA = [sin(i*2*j*3.14/pas) for j in LA for i in range(pas) ]
In [82]:
a = Maker(l_LA)
In [83]:
Audio(a, rate = pas)
Out[83]:
In [84]:
plot(l_LA)
Out[84]:
In [85]:
hist(l_LA)
Out[85]:
In [87]:
black = { 'do': [32.7,65.41,130.81,261.63,523.25,1046.5,2093,4186.01],
're': [36.71,73.42,146.83,293.66,587.33,1174.66,2349.32,4698.64],
'mi': [41.2,82.41,164.81,329.63,659.26,1318.51,2637.02,5274.04],
'fa': [43.65,87.31,174.61,349.23,698.46,1396.91,2793.83,5587.65],
'sol': [49,98,196,392,783.99,1567.98,3135.96,6271.93],
'la': [55, 110, 220, 440, 880, 1760, 3520, 7040],
'si': [61.74,123.47,246.94,493.88,987.77,1975.53,3951.07,7902.13],
}
In [137]:
Partition = ['do', 're', 'mi']
Hauteur = [0,0,0]
Duree = [1,1,2]
def Sequence(Partition, Hauteur, Duree):
P = []
Sequence_C = []
for i in xrange(len(Partition)):
for j in range(Duree[i]):
P.append(Partition[i])
Sequence_C.append([sin(numpy.pi*2*j*black[Partition[i]][Hauteur[i]]/pas) for i in xrange(len(Partition)) for j in xrange(pas)])
S = Sequence_C[0]
for i in (xrange(len(Sequence_C)-1)):
S = append(S, Sequence_C[i+1])
return S
In [138]:
S_phd = Sequence(Partition, Hauteur, Duree)
In [139]:
a = Maker(S_phd)
In [136]:
Audio(a, rate = pas)
Out[136]:
In [140]:
plot(S_phd)
Out[140]:
In [126]:
Pi
In [151]:
plot(sin([2*numpy.pi*i*100 for i in range(10000)]))
Out[151]:
In [147]:
100:1
In [ ]: