EndTime() public method

public EndTime ( ) : int
return int
Ejemplo n.º 1
0
        /** Create a new SheetMusic control.
         * MidiFile is the parsed midi file to display.
         * SheetMusic Options are the menu options that were selected.
         *
         * - Apply all the Menu Options to the MidiFile tracks.
         * - Calculate the key signature
         * - For each track, create a list of MusicSymbols (notes, rests, bars, etc)
         * - Vertically align the music symbols in all the tracks
         * - Partition the music notes into horizontal staffs
         */
        public void init(MidiFile file, MidiOptions options)
        {
            if (options == null) {
            options = new MidiOptions(file);
            }
            zoom = 1.0f;
            filename = file.FileName;

            SetColors(options.colors, options.shadeColor, options.shade2Color);
            pen = new Pen(Color.Black, 1);

            List<MidiTrack> tracks = file.ChangeMidiNotes(options);
            SetNoteSize(options.largeNoteSize);
            scrollVert = options.scrollVert;
            showNoteLetters= options.showNoteLetters;
            TimeSignature time = file.Time;
            if (options.time != null) {
            time = options.time;
            }
            if (options.key == -1) {
            mainkey = GetKeySignature(tracks);
            }
            else {
            mainkey = new KeySignature(options.key);
            }

            numtracks = tracks.Count;

            int lastStart = file.EndTime() + options.shifttime;

            /* Create all the music symbols (notes, rests, vertical bars, and
             * clef changes).  The symbols variable contains a list of music
             * symbols for each track.  The list does not include the left-side
             * Clef and key signature symbols.  Those can only be calculated
             * when we create the staffs.
             */
            List<MusicSymbol>[] symbols = new List<MusicSymbol> [ numtracks ];
            for (int tracknum = 0; tracknum < numtracks; tracknum++) {
            MidiTrack track = tracks[tracknum];
            ClefMeasures clefs = new ClefMeasures(track.Notes, time.Measure);
            List<ChordSymbol> chords = CreateChords(track.Notes, mainkey, time, clefs);
            symbols[tracknum] = CreateSymbols(chords, clefs, time, lastStart);
            }

            List<LyricSymbol>[] lyrics = null;
            if (options.showLyrics) {
            lyrics = GetLyrics(tracks);
            }

            /* Vertically align the music symbols */
            SymbolWidths widths = new SymbolWidths(symbols, lyrics);
            // SymbolWidths widths = new SymbolWidths(symbols);
            AlignSymbols(symbols, widths);

            staffs = CreateStaffs(symbols, mainkey, options, time.Measure);
            CreateAllBeamedChords(symbols, time);
            if (lyrics != null) {
            AddLyricsToStaffs(staffs, lyrics);
            }

            /* After making chord pairs, the stem directions can change,
             * which affects the staff height.  Re-calculate the staff height.
             */
            foreach (Staff staff in staffs) {
            staff.CalculateHeight();
            }

            BackColor = Color.White;

            SetZoom(1.0f);
        }
Ejemplo n.º 2
0
        private NumericUpDown startMeasure; /** The starting measure */

        #endregion Fields

        #region Constructors

        /** Create a new PlayMeasuresDialog. Call the ShowDialog() method
         *  to display the dialog.
         */
        public PlayMeasuresDialog(MidiFile midifile)
        {
            int lastStart = midifile.EndTime();
            int lastMeasure = 1 + lastStart / midifile.Time.Measure;

            /* Create the dialog box */
            dialog = new Form();
            dialog.Text = "Play Selected Measures in a Loop";
            dialog.MaximizeBox = false;
            dialog.MinimizeBox = false;
            dialog.ShowInTaskbar = false;
            dialog.Icon = new Icon(GetType(), "NotePair.ico");
            dialog.AutoScroll = true;

            Font font = dialog.Font;
            dialog.Font = new Font(font.FontFamily, font.Size * 1.4f);
            int labelheight = dialog.Font.Height * 2;
            int xpos = labelheight/2;
            int ypos = labelheight/2;

            enable = new CheckBox();
            enable.Parent = dialog;
            enable.Text = "Play Selected Measures in a Loop";
            enable.Checked = false;
            enable.Location = new Point(xpos, ypos);
            enable.Size = new Size(labelheight*9, labelheight);

            ypos += labelheight * 3/2;

            Label label = new Label();
            label.Parent = dialog;
            label.Text = "Start Measure";
            label.Location = new Point(xpos, ypos);
            label.Size = new Size(labelheight * 3, labelheight);

            xpos += labelheight * 4;

            startMeasure = new NumericUpDown();
            startMeasure.Parent = dialog;
            startMeasure.Minimum = 1;
            startMeasure.Maximum = lastMeasure;
            startMeasure.Value = 1;
            startMeasure.Location = new Point(xpos, ypos);
            startMeasure.Size = new Size(labelheight*2, labelheight);

            xpos = labelheight/2;
            ypos += labelheight * 3/2;

            label = new Label();
            label.Parent = dialog;
            label.Text = "End Measure";
            label.Location = new Point(xpos, ypos);
            label.Size = new Size(labelheight * 3, labelheight);

            xpos += labelheight * 4;
            endMeasure = new NumericUpDown();
            endMeasure.Parent = dialog;
            endMeasure.Minimum = 1;
            endMeasure.Maximum = lastMeasure;
            endMeasure.Value = lastMeasure;
            endMeasure.Location = new Point(xpos, ypos);
            endMeasure.Size = new Size(labelheight*2, labelheight);

            /* Create the OK and Cancel buttons */
            xpos = labelheight/2;
            ypos += labelheight * 3/2;
            Button ok = new Button();
            ok.Parent = dialog;
            ok.Text = "OK";
            ok.Location = new Point(xpos, ypos);
            ok.DialogResult = DialogResult.OK;

            dialog.Size = new Size(labelheight * 10,
                               labelheight * 8);
        }
Ejemplo n.º 3
0
        public bool useDefaultInstruments; /** If true, don't change instruments */

        #endregion Fields

        #region Constructors

        public MidiOptions(MidiFile midifile)
        {
            int numtracks = midifile.Tracks.Count;
            tracks = new bool[numtracks];
            mute =  new bool[numtracks];
            instruments = new int[numtracks];
            for (int i = 0; i < tracks.Length; i++) {
            tracks[i] = true;
            mute[i] = false;
            instruments[i] = midifile.Tracks[i].Instrument;
            if (midifile.Tracks[i].InstrumentName == "Percussion") {
                tracks[i] = false;
            }
            }
            useDefaultInstruments = true;
            scrollVert = true;
            largeNoteSize = false;
            if (tracks.Length == 1) {
            twoStaffs = true;
            }
            else {
            twoStaffs = false;
            }
            showNoteLetters = NoteNameNone;
            showLyrics = true;
            showMeasures = false;
            shifttime = 0;
            transpose = 0;
            key = -1;
            time = midifile.Time;
            colors = null;
            shadeColor = Color.FromArgb(210, 205, 220);
            shade2Color = Color.FromArgb(80, 100, 250);
            combineInterval = 40;
            tempo = midifile.Time.Tempo;
            pauseTime = 0;
            playMeasuresInLoop = false;
            playMeasuresInLoopStart = 0;
            playMeasuresInLoopEnd = midifile.EndTime() / midifile.Time.Measure;
        }