Author Topic: Synth Engine update for more SoundFont support  (Read 26438 times)

QuentinC

  • Posts: 50
Re: Synth Engine update for more SoundFont support
« Reply #25 on: 1 Jun '14 - 17:25 »
Hello,

As we are talking about MIDI and SF2, can we hope at some point the support of
1 - The ability to send delayed MIDI messages / message that will occur in the future (take into account the tick parameter when sending messages using BASS_MIDI_StreamEvents)
2 - Support of controllers 76 and 77 (vibrato rate, vibrato delay). I think it's in GM2 standard (to be verified)
3 - Aftertouch support or at least the possibility to intercept them with BASS_ChannelSetSync. By default redirect to controller 1 or 71+74.
4 - I know that documentation is annoying to write, but +1 to list all SF2 parameters supported, as well as all MIDI controllers supported and their effect if it isn't obvious. At the moment I have determined that the following MIDI controllers are supported: 0, 1, 5, 6, 7, 10, 11, 32, 64, 65, 71, 72, 73, 74, 84, 91, 93, 98, 99, 100, 101, 121, 123.

The #1 would be great. I think it can be very useful if you want to send multiple additionnal notes over a playing song (a chord or a small rythmic pattern) when pressing a single key, without issues to stay in sync with the song, without the need for home-made threading just to send a few messages at the right exact moment, etc.

Three others are pure bonus. But since BASS MIDI is already a very good all purpose MIDI player, these are just some general suggestions to make it even better if you wish. Thank you anyway for this great MIDI playing API.

rv

  • Posts: 319
Re: Synth Engine update for more SoundFont support
« Reply #26 on: 2 Jun '14 - 07:57 »
I suggest to add #2:
From GM2 spec : http://www.midi.org/techspecs/gm.php

