Exemplo n.º 1
0
        private Midi.Message ToMessage(MidiMessage m, OutputDevice device, Clock clock, out float time)
        {
            TomiSoft.RolandStyleReader.NoteMessage msg = (TomiSoft.RolandStyleReader.NoteMessage)m;
            time = msg.TotalTime / 120f;

            Channel ch;

            switch (this.instr)
            {
            case TomiSoft.RolandStyleReader.Instrument.Drum:
                ch = Channel.Channel10;
                break;

            case TomiSoft.RolandStyleReader.Instrument.Bass:
                ch = Channel.Channel2;
                break;

            default:
                ch = Channel.Channel4;
                break;
            }

            return(new NoteOnOffMessage(
                       device,
                       ch,
                       (Pitch)((msg.Note < 128) ? msg.Note : 1),
                       msg.Velocity,
                       msg.TotalTime / 120f,
                       clock,
                       msg.Length
                       ));
        }
Exemplo n.º 2
0
        private NoteOnOffMessage GetNoteOnOffMessage(StyleEntry msg)
        {
            TomiSoft.RolandStyleReader.NoteMessage m = (TomiSoft.RolandStyleReader.NoteMessage)msg.Message;

            return(new NoteOnOffMessage(
                       this.Device,
                       ChannelMappings[msg.Instrument],
                       (Pitch)((m.Note < 128) ? m.Note : 1),
                       m.Velocity,
                       m.TotalTime / 120f,
                       this.clock,
                       m.Length
                       ));
        }
        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);
            }
        }
Exemplo n.º 4
0
        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
                    );
            }
        }