【发布时间】:2017-08-05 15:58:28
【问题描述】:
所以在下面的程序中,它会加快音频文件的速度,让它听起来好像这个人有一个“氦气声音”。这是通过更改索引值来完成的,当您增加它时,文件会变得更高音调和更快。我想知道是否有办法做相反的事情,让音频播放得更慢,声音更深。
public void helium(String sourceFile, String targetFile)
{
Sound sourceObj = new Sound(sourceFile);
Sound target = new Sound(targetFile);
int sampleValue = 0;
int targetIndex = 0;
for(int index = 0; index < sourceObj.getLength(); index+=2)
{
sampleValue = sourceObj.getSampleValueAt(index);
target.setSampleValueAt(targetIndex,sampleValue);
targetIndex++;
}
target.play();
}
【问题讨论】:
-
使用负值?
-
如果给索引放负值,只会报错
-
如果你加1并使用
index / 2会怎样? -
我刚试过,但它只是让音频听起来正常,只播放一半的音频。