meltysynth icon indicating copy to clipboard operation
meltysynth copied to clipboard

Add InstrumentChange constant

Open MatheusMoura17 opened this issue 1 year ago • 2 comments

In alternative to #25, we can add single constant InstrumentChange inside Synthesizer?

Sample:

Before

// Change the instrument to electric guitar (#30).
synthesizer.ProcessMidiMessage(0, 0xC0, 30, 0);

After

// Change the instrument to electric guitar (#30).
synthesizer.ProcessMidiMessage(0, Synthesizer.InstrumentChange, 30, 0);

MatheusMoura17 avatar Aug 25 '22 11:08 MatheusMoura17

There are a number of commands defined in the General MIDI specifications. Is there a particular reason to add a constant only for instrument change?

sinshu avatar Aug 26 '22 10:08 sinshu

0xC0 its a unique code i'm using in HGS-Tone:

    public void SetInstrument(MidiInstrumentCode code)
    {
      SetInstrument((int)code);
    }

    public void SetInstrument(int id)
    {
      _synthesizer.ProcessMidiMessage(0, 0xC0, id, 0);
    }

I was thinking of creating a constant InstrumentChange in my code, but I think having this constant in MeltySynth could help other people. My library is too simple, I don't think I will manage MIDI codes.

MatheusMoura17 avatar Aug 28 '22 13:08 MatheusMoura17

Here is my opinion:

I believe that this library should provide only what users cannot easily achieve. Since adding a constant for convenience is not hard for users, that should not be in the library. This is mainly to keep the API simple.

sinshu avatar Sep 03 '22 15:09 sinshu

Hey, sorry for delay, i agree with you, i'll keep the constants in my code base.

Thank you! :D

MatheusMoura17 avatar Sep 06 '22 13:09 MatheusMoura17