Author Topic: problems and suggestions with bassmidi sfz support  (Read 2745 times)

raygrote

  • Posts: 28
Hi,
Wasn't sure if this was the right place to post these things, but I'm pretty sure it is, as I've tested the things I am mentioning both with the Bassmidi VST plug-in from Falcosoft, and XM Play's midi input plug-in revision 15A. I'll list the things I'm addressing in order from most to least important to me.
1. When making an SFZ that references .wav samples, things seem to work just fine. But with Flac samples, the transpose and tune opcodes don't seem to work. Haven't tried with other formats like wavpack, but this is a major setback for me.
2. Things like loop_mode=loop_sustain don't seem to work, but in soundfonts this behavior is possible so I think this was simply overlooked. While I don't have many things that use it, it is quite handy to have if you want to add release effects to something. What I think loop_mode=loop_sustain does, is play a sample, repeating between the loop start and loop end as it does with loop_continuous. But when a note off is received, it will play the rest of the sample past loop end. Can't remember if it finishes the loop first or not though I suspect it does. I need to test this more with the soundfont format so that I know what to expect with SFZ support. Regardless it doesn't seem to be working at all at present, it treats it as loop_continuous, which I think is default.
3. There seems to be no way to allow mod wheel (CC1) to control anything. In Bassmidi's sound font support, cC1 controls a pitch LFO, but I don't think even that is possible with the SFZ support. In other SFZ players you can link an LFO depth to a midi CC manually but since Basmidi doesn't support this behavior so far as I can tell, I'm not sure how I would do this.
4. If you importa an SFZ that is encoded in UTF8, some opcodes are not recognized (I discovered this by accident.) Not sure if this is documented anywhere, but the Falcosoft VST doesn't mention it and that was the first thing I tested SFZ support in. If this is widely known information, I'll consider it my mistake without hesitation, but it took me a few hours to figure out what was going on with an sFZ that in certain spots just would not do what it was supposed to do.

5. Not sure if all of the supported SFZ opcodes are mapped to soundfont parameters or if some of them are SFZ-specific. I do know the ranges of some of them can be taken to extremes outside the capabilities of a soundfont, which I find really cool. In any case, I've made a short list of all the SFZ opcodes I find myself using a lot with SForzanod and which are pretty standard when looking at SFZ opcode references.
While groups and regions work fine, globals don't seem to be supported, unless I am doing something wrong. I find myself using globals to share settings among several groups, such as an amp envelope or something.
delay=num, sets the region to wait a certain amount of time before it plays (not the same as ampeg_delay).
bend_up=num, bend_down=num, specifies pitch bend range in cents. You can do this with rpn messages, but if an sFZ has it, I think it would be convenient for that range to be used over the default, until an rpn is received.
trigger=(attack/release are the two I use, there are others but the two I specified are most important to me). Attack means a region will play on note on as normal, release means the region will play on a note-off.
If trigger=release is supported, rt_decay=num is useful to allow the release region to decay so that if you're using a decaying instrument, the release can play at a suitable volume depending on how long you hold the note. Num is measured in dB/sec. So, if you use rt_decay=10, and you hold a note for 2.5 seconds, the release sample will play -25dB quieter than it otherwise would.
fil_keytrack=num (same as pitch_keytrack but moves the filter cutoff instead). I'm pretty sure this is centered around C4 by default though fil_keycenter=num can change that.

That about wraps it up. If you're still with me, thanks for reading!

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #1 on: 9 Jan '18 - 13:52 »
1. When making an SFZ that references .wav samples, things seem to work just fine. But with Flac samples, the transpose and tune opcodes don't seem to work. Haven't tried with other formats like wavpack, but this is a major setback for me.

Oops. Here's an update to fix that:

   www.un4seen.com/stuff/bassmidi.zip

2. Things like loop_mode=loop_sustain don't seem to work, but in soundfonts this behavior is possible so I think this was simply overlooked. While I don't have many things that use it, it is quite handy to have if you want to add release effects to something. What I think loop_mode=loop_sustain does, is play a sample, repeating between the loop start and loop end as it does with loop_continuous. But when a note off is received, it will play the rest of the sample past loop end. Can't remember if it finishes the loop first or not though I suspect it does. I need to test this more with the soundfont format so that I know what to expect with SFZ support. Regardless it doesn't seem to be working at all at present, it treats it as loop_continuous, which I think is default.

