<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > TBASS (Sound Module) > Music >





Loads music from file or memory.




music = TBASS_LoadMusic(mem, source, offset, length, flags, freq)




Number, music handle - non-zero in case of success.











flag indicating if you want to load the sample from memory


String / Pointer


file name (if mem is FALSE), otherwise memory location of sample


file offset to load the sample from (only used if mem is FALSE).


Data length... 0 = use all data up to the end of file (if mem is FALSE). If length over-runs the end of the file, it will automatically be lowered to the end of the file.


A combination of these flags


A combination of these flags.


Use 8-bit resolution. If neither this or the %TBASS_SAMPLE_FLOAT flags are specified, then the sample data will be 16-bit.


Use 32-bit floating-point sample data. See Floating-point channels for info.


Decode/play the MOD music in mono (uses less CPU than stereo). This flag is automatically applied if %TBASS_DEVICE_MONO was specified when calling TBASS_Init.


Force the MOD music to not use hardware DirectSound mixing.


Enable 3D functionality. This requires that the %TBASS_DEVICE_3D flag was specified when calling TBASS_Init. 3D channels must also be mono, so %TBASS_SAMPLE_MONO is automatically applied. The SPEAKER flags cannot be used together with this flag.


Loop the music.


Use non-interpolated sample mixing. This generally reduces the sound quality, but can be good for chip-tunes.


Use sinc interpolated sample mixing. This increases the sound quality, but also requires more CPU. If neither this or the %TBASS_MUSIC_NONINTER flag is specified, linear interpolation is used.


Use "normal" ramping (as in FastTracker 2).


Use "sensitive" ramping.


Apply XMPlay's surround sound to the music. This is ignored if the %TBASS_SAMPLE_MONO flag is also specified.


Apply XMPlay's surround sound mode 2 to the music. This is ignored if the %TBASS_SAMPLE_MONO flag is also specified.


Apply FastTracker 2 panning to XM files.


Play .MOD files as FastTracker 2 would, including applying FastTracker 2 panning.


Play .MOD files as ProTracker 1 would.


Stop all notes when seeking (TBASS_ChannelSetPosition).


Stop all notes and reset bpm/etc when seeking.


Stop the music when a backward jump effect is played. This stops musics that never reach the end from going into endless loops. Some MOD musics are designed to jump all over the place, so this flag would cause those to be stopped prematurely. If this flag is used together with the %TBASS_SAMPLE_LOOP flag, then the music would not be stopped but any %TBASS_SYNC_END sync would be triggered.


Calculate the playback length of the music, and enable seeking in bytes. This slightly increases the time taken to load the music, depending on how long it is. In the case of musics that loop, the length until the loop occurs is calculated. Use TBASS_ChannelGetLength to retrieve the length.


Do not load the samples. This reduces the time (and memory) taken to load the music, notably with MO3 files, which is useful if you just want to get the text and/or length of the music without playing it.


Automatically free the music when playback ends. Note that some musics have infinite loops, so never actually end on their own.


Decode/render the sample data, without playing it. Use TBASS_ChannelGetData to retrieve decoded sample data. The %TBASS_SAMPLE_3D, %TBASS_STREAM_AUTOFREE and SPEAKER flags cannot be used together with this flag. The %TBASS_SAMPLE_SOFTWARE and %TBASS_SAMPLE_FX flags are also ignored.


Speaker assignment flags. The %TBASS_SAMPLE_MONO flag is automatically applied when using a mono speaker assignment flag.


file is in UTF-16 form. Otherwise it is ANSI on Windows or Windows CE, and UTF-8 on other platforms.




Sample rate to render/play the MOD music at... 0 = the rate specified in the TBASS_Init call, 1 = the device's current output rate (or the TBASS_Init rate if that is not available).







See also