Author Topic: MIDI_EVENT_PITCHRANGE  (Read 1189 times)

BassUser

  • Posts: 121
MIDI_EVENT_PITCHRANGE
« on: 7 Oct '12 - 11:49 »
Hi.
I am evaluating Bass/BassMidi/BassAsio via Bass.NET and C#

As far as I understand MIDI_EVENT_PITCHRANGE should set the pitch wheel range in semitones.

Unfortunately a value of 12 semitones results in a 2 octaves bending up/down range - or 4 octaves in total. The basic pitch with bending set to  +/- 0 changes dramatically either - compared to setting pitch range to zero.

Is this a bug or do I need to set the value differently from what I currently do:

   BassMidi.BASS_MIDI_StreamEvent(hMidiStream, ch, BASSMIDIEvent.MIDI_EVENT_PITCHRANGE, 12);

Best regards, BassUser
« Last Edit: 8 Oct '12 - 09:07 by BassUser »

BassUser

  • Posts: 121
Re: MIDI_EVENT_PITCHRANGE
« Reply #1 on: 7 Oct '12 - 12:20 »
Hi.
This fix seems to cure at least the pitch wheel range issue - but are parameters intended that way???

   byte d1 = (byte)(data2 / 2);
   byte d2 = (byte)(data2 % 2 * 64);
   BassMidi.BASS_MIDI_StreamEvent(hMidiStream, ch, BASSMIDIEvent.MIDI_EVENT_PITCHRANGE, d1, d2);


best regards, BassUser

BassUser

  • Posts: 121
Re: MIDI_EVENT_PITCHRANGE
« Reply #2 on: 8 Oct '12 - 09:05 »
Hi.
The above fix does not address the allover pitch shift I mentioned when applying MIDI_EVENT_PITCHRANGE...

I've found another fix that seems to cure this most of the time...

   BassMidi.BASS_MIDI_StreamEvent(hMidiStream, ch, BASSMIDIEvent.MIDI_EVENT_COARSETUNE, (byte)(64 - d1), 0);

For odd pitch shift ranges I even would need a fine tune adjustment... All this will make normal use of course/fine tuning in a channel cumbersome as it needs to combine tuning offsets...

To be honest - all this looks quite odd. Is there a bug or do I interpret MIDI_EVENT_PITCHRANGE wrong and need more information?

BassUser

Ian @ un4seen

  • Administrator
  • Posts: 22033
Re: MIDI_EVENT_PITCHRANGE
« Reply #3 on: 8 Oct '12 - 15:39 »
The MIDI_EVENT_PITCHRANGE setting in your original post looks correct. Please also confirm how you're using the MIDI_EVENT_PITCH event. Perhaps you're expecting 0 to be the pitch wheel's normal/middle position? If so, that is not the case: 8192 = normal, 0 = -pitchrange, 16383 = +pitchrange.

BassUser

  • Posts: 121
Re: MIDI_EVENT_PITCHRANGE
« Reply #4 on: 8 Oct '12 - 17:05 »
Hi.
Thanks a lot for your response.  ;)

It looks like I fell over an issue with the Bass .NET API...

Your point with MIDI_EVENT_PITCH was somehow right - also I am aware of the 8192 centered zero value which was not the problem...

It seems like BASS .NET call with split 14 bit values does not work as I expected...

  BassMidi.BASS_MIDI_StreamEvent(hMidiStream, ch,
      BASSMIDIEvent.MIDI_EVENT_PITCH, data1, data2);


Calculating the 14bit value with my own routine and passing it as single value worked.

  BassMidi.BASS_MIDI_StreamEvent(hMidiStream, ch,
      BASSMIDIEvent.MIDI_EVENT_PITCH, Midi.Data14.Value14(data2, data1) );


Sometimes little things can drive you nuts...  :P

BassUser

radio42

  • Posts: 4659
Re: MIDI_EVENT_PITCHRANGE
« Reply #5 on: 8 Oct '12 - 20:00 »
If you are using the "bool BASS_MIDI_StreamEvent(int handle, int chan, BASSMIDIEvent eventtype, byte loParam, byte hiParam)" overload, this performs the following internally:
Code: [Select]
return BASS_MIDI_StreamEvent(handle, chan, eventtype, Utils.MakeWord(loParam, hiParam));As such the "Utils.MakeWord" is called to construct the Int16 value (as expected by the native "BASS_MIDI_StreamEvent" call).

"Utils.MakeWord" does the following:
Code: [Select]
return (short)((highByte << 8) | lowByte)

BassUser

  • Posts: 121
Re: MIDI_EVENT_PITCHRANGE
« Reply #6 on: 9 Oct '12 - 09:13 »
Hi.
Thanks for this hint - I'll keep that in mind.  8)