private void UpdateMidiEvents()
        {
            var Result = from c in this.Data.data
                         where
                         c.Arrangement == this.SelectedArrangement &&
                         c.ChordType == this.SelectedChordFamily &&
                         c.Instrument == this.SelectedInstrument &&
                         c.Part == this.SelectedPart
                         select c;

            lwMessages.Items.Clear();

            foreach (var item in Result)
            {
                ListViewItem lwi = new ListViewItem(StyleTime.FromStyleMessage(item.Message, this.Data).ToString());

                MidiMessage msg = item.Message;
                lwi.Tag = item;

                lwi.SubItems.Add(msg.MessageType.ToString());
                lwi.SubItems.Add(msg.Channel.ToString());

                switch (msg.MessageType)
                {
                case MidiMessageType.ControlChange:
                    TomiSoft.RolandStyleReader.ControlChangeMessage ccm = (TomiSoft.RolandStyleReader.ControlChangeMessage)msg;
                    lwi.SubItems.Add(ccm.Control.ToString());
                    lwi.SubItems.Add(ccm.Value.ToString());
                    break;

                case MidiMessageType.ProgramChange:
                    TomiSoft.RolandStyleReader.ProgramChangeMessage pcm = (TomiSoft.RolandStyleReader.ProgramChangeMessage)msg;
                    lwi.SubItems.Add(pcm.MSB.ToString());
                    lwi.SubItems.Add(pcm.LSB.ToString());
                    lwi.SubItems.Add(pcm.Program.ToString());
                    break;

                case MidiMessageType.Note:
                    TomiSoft.RolandStyleReader.NoteMessage nm = (TomiSoft.RolandStyleReader.NoteMessage)msg;
                    lwi.SubItems.Add(nm.Name + " " + nm.Octave);
                    lwi.SubItems.Add(nm.Velocity.ToString());
                    lwi.SubItems.Add(nm.Length.ToString());
                    break;
                }

                lwMessages.Items.Add(lwi);
            }
        }
示例#2
0
        private Midi.ControlChangeMessage GetControlChangeMessage(StyleEntry msg)
        {
            TomiSoft.RolandStyleReader.ControlChangeMessage m = (TomiSoft.RolandStyleReader.ControlChangeMessage)msg.Message;

            Dictionary <ControlType, Control> ControlMappings = new Dictionary <ControlType, Control>()
            {
                { ControlType.Chorus, Control.ChorusLevel },
                { ControlType.Expression, Control.Expression },
                { ControlType.Pan, Control.Pan },
                { ControlType.Reverb, Control.ReverbLevel }
            };

            return(new Midi.ControlChangeMessage(
                       this.Device,
                       ChannelMappings[msg.Instrument],
                       ControlMappings[m.Control],
                       m.Value,
                       m.TotalTime
                       ));
        }
        private void RenderMessages()
        {
            lwMessages.Items.Clear();

            try {
                var Messages = from Current in this.data.data
                               where
                               Current.Arrangement == (this.IsBasic ? Arrangement.Basic : Arrangement.Advanced) &&
                               Current.Part == this.Part &&
                               Current.Instrument == this.instr &&
                               Current.ChordType == this.ctype
                               select Current;

                foreach (StyleEntry Entry in Messages)
                {
                    var msg = Entry.Message;

                    ListViewItem lwi = new ListViewItem(StyleTime.FromStyleMessage(msg, this.data).ToString());
                    lwi.SubItems.Add(msg.MessageType.ToString());
                    lwi.SubItems.Add(msg.Channel.ToString());

                    switch (msg.MessageType)
                    {
                    case MidiMessageType.ControlChange:
                        TomiSoft.RolandStyleReader.ControlChangeMessage ccm = (TomiSoft.RolandStyleReader.ControlChangeMessage)msg;
                        lwi.SubItems.Add(ccm.Control.ToString());
                        lwi.SubItems.Add(ccm.Value.ToString());
                        break;

                    case MidiMessageType.ProgramChange:
                        TomiSoft.RolandStyleReader.ProgramChangeMessage pcm = (TomiSoft.RolandStyleReader.ProgramChangeMessage)msg;
                        lwi.SubItems.Add(pcm.MSB.ToString());
                        lwi.SubItems.Add(pcm.LSB.ToString());
                        lwi.SubItems.Add(pcm.Program.ToString());
                        break;

                    case MidiMessageType.Note:
                        TomiSoft.RolandStyleReader.NoteMessage nm = (TomiSoft.RolandStyleReader.NoteMessage)msg;
                        lwi.SubItems.Add(nm.Name + " " + nm.Octave);
                        lwi.SubItems.Add(nm.Velocity.ToString());
                        lwi.SubItems.Add(nm.Length.ToString());
                        break;
                    }

                    lwMessages.Items.Add(lwi);
                }
            }
            catch (NoteValueOutOfRangeException) {
                MessageBox.Show(
                    "Note number must be in range 0-127",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
            catch (NoteVelocityOutOfRangeException) {
                MessageBox.Show(
                    "Note velocity must be in range 0-127",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
            catch (Exception) {
                MessageBox.Show(
                    "The style does not contain information for the selected part",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
        }