我是音频处理新手,我希望提取音频文件的主频,并使用python和librosa将其投影到乐器的声音中。有使用频率生成正弦音调的例子,但我想使用特定的声音,如钢琴或吉他
这是我到目前为止所拥有的。请随意更正,因为我对这一切都是新手,只是随机应变而已
import librosa as lr
import librosa.display as lrd
import numpy as np
#load music with Librosa
y, sr = lr.load('my_beautiful_song.wav', duration=30)
#seperate percussive and harmonic
y_harm, y_perc = lr.effects.hpss(y)
#calculate the cqt
cqt = lr.cqt(y_harm, sr)
#get the top 3 dominant frequencies per frame(?)
empties = np.zeros(cqt.shape)
for i in range(cqt.shape[1]):
#get the top 5 dominant notes
most_dominant_notes = (-cqt[:,i]).argsort()[:3]
empties[:,i][most_dominant_notes] = cqt[:,i][most_dominant_notes]
#display
empties_log = lr.amplitude_to_db(np.abs(empties), ref=np.max)
lrd.specshow(empties_log, x_axis='time', y_axis='cqt_note', cmap='coolwarm')
这个specshow
向我展示了我想要的东西,但我不知道如何从这里开始在乐器中播放这些频率的声音
PS:我很欣赏能正确探索声音谐波成分的材料的建议。大多数材料深入研究了节奏特征,但没有太多关于和声的实用材料。我浏览了这个{a1}网站,没有找到多少帮助。我现在正在读Fundamentals of Music Processing,但它有点太技术化了。谢谢
目前没有回答
相关问题 更多 >
编程相关推荐