Author Topic: [SOLVED] BASSMIDI Master Tuning RPN trouble  (Read 103 times)

Nicholas

  • Posts: 8
[SOLVED] BASSMIDI Master Tuning RPN trouble
« on: 18 Nov '21 - 21:02 »
I've been having some trouble getting the Master Tuning RPN to have any effect in BASSMIDI.  I saw the change log note from >15 years ago (and a couple forum topics from around the same time) saying that they should be implemented, so I'm sure I'm just missing something.

When I send this stream of MIDI messages, the Microsoft GM Synth will change the tuning of all notes on that channel, but BASSMIDI does not:

   B0, 64, 02
   B0, 65, 00

   B0, 06, 20
   B0, 26, 00

   B0, 64, 7F
   B0, 65, 7F

Please let me know where I'm going wrong.  Thanks!
« Last Edit: 19 Nov '21 - 20:03 by Nicholas »

Ian @ un4seen

  • Administrator
  • Posts: 23980
Re: BASSMIDI Master Tuning RPN trouble
« Reply #1 on: 19 Nov '21 - 14:32 »
I tried that sequence just now, and it seemed to work fine (the channel was tuned 32 semitones lower). Please confirm how you're sending it to BASSMIDI, eg. is it in a MIDI file or are you using BASS_MIDI_StreamEvents with BASS_MIDI_EVENTS_RAW? And are notes subsequently played in the same MIDI channel (channel 1), not a different channel?

Note that adjusting the tuning won't change the key that's played, so it won't take advantage of soundfonts that use different samples for different key ranges and probably won't sound great with such large adjustments. Using the MIDI_EVENT_TRANSPOSE event (which does change the key/sample that's played) instead will probably sound better in this case.

Nicholas

  • Posts: 8
Re: BASSMIDI Master Tuning RPN trouble
« Reply #2 on: 19 Nov '21 - 15:11 »
Hmm, thanks for the quick follow-up.

I should have given a little more context: those messages were just the hammer I was using to test an extreme case to make sure I could hear the difference immediately.  A user wanted to change the tuning from A4=440Hz to something like A4=432Hz, so eventually it'll be more subdued.

For the test I'm sending those six messages sixteen times (modifying the status each time) to all MIDI channels via BASS_MIDI_StreamEvents with (BASS_MIDI_EVENTS_RAW | BASS_MIDI_EVENTS_NORSTATUS).  Events sent afterward (via the same StreamEvents code) play just fine... but with the default master tuning.

Are there any configuration settings I may have inadvertently set that might disable tuning?  Thanks again!

Ian @ un4seen

  • Administrator
  • Posts: 23980
Re: BASSMIDI Master Tuning RPN trouble
« Reply #3 on: 19 Nov '21 - 16:58 »
No, there aren't any config options that would affect this.

What return values are you getting from the BASS_MIDI_StreamEvents calls? If you send the 6 messages separately then you should get 1 from the "B0, 06, 20" call and 0 from the rest. If you send them all in a single call then that call should return 1. You could also use MIDI_EVENT_COARSETUNE with BASS_MIDI_StreamEvent (or BASS_MIDI_StreamEvents and BASS_MIDI_EVENTS_STRUCT) instead, which will be a bit more efficient as BASSMIDI doesn't need to parse MIDI data then.

Nicholas

  • Posts: 8
Re: BASSMIDI Master Tuning RPN trouble
« Reply #4 on: 19 Nov '21 - 20:03 »
I just got exactly that stream of return values.  (1 for the 3rd message, 0 for the rest.)

... and while I was scrutinizing it in the debugger, I just discovered my own mistake: I was inadvertently sending a MIDI_SYSTEM_GS reset immediately afterward.  Reordering those so the master tuning comes after the reset made it behave exactly as expected.

Sorry for pestering you!  As always, BASS is among my favorite libraries of all time.  Incredible support, the simplest API, and it always does exactly what I'm hoping it will (even when I accidentally tell it to do something I didn't intend).  ;D

Ian @ un4seen

  • Administrator
  • Posts: 23980
Re: [SOLVED] BASSMIDI Master Tuning RPN trouble
« Reply #5 on: 22 Nov '21 - 17:26 »
Good to hear that you've got it working now.

One thing to be aware of when using RPN with non-0 LSB values (supported with RPN 1 and 5) is that the LSB (CC38) currently must immediately follow the MSB (CC6) in the same BASS_MIDI_StreamEvents call. If the LSB (CC38) is sent separately then it will be ignored.

Whenever possible (eg. when you're not forwarding MIDI data to BASSMIDI), I would recommend using the MIDI_EVENT_xxx events instead of raw MIDI data because it's simpler to use and more efficient.