sinshu / rustysynth

A SoundFont MIDI synthesizer written in pure Rust
Other
108 stars 20 forks source link

Use smaller integer types for MIDI events #2

Open lunabunn opened 1 year ago

lunabunn commented 1 year ago

Synthesizer::note_on, Synthesizer::note_off, Synthesizer::process_midi_message and friends expect input parameters that are a byte each, i.e. u8 or i8. However, currently, they all take i32, making it difficult to guess what ranges of values are expected.

Most notably, note_on will fail silently with a velocity larger than i8::MAX.

Would it be possible for these public APIs (and ideally their internals as well, so that the library doesn't consume more memory than needed) to be adjusted to use smaller integer types that better represent their actual size?

sinshu commented 1 year ago

I was thinking about the same thing, but haven't started yet because it looks like there will be more changes than expected. It might be a good idea to patch only the public part as an ad-hoc fix.