- Decay Time (cc#75) (new message)
- Vibrato Rate (cc#76) (new message)
- Vibrato Depth (cc#77) (new message)
- Vibrato Delay (cc#78) (new message)

Ian @ un4seen

  • Administrator
  • Posts: 22852
Re: Synth Engine update for more SoundFont support
« Reply #27 on: 3 Jun '14 - 15:11 »
1 - The ability to send delayed MIDI messages / message that will occur in the future (take into account the tick parameter when sending messages using BASS_MIDI_StreamEvents)

I'll have to think about it. One issue that immediately comes to mind is that MIDI streams created via BASS_MIDI_StreamCreate aren't tick-based, eg. they don't have a PPQN value. So the delay would probably need to be byte-based, eg. using the "pos" BASS_MIDI_EVENT member rather than "tick".

2 - Support of controllers 76 and 77 (vibrato rate, vibrato delay). I think it's in GM2 standard (to be verified)

The question is how much should the vibrato rate/delay be affected by those controllers? The same goes for #75 and #78. I don't think I've seen any standard definitions for them.

3 - Aftertouch support or at least the possibility to intercept them with BASS_ChannelSetSync. By default redirect to controller 1 or 71+74.

Are you referring to per-channel or per-key pressure/aftertouch, or both? Channel pressure/aftertouch is supported (MIDI_EVENT_CHANPRES), and it can be routed to any combination of filter/pitch/vibrato/volume (MIDI_EVENT_CHANPRES_FILTER/PITCH/VIBRATO/VOLUME). Key pressure/aftertouch isn't currently supported, but I'll add that for the next release with the same routing options.

4 - I know that documentation is annoying to write, but +1 to list all SF2 parameters supported, as well as all MIDI controllers supported and their effect if it isn't obvious. At the moment I have determined that the following MIDI controllers are supported: 0, 1, 5, 6, 7, 10, 11, 32, 64, 65, 71, 72, 73, 74, 84, 91, 93, 98, 99, 100, 101, 121, 123.

A list of supported controllers (and RPN) can be found in the BASS_MIDI_StreamEvent documentation. It is what you have deduced above plus 38, 67, 120, 126, 127.

QuentinC

  • Posts: 50
Re: Synth Engine update for more SoundFont support
« Reply #28 on: 3 Jun '14 - 16:59 »
Quote
I'll have to think about it. One issue that immediately comes to mind is that MIDI streams created via BASS_MIDI_StreamCreate aren't tick-based, eg. they don't have a PPQN value. So the delay would probably need to be byte-based, eg. using the "pos" BASS_MIDI_EVENT member rather than "tick".

As long as there is a way to easily convert back and forth between bytes and ticks, it wouldn't be a big problem.

From there, I see the problem you have: IN order to convert ticks into time, I need current tempo and current resolution. I can already get the current tempo with BASS_MIDI_StreamGetEvent function (event type BASS_MIDI_TEMPO). However BASS_ATTRIB_MIDI_PPQN will have to be updated to return the correct value instead of 0 (e.g. 480). It a priori just requires to store the value somewhere.

By simplicity, I think we can assume that the tempo wont change between the time the function is called and the time the events have to be effectively played.

Remains to define what to do in case of seeking: will the delayed events sent  be permanently stored in the sequence and thus played again when seeking backwards, or be discarded once played. The two points of views are defendable.

Quote
The question is how much should the vibrato rate/delay be affected by those controllers? The same goes for #75 and #78. I don't think I've seen any standard definitions for them.

Is there a clear deffinition on how much the envelope attack/release phase duration are affected by CC72 and 73 ? same question for portamento time, and filters.

I suppose the answer is no, otherwise all MIDI players would tend to sound exactly the same given they are using the same banks with the same parameters. I personnally never saw two different MIDI players using identical sequence and banks sounding exactly the same...

Quote
Are you referring to per-channel or per-key pressure/aftertouch, or both? Channel pressure/aftertouch is supported (MIDI_EVENT_CHANPRES), and it can be
routed to any combination of filter/pitch/vibrato/volume (MIDI_EVENT_CHANPRES_FILTER/PITCH/VIBRATO/VOLUME). Key pressure/aftertouch isn't currently supported, but I'll add that for the next release with the same routing options.

Yes, I talk about per key aftertouch/pressure. If there could be the same options as for channel pressure, it's nice !


Quote
A list of supported controllers (and RPN) can be found in the BASS_MIDI_StreamEvent documentation. It is what you have deduced above plus 38, 67, 120,
126, 127.

OK, Thank you. I should have seen it before, sorry.

QuentinC

  • Posts: 50
Re: Synth Engine update for more SoundFont support
« Reply #29 on: 4 Jun '14 - 17:10 »
I have got another idea, probably a much simpler one than the others: why not add a new event type BASS_MIDI_EVENT_NRPN, which would allow syncing on and sending custom NRPNs ?
data/parameter: LOWORD = parameter value (0-16383), HIWORD = type of parameter (0-16383).

I wanted to put some BASS FX from bass_Fx.dll to a given MIDI channel, and be able to control parameters of the FX via MIDI messages. 127 values is a too short range and that's basicly the reason why RPN and NRPN have been invented.

I tried to sync for custom controls (MIDI_EVENT_CONTROL), but relevant controllers (98, 99, 100, 101, 6, 38) don't even trigger the sync callback. Hance the idea.

What do you think?

Useful thing for a sampler...


Ian @ un4seen

  • Administrator
  • Posts: 22852
Re: Synth Engine update for more SoundFont support
« Reply #30 on: 5 Jun '14 - 16:09 »
Quote
The question is how much should the vibrato rate/delay be affected by those controllers? The same goes for #75 and #78. I don't think I've seen any standard definitions for them.

Is there a clear deffinition on how much the envelope attack/release phase duration are affected by CC72 and 73 ? same question for portamento time, and filters.

I suppose the answer is no, otherwise all MIDI players would tend to sound exactly the same given they are using the same banks with the same parameters. I personnally never saw two different MIDI players using identical sequence and banks sounding exactly the same...

The question remains though: how should BASSMIDI handle them? :)

Are the MIDI_EVENT_RELEASE/ATTACK (cc#72/73) events working well? If so, I guess the same processing could be applied to a MIDI_EVENT_DECAY (cc#75) event.

I have got another idea, probably a much simpler one than the others: why not add a new event type BASS_MIDI_EVENT_NRPN, which would allow syncing on and sending custom NRPNs ?
data/parameter: LOWORD = parameter value (0-16383), HIWORD = type of parameter (0-16383).

I wanted to put some BASS FX from bass_Fx.dll to a given MIDI channel, and be able to control parameters of the FX via MIDI messages. 127 values is a too short range and that's basicly the reason why RPN and NRPN have been invented.

I tried to sync for custom controls (MIDI_EVENT_CONTROL), but relevant controllers (98, 99, 100, 101, 6, 38) don't even trigger the sync callback. Hance the idea.

Due to the way that event sequences (eg. read from a MIDI file) are retained internally by BASSMIDI, per-channel event parameters are limited to 21 bits, so a MIDI_EVENT_NRPN event unfortunately isn't possible, as it would need 28 bits (14 for the NRPN number + 14 for its parameter). But if you're looking to use your own custon NRPN, couldn't you just pick any 4 unused controllers (perhaps 2 would suffice) to implement them (via a MIDI_EVENT_CONTROL sync), ie. there's no need to use the standard NRPN controllers for it?

Ian @ un4seen

  • Administrator
  • Posts: 22852
Re: Synth Engine update for more SoundFont support
« Reply #31 on: 6 Jun '14 - 15:42 »
Here's an update that includes support for key pressure/aftertouch...

   www.un4seen.com/stuff/bassmidi.zip

These are the new events...

Code: [Select]
#define MIDI_EVENT_KEYPRES 71
#define MIDI_EVENT_KEYPRES_VIBRATO 72
#define MIDI_EVENT_KEYPRES_PITCH 73
#define MIDI_EVENT_KEYPRES_FILTER 74
#define MIDI_EVENT_KEYPRES_VOLUME 75

MIDI_EVENT_KEYPRES sets a key's pressure level (LOBYTE = key, HIBYTE = pressure). MIDI_EVENT_KEYPRES_VIBRATO/PITCH/FILTER/VOLUME work the same way as MIDI_EVENT_CHANPRES_VIBRATO/PITCH/FILTER/VOLUME (see the BASS_MIDI_StreamEvent documentation for details), and can also be accessed via the corresponding GM2/GS/XG sysex messages.

This update also adds a MIDI_EVENT_DECAY event for cc#75, which afffects the decay time in the same way as MIDI_EVENT_RELEASE/ATTACK affect the release/attack times...

Code: [Select]
#define MIDI_EVENT_DECAY 29

Please report any problems.

QuentinC

  • Posts: 50
Re: Synth Engine update for more SoundFont support
« Reply #32 on: 10 Jun '14 - 10:53 »
Key pressure seems to work correctly, thank you !
I didn't tested yet cc75.

Questions/toughts:
1 - It might be useful to enter MIDI_KEYPRES_PITCH in 10th of semitone instead of semitones, i.e. between 0 and 240 instead of 0 to 24. 1 semitone is sometimes already a lot.
2 - I don't know if it's intentional, nor if it has to be so or not, but by default, key pressure does nothing before you set MIDI_KEYPRES_VIBRATO/PITCH/FILTER/VOLUME or send corresponding messages

Ian @ un4seen

  • Administrator
  • Posts: 22852
Re: Synth Engine update for more SoundFont support
« Reply #33 on: 10 Jun '14 - 15:39 »
Good to hear that the key pressure events are working fine. Regarding your questions, I believe the current behaviour matches the GM2/GS/XG specs: key pressure does nothing by default and the maximum pitch change is set in semitones. Note it defines the maximum pitch change and smaller changes are possible via the key pressure... pitch change = max pitch change * pressure / 127.

By the way, another little addition in the update above that I forgot to mention is that it's now possible to have up to 65536 presets per bank. Soundfonts can be assigned to preset numbers above 127 (up to 65535) via BASS_MIDI_StreamSetFonts, which can then be accessed via MIDI_EVENT_PROGRAM events.

rv

  • Posts: 319
Re: Synth Engine update for more SoundFont support
« Reply #34 on: 10 Jun '14 - 19:25 »
Now that you improved BassMidi so much...

I have asked something, and I am sure many people want this !

If it's possible to add a 3rd vst FX  (like xg on cc94).

Just copy the code from chorus, and paste to fx3 :)

This does not have any implication on soundfonts part like reverb & chorus sends

QuentinC

  • Posts: 50
Re: Synth Engine update for more SoundFont support
« Reply #35 on: 11 Jun '14 - 07:09 »
Quote
I have asked something, and I am sure many people want this !
If it's possible to add a 3rd vst FX  (like xg on cc94).

Unless you mean replacing completely the current behavior off cc74, you can already add 3rd effects by adding a DSP/FX on a MIDI channel and sincing on a custom cc to make parameters of the effect vary over time.

If I don't make any misstake, 3rd/custom/special effects in XG are on cc70; cc74 always remains for standard filter cutoff.
You can also use cc 3, 4, 9, 12-31 and their +32 LSB.

I will experiment with this possibility when I have time. I don't know if it really works, and if delay between the interception of the cc command and actual hearing of the result is acceptable.

Perhaps the possibility of setting up any bass_fx effect automatically (or why not some VST registered in advance) based on some custom marker message could be interesting (the best would be to handle custom sysex but code to intercept markers already exists, so Yann would have nothing to do).

Anyway, it opens many interesting possibilities to MIDI composition/sequencing;

Remains a curiosity: the state of  possible channels beyond the 16th. Currently, as I understand it, it's impossible to load MIDI files with more than 16 channels because of obvious reason (the format doesn't support it), but it's also impossible to create a sequence with more than 16 channels using BASS_MIDI_StreamCreateEvents. So the only current possible use of these additionnal channels is for real time.

rv

  • Posts: 319
Re: Synth Engine update for more SoundFont support
« Reply #36 on: 11 Jun '14 - 10:06 »
No. I need Ian to add this 3rd FX because I want to load only ONE effect for all the midi channels.
And send an amount for every channel.

I can't do it without Ian adding it.

The 3rd FX is CC94 on Yamaha XG.

I want to use it mostly for the Delay FX.

Once the delay it is set on the song tempo, I don't want to load many FX on every track for CPU reasons and because it need to adjust it to the tempo on every channel ...

Ian @ un4seen

  • Administrator
  • Posts: 22852
Re: Synth Engine update for more SoundFont support
« Reply #37 on: 11 Jun '14 - 17:55 »
I'll look into it.

kinwie

  • Posts: 21
Re: Synth Engine update for more SoundFont support
« Reply #38 on: 22 Jun '14 - 08:28 »
I read the CCs above, is that mean we set the CC inside the SF2 (modulator)? or via BASSMIDI configuration?
Sorry I'm lack of knowledge about this.

Ian @ un4seen

  • Administrator
  • Posts: 22852
Re: Synth Engine update for more SoundFont support
« Reply #39 on: 23 Jun '14 - 17:07 »
The CC values can be read from MIDI files and/or applied via BASS_MIDI_StreamEvent(s) calls. A list of supported CC numbers can be found in the BASS_MIDI_StreamEvent documentation.