public PlayingMidi()
        {
            this.transpose = 60;
            if (OutputDevice.DeviceCount == 0)
            {
                MessageBox.Show("No MIDI output devices available.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            outDevice = new OutputDevice(0);
            builder = new ChannelMessageBuilder();
            isDeviceOpen = true;

            //Set instrument to piano
            builder.Command = ChannelCommand.ProgramChange;
            builder.MidiChannel = 0;
            builder.Data1 = 0;
            builder.Build();
            outDevice.Send(builder.Result);

            ParseCommaDelimited();

            tmpmidiFilePlayer = new MidiFilePlayer(outDevice);
            midiFilePlayer1 = new MidiFilePlayer(outDevice);
            midiFilePlayer1.PlayingFinished += this.midiFilePlayer1_PlayingFinished;
        }
Exemple #2
0
        public MidiChord(int channel, MidiChordDef midiChordDef, OutputDevice midiOutputDevice)
            : base(channel, 0, midiChordDef.MsDuration)
        {
            _midiOutputDevice = midiOutputDevice;

            List<BasicMidiChordDef> basicMidiChordDefs = midiChordDef.BasicMidiChordDefs;
            Debug.Assert(basicMidiChordDefs.Count > 0);
            List<int> realBasicMidiChordDurations = MidiChordDef.GetIntDurations(MsDuration, midiChordDef.BasicChordDurations, basicMidiChordDefs.Count);

            var notesToStop = new SortedSet<byte>();
            int i = 0;
            foreach(BasicMidiChordDef basicMidiChordDef in midiChordDef.BasicMidiChordDefs)
            {
                this._basicMidiChords.Add(new BasicMidiChord(channel, this, basicMidiChordDef, realBasicMidiChordDurations[i++]));
                if(basicMidiChordDef.HasChordOff)
                {
                    foreach(byte note in basicMidiChordDef.Pitches)
                    {
                        if(!notesToStop.Contains(note))
                            notesToStop.Add(note);
                    }
                }
            }

            if(midiChordDef.Bank != null)
            {
                _bank = new BankControl(channel, (byte)midiChordDef.Bank);
            }
            if(midiChordDef.Patch != null)
            {
                _patch = new PatchControl(channel, (byte)midiChordDef.Patch);
            }

            // Moritz currently never repeats MidiChords, so the _repeat field is unnecessary.
            // However: the value of midiChordDef.Repeat is saved in SVG-MIDI files,
            // and may be used by the web AssistantPerformer.
            //_repeat = midiChordDef.Repeat;

            if(midiChordDef.PitchWheelDeviation != null)
            {
                _pitchWheelDeviation = new PitchWheelDeviation(channel, (byte)midiChordDef.PitchWheelDeviation);
            }
            if(midiChordDef.MidiChordSliderDefs != null)
                CreateSliders(channel, midiChordDef.MidiChordSliderDefs, MsDuration);

            SetMessagesDict();
        }
Exemple #3
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     this.inDevice = new Multimedia.Midi.InputDevice(this.components);
     this.outDevice = new Multimedia.Midi.OutputDevice(this.components);
     this.tickGen = new Multimedia.Midi.TickGenerator(this.components);
     //
     // outDevice
     //
     this.outDevice.RunningStatusEnabled = true;
     //
     // tickGen
     //
     this.tickGen.Ppqn = 96;
     this.tickGen.Tempo = 500000;
     this.tickGen.Tick += new System.EventHandler(this.TickHandler);
 }
Exemple #4
0
 /// <summary>
 /// Disconnects from an output device to cease Midi thru operations.
 /// </summary>
 /// <param name="outDevice">
 /// The output device from which to disconnect.
 /// </param>
 public void Disconnect(OutputDevice outDevice)
 {
     if(IsOpen() && outDevice.IsOpen())
     {
         midiDisconnect(handle, outDevice.DeviceHandle, 0);
     }
 }