"loop_mode=loop_sustain" should be supported. I just did a quick test to check, and it seemed to be working. Can you provide an example SFZ+WAV to reproduce the problem with?

3. There seems to be no way to allow mod wheel (CC1) to control anything. In Bassmidi's sound font support, cC1 controls a pitch LFO, but I don't think even that is possible with the SFZ support. In other SFZ players you can link an LFO depth to a midi CC manually but since Basmidi doesn't support this behavior so far as I can tell, I'm not sure how I would do this.

CC1 can be manually set (via the MIDI_EVENT_MOD_FILTER/PITCH/VIBRATO/VOLUME events) to affect filter cutoff, pitch, vibrato depth, and volume.

4. If you importa an SFZ that is encoded in UTF8, some opcodes are not recognized (I discovered this by accident.) Not sure if this is documented anywhere, but the Falcosoft VST doesn't mention it and that was the first thing I tested SFZ support in. If this is widely known information, I'll consider it my mistake without hesitation, but it took me a few hours to figure out what was going on with an sFZ that in certain spots just would not do what it was supposed to do.

I think the only thing that UTF-8 would really affect is the sample filenames. UTF-8 filenames are supported by BASSMIDI on other platforms, but not on Windows currently. The update above should add support for UTF-8 filenames. Let me know if you still have UTF-8 issues with it.

5. Not sure if all of the supported SFZ opcodes are mapped to soundfont parameters or if some of them are SFZ-specific. I do know the ranges of some of them can be taken to extremes outside the capabilities of a soundfont, which I find really cool. In any case, I've made a short list of all the SFZ opcodes I find myself using a lot with SForzanod and which are pretty standard when looking at SFZ opcode references.
While groups and regions work fine, globals don't seem to be supported, unless I am doing something wrong. I find myself using globals to share settings among several groups, such as an amp envelope or something.
delay=num, sets the region to wait a certain amount of time before it plays (not the same as ampeg_delay).
bend_up=num, bend_down=num, specifies pitch bend range in cents. You can do this with rpn messages, but if an sFZ has it, I think it would be convenient for that range to be used over the default, until an rpn is received.
trigger=(attack/release are the two I use, there are others but the two I specified are most important to me). Attack means a region will play on note on as normal, release means the region will play on a note-off.
If trigger=release is supported, rt_decay=num is useful to allow the release region to decay so that if you're using a decaying instrument, the release can play at a suitable volume depending on how long you hold the note. Num is measured in dB/sec. So, if you use rt_decay=10, and you hold a note for 2.5 seconds, the release sample will play -25dB quieter than it otherwise would.
fil_keytrack=num (same as pitch_keytrack but moves the filter cutoff instead). I'm pretty sure this is centered around C4 by default though fil_keycenter=num can change that.

I will look into these. If you can provide any examples of the opcodes in use, that would be helpful for testing.

raygrote

  • Posts: 28
Re: problems and suggestions with bassmidi sfz support
« Reply #2 on: 10 Jan '18 - 12:13 »
Hi Ian, thanks for the reply and the update! I'll try it soon and get back to you.
I think I have an sfz that's in UTF8 where the looping didn't work properly because there was a strange character in the loop_mode opcodes that wasn't visible in Notepad, but in a hex editor I found it. I'll double check that and send it to you to look at. How should I upload things?

I'll have a look at what you said about the mod wheel stuff and see what I come up with. Also an example of some of the opcodes I mentioned can be found in the Salamander Grand Piano. That at least uses trigger=release and rt_decay. It's been a while since I looked at it so there may be more, but I know it has those two.

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #3 on: 10 Jan '18 - 17:05 »
I think I have an sfz that's in UTF8 where the looping didn't work properly because there was a strange character in the loop_mode opcodes that wasn't visible in Notepad, but in a hex editor I found it. I'll double check that and send it to you to look at. How should I upload things?

Oh, that sounds like a bad/corrupt SFZ file then. It probably wouldn't work properly with any software. You can upload the files via FTP here:

   ftp.un4seen.com/incoming/

raygrote

  • Posts: 28
Re: problems and suggestions with bassmidi sfz support
« Reply #4 on: 24 Apr '18 - 01:05 »
Sorry for leaving this topic dead. I've been meaning to post, but life got busy and I haven't had a lot of time to mess with many things I'd like to mess with :)

