PDA

View Full Version : Help file: TBASS_SampleGetChannel



Petr Schreiber
15-05-2011, 11:59
Hi,

the following topic is empty:
thinBasic Modules > TBASS (Sound Module) > Samples > TBASS_SampleGetChannel

I would propose:

Description
Creates/initializes a playback channel for a sample.


Syntax
hChannel = TBASS_SampleGetChannel( hSample, onlyNew )

Returns
If successful, returned value is channel handle.
Otherwise 0 is returned, use TBASS_ErrorGetCode to find reason of failure.

Parameters
hSample;Number;Handle of the sample to play
onlyNew;Number;Set to %TBASS_TRUE to not recycle/override one of the sample's existing channels. Use %TBASS_FALSE for opposite.

Remarks
If a sample has a maximum number of simultaneous playbacks of 1 (the max parameter was 1 when calling TBASS_SampleLoad), then the hChannel returned will be identical to the hSample. That means you can use the hSample with functions that usually require a hChannel, but you must still call this function first to initialize the channel.

A sample channel is automatically freed when it's overridden by a new channel, or when stopped by TBASS_ChannelStop. If you wish to stop a channel and re-use it, it should be paused (TBASS_ChannelPause) instead of stopped. Determining whether a channel still exists can be done by trying to use the handle in a function call, eg. TBASS_ChannelGetAttributes.


All of a sample's channels share the same sample data, and just have their own individual playback state information (volume/position/etc).

Restrictions

See also
TBASS_SampleLoad

Examples
' -- Load sample
hSample = TBASS_SampleLoad(%TBASS_FALSE, APP_SOURCEPATH+"monster.wav", 0, 0, 1, %TBASS_SAMPLE_LOOP )

' -- Retrieve channel
hChannel = TBASS_SampleGetChannel(hSample , %TBASS_FALSE)