python - 如何将音频文件的主要频率投射到乐器的声音上
问题描述
我是音频处理的新手,我希望提取音频文件的主要频率,并使用 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:我会很感激有关正确探索声音谐波分量的材料的建议。那里的大多数材料都深入研究了节奏特征,但在谐波方面没有太多实用的东西。我浏览了这个音乐信息检索网站,但没有找到太多帮助。我目前正在阅读“音乐处理基础”,但它有点过于技术化。谢谢!
解决方案
推荐阅读
- python - 如何在 matplotlib 中获得更轻的“喷射”颜色图
- wix - 降级会删除新版本的可执行文件,但不会重新安装旧版本
- c# - 如何使用 Azure Functions 提取 PDF 文件的文本?
- python - Python pandas 确保基于列值的每一行都有一组数据存在,如果没有添加行
- python - 仅在形状 geopandas 内获取值
- python - 将列表与字符串进行比较并在字符串中打印列表的匹配行
- javascript - JS中的东西可以同时作为对象和函数吗?
- python - 在 python 中读取 .fasta 文件时出现错误
- c++ - 在 Paraview 属性面板上修改默认属性 (5.7.0)
- android - 两个不同的 AsyncTask 方法正在等待对方