1. When making an SFZ that references .wav samples, things seem to work just fine. But with Flac samples, the transpose and tune opcodes don't seem to work. Haven't tried with other formats like wavpack, but this is a major setback for me.

Oops. Here's an update to fix that:

   www.un4seen.com/stuff/bassmidi.zip
Thanks, the update works! It seems to be a newer version than the bassmidi version on this site though. Is this a test release or something?

"loop_mode=loop_sustain" should be supported. I just did a quick test to check, and it seemed to be working.
It works here too, I just tested with the updated Bassmidi. Maybe something was broken in the old one that came with the vst, since it is I think a few months out of date. Or maybe I forgot to put in a suitable "ampeg_release" value, which I sometimes forget to do, but I'm sure I would've thought of that at least once before posting here. In any case, it's working now.

CC1 can be manually set (via the MIDI_EVENT_MOD_FILTER/PITCH/VIBRATO/VOLUME events) to affect filter cutoff, pitch, vibrato depth, and volume.
I don't remember hearing about these opcodes. How do you set them up? For example the vibrato speed, and the cc1 to vibrato amount if that can be set? I just tried "MIDI_EVENT_MOD_VIBRATO=50" and even with a pitch LFO set up, I don't hear a difference when sending CC1 out. I'm probably doing something wrong though.

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #5 on: 24 Apr '18 - 15:01 »
CC1 can be manually set (via the MIDI_EVENT_MOD_FILTER/PITCH/VIBRATO/VOLUME events) to affect filter cutoff, pitch, vibrato depth, and volume.
I don't remember hearing about these opcodes. How do you set them up? For example the vibrato speed, and the cc1 to vibrato amount if that can be set? I just tried "MIDI_EVENT_MOD_VIBRATO=50" and even with a pitch LFO set up, I don't hear a difference when sending CC1 out. I'm probably doing something wrong though.

They aren't SFZ opcodes but rather MIDI events, which can be applied via BASS_MIDI_StreamEvent (and sysex messages in MIDI files). For example, you could set the CC1 to vibrato depth on channel 1 like this:

Code: [Select]
BASS_MIDI_StreamEvent(handle, 0, MIDI_EVENT_MOD_VIBRATO, 50);

Note MIDI_EVENT_MOD_VIBRATO defaults to 64, so you may not hear much of a difference with it set to 50.

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #6 on: 7 Sep '18 - 00:04 »
Hello,

MIDI_EVENT_CUTOFF and MIDI_EVENT_RESONNANCE works for SF2, but does not seems to with with SFZ

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #7 on: 7 Sep '18 - 14:29 »
Those events do apply to SFZ too, but perhaps the SFZ file that you're testing with doesn't have a "cutoff" setting? That disables filtering.

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #8 on: 7 Sep '18 - 15:08 »
As many sfz files does not have any cutoff settings, I think it is a good idea to set a default cutoff value in this case.
Most of hardware synths reacts to the cut off midi message, unless it is voluntary disabled.
I can see that >ADSR  , fine tune, expression etc.... works even without any settings in the file

I just see from the sfz spec that no cutoff=  mean filter disabled (to save cpu)
maybe better to do, if no cutoff= is defined in the sfz file : 
if MIDI_EVENT_CUTOFF =64 or no MIDI_EVENT_CUTOFF  sent then > no filter applied
but if the MIDI_EVENT_CUTOFF is voluntary changed, we should apply a filter, as most of the GM synths react to the CC74



I am not an sfz expert, so I let the other  experts here to tell me if I am wrong ??

If this idea is accepted, we can think what should be the best filter type and freq  for a default value (the ones from the SF2 engine does not sound enough good to my ear)

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #9 on: 7 Sep '18 - 17:32 »
The issue is that the MIDI_EVENT_CUTOFF event is a relative setting rather than an absolute setting, ie. it modifies an existing cutoff value. So if the SFZ file doesn't have a cutoff value then there's nothing for it to modify. I suppose some default cutoff value could be applied in that case.

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #10 on: 7 Sep '18 - 17:46 »
yes. What is the current rule for the SF2 and bassmidi ?

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #11 on: 7 Sep '18 - 18:07 »
SF2 always defines a cutoff value. Here's an update for you to try, which defaults to 13500 Hz for SFZ:

   www.un4seen.com/stuff/bassmidi.zip

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #12 on: 7 Sep '18 - 18:48 »
Yes it works !

