BASS.NET API for the Un4seen BASS Audio LibraryBassMixBASS_Mixer_ChannelSetEnvelope Method (Int32, BASSMIXEnvelope, BASS_MIXER_NODE)BASS.NET API for the Un4seen BASS Audio Library
Sets an envelope to modify the sample rate, volume or pan of a channel over a period of time.

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

public static bool BASS_Mixer_ChannelSetEnvelope(
	int handle,
	BASSMIXEnvelope type,
	BASS_MIXER_NODE[] nodes
)

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 get the position/value of. One of the following (see BASSMIXEnvelope):
BASS_MIXER_ENV_FREQSample rate.
BASS_MIXER_ENV_VOLVolume.
BASS_MIXER_ENV_PANPanning/balance.
BASS_MIXER_ENV_LOOPLoop the envelope. This is a flag and can be used in combination with any of the above.
nodes
Type: Un4seen.Bass.AddOn.MixBASS_MIXER_NODE
The array of envelope nodes, which should have sequential positions ( = no envelope).

Return Value

Type: Boolean
If successful, is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

Envelopes are applied on top of the channel's attributes, as set via BASS_ChannelSetAttribute(Int32, BASSAttribute, Single). In the case of BASS_MIXER_ENV_FREQ and BASS_MIXER_ENV_VOL, the final sample rate and volume is a product of the channel attribute and the envelope. While in the BASS_MIXER_ENV_PAN case, the final panning is a sum of the channel attribute and envelope.

BASS_Mixer_ChannelGetEnvelopePos(Int32, BASSMIXEnvelope, Single) can be used to get the current envelope position, and a BASS_SYNC_MIXER_ENVELOPE sync can be set via BASS_Mixer_ChannelSetSync(Int32, BASSSync, Int64, SYNCPROC, IntPtr) to be informed of when an envelope ends. The function can be called again from such a sync, in order to set a new envelope to follow the old one.

Any previous envelope of the same type is replaced by the new envelope. A copy is made of the nodes array, so it does not need to persist beyond this function call.

Note: Envelopes deal in mixer positions, not sources! You might use BASS_Mixer_ChannelSetEnvelopePos(Int32, BASSMIXEnvelope, Int64) to adjust the envelope to a source channel position.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not plugged into a mixer.
BASS_ERROR_ILLTYPEtype is not valid.

Examples

Volume curve envelope starting after 3 seconds, ending after 9 seconds:
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), 0.3F), 
    New BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 7.0), 0.5F), 
    New BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 9.0), 1F)
  }
BassMix.BASS_Mixer_ChannelSetEnvelope(_channel, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, nodes)
BASS_MIXER_NODE[] nodes = 
  {
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 3d), 1f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 5d), 0.3f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 7d), 0.5f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 9d), 1f)
  };
BassMix.BASS_Mixer_ChannelSetEnvelope(_channel, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, nodes);
See Also

Reference