Beispiel #1
0
        public Score(int measureCount, Dictionary <int, TimeSignature> timeSignatures, Dictionary <int, int> tempoChanges,
                     IReadOnlyCollection <InstrumentTrack> instrumentTracks, PercussionTrack percussionTrack)
        {
            _measureCount = measureCount;

            _timeSignatures = timeSignatures;
            _tempoChanges   = tempoChanges;

            ValidateInitial(_timeSignatures, "time signature");
            ValidateInitial(_tempoChanges, "tempo");

            if (instrumentTracks.Count > 15)
            {
                throw new Exception("Too many instruments. MIDI is limited to 16 channels: 15 instrument and 1 percussion.");
            }

            _instrumentTracks = instrumentTracks;
            _percussionTrack  = percussionTrack;

            foreach (var instrumentTrack in _instrumentTracks)
            {
                ValidateInstrumentTrackLength(instrumentTrack, _measureCount);
            }

            ValidatePercussionTrackLength(_percussionTrack, _measureCount);
        }
Beispiel #2
0
        private static void ValidatePercussionTrackLength(PercussionTrack track, int length)
        {
            if (track == null)
            {
                throw new ArgumentNullException("track");
            }

            if (track.Notes.Count != length)
            {
                throw new ArgumentException(string.Format("Percussion track must be {0} measures long.", length));
            }
        }