Author Topic: Getting volume when in a BASS_FX Volume Envelope  (Read 227 times)

Ballinger

  • Posts: 47
Is it possible to retrieve a numerical value of the volume at any given time during the execution of a volume envelope slide? There doesn't appear to a value within the BASS_BFX_VOLUME_ENV structure and BASS_BFX_VOLUME does seem to give the correct value either. Thanks in advance for your help.

Ian @ un4seen

  • Administrator
  • Posts: 25612
Re: Getting volume when in a BASS_FX Volume Envelope
« Reply #1 on: 1 Aug '23 - 17:39 »
There isn't currently any way to get an envelope's value from BASS_FX, but perhaps you can calculate it from the envelope yourself. Do you have "bFollow" enabled? If so, the envelope position tracks the playback position, which you can get from BASS_ChannelGetPosition (and BASS_ChannelBytes2Seconds). When the position is between 2 nodes, linear interpolation is used to get the value. Something like this:

Code: [Select]
double pos = BASS_ChannelBytes2Seconds(handle, BASS_ChannelGetPosition(handle, BASS_POS_BYTE)); // get playback position
float val;
for (int n = 0; n < nodes; n++)
if (pos < node[n].pos) { // this node is beyond the position
val += (node[n].val - val) * (pos - node[n - 1].pos) / (node[n].pos - node[n - 1].pos); // interpolate from previous node
break;
}
val = node[n].val;
}

Ballinger

  • Posts: 47
Re: Getting volume when in a BASS_FX Volume Envelope
« Reply #2 on: 1 Aug '23 - 18:37 »
Ah yes... I feared that might be the only way to do it! Thanks for the response Ian.