public PatternActionResult Invoke(long time, PatternContext context)
        {
            var programEvent = Program.GetProgramEvent(context.Channel);
            var timedEvent   = new TimedEvent(programEvent, time);

            return(new PatternActionResult(time, new[] { timedEvent }));
        }
示例#2
0
        public PatternActionResult Invoke(long time, PatternContext context)
        {
            var programChangeEvent = new ProgramChangeEvent(ProgramNumber);
            var timedEvent         = new TimedEvent(programChangeEvent, time);

            return(new PatternActionResult(time, new[] { timedEvent }));
        }
示例#3
0
        public PatternActionResult Invoke(long time, PatternContext context)
        {
            var textEvent  = (BaseTextEvent)Activator.CreateInstance(typeof(TEvent), Text);
            var timedEvent = new TimedEvent(textEvent, time);

            return(new PatternActionResult(time, new[] { timedEvent }));
        }
示例#4
0
        private static bool IsAppropriateNoteOnTimedEvent(TimedEvent timedEvent, FourBitNumber channel, SevenBitNumber noteNumber)
        {
            var noteOnEvent = timedEvent.Event as NoteOnEvent;

            return(noteOnEvent != null &&
                   noteOnEvent.Channel == channel &&
                   noteOnEvent.NoteNumber == noteNumber);
        }
        /// <summary>
        /// Sets time of the specified timed event.
        /// </summary>
        /// <param name="timedEvent">Timed event to set time to.</param>
        /// <param name="time">Time to set to <paramref name="timedEvent"/>.</param>
        /// <param name="tempoMap">Tempo map that will be used for time conversion.</param>
        /// <returns>An input <paramref name="timedEvent"/> with new time.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="timedEvent"/> is null. -or-
        /// <paramref name="time"/> is null. -or- <paramref name="tempoMap"/> is null.</exception>
        public static TimedEvent SetTime(this TimedEvent timedEvent, ITimeSpan time, TempoMap tempoMap)
        {
            ThrowIfArgument.IsNull(nameof(timedEvent), timedEvent);
            ThrowIfArgument.IsNull(nameof(time), time);
            ThrowIfArgument.IsNull(nameof(tempoMap), tempoMap);

            timedEvent.Time = TimeConverter.ConvertFrom(time, tempoMap);
            return(timedEvent);
        }
示例#6
0
文件: Note.cs 项目: mbyht/drywetmidi
        /// <summary>
        /// Initializes a new instance of the <see cref="Note"/> with the specified
        /// Note On and Note Off timed events.
        /// </summary>
        /// <param name="timedNoteOnEvent">Wrapped <see cref="NoteOnEvent"/>.</param>
        /// <param name="timedNoteOffEvent">Wrapped <see cref="NoteOffEvent"/>.</param>
        internal Note(TimedEvent timedNoteOnEvent, TimedEvent timedNoteOffEvent)
        {
            Debug.Assert(timedNoteOnEvent != null);
            Debug.Assert(timedNoteOnEvent.Event is NoteOnEvent, "Timed event doesn't wrap a Note On event.");

            Debug.Assert(timedNoteOffEvent != null);
            Debug.Assert(timedNoteOffEvent.Event is NoteOffEvent, "Timed event doesn't wrap a Note Off event.");

            //

            var noteOnEvent  = (NoteOnEvent)timedNoteOnEvent.Event;
            var noteOffEvent = (NoteOffEvent)timedNoteOffEvent.Event;

            TimedNoteOnEvent  = timedNoteOnEvent;
            TimedNoteOffEvent = timedNoteOffEvent;

            _noteDefinition = NoteDefinition.Get(noteOnEvent.NoteNumber);

            Velocity    = noteOnEvent.Velocity;
            OffVelocity = noteOffEvent.Velocity;
            Channel     = noteOnEvent.Channel;
        }
示例#7
0
 public void CompleteNote(TimedEvent noteOffTimedEvent)
 {
     NoteOffTimedEvent = noteOffTimedEvent;
     IsNoteCompleted   = true;
 }
示例#8
0
 public NoteEventsDescriptor(TimedEvent noteOnTimedEvent, IEnumerable <TimedEvent> eventsTail)
 {
     NoteOnTimedEvent = noteOnTimedEvent;
     EventsTail       = eventsTail;
 }
示例#9
0
 private static bool IsTimeSignatureEvent(TimedEvent timedEvent)
 {
     return(timedEvent?.Event is TimeSignatureEvent);
 }
示例#10
0
 private static bool IsTempoEvent(TimedEvent timedEvent)
 {
     return(timedEvent?.Event is SetTempoEvent);
 }
示例#11
0
 private static bool IsTempoMapEvent(TimedEvent timedEvent)
 {
     return(IsTempoEvent(timedEvent) || IsTimeSignatureEvent(timedEvent));
 }