Sign in

Implementing bank select lsb in soundfonts

Category: Coffee break
  • 70 0
    Message from Sylvia on 1
    Hi everyone!

    While looking at the soundfont specification with a friend, we saw that the wBank and wPreset values, which determine the bank and preset numbers of presets in a soundfont file, are 16-bit values (rather then 8-bit values). So, the last 8 bits of each value in a soundfont file are normally unused.

    My proposal is to use the unused 8 bits of the wBank value to encode the bank select lsb control change (CC#32), increasing the number of possible instrument spaces to just over 2 million.

    This would be very useful, as this would allow proper XG or GM2 support, among other things, but getting other people to support this implementation might be difficult.

    Maybe, if we implement it in Polyphone, we can make it an optional feature which can be enabled or disabled, to prevent confusion, because not all players would support this.

    I hope you read all of this,

    sylvia.
  • 4 0
    Message from stgiga on
    I am the friend mentioned in the post (stgiga). It was a very interesting discovery!
  • BO 282 13
    Message from bottrop on
    sounds great! what about composing a piece for two million instruments in advance?
    regards bottrop
  • ZI 190 0
    I think "WORD wPresetBagNdx;" It won't be enough to hold them all.
  • 4 0
    Message from stgiga on
    The main use for doing MSB+LSB via the full wBank utilization is storing General MIDI 2 and Yamaha XG patches properly, since both use LSB for banks. Sylvia has already made a proof-of-concept XG soundfont that uses this 16bit wBank discovery. Meaning no need to split banks just for storing XG right, what with its LSB use. This is a major feature that is very important to add.

    The test soundfonts:

    XG:
    http://soundfonts.kor.ninja/Soundfont%20Research/XG%20soundfont%20reference.sf2

    GM2:
    http://soundfonts.kor.ninja/Soundfont%20Research/GM2%20soundfont%20reference.sf2
  • CS 73 0
    Message from csw900 on
    Interesting but both of these links give a 404 Not Found error!!!

    csw900
  • ZI 190 0
  • 4 0
    Message from stgiga on
    Sylvia or t999clint must have renamed the folder. I didn't.
  • CS 73 0
    Message from csw900 on 1
    Thank you - the new link is OK

    I need to spend some time looking further into this. I did not realise there were that may instruments - let alone playing them on polyphone.

    However there is a problem - some of the instruments cause poly polyphone to crash - possibly because it is not using sufficiently wide integers internally. It would be a good idea to remedy this as soon as possible once the cause is found.

    Also some of the samples leave a bit to be desired when playing a scale with the mouse.

    csw900

    Later: There are significant problems with ths idea when you consider how midi messages are transmitted. They are three bytes only thus the LSB and MSB have to be sent in two seperate messages and added together by the receiver. Unless this is carefully planned it will not work for two reasons: 1. Most midi receivers do not add these two messages because they do not expect to reveive them in this way. 2. Midi messages are subject to "out of order execution" by both senders and receivers - unless this is correctly dealt with the two messages will not necessarily arrive in the correct order. NRPN's also have this problem and unless special care is taken in the software design they are not correctly interpreted.

    Also I think you will have a hard time convincing midi manufacturers that more than 16129 presets are needed in a sound font.

    csw900
  • 70 0
    Message from Sylvia on
    Hi CSW900,

    I understand your concerns relating to the proposed new soundfont bank select format and the MIDI instruction format, and I decided to implement it in a way that is as backwards compatible as possible with older soundfont players.

    It makes it easier if we consider the first and second bytes of wBank to be separate values with no connection. Since the soundfont format is little endian, the first byte is the least significant byte, so the first byte is what stores the banks 0-128 used in the current soundfont bank storage format. Since only the first byte of wBank is used, the second byte can treated as a completely different value. Therefore, it's not really "adding two values together", it's more like adding a parallel value which directly maps to bank select lsb, which isn't implemented in soundfonts.

    Because Polyphone reads the 16-bit value of the wBank, instruments mapped in the way I proposed would appear to have a "bank number" of (256 * LSB) + MSB. If lsb was implemented as I described, the wBank would be read as two separate 8-bit values for each byte, one for msb and one for lsb. Therefore, not only order of the bank select commands would not matter (as an msb instruction does not affect the lsb value or vice versa), but the two bank select commands would not need to be called simultaneously.

    Also, as a reminder, the goal is to enable XG or GM2 compatibility (~300-500 presets) rather than to have an extremely large number.

    Thanks,

    sylvia.

    Edit: Because of the separate nature of the two bytes in the wBank field, msb and lsb commands do not need to be called together, they can be called separately. So if a file only calls msb, or only calls lsb, it will still work.
  • CS 73 0
    Message from csw900 on
    Hi Sylvia

    Just a quick response - I think you may be missing the point. There is no guarantee that both bytes of a bank select message will be sent. In my experience only one byte of the message is ever used in midi files or messages. Each message has its own identification byte i.e.0 for the MSB and 32 for the LSB. These messages may be received in any order and at any time. What Polyphone does is not relevent.

    csw900

    Later: Unfortunately Polyphone has no midi output so it is difficult to find out what is really happening with the bank select. (For example why does bank 128 select default percussion) One way could be to load the resulting sound font into a reliable synth such as Fluidsynth and see what it does. However even this synth is open to interpretation as it has always been a bit weak on reliably selecting banks. As far as I am aware what happens when banks above 127 are selected is not defined by any midi specification.
    csw900
  • 4 0
    Message from stgiga on
    We made a test sf2 and a bit infographic

    Test SF2: here (https://drive.google.com/file/d/1cerpko6kL4SctyHG9ozYFtwePmbHX7CW/view)
    Based off of my libre JummBox SoundFont here (http://stgiga.itch.io/jummboxsoundfont) or here (http://musical-artifacts.com/artifacts/2722)

Sign in or register to take part in discussions.

Polyphone needs you!

Polyphone is free but there are costs associated with its website and development. A small donation will help a lot.

Donate
Learn the basics Try a tutorial
Scroll to
top