Exemple #1
0
        /// <summary>
        /// Set Midi instrument for all channels
        /// </summary>
        /// <param name="instrument"></param>
        public void SetInstrument(MyMidi.Instrument instrument)
        {
            try
            {
                foreach (var c in Enum.GetValues(typeof(MyMidi.Channel)))
                {
                    //outputDevice.SendProgramChange((Midi.Channel)c, instrument);

                    // Change the patch while playing
                    int nChannel = (int)c;

                    int p = (int)instrument;
                    int v = 0;

                    ChannelMessageBuilder builder = new ChannelMessageBuilder()
                    {
                        Command     = ChannelCommand.ProgramChange,
                        MidiChannel = nChannel,
                        Data1       = p,
                        Data2       = v,
                    };
                    builder.Build();
                    outDevice.Send(builder.Result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #2
0
 public void SetInstrument(MyMidi.Instrument instrument)
 {
     midi.SetInstrument(instrument);
 }