BASS_MIDI_StreamCreate
Creates a sample stream to render real-time MIDI events.
HSTREAM BASS_MIDI_StreamCreate( DWORD channels, DWORD flags, DWORD freq );
Parameters
channels | The number of MIDI channels... 1 (min) - 128 (max). The number of channels can subsequently be changed via the BASS_ATTRIB_MIDI_CHANS attribute. | ||||||||||||||||||||||||||
flags | A combination of these flags.
| ||||||||||||||||||||||||||
freq | Sample 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_INIT | BASS_Init has not been successfully called. |
BASS_ERROR_NOTAVAIL | Only decoding channels (BASS_STREAM_DECODE) are allowed when using the "no sound" device. The BASS_STREAM_AUTOFREE flag is also unavailable to decoding channels. |
BASS_ERROR_ILLPARAM | channels is not valid. |
BASS_ERROR_FORMAT | The sample format is not supported by the device/drivers. If the stream is more than stereo or the BASS_SAMPLE_FLOAT flag is used, it could be that they are not supported. |
BASS_ERROR_SPEAKER | The specified SPEAKER flags are invalid. The device/drivers do not support them or 3D functionality is enabled. |
BASS_ERROR_MEM | There is insufficient memory. |
BASS_ERROR_NO3D | Could not initialize 3D support. |
BASS_ERROR_UNKNOWN | Some other mystery problem! |
Remarks
This function creates a stream solely for real-time MIDI events. As it is not based on any file, the stream has no predetermined length and is never-ending. Seeking is not possible, but it is possible to reset everything, including playback buffer, by calling BASS_ChannelPlay (restart = TRUE) or BASS_ChannelSetPosition (pos = 0).MIDI events are applied using the BASS_MIDI_StreamEvent and BASS_MIDI_StreamEvents functions. If the stream is being played (it is not a decoding channel), then there will be some delay in the effect of the events being heard. This latency can be reduced by making use of the BASS_CONFIG_BUFFER and BASS_CONFIG_UPDATEPERIOD config options.
If a stream has 16 MIDI channels, then channel 10 defaults to percussion/drums and the rest melodic, otherwise they are all melodic. That can be changed using BASS_MIDI_StreamEvent and the MIDI_EVENT_DRUMS event.
Soundfonts provide the sounds that are used to render a MIDI stream. A default soundfont configuration is applied initially to the new MIDI stream, which can subsequently be overridden using BASS_MIDI_StreamSetFonts.
To play a MIDI file, use BASS_MIDI_StreamCreateFile.
Platform-specific
Away from Windows, all mixing is done in software (by BASS), so the BASS_SAMPLE_SOFTWARE flag is unnecessary. The BASS_SAMPLE_FX flag is also ignored. On Android and iOS, sinc interpolation requires a NEON-supporting CPU; the BASS_MIDI_SINCINTER flag will otherwise be ignored. Sinc interpolation is not available on Windows CE.See also
BASS_MIDI_StreamCreateEvents, BASS_MIDI_StreamCreateFile, BASS_MIDI_StreamEvent, BASS_MIDI_StreamEvents, BASS_MIDI_StreamGetChannel, BASS_MIDI_StreamSetFonts, BASS_ATTRIB_MIDI_CPU, BASS_ATTRIB_MIDI_SRC, BASS_CONFIG_MIDI_DEFFONT, BASS_CONFIG_MIDI_VOICESBASS_ChannelGetInfo, BASS_ChannelPlay, BASS_ChannelSetAttribute, BASS_ChannelSetDSP, BASS_ChannelSetFX, BASS_ChannelSetLink, BASS_StreamFree