Exemplo n.º 1
0
        public void AddTrack(TrackName trackName, List <MidiEvent> midiEvents = null)
        {
            var trackNameEvent = new TextEvent(trackName.ToString(), MetaEventType.SequenceTrackName, 0);

            midiEvents = midiEvents ?? new List <MidiEvent>();
            midiEvents.Insert(0, trackNameEvent);
            var lastEvent = midiEvents.OrderBy(e => e.AbsoluteTime).Last();

            midiEvents.Add(new MetaEvent(MetaEventType.EndTrack, 0, lastEvent.AbsoluteTime));

            MidiFile.Events.AddTrack(midiEvents);
        }
Exemplo n.º 2
0
        public void RemoveNote(TrackName trackName, NoteOnEvent noteEvent)
        {
            int trackNumber;

            if (!_tracksNumbersByName.TryGetValue(trackName.ToString(), out trackNumber))
            {
                throw new ArgumentException($"No track named: {trackName}", nameof(trackName));
            }

            MidiFile.Events[trackNumber].Remove(noteEvent);
            MidiFile.Events[trackNumber].Remove(noteEvent.OffEvent);
        }
Exemplo n.º 3
0
        public void AddEvents(TrackName trackName, IEnumerable <MidiEvent> newEvents)
        {
            int trackNumber;

            if (!_tracksNumbersByName.TryGetValue(trackName.ToString(), out trackNumber))
            {
                throw new ArgumentException($"No track named: {trackName}", nameof(trackName));
            }

            foreach (var newEvent in newEvents)
            {
                MidiFile.Events.AddEvent(newEvent, trackNumber);
            }
        }
Exemplo n.º 4
0
 public void AddEvent(TrackName trackName, MidiEvent newEvent)
 {
     AddEvents(trackName, new[] { newEvent });
 }