java回声机程序_java - 创建Java回声效果 - 堆栈内存溢出

因此,我试图通过将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如果我正在解释此权利,但我希望这将是一个简单的解决方法。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值