BASS.NET API for the Un4seen BASS Audio Library

BassMixBASS_Mixer_ChannelSetEnvelope Method (Int32, BASSMIXEnvelope, BASS_MIXER_NODE, Int32)

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.17.5
Syntax

[DllImportAttribute("bassmix")]
public static bool BASS_Mixer_ChannelSetEnvelope(
	int handle,
	BASSMIXEnvelope type,
	BASS_MIXER_NODE[] nodes,
	int count
)

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.
BASS_MIXER_ENV_REMOVERemove the source from the mixer at the end of 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.
count
Type: SystemInt32
The number of elements in the nodes array... 0 = 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.
BASS_ERROR_NOTAVAILThe BASS_MIXER_ENV_PAN envelope is not available when matrix mixing is enabled.

Examples

Set an envelope to bounce the pan position between left and right every 4 seconds:
BASS_MIXER_NODE[] nodes = 
  {
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 0d), 0f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 1d), -1f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 3d), 1f),
    new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 4d), 0f)
  };
BassMix.BASS_Mixer_ChannelSetEnvelope(_channel, BASSMIXEnvelope.BASS_MIXER_ENV_PAN | BASSMIXEnvelope.BASS_MIXER_ENV_LOOP, nodes, 4);
Remove any still available envelope nodes:
BassMix.BASS_Mixer_ChannelSetEnvelope(_channel, BASSMIXEnvelope.BASS_MIXER_ENV_PAN, null, 0);
See Also

Reference