BASS.NET API for the Un4seen BASS Audio Library

BassMixBASS_Mixer_ChannelSetEnvelopePos Method

BASS.NET API for the Un4seen BASS Audio Library
Sets the current position of an envelope on a channel.

Namespace:  Un4seen.Bass.AddOn.Mix
Assembly:  Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax

[DllImportAttribute("bassmix")]
public static bool BASS_Mixer_ChannelSetEnvelopePos(
	int handle,
	BASSMIXEnvelope type,
	long pos
)

Parameters

handle
Type: SystemInt32
The mixer source channel handle (which was add via BASS_Mixer_StreamAddChannel(Int32, Int32, BASSFlag) or BASS_Mixer_StreamAddChannelEx(Int32, Int32, BASSFlag, Int64, Int64)) beforehand).
type
Type: Un4seen.Bass.AddOn.MixBASSMIXEnvelope
The envelope to set the position/value of. One of the following (see BASSMIXEnvelope):
BASS_MIXER_ENV_FREQSample rate.
BASS_MIXER_ENV_VOLVolume.
BASS_MIXER_ENV_PANPanning/balance.
pos
Type: SystemInt64
The new envelope position, in bytes. If this is beyond the end of the envelope it will be capped or looped, depending on whether the envelope has looping enabled.

Return Value

Type: Boolean
If successful, the current position of the envelope is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

During playback, the effect of changes are not heard instantaneously, due to buffering. To reduce the delay, use the BASS_CONFIG_BUFFER config option config option to reduce the buffer length.

Note: Envelopes deal in mixer positions, not sources! So when you are changing the source position (e.g. via BASS_Mixer_ChannelSetPosition(Int32, Int64, BASSMode) the envelope's positions doesn't change with it. You might use this method to align the envelope position accorting to the new source position (see example below).

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not plugged into a mixer.
BASS_ERROR_ILLTYPEtype is not valid.
BASS_ERROR_NOTAVAILThere is no envelope of the requested type on the channel.

Examples

Align the envelope position when seeking on the source:
// set a volume envelope on a source mixer channel (do this just once)
BASS_MIXER_NODE[] nodes = 
  {
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 3d), 1f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 5d), 0f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 7d), 0f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 9d), 1f)
  };
BassMix.BASS_Mixer_ChannelSetEnvelope(source, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, nodes);
...

// change the source position and align the envelope position to it
// pause mixer
Bass.BASS_ChannelLock(mixer, true);
BassMix.BASS_Mixer_ChannelSetPosition(source, newPos);
// convert source pos to mixer pos 
long envPos = Bass.BASS_ChannelSeconds2Bytes(mixer, Bass.BASS_ChannelBytes2Seconds(source, newPos));
BassMix.BASS_Mixer_ChannelSetEnvelopePos(source, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, envPos);
// resume mixer 
Bass.BASS_ChannelLock(mixer, false);
...
See Also

Reference