改变android中声音文件的频率
我尝试更改单个声音文件的频率。我设法在 Android 中使用 SoundPool 来做到这一点。但结果听起来确实很糟糕。 所以我开始进行傅里叶变换 - 但我不确定这是否是我正在寻找的。
我想加载一个文件并在每次播放该文件时更改该文件的频率。所以我可以用一种音调创作旋律。 android/java 可以吗?
这就是我设法做到的方式。我所说的“坏”是指听起来不合时宜。
如果我想播放文件中音符的下一个频率,我必须将其乘以 2^(1/12)。但由于它只是一个浮点数,我想它不够精确,无法获得下一个音符的“真实”频率。
有没有一种“简单”的方法来实现这个目标?
I try to change the frequency of a single soundfile. I managed to do that in android with the SoundPool thing. But the result sounds really bad.
So I stepped about the Fourier Transformation - but I am not sure if this is what I am looking for.
I want to load a single file and change the frequency of that file every time that file is played. So I can create melodies out of one tone. Is that possible with android/java?
This is the way I managed to do it. With "bad" I mean it sounds out of tune.
If I want to play the next frequency of the note in the file I must multiply it by 2^(1/12). But since it's just a float, I guess it's not precise enough to get the "real" frequency of the next note.
Is there a "simple" way to achieve that goal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 SoundPool 最简单的方法是调整调用 play() 时的速率:
速率可以从 0.5f 到 2.0f 变化,尽管极端情况通常听起来不太好,所以您可能需要设置一个可接受的范围 (例如,0.4f)和最小速率(例如,0.85f)。然后您可以使用一个变量来控制您在该范围内的位置(例如,范围在 .0f 和 1.0f 之间的浮点数):
The simplest way with the SoundPool is to adjust the rate on your call to play():
The rate can vary from .5f to 2.0f, though the extremes typically don't sound great, so you may want to set an acceptable range (e.g., .4f) and a minimum rate (e.g., .85f). Then you can have a variable to control where you are within that range (e.g., a float that ranges between .0f and 1.0f):