Wow, so in fact I understand now, that all my SF2 sounds are in fact limited to 13500 Hz? as this is the default value?
I thought it was 20000 hz :)

So now, I understand more the default SF2 modulator . this allow you to go up to 15900 Hz ? when you press key harder, as it is actually 13500.  Right? :)

Quote
8.4.2 MIDI Note-On Velocity to Filter Cutoff
Source Enumeration = 0x0102 (type=0, P=0, D=1, CC=0, index = 2)
Destination Enumeration = Initial Filter Cutoff
Amount = -2400 Cents
Amount Source Enumeration = 0x502 (type=3, P=0, D=1, CC=0, index=2)
Transform Enumeration = 0 (Linear)
The MIDI key number is used as a Negative Unipolar source; thus the input value of 1 is mapped to a
value of 127/128, an input value of 127 is mapped to 0 and all other values are mapped between 127/128
and 1 in a linear fashion. The MIDI velocity number is also used as a secondary source for this
modulator; it is a negative unipolar switch. This has the effect of turning off velocity-to-filter for velocity
numbers less than 64. The amount of this modulator is -2400 Cents. Note that the MIDI specification is
such that a note-on velocity amount of zero indicates a note-off, thus it is not considered in this
modulator.
SoundFont 2.01 Technical Specification - Page 54 - 08/05/98 12:43 PM
The product of these values is passed through a Linear Transform (or is left uninhibited) and is added to
the Initial Filter Cutoff generator summing node.

I know that you once did it in the beta version, then removed. Maybe now that i understand the goal of this, it may be interesting to put it back so I can listen well




Also, most hardware synth use a Low pass filter of 24dB Slope (4-pole)
What is the case of Bassmidi?

I can see in the graphical of the SF2 spec it is 12db per octave, but it is not explicitly writen in the specs, and can be depending on the synth implementation

Maybe you can add a global option for a 24 db per octave for the SF2 and SFZ engine , as default ?

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #13 on: 9 Sep '18 - 18:11 »
The mod wheel does not work with SFZ files
I think it should work as default, like with SF2 , if no cc1 things are defined in the sfz file

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #14 on: 10 Sep '18 - 16:19 »
Wow, so in fact I understand now, that all my SF2 sounds are in fact limited to 13500 Hz? as this is the default value?
I thought it was 20000 hz :)

The default 13500 Hz cutoff is a bit misleading. The filter used by Creative/Soundblaster (and BASSMIDI too) actually only takes effect when the cutoff is below 1/6th of the output rate, eg. up to 8000 Hz when the output is 48000 Hz. So 13500 Hz and 20000 Hz are likely to have the same effect, ie. no effect :)

Quote
8.4.2 MIDI Note-On Velocity to Filter Cutoff
Source Enumeration = 0x0102 (type=0, P=0, D=1, CC=0, index = 2)
Destination Enumeration = Initial Filter Cutoff
Amount = -2400 Cents
Amount Source Enumeration = 0x502 (type=3, P=0, D=1, CC=0, index=2)
Transform Enumeration = 0 (Linear)
The MIDI key number is used as a Negative Unipolar source; thus the input value of 1 is mapped to a
value of 127/128, an input value of 127 is mapped to 0 and all other values are mapped between 127/128
and 1 in a linear fashion. The MIDI velocity number is also used as a secondary source for this
modulator; it is a negative unipolar switch. This has the effect of turning off velocity-to-filter for velocity
numbers less than 64. The amount of this modulator is -2400 Cents. Note that the MIDI specification is
such that a note-on velocity amount of zero indicates a note-off, thus it is not considered in this
modulator.
SoundFont 2.01 Technical Specification - Page 54 - 08/05/98 12:43 PM
The product of these values is passed through a Linear Transform (or is left uninhibited) and is added to
the Initial Filter Cutoff generator summing node.

I know that you once did it in the beta version, then removed. Maybe now that i understand the goal of this, it may be interesting to put it back so I can listen well

That modulator is supported in the current BASSMIDI release (actually since 2.4.10).

Also, most hardware synth use a Low pass filter of 24dB Slope (4-pole)
What is the case of Bassmidi?

I can see in the graphical of the SF2 spec it is 12db per octave, but it is not explicitly writen in the specs, and can be depending on the synth implementation

BASSMIDI emulates the Creative/Soundblaster filter, which is indeed 12dB per octave.

The mod wheel does not work with SFZ files
I think it should work as default, like with SF2 , if no cc1 things are defined in the sfz file

Indeed, the mod wheel currently has no effect on SFZ. I'm not sure if there's an SFZ equivalent of the SF2 "freqVibLFO" setting. I'll look into it.

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #15 on: 12 Sep '18 - 18:53 »
From SF2 doc :
Default rate is 8.176 Hz    I think it is ok to take the same behavior for sfz, unless it is defined something else

Quote
8.4.4 MIDI Continuous Controller 1 to Vibrato LFO Pitch Depth
Source Enumeration = 0x0081 (type=0, P=0, D=0, CC=1, index = 1)
Destination Enumeration = Vibrato LFO to Pitch
Amount = 50
Amount Source Enumeration = 0x0 (No controller)
Transform Enumeration = 0 (Linear)
SoundFont 2.01 Technical Specification - Page 43 - Printed 12/10/1996 5:57 PM
The MIDI Continuous Controller 1 data value is used as a Positive Unipolar source; thus the input value of 0 is mapped to a
value of 0, an input value of 127 is mapped to 127/128 and all other values are mapped between 0 and 127/128 in a linear
fashion. The MIDI Continuous Controller 33 data value may be optionally used for increased resolution of the controller
input.
There is no secondary source for this modulator; thus its effect is the same as the effect of multiplying the amount by 1.
The amount of this modulator is 50 cents/max excursion of vibrato modulation.
The product of these values is passed through a Linear Transform (or is left uninhibited) and is added to the Vibrato LFO to
Pitch generator summing node.

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #16 on: 21 Sep '18 - 13:32 »
Here's an update for you to try:

   www.un4seen.com/stuff/bassmidi.zip

SFZ doesn't have a separate vibrato LFO like SF2 does. Instead, the mod wheel can modify the pitch LFO, which this update adds support for. The pitchlfo_freq opcode's default value is also changed to 8.176 (instead of 0), so that CC1 should have some vibrato effect by default.

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #17 on: 23 Sep '18 - 16:09 »
Nice It is working ! LFO Rate seems the same. Not sure if it is the same depth as the SF2 when we are at value 127

By the way, can you do the same by default to plug the channel aftertouch to the same vibrato , like with the SF2

And I am also using this

BASS_MIDI_StreamEvent(_midiStream, i, MIDI_EVENT_KEYPRES_VIBRATO, 64)

So if you can do the same with the key aftertouch if you receive this message?

Then the synth will react the same when using SF2 or SFZ

Then anyone will adjust values on the SFZ files, if they want other things

Thank you !

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #18 on: 24 Sep '18 - 13:07 »
Nice It is working ! LFO Rate seems the same. Not sure if it is the same depth as the SF2 when we are at value 127

The effect of the mod wheel is added to the instrument's own vibrato depth setting (vibLfoToPitch in SF2 and pitchlfo_depth in SFZ), so the final vibrato depth can be different with different instruments.

By the way, can you do the same by default to plug the channel aftertouch to the same vibrato , like with the SF2

And I am also using this

BASS_MIDI_StreamEvent(_midiStream, i, MIDI_EVENT_KEYPRES_VIBRATO, 64)

So if you can do the same with the key aftertouch if you receive this message?

Channel and key pressure should already work the same with SFZ as with SF2. Are you sure they don't?

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #19 on: 25 Sep '18 - 21:05 »
They don't.
I don't have vibrato with SFZ instruments when I play aftertouch on my keyboard and send this event to bassmidi
But I have them with SF2

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: problems and suggestions with bassmidi sfz support
« Reply #20 on: 26 Sep '18 - 16:24 »
That's strange. I tried channel and key pressure with SFZ files just now, and both were working. Are you using the BASSMIDI update posted above? It will be needed for channel and key pressure (along with the mod wheel) to affect vibrato with SFZ files. If vibrato modification still isn't working, what about pitch modification? (enabled via the MIDI_EVENT_CHANPRES_PITCH and MIDI_EVENT_KEYPRES_PITCH events)

rv

  • Posts: 249
Re: problems and suggestions with bassmidi sfz support
« Reply #21 on: 27 Sep '18 - 09:20 »
I am sorry, you are right, finally aftertouch seems to work too... with the latest bassmidi and sfz