voice-moption

Die Visualisierung der Stimmenbewegung kann durch folgenden Script realisiert werden:

import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate
from music21 import corpus

bach = corpus.parse('bwv66.6') #hier das gewünschte Beispiel laden

fig = plt.figure()
subplot = fig.add_subplot(1, 1, 1)

for i in range(len(bach.parts)):
    top = bach.parts[i].flat.notes
    y = [n.pitch.ps for n in top]
    x = [n.offset + n.quarterLength/2.0 for n in top]

    tick = interpolate.splrep(x, y, s=0)
    xnew = np.arange(0, max(x), 0.01)
    ynew = interpolate.splev(xnew, tick, der=0)

    subplot.plot(xnew, ynew)
    subplot.spines['top'].set_color('none')
    subplot.spines['right'].set_color('none')

plt.title('Bach motion')

plt.show()

Quelle

  • voice-moption.txt
  • Zuletzt geändert: 2021/04/12 22:41
  • von egor