Assembly: Bass.Net (in Bass.Net.dll) Version: 188.8.131.52
[DllImportAttribute("bassmix")] public static bool BASS_Mixer_StreamAddChannel( int handle, int channel, BASSFlag flags )
<DllImportAttribute("bassmix">] Public Shared Function BASS_Mixer_StreamAddChannel ( handle As Integer, channel As Integer, flags As BASSFlag ) As Boolean
- Type: SystemInt32
The mixer handle (created with BASS_Mixer_StreamCreate(Int32, Int32, BASSFlag)).
- Type: SystemInt32
The handle of the channel to plug into the mixer... a HMUSIC, HSTREAM or HRECORD (e.g. created with BASS_StreamCreateFile(String, Int64, Int64, BASSFlag)).
- Type: Un4seen.BassBASSFlag
Any combination of these flags (see BASSFlag):
BASS_MIXER_CHAN_BUFFER Buffer the sample data, for use by BASS_Mixer_ChannelGetData(Int32, IntPtr, Int32) and BASS_Mixer_ChannelGetLevel(Int32). This increases memory requirements, so should not be enabled needlessly. The size of the buffer can be controlled via the BASS_CONFIG_MIXER_BUFFER config option. BASS_MIXER_CHAN_DOWNMIX Downmix to stereo, or mono if the mixer output is mono. BASS_MIXER_CHAN_LIMIT Limit the mixer processing to the amount of data available from this source, while the source is active (not ended). If the source stalls, then the mixer will too, rather than continuing to mix other sources, as it would normally do. This flag can only be applied to one source per mixer, so it will automatically be removed from any other source of the same mixer. BASS_MIXER_CHAN_MATRIX Creates a channel matrix, allowing the source channels to be sent to any of the mixer output channels, at any levels. The matrix can be retrieved and modified via the BASS_Mixer_ChannelGetMatrix(Int32, Single) and BASS_Mixer_ChannelSetMatrix(Int32, Single) functions. The matrix will initially contain a one-to-one mapping, eg. left out = left in, right out = right in, etc... BASS_MIXER_CHAN_NORAMPIN Don't ramp-in the start, including after seeking (BASS_Mixer_ChannelSetPosition(Int32, Int64, BASSMode)). This is useful for gap-less playback, where a source channel is intended to seamlessly follow another. This does not affect volume and pan changes, which are always ramped. BASS_MIXER_CHAN_PAUSE Don't process the source channel (add it in a paused mode). Use BASS_Mixer_ChannelFlags(Int32, BASSFlag, BASSFlag) in order to toggle processing of the source channel. BASS_STREAM_AUTOFREE Automatically free the source channel when it ends. This allows you to add a channel to a mixer and forget about it, as it will automatically be freed when it has reached the end, or when the source is removed from the mixer or when the mixer is freed. BASS_SPEAKER_xxx Speaker assignment flags.
If matrix mixing is enabled then the matrix will be initialized to place the source on the requested speaker(s), with downmixing also applied if the BASS_MIXER_CHAN_DOWNMIX flag is specified. TheBASS_DEVICE_NOSPEAKER flag has effect here.
Return ValueType: Boolean
If successful, then is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Internally, a mixer will use the BASS_ChannelGetData(Int32, IntPtr, Int32) function to get data from its source channels. That means that the source channels must be decoding channels (not using a RECORDPROC in the case of a recording channel). Plugging a channel into more than one mixer at a time is not possible because the mixers would be taking data away from each other. An advantage of this is that there is no need for a mixer's handle to be provided with the channel functions. It is actually possible to plug a channel into multiple mixers via the use of splitter streams.
Channels are removed with the BASS_Mixer_ChannelRemove(Int32) function. Channels are also automatically unplugged when they are freed.
When mixing a channel, the mixer makes use of the channel's attributes (freq/volume/pan), as set with BASS_ChannelSetAttribute(Int32, BASSAttribute, Single) or BASS_ChannelSlideAttribute(Int32, BASSAttribute, Single, Int32). The BASS_CONFIG_CURVE_VOL and BASS_CONFIG_CURVE_PAN config option settings are also used (see BASS_SetConfig(BASSConfig, Int32)).
If a multi-channel stream has more channels than the mixer output, the extra channels will be discarded. For example, if a 5.1 stream is plugged into a stereo mixer, only the front-left/right channels will be retained. That is unless matrix mixing is used.
The mixer processing is performed in floating-point, so it makes sense (for both quality and efficiency reasons) for the source channels to be floating-point too, though they do not have to be. It is also more efficient if the source channels have the same sample rate as the mixer output because no sample rate conversion is required then. When sample rate conversion is required, windowed sinc interpolation is used and the source's BASS_ATTRIB_SRC attribute determines how many points/samples are used in that, as follows: 0 (or below) = 4 points, 1 = 8 points, 2 = 16 points, 3 = 32 points, 4 = 64 points, 5 = 128 points, 6 (or above) = 256 points. 8 points are used if the BASS_ATTRIB_SRC attribute is unavailable (old BASS version). A higher number of points results in better sound quality (less aliasing and smaller transition band in the low-pass filter), but also higher CPU usage.
|BASS_ERROR_HANDLE||At least one of handle and channel is not valid.|
|BASS_ERROR_DECODE||channel is not a decoding channel.|
|BASS_ERROR_ALREADY||channel is already plugged into a mixer. It must be unplugged first.|
|BASS_ERROR_SPEAKER||The mixer does not support the requested speaker(s), or you're attempting to assign a stereo stream to a mono speaker.|
The sample rate conversion processing is limited to 128 points on iOS and Android. The mixer processing is also performed in fixed-point rather than floating-point on Android.
// this will be the final mixer output stream being played int mixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT ); // now we need some channels to plug them in...create two decoding sources int streamA = Bass.BASS_StreamCreateFile("testA.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); int streamB = Bass.BASS_StreamCreateFile("testB.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); // finally we plug them into the mixer (no downmix, since we assume the sources to be stereo) bool okA = BassMix.BASS_Mixer_StreamAddChannel(mixer, streamA, BASSFlag.BASS_DEFAULT); bool okB = BassMix.BASS_Mixer_StreamAddChannel(mixer, streamB, BASSFlag.BASS_DEFAULT); // and play it... Bass.BASS_ChannelPlay(mixer, false);
' this will be the final mixer output stream being played Dim mixer As Integer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT) ' now we need some channels to plug them in...create two decoding sources Dim streamA As Integer = Bass.BASS_StreamCreateFile("testA.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT) Dim streamB As Integer = Bass.BASS_StreamCreateFile("testB.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT) ' finally we plug them into the mixer (no downmix, since we assume the sources to be stereo) Dim okA As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, streamA, BASSFlag.BASS_DEFAULT) Dim okB As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, streamB, BASSFlag.BASS_DEFAULT) ' and play it... Bass.BASS_ChannelPlay(mixer, False)