Is it possible to play a single note, or is it a missunderstanding of mine?
Do you want to play a note without playing a MIDI file? If so, you can use BASS_MIDI_StreamCreate instead of BASS_MIDI_StreamCreateFile to create the MIDI stream.
First I tried to change the tempo of a MIDI-File Loop
Stream = BassMidi.BASS_MIDI_StreamCreateFile("C:\Users\Stephan\Downloads\output(29).mid", 0, 0, BASSFlag.BASS_SAMPLE_LOOP, 44100)
BassMidi.BASS_MIDI_StreamEvent(Stream, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO, 100000)
The fist time the midifile was played with the new tempo, but the other times the midifile was played with the original tempo.
Yes, the MIDI file can override your events, eg. with its own tempo changes. In order to keep your changes, you can override the MIDI file's events via BASS_SYNC_MIDI_EVENT syncs. For example, to keep the tempo set to 100000, you could do this...
BASS_ChannelSetSync(stream, BASS_SYNC_MIDI_EVENT|BASS_SYNC_MIXTIME, MIDI_EVENT_TEMPO, TempoSyncProc, NULL); // set a "mixtime" sync on tempo events
void CALLBACK TempoSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
BASS_MIDI_StreamEvent(channel, 0, MIDI_EVENT_TEMPO, 100000); // enforce the 100000 tempo setting
A more complete tempo changing demonstration can be found in the MIDITEST example in the BASSMIDI package.
But I discovered also, that the change of the tickvalue did not have any effect.
Yes, BASS_MIDI_StreamEvents applies the event(s) immediately (the "tick" and "pos" BASS_MIDI_EVENT members are ignored). If you would like to apply an event at a particular position, that can be achieved via a "mixtime" BASS_SYNC_POS or BASS_SYNC_MIDI_TICK sync, ie. set the sync at the wanted position and apply the event in your SYNCPROC callback function.
In case it is of interest, the next BASSMIDI release will include the option of providing a sequence of events for a MIDI stream to play. An update is also available to try now (BASS.Net already includes support for it)... www.un4seen.com/forum/?topic=13542.msg94618#msg94618
A further problem seems to me, that the change of tempo did not take place at the beginning of the midifile, but at the second quaver. Also when the tickvalue was 1 or 0. So the midifile is played in a musical wrong way. It is musical senseless.
What I have to do?
To have the tempo applied from the start, you will need to make the BASS_MIDI_StreamEvent call before you call BASS_ChannelPlay to begin playback. As above, you should also set a sync to enforce your tempo setting in case the MIDI file tries to set its own tempo.