Hi guys,
I want to play/save my channel with fade in and fade out, but it doesn't work, below is my code, which COULD fade in BUT COULD NOT fade out, could you please give me some advice?
public static int handleSound(int channel, int effect, float volumeRatio, boolean fadein, boolean fadeout) {
if (effect != 0) {
BASS.BASS_ChannelRemoveFX(channel, effect);
}
final int nodeCount = 4;
BASS_FX.BASS_BFX_ENV_NODE[] nodes = new BASS_FX.BASS_BFX_ENV_NODE[nodeCount];
BASS_FX.BASS_BFX_ENV_NODE node0 = new BASS_FX.BASS_BFX_ENV_NODE();
node0.pos = 0;
node0.val = fadein ? 0f : volumeRatio;
BASS_FX.BASS_BFX_ENV_NODE node1 = new BASS_FX.BASS_BFX_ENV_NODE();
node1.pos = fadein ? 5 : 0;
node1.val = volumeRatio;
double duration = BASS.BASS_ChannelBytes2Seconds(channel, BASS.BASS_ChannelGetLength(channel, BASS.BASS_POS_BYTE));
BASS_FX.BASS_BFX_ENV_NODE node3 = new BASS_FX.BASS_BFX_ENV_NODE();
node3.pos = duration;
node3.val = fadeout ? 0.0f : volumeRatio;
BASS_FX.BASS_BFX_ENV_NODE node2 = new BASS_FX.BASS_BFX_ENV_NODE();
node2.pos = fadeout ? (node3.pos - 5) : node3.pos;
node2.val = volumeRatio;
nodes[0] = node0;
nodes[1] = node1;
nodes[2] = node2;
nodes[3] = node3;
BASS_FX.BASS_BFX_VOLUME_ENV volume = new BASS_FX.BASS_BFX_VOLUME_ENV();
volume.lChannel = BASS_FX.BASS_BFX_CHANALL;
volume.lNodeCount = nodeCount;
volume.pNodes = nodes;
volume.bFollow = false;
//volume.bFollow = true; //if set true, the sound listens so terrible
effect = BASS.BASS_ChannelSetFX(channel, BASS_FX.BASS_FX_BFX_VOLUME_ENV, 0);
BASS.BASS_FXSetParameters(effect, volume);
return effect;
}