BASS_WMA_StreamCreateFile

Creates a sample stream from a WMA file or URL.

HSTREAM BASS_WMA_StreamCreateFile(
    BOOL mem,
    void *file,
    QWORD offset,
    QWORD length,
    DWORD flags
);

Parameters

memTRUE = stream the file from memory, 2 = stream from an IStream object.
fileFilename or URL (mem = FALSE) or a memory location (mem = TRUE), or a pointer to an IStream object (mem = 2).
offsetFile offset to begin streaming from (only used if mem = FALSE).
lengthData length... 0 = use all data up to the end of the file (if mem = FALSE).
flagsA combination of these flags.
BASS_SAMPLE_FLOATUse 32-bit floating-point sample data. See Floating-point channels for info.
BASS_SAMPLE_3DEnable 3D functionality. The stream must be mono. The SPEAKER flags cannot be used together with this flag.
BASS_SAMPLE_LOOPLoop the file. This flag can be toggled at any time using BASS_ChannelFlags.
BASS_STREAM_AUTOFREEAutomatically free the stream when playback ends.
BASS_STREAM_DECODEDecode the sample data, without playing it. Use BASS_ChannelGetData to retrieve decoded sample data. The BASS_SAMPLE_3D, BASS_STREAM_AUTOFREE and SPEAKER flags cannot be used together with this flag.
BASS_SPEAKER_xxxSpeaker assignment flags. These flags have no effect when the stream is more than stereo.
BASS_ASYNCFILERead the file asynchronously. When enabled, the file is read and buffered in parallel with the decoding, to reduce the chances of the decoder being affected by I/O delays. This can be particularly useful with slow storage media and/or low latency output. The size of the file buffer is determined by the BASS_CONFIG_ASYNCFILE_BUFFER config option. This flag only applies when the BASS_CONFIG_WMA_BASSFILE config option is enabled, and is ignored when streaming from memory (mem = TRUE).
BASS_UNICODEfile is in UTF-16 form. Otherwise it is ANSI.

Return value

If successful, the new stream's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_WMAThe Windows Media modules (v9 or above) are not installed.
BASS_ERROR_INITBASS_Init has not been successfully called.
BASS_ERROR_NOTAVAILThe BASS_STREAM_AUTOFREE flag cannot be combined with the BASS_STREAM_DECODE flag.
BASS_ERROR_ILLPARAMOne or more of the parameters are invalid.
BASS_ERROR_PROTOCOLThe protocol in file is not supported.
BASS_ERROR_TIMEOUTThe server did not respond to the request within the timeout period, as set with the BASS_CONFIG_NET_TIMEOUT config option.
BASS_ERROR_FILEOPENThe file could not be opened.
BASS_ERROR_FILEFORMThe file's format is not recognised/supported.
BASS_ERROR_NOTAUDIOThe file does not contain audio, or it also contains video and videos are disabled.
BASS_ERROR_CODECThe file uses a codec that is not available/supported.
BASS_ERROR_FORMATThe sample format is not supported.
BASS_ERROR_SPEAKERThe specified SPEAKER flags are invalid.
BASS_ERROR_MEMThere is insufficient memory.
BASS_ERROR_NO3DCould not initialize 3D support.
BASS_ERROR_WMA_LICENSEThe WMA file cannot be played because it is protected.
BASS_ERROR_UNKNOWNSome other mystery problem!

Remarks

Use BASS_ChannelGetInfo to retrieve information on the format (sample rate, resolution, channels) of the stream. The bitrate (amongst other things) can be retrieved through BASS_ChannelGetTags (BASS_TAG_WMA), which will return a pointer to a series of null-terminated UTF-8 strings, the final string ending with a double null. If the stream contains mid-stream tags (script), the latest tag can be retrieved through BASS_ChannelGetTags (BASS_TAG_WMA_META), which will return a single UTF-8 string. Each tag is in the form of "key=value".

A description of the codec used by the file is also available from BASS_ChannelGetTags (BASS_TAG_WMA_CODEC). 2 null-terminated UTF-8 strings are returned, with the 1st string being the name of the codec, and the 2nd containing additional information like what VBR setting was used.

The playback length of the stream can be retrieved using BASS_ChannelGetLength. Until the whole file has been streamed, whatever length the file's header says is returned, which may or may not be exact.

Although the Windows Media modules uses its own internet streaming routines (not BASS's), the BASS_CONFIG_NET_PROXY and BASS_CONFIG_NET_TIMEOUT config options do have effect when opening WMA streams. When the BASS_CONFIG_NET_PLAYLIST config option is enabled, BASSWMA will process ASX and WPL files. None of the other NET config options apply.

Unless the BASS_CONFIG_WMA_BASSFILE config option is enabled, the Windows Media modules uses its own file reading routines, and the offset and length parameters are ignored, except that length is still the length when playing from memory. Also, BASS_StreamGetFilePosition is not fully supported. The file size (BASS_FILEPOS_END) can be retrieved, but the decode position (BASS_FILEPOS_CURRENT) is not available. The download progress of streamed files (BASS_FILEPOS_DOWNLOAD) can also be retrieved. The buffering progress (percentage) can be retrieved using the BASS_FILEPOS_WMA_BUFFER mode.

When streaming a file from the internet, it is not possible to seek with BASS_ChannelSetPosition until the whole file has been downloaded. A sync (BASS_SYNC_DOWNLOAD) can be set to be notified when the file has been downloaded. When streaming from the internet, the WMA decoding is performed in a separate thread, so the CPU used to decode the stream during playback will not be included in the BASS_GetCPU return value.

The playback rate of local files can be altered with BASS_ChannelSetAttribute. The playback rate of internet streams should not be changed, because they are delivered at a fixed rate: the rate required to sustain playback at normal speed. So increasing the rate will result in playback stalling.

See also

BASS_WMA_StreamCreateFileAuth, BASS_WMA_StreamCreateFileUser, BASS_CONFIG_WMA_BASSFILE

BASS_ChannelGetInfo, BASS_ChannelGetLength, BASS_ChannelPlay, BASS_ChannelSetAttribute, BASS_ChannelSetDSP, BASS_ChannelSetFX, BASS_ChannelSetLink, BASS_StreamFree, BASS_ChannelGetTags