private void InternalNote(Object o, ChannelMessageEventArgs args)
        {
            ChannelMessageBuilder builder = new ChannelMessageBuilder(args.Message);

            NoteEvent noteEvent = new NoteEvent {
                note     = builder.Data1,
                origNote = builder.Data1,
                trackNum = sequencer.GetTrackNum(args.MidiTrack),
                track    = args.MidiTrack,
            };

            if (sequencer.GetTrackNum(noteEvent.track) == this.TrackNum)
            {
                noteEvent.note = NoteHelper.ApplyOctaveShift(noteEvent.note, this.OctaveNum);

                ChannelCommand cmd = args.Message.Command;
                int            vel = builder.Data2;
                if ((cmd == ChannelCommand.NoteOff) || (cmd == ChannelCommand.NoteOn && vel == 0))
                {
                    this.ProcessOffNote(noteEvent);
                }
                if ((cmd == ChannelCommand.NoteOn) && vel > 0)
                {
                    this.ProcessOnNote(noteEvent);
                }
            }
        }
示例#2
0
        private int ApplyOctaveShift(int note)
        {
            // octaveShift now holds the track octave and the selected octave together
            int os = octaveShift;

            return(NoteHelper.ApplyOctaveShift(note, os));
        }
        public void Update(BmpSequencer bmpSeq)
        {
            int tn = this.TrackNum;

            if (!(bmpSeq is BmpSequencer))
            {
                return;
            }

            Sequence seq = bmpSeq.Sequence;

            if (!(seq is Sequence))
            {
                return;
            }

            Keyboard.UpdateFrequency(new List <int>());
            if ((tn >= 0 && tn < seq.Count) && seq[tn] is Track track)
            {
                int po = bmpSeq.GetTrackPreferredOctaveShift(track);
                Console.WriteLine(String.Format("Track {0} {1} po {2}", tn, bmpSeq.MaxTrack, po));
                List <int> notes = new List <int>();
                foreach (MidiEvent ev in track.Iterator())
                {
                    if (ev.MidiMessage.MessageType == MessageType.Channel)
                    {
                        ChannelMessage msg = (ev.MidiMessage as ChannelMessage);
                        if (msg.Command == ChannelCommand.NoteOn)
                        {
                            int note = msg.Data1;
                            int vel  = msg.Data2;
                            if (vel > 0)
                            {
                                notes.Add(NoteHelper.ApplyOctaveShift(note, this.OctaveNum + po));
                            }
                        }
                    }
                }
                this.OctaveShift.Value = po;
                Keyboard.UpdateFrequency(notes);
                ChosenInstrument = bmpSeq.GetTrackPreferredInstrument(track);
            }

            if (hostProcess)
            {
                this.BackColor = Color.FromArgb(235, 235, 120);
            }
            else
            {
                this.BackColor = Color.Transparent;
            }
        }
示例#4
0
 public void ProcessOnNote(NoteEvent note)
 {
     foreach (Control ctl in PerformerLayout.Controls)
     {
         BmpLocalPerformer performer = (ctl as BmpLocalPerformer);
         if (performer != null && performer.UiEnabled && performer.PerformerEnabled)
         {
             if (note.trackNum == performer.TrackNum)
             {
                 int po = SequencerReference.GetTrackPreferredOctaveShift(note.track);
                 note.note = NoteHelper.ApplyOctaveShift(note.origNote, performer.OctaveNum + po);
                 performer.ProcessOnNote(note);
             }
         }
     }
 }
        public void Update(BmpSequencer sequencer)
        {
            int tn = this.TrackNum;

            Sequence seq = sequencer.Sequence;

            if (!(seq is Sequence))
            {
                return;
            }

            Keyboard.UpdateFrequency(new List <int>());
            if ((tn >= 0 && tn < seq.Count) && seq[tn] is Track track)
            {
                List <int> notes = new List <int>();
                foreach (MidiEvent ev in track.Iterator())
                {
                    if (ev.MidiMessage.MessageType == MessageType.Channel)
                    {
                        ChannelMessage msg = (ev.MidiMessage as ChannelMessage);
                        if (msg.Command == ChannelCommand.NoteOn)
                        {
                            int note = msg.Data1;
                            int vel  = msg.Data2;
                            if (vel > 0)
                            {
                                int po = sequencer.GetTrackPreferredOctaveShift(track);
                                notes.Add(NoteHelper.ApplyOctaveShift(note, this.OctaveNum + po));
                            }
                        }
                    }
                }
                Keyboard.UpdateFrequency(notes);
                ChosenInstrument = sequencer.GetTrackPreferredInstrument(track);
            }

            if (hostProcess)
            {
                this.BackColor = Color.FromArgb(235, 235, 120);
            }
            else
            {
                this.BackColor = Color.Transparent;
            }
        }
示例#6
0
        private int ApplyOctaveShift(int note)
        {
            int os = octaveShift + player.GetTrackPreferredOctaveShift(player.LoadedTrack);

            return(NoteHelper.ApplyOctaveShift(note, os));
        }