改变Android的一个音效档的频率 [英] changing the frequency of a soundfile in android
问题描述
我试图改变一个音效档的频率。我能够做到这在Android中的的Soundpool的事情。但结果听起来很糟糕。 所以我踩对傅立叶变换 - 但我不知道这是否是我所期待的。
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.
我想加载一个文件,每一个文件播放时更改该文件的频率。所以,我可以创造出的旋律一个音调的。这有可能与Android / java吗?
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.
如果我想打音符的下一个频率在文件中我必须用2 ^(1/12)相乘。但是,由于它只是一个浮动的,我想这不是precise足以让下一个音符的真实的频率。
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?
推荐答案
用的Soundpool最简单的方法是调整利率上你的电话打():
The simplest way with the SoundPool is to adjust the rate on your call to play():
play(aSoundId, leftVolume, rightVolume, 1, 0, rate);
率可能从.5f为2.0f,虽然极端通常听起来不是很大,所以你可能要设置一个可以接受的范围(例如,.4f)和最小速率(例如,.85f)。然后你就可以有一个变量来控制你在哪里该范围内(例如,一个浮动的.0f和1.0F之间的范围):
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):
float rate = RATE_RANGE * pitch + MINIMUM_RATE;
这篇关于改变Android的一个音效档的频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!