Bassmidi: Sysex tuning support

Started by Karl Eick,

Karl Eick

Hello all,
From what I can see, Bassmidi doesn't support changing the tuning via Sysex messages. I would love this feature because it would make playing microtonal Midis much easier, and I wouldn't need to use Timidity because it's old and does not work on ARM.
Thanks in advance!

Ian @ un4seen

BASSMIDI does include support for the standard "MIDI Tuning Scale/Octave Extensions" sysex, as described here:

    https://midi.org/midi-tuning-updated-specification

The equivalent Yamaha XG and Roland GS sysex are also supported.

Karl Eick

Oh, that's interesting! You see, I'm using Cool Soft Virtual Midi Synth, which uses the bass libraries, and it does not respond to sysex files correctly, like you can create with sevish.com/scaleworkshop. In Timidity, they operate with no problems. So, it's an issue with Virtual Midi Synth then?

Ian @ un4seen

That webpage is generating "Bulk Tuning Dump" sysex, which has tuning for every key. BASSMIDI doesn't currently support that but rather the "Scale/Octave Tuning" sysex, which has tuning adjustment for 12 keys applied to every octave. Will the latter work for your purposes or do you absolutely need the former?

Karl Eick

Ah, that explains it! The former would be better, because to my knowledge, for achieving things like 17 TET, that's the only way that would work.

Ian @ un4seen

OK. I'll check next week if support for the "Bulk Tuning Dump" sysex can be added, and hopefully come back with an update for you to try.


Ian @ un4seen

Do you have any MIDI files that use the "Bulk Tuning Dump" sysex? If so, please upload (or link) them for reference. They can be uploaded here:

    ftp://ftp.un4seen.com/incoming/

I'm mostly interested in seeing what tuning program numbers are used. The spec states that 128 is the maximum, but also that fewer may be supported. I don't suppose there's usually any need for more than 1? It might not be possible to support 128 in BASSMIDI due to its 32-bit event parameter size limit - a tuning program number, a key number and a frequency will need to be squeezed into that.

Karl Eick

I'm sorry, how do I upload something there? Any credentials needed? I don't seem to be able to do it through the browser, and I don't know how I can access the server properly using clients like WinSCP or something. Is a Dropbox link fine as well? That would be much easier for me. OTherwise, I would appreciate some help for uploading. I'm blind and use a screen reader. Thank you.

Ian @ un4seen

I don't think any browsers still support FTP links these days, but you can open it in File Explorer and then copy'n'paste the files into it. A publicly accessible Dropbox link will be fine too.

Karl Eick

Oh, didn't know it was that simple! Well, I tried to copy paste it, and it worked the first time, but when I updated the folder with f5, the file was gone, and copying it again threw an access denied error. But since it worked the first time, can you see it? If not, I'll post a dropbox link.

Ian @ un4seen

Your file was received, thanks. Uploaded files aren't publicly visible/accessible, so that's why you couldn't see the file after refreshing.

As I suspected, the file is only using/modifying the default tuning program 0, so perhaps BASSMIDI doesn't need to support any other tuning programs. That would simplify things. Do you have any more such files? If so, please upload them too, to check whether they're also only using tuning program 0.

Karl Eick

That's great! And actually, that's all I need! Unless you want to see other tunings, if it makes a significant difference. This one was 22 tone equal temperament, I could show you a different one, like 17 or 19. Essentially, what I did, is just creating a sysex file with scaleworkshop, and then adding that track to the midi file, which timidity can process correctly. I guess, it's using the same system all the time, just different values for the tuning. And you can select the preset index, but I never bothered to mess with that.

Karl Eick

Ok, better safe than sorry, I uploaded two more files you can look at.

Ian @ un4seen

Thanks. Here now is a BASSMIDI update for you to try:

    www.un4seen.com/stuff/bassmidi.zip

It adds support for the "BULK TUNING DUMP" (08 01) and "SINGLE NOTE TUNING CHANGE" (08 02) sysex with tuning program 0 (other programs are ignored), which will apply to all channels except drum channels (they have their own key tuning options). Changes should take immediate effect, ie. on notes that are already playing. The tuning is reset to default by a system reset sysex.

Your test files still sound a bit strange to me, but perhaps that's how they're meant to be? Let me know whether they sound OK to you.

Karl Eick

#15
Thanks so much for such a quick update! The tuning is now applied correctly. However,  the current Bulk Tuning Dump implementation always retunes the original sample assigned to the MIDI note number itself.
This causes unnecessarily large pitch shifts in many tunings such as 17-TET.
It would sound much more natural if BASSMIDI selected the sample whose original pitch is already closest to the target frequency, and only applied the remaining fine detuning afterwards.
In other words, the tuning should influence sample selection as well, not only the final playback pitch.

Ian @ un4seen

Yeah, that is likely to sound better, but complicates applying changes to any already playing notes. I'll look into it and hopefully come back with another update for you to try next week.

Karl Eick

Thank you so much! I really appreciate your efforts to make this work. Looking forward to the new version!

Ian @ un4seen

Here's another update for you to try:

    www.un4seen.com/stuff/bassmidi.zip

Let me know how it goes. One thing I'm unsure about is how this key tuning should interact with the master tuning and channel tuning and octave tuning, so please let me know if you see any issues with that stuff. Currently, the coarse tuning values are added to the note, and the key tuning is applied to the result of that, and then the finetune values are added.

Karl Eick

#19
Yes, this result is already much better. However, it's still not quite the same as I used to hear from timidity. Maybe the Key mapping needs to be made to find the closest key, and only do the fine tuning after that. I mean, this is kind of what happens here, but with some, I still don't hear the same result as in Timidity in terms of sample selection.

Karl Eick

To clarify, I don't think there is any tuning issue. The pitches are correct, and have always been.
The remaining differences compared to Timidity++ seem to be entirely due to sample region selection. Some instruments still sound different because Timidity++ appears to choose a different source sample before applying the final tuning. This is only a guess, but perhaps Timidity++ bases sample selection on the nearest equivalent standard tuning note, and applies the microtonal offset afterwards. That might explain some of the remaining differences in timbre.

Karl Eick

As for your questions about coarse tuning and the other tuning types, I haven't tested any combinations of key tuning with master tuning, channel tuning or octave tuning yet. For my current files, everything sounds correct apart from the sample selection differences compared to TiMidity++.

Ian @ un4seen

It should already be using the most appropriate samples from the soundfont based on the effective key after tuning. For example, if key 60 is played and the tuning says key 60 should sound like key 50 normally would, then it'll use the key 50 sample(s). Do you have a MIDI file & soundfont combination in particular that doesn't seem right? If so, please upload that and give an affected position and/or keys to check.

Karl Eick

blackwood22notes.mid is a file where I notice the differences very clearly, which I already uploaded. I'll give you the soundfont I prefer to use with this, and then the audio file from timidity to compare. I hope that helps. Timidity does something that makes it sound more like the original soundfont. In particular, I notice it with the violin, right at the beginning of the piece. It's the second and third note the violin plays, and various other parts throughout the piece. In fact, I can give you a key now. The second and third note in the violin track is a note which would correspond to key 71 in standard tuning, but bassmidi seems to select a sample region from the key before.

Karl Eick

I'm sorry, it may also be a sample region from the key after it. In any case, using 22 tone equal temperament as an example, the note which would correspond to key 71 in 12 tone equal (standard) is using a different sample than normal. It may be a rounding issue, but that's only a guess.