BASS.NET API for the Un4seen BASS Audio LibraryBassMixBASS_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.12.0
Syntax

[DllImportAttribute("bassmix.dll", CharSet = CharSet.Unicode)]
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:
VB
Dim nodes As BASS_MIXER_NODE() =  
  {
    New BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 3.0), 1F), 
    New BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 5.0), 0F), 
    New BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 7.0), 0F), 
    New BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 9.0), 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 
Dim envPos As Long = 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)
...
// 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