ryohey / signal

Online MIDI Editor: signal
https://signal.vercel.app
MIT License
1.2k stars 136 forks source link

Some MIDI files broken with Signal Factory Sound #368

Closed spessasus closed 3 weeks ago

spessasus commented 3 weeks ago

Describe the bug Some MIDI files don't seem to work when using Signal Factory Sound (either default soundfont or a custom one). Sometimes there's no sound at all or only drums. I've attached one of the files that don't work. MIDI outputs work fine.

To Reproduce Steps to reproduce the behavior:

  1. Open up Signal
  2. Enable Signal Factory Sound (if disabled)
  3. Upload the attached midi issue.zip
  4. No sound until broken drums at 0015:01

Expected behavior The MIDI file should play without a problem.

Screenshots N/A

Desktop (please complete the following information):

Smartphone (please complete the following information): N/A

Additional context The MIDI file has a ton of System Exclusive messages and controller changes at the start. Maybe that's the problem? issue.zip

ryohey commented 3 weeks ago

This is because Bank Select is specified. I am aware of this problem and am wondering how to address it. Bank Select is a MIDI event that selects a set of tones. It means that you can specify more tones than the normal number of tones. By the way, Signal Factory Sound (A320U.sf2) is a very minimal sound source, so it has only the minimum number of tones. The Touhou MIDI is designed for the SC-88Pro, a rich sound module, and uses Bank Select.

The behavior when there is no corresponding Bank for Bank Select is not standardized and could be as follows:

  1. If there is no specified tone for the specified bank, the specification is ignored.
  2. If there is no specified tone in the specified bank, no sound is played.
  3. If there is no specified bank, the bank specification is ignored.
  4. If there is no specified tone for the specified bank, sounds a similar tone

signal uses 2, but many users do not know about Bank Select and face the problem of no sound. I am considering adding a setting to ignore Bank Select (fix it to 0th) and the ability to enable/disable it in the settings screen.

@robertnhart If you know how Bank Select is handled by other sequencers, etc., it would be very helpful to let me know.

spessasus commented 3 weeks ago

I see. I would suggest using bank select 0. Most soundfont synths use it (for example fluidsynth, TinySoundFont and SpessaSynth do). Simply defaulting to the GM instrument set when no valid tone variant matches the Bank Select will be a good solution.

ryohey commented 3 weeks ago

@spessasus Thank you for the detailed information! Will do.

robertnhart commented 3 weeks ago

The issue is already fixed using a method that I think is good. Here is a reply that I was in the process of researching:

I'm not very familiar with how devices handle undefined bank and program combinations. (When I compose MIDI files, I design my MIDI files to use General MIDI Level 1 sounds. I use Program Change messages and never use Bank Select messages.) But here are some thoughts...

I just did a quick check and when I play the th06_01.mid file on the following MIDI sound sources that I have, they all seem to make sounds for every part in the MIDI file:

Only Synthesia has an option to not send Bank Select messages. I think the other MIDI file player software always sends the Bank Select messages, and it's up to the output device or software synthesizer to decide how it handles undefined bank and program numbers.

I took a quick look at several MIDI specification documents (the MIDI 1.0 spec, the GM1 spec, the GM1 Developer Guidelines, and the GM2 spec), but none of them discuss what to do when the Bank Select and Program change messages indicate a undefined sound.

I took a look at some Yamaha XG specification documents, and a look at the Roland Sound Canvas SC-55 manual, and they describe various substitution rules to use when an undefined bank and program number is selected. In some cases, these rules say the sound generator should make no sounds.

I think it's a good idea for a MIDI sound source to make a sound even if it gets Bank Select and Program Change messages that indicate a Bank and Program that it doesn't have any defined sounds for. If a sound source includes the General MIDI Level 1 sounds, then any time an undefined Bank and Program is selected, I think it's a good idea for it to default to the General MIDI Level 1 sound for the Program number.