因此,我试图通过将Java声音文件分解为样本并将这些样本存储在数组中来对其进行操作。 然后,我遍历数组以更改每个样本。 我意识到Java中已经有一个回声过滤器,但是我需要通过减小声音在整个声音片段中以不同的间隔重复声音来设计自己的声音。 我目前有一种控制音量的方法,但是当要使声音在当前声音文件的特定延迟处开始重复播放时,我感到很困惑。 这是我到目前为止的内容:
public void echoEffect(int delay){
SoundSample[] sampleArray = this.getSamples(); // get array
SoundSample sample = null; // current sample obj
int value = 0; // value at sample
// loop through SoundSample objects
for(int i = 0, index = 0; index < sampleArray.length; i++,index++)
{
sample = sampleArray[index]; // get current obj
value = sample.getValue(); // get the value
sample.setValue(value*2); // set the value
}
}
我相信我需要做的是将方法从void更改为Sound并返回延迟的声音文件。 可能返回诸如value + value [i + delay] *(降低声音的某种分数)之类的东西
新更新,而不是发布:
无论如何,到目前为止,我似乎无法使代码正常工作,并且我知道我已经接近了,但是我需要一种在声音文件上输出回声效果的方法。 这是我目前所拥有的:
public void echo(int delay){
SoundSample[] sampleArray = this.getSamples(); // get array
//Sound target = new Sound(sampleArray.length);
SoundSample sampleDelay = null;
SoundSample sample = null; // current sample obj
int value = 0; // value at sample
int index = 0;
double value2 = 0;
// loop through SoundSample objects
while (index < sampleArray.length)
{
sample = sampleArray[index]; // get current obj
value = sample.getValue(); // get the value
sampleDelay = (sampleArray[delay-index]);
value2 = (sampleDelay.getValue()*.6);
sample.setValue(value + (int) value2); // set the value
index++; // increment index
}
}
让我知道你们认为所有这一切似乎是出于某种原因而改变了振幅...发布SSCCE的问题在于,我相信这使用的Java不定期使用某些类,因此我只是在寻找有人帮助逻辑。 我试图遍历声音文件的样本,然后将延迟点的值设置为声音的开始,但音量变弱。 IDK如果我正在解释此权利,但我希望这将是一个简单的解决方法。