简体   繁体   English

如何创建声音淡入效果

[英]How can I create a sound fade out effect

using this code 使用此代码

for (int k = 0; k < 16; k++) {
    Track track = musicS.createTrack();
    track.add(new MidiEvent(new ShortMessage(ShortMessage.CONTROL_CHANGE, k, 7, 20), track.ticks() -3));
}

How can I make the volume fade out right before the song ends 如何使音量在歌曲结束前逐渐消失

这里看 ,您可能想要将MidiEvent的滴答声设​​置为(track.getTicks()-someNumberOfTicks)之类的值,以更改歌曲结尾的音量。

How many ticks are there in your Track? 您的足迹中有多少滴答声?

You need to add a lot of MidiEvents to the end of you track, starting with where you want the fade to begin, gradually lowering the volume for each event. 您需要在跟踪的末尾添加很多MidiEvent,从您希望淡入淡出的位置开始,逐渐降低每个事件的音量。

Your code snippet is setting the volume at tick 0. Do you know if you are setting 7 to 'volume' or 'volume' to 7? 您的代码段将音量设置为刻度0。您是否知道将7设置为“ volume”还是将“ volume”设置为7?

You need a new loop to add your MidiEvents to the end of your track. 您需要一个新的循环将MidiEvents添加到曲目的末尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM