19 Jun '13 - 15:58 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Filter Midi notes from BASS_MIDI_StreamCreateFile (iOS)  (Read 340 times)
skinnyTod
Posts: 22


« on: 26 Sep '11 - 00:38 »
Reply with quoteQuote

Hi - I need to filter midi from a stream created through BASS_MIDI_StreamCreateFile.

I searched the forums and found this old thread:
http://www.un4seen.com/forum/?topic=7914.msg53930#msg53930

The method described there sort of works but I still hear the midi file playing faintly muted. I am using the exact code from the earlier post to test this (below). Any tips on why this may not be working?

BASS_ChannelSetSync(midi, BASS_SYNC_MIDI_EVENT|BASS_SYNC_MIXTIME, MIDI_EVENT_NOTE, PianoFilter, 0); // set NOTE event sync

...

void CALLBACK PianoFilter(HSYNC handle, DWORD channel, DWORD data, void *user)
{
if (!HIBYTE(data)) return; // it's a "note off", nothing to do
if (BASS_MIDI_StreamGetEvent(channel, HIWORD(data), MIDI_EVENT_DRUMS)) return; // ignore drum channels
DWORD preset=BASS_MIDI_StreamGetEvent(channel, HIWORD(data), MIDI_EVENT_PROGRAM); // get current preset
if (preset<9) // it's a piano
BASS_MIDI_StreamEvent(channel, HIWORD(data), MIDI_EVENT_NOTE, LOBYTE(data)); // release note (velocity=0)
}
Logged
Ian @ un4seen
Administrator
Posts: 15363


« Reply #1 on: 26 Sep '11 - 16:55 »
Reply with quoteQuote

It isn't currently possible to filter out notes at load-time, but it should be possible to achieve what you want in the way that you refer to above with a slight modification. The reason the code from that old thread no longer works very well is because BASSMIDI has since been modified to play 0-length notes (which some MIDI files use for drums), so the notes will still be heard when you immediately release them. To get around that, a note "kill" option has been added recently, which is used by setting velocity=255 in the MIDI_EVENT_NOTE event. For example, the final line above would be modified like this...

BASS_MIDI_StreamEvent(channel, HIWORD(data), MIDI_EVENT_NOTE, MAKEWORD(LOBYTE(data), 255)); // kill note (velocity=255)

That "kill" option isn't in the BASSMIDI release version (on the BASS page) yet, but I think it is in the iOS version. Let me know if you find that it doesn't work, and I'll post an updated build.
Logged
skinnyTod
Posts: 22


« Reply #2 on: 26 Sep '11 - 17:47 »
Reply with quoteQuote

Yes, that works (in iOS).

Thanks for the quick reply!
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines