Форум сайта python.su
0
Привет!
Стоит задача определить время первого бита в песне, имеется ввиду beat, а не bit конечно))
По этой задаче я нашел прикрепленный файл.
Там есть код, который по идее должен найти пики, я думал применить фильтр низких частот к песне (примеры так же есть в статье) и применить к результату те методы для поиска пиков, но пока я не могу затавить работать даже тот код из статьи.
import simpl import matplotlib.pyplot as plt from scipy.io.wavfile import read # read audio samples audio = read("/home/user/Documents/first_beat/70.wav")[1] # take just the first few frames audio = audio[0:4096] # Peak detection with SndObj pd = simpl.SndObjPeakDetection() pd.max_peaks = 20 pks = pd.find_peaks(audio) # Partial Tracking with # the McAulay-Quatieri algorithm pt = simpl.MQPartialTracking() pt.max_partials = 20 partls = pt.find_partials(pks) # plot the detected partials simpl.plot.plot_partials(partls) # set title and label axes plt.title("Flute Partials") plt.ylabel("Frequency (Hz)") plt.xlabel("Frame Number") plt.show()
Отредактировано carlos0n (Март 17, 2013 16:13:48)
Прикреплённый файлы:
40.pdf (538,0 KБ)
Офлайн
0
Так же при попытке применить фильтр нижних частот по примеру из статьи
from sndobj import \ SndObj, SndRTIO, SND_OUTPUT import scipy as sp from scipy.signal import firwin from scipy.io.wavfile import read import matplotlib.pyplot as plt input_data = read("/home/user/Documents/first_beat/70.wav") audio = input_data[1] order = 101 cutoff = 0.02 filter = firwin(order, cutoff) audio = sp.convolve(audio,filter,"same") plt.plot(audio[0:1024]) plt.ylabel("Amplitude") plt.xlabel("Time (samples)") plt.title("Flute Sample") plt.show()
Офлайн
173
Попробуйте файл с одним каналом (моно).
Офлайн
0
reclosedev
Попробуйте файл с одним каналом (моно).
Офлайн
0
над было использовать simpl.read_wav
import simpl import matplotlib.pyplot as plt from scipy.io.wavfile import read import scipy as sp from scipy.signal import firwin # read audio samples audio = simpl.read_wav("/home/user/Documents/first_beat/70.wav")[0] # take just the first few frames print audio.size audio = audio[0:(4096*8)] # low pass filter order = 101 cutoff = 0.02 filter = firwin(order, cutoff) audio = sp.convolve(audio,filter,"same") # Peak detection with SndObj pd = simpl.SndObjPeakDetection() pd.max_peaks = 50 pks = pd.find_peaks(audio) # Partial Tracking with # the McAulay-Quatieri algorithm pt = simpl.MQPartialTracking() pt.max_partials = 100 partls = pt.find_partials(pks) # plot the detected partials simpl.plot.plot_partials(partls) # set title and label axes plt.title("Flute Partials") plt.ylabel("Frequency (Hz)") plt.xlabel("Frame Number") plt.show()
Отредактировано carlos0n (Март 18, 2013 13:27:41)
Офлайн