MidiSheetMusic.MidiFile.ChangeMidiNotes C# (CSharp) Method

ChangeMidiNotes() public method

public ChangeMidiNotes ( MidiOptions options ) : List
options MidiOptions
return List
        public List<MidiTrack> ChangeMidiNotes(MidiOptions options)
        {
            List<MidiTrack> newtracks = new List<MidiTrack>();

            for (int track = 0; track < tracks.Count; track++) {
            if (options.tracks[track]) {
                newtracks.Add(tracks[track].Clone() );
            }
            }

            /* To make the sheet music look nicer, we round the start times
             * so that notes close together appear as a single chord.  We
             * also extend the note durations, so that we have longer notes
             * and fewer rest symbols.
             */
            TimeSignature time = timesig;
            if (options.time != null) {
            time = options.time;
            }
            MidiFile.RoundStartTimes(newtracks, options.combineInterval, timesig);
            MidiFile.RoundDurations(newtracks, time.Quarter);

            if (options.twoStaffs) {
            newtracks = MidiFile.CombineToTwoTracks(newtracks, timesig.Measure);
            }
            if (options.shifttime != 0) {
            MidiFile.ShiftTime(newtracks, options.shifttime);
            }
            if (options.transpose != 0) {
            MidiFile.Transpose(newtracks, options.transpose);
            }

            return newtracks;
        }

Usage Example

Exemplo n.º 1
0
        /** Set the MidiFile to use.
         *  Save the list of midi notes. Each midi note includes the note Number
         *  and StartTime (in pulses), so we know which notes to shade given the
         *  current pulse time.
         */
        public void SetMidiFile(MidiFile midifile, MidiOptions options)
        {
            if (midifile == null) {
            notes = null;
            useTwoColors = false;
            return;
            }

            List<MidiTrack> tracks = midifile.ChangeMidiNotes(options);
            MidiTrack track = MidiFile.CombineToSingleTrack(tracks);
            notes = track.Notes;

            maxShadeDuration = midifile.Time.Quarter * 2;

            /* We want to know which track the note came from.
             * Use the 'channel' field to store the track.
             */
            for (int tracknum = 0; tracknum < tracks.Count; tracknum++) {
            foreach (MidiNote note in tracks[tracknum].Notes) {
                note.Channel = tracknum;
            }
            }

            /* When we have exactly two tracks, we assume this is a piano song,
             * and we use different colors for highlighting the left hand and
             * right hand notes.
             */
            useTwoColors = false;
            if (tracks.Count == 2) {
            useTwoColors = true;
            }

            showNoteLetters = options.showNoteLetters;
            this.Invalidate();
        }
All Usage Examples Of MidiSheetMusic.MidiFile::ChangeMidiNotes