BASS_MIDI_StreamCreateURL

Creates a sample stream from an MIDI file on the internet, optionally receiving the downloaded data in a callback.

HSTREAM BASS_MIDI_StreamCreateURL(
    char *url,
    DWORD offset,
    DWORD flags,
    DOWNLOADPROC *proc,
    void *user,
    DWORD freq
);

Parameters

urlURL of the file to stream. Should begin with "http://" or "https://" or "ftp://".
offsetFile position to start streaming from. This is ignored by some servers, specifically when the file length is unknown.
flagsAny combination of these flags.
BASS_SAMPLE_8BITSUse 8-bit resolution. If neither this or the BASS_SAMPLE_FLOAT flags are specified, then the stream is 16-bit.
BASS_SAMPLE_FLOATUse 32-bit floating-point sample data. See Floating-point channels for info.
BASS_SAMPLE_MONODecode/play the MIDI in mono. This flag is automatically applied if BASS_DEVICE_MONO was specified when calling BASS_Init.
BASS_SAMPLE_3DEnable 3D functionality. The stream must be mono, so BASS_SAMPLE_MONO is automatically applied. 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_STATUSPass status info (HTTP/ICY tags) from the server to the DOWNLOADPROC callback during connection. This can be useful to determine the reason for a failure.
BASS_STREAM_AUTOFREEAutomatically free the stream when playback ends.
BASS_STREAM_DECODEDecode/render 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. The BASS_SAMPLE_MONO flag is automatically applied when using a mono speaker assignment flag.
BASS_MIDI_ASYNCProcess events asynchronously in BASS_MIDI_StreamEvent and BASS_MIDI_StreamEvents calls. This flag can be toggled at any time using BASS_ChannelFlags.
BASS_MIDI_DECAYENDLet the sound decay naturally (including reverb) instead of stopping abruptly at the end of the file, including when looping. This flag can be toggled at any time using BASS_ChannelFlags.
BASS_MIDI_DECAYSEEKLet the old sound decay naturally (including reverb) when changing the position, including looping. This flag can be toggled at any time using BASS_ChannelFlags, but it should generally only be used in BASS_ChannelSetPosition calls to have it applied to particular position changes, eg. custom loops.
BASS_MIDI_NOCROPDo not remove empty space (containing no events) from the end of the file.
BASS_MIDI_NODRUMPARAMDo not apply default per-drum reverb and chorus levels and instead set them all to full. The default is to set different levels for different types of drum, eg. lower levels on kick drums. The levels can subsequently be changed via the MIDI_EVENT_DRUM_REVERB and MIDI_EVENT_DRUM_CHORUS events. This flag can be toggled at any time using BASS_ChannelFlags, but will only take effect upon a program change or system reset.
BASS_MIDI_NOFXDisable reverb and chorus processing, saving some CPU time. This flag can be toggled at any time using BASS_ChannelFlags.
BASS_MIDI_NOSYSRESETIgnore system reset events (MIDI_EVENT_SYSTEM) when the system mode is unchanged. This flag can be toggled at any time using BASS_ChannelFlags.
BASS_MIDI_NOTEOFF1Only release the oldest instance upon a note off event (MIDI_EVENT_NOTE with velocity=0) when there are overlapping instances of the note. Otherwise all instances are released. This flag can be toggled at any time using BASS_ChannelFlags.
BASS_UNICODEurl is in UTF-16 form. Otherwise it is ANSI on Windows or Windows CE, and UTF-8 on other platforms.
procCallback function to receive the downloaded file... NULL = no callback.
userUser instance data to pass to the callback function.
freqSample rate to render/play the MIDI stream at... 0 = the rate specified in the BASS_Init call, 1 = the device's current output rate (or the BASS_Init rate if that is not available).

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_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_NONETNo internet connection could be opened.
BASS_ERROR_ILLPARAMurl is not a valid URL.
BASS_ERROR_PROTOCOLThe protocol in url is not supported.
BASS_ERROR_SSLSSL/HTTPS support is not available.
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_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_UNKNOWNSome other mystery problem!

Remarks

This is an internet version of the BASS_MIDI_StreamCreateFile function and the remarks in its documentation also apply here, except that the BASS_CONFIG_MIDI_AUTOFONT config option has no effect.

See also

BASS_MIDI_StreamCreateFile, BASS_MIDI_StreamCreateFileUser, BASS_MIDI_StreamGetChannel, BASS_MIDI_StreamGetMark, BASS_MIDI_StreamLoadSamples, BASS_MIDI_StreamSetFonts, BASS_ATTRIB_MIDI_CPU, BASS_ATTRIB_MIDI_SRC, BASS_CONFIG_MIDI_DEFFONT, BASS_CONFIG_MIDI_VOICES

BASS_ChannelGetInfo, BASS_ChannelGetLength, BASS_ChannelGetTags, BASS_ChannelPlay, BASS_ChannelSetAttribute, BASS_ChannelSetDSP, BASS_ChannelSetFX, BASS_ChannelSetLink, BASS_StreamFree, DOWNLOADPROC callback, BASS_CONFIG_NET_AGENT, BASS_CONFIG_NET_PROXY, BASS_CONFIG_NET_TIMEOUT