Ejemplo n.º 1
0
        /** The MidiFile and/or SheetMusic has changed. Stop any playback sound,
         *  and store the current midifile and sheet music.
         */
        public void SetMidiFile(MidiFile file, MidiOptions opt, SheetMusic s)
        {
            /* If we're paused, and using the same midi file, redraw the
             * highlighted notes.
             */
            if ((file == midifile && midifile != null && playstate == paused))
            {
                options = opt;
                sheet   = s;
                sheet.ShadeNotes((int)currentPulseTime, (int)-10, false);
                sheet.MouseClick += new MouseEventHandler(MoveToClicked);

                /* We have to wait some time (200 msec) for the sheet music
                 * to scroll and redraw, before we can re-shade.
                 */
                Timer redrawTimer = new Timer();
                redrawTimer.Interval = 200;
                redrawTimer.Tick    += new EventHandler(ReShade);
                redrawTimer.Enabled  = true;
                redrawTimer.Start();
            }
            else
            {
                this.Stop(null, null);
                midifile = file;
                options  = opt;
                sheet    = s;
                if (sheet != null)
                {
                    sheet.MouseClick += new MouseEventHandler(MoveToClicked);
                }
            }
            this.DeleteSoundFile();
        }
 public static void Main(string[] argv)
 {
     if (argv.Length < 1) {
         Console.WriteLine("Usage: ExampleSheetMusicDLL filename.mid");
         return;
     }
     string filename = argv[0];
     Form form = new Form();
     SheetMusic sheet = new SheetMusic(filename, null);
     sheet.Parent = form;
     form.Size = new Size(600, 400);
     form.AutoScroll = true;
     Application.Run(form);
 }
Ejemplo n.º 3
0
        private int measureLength;          /** The time (in pulses) of a measure */

        /** Create a new staff with the given list of music symbols,
         * and the given key signature.  The clef is determined by
         * the clef of the first chord symbol. The track number is used
         * to determine whether to join this left/right vertical sides
         * with the staffs above and below. The SheetMusicOptions are used
         * to check whether to display measure numbers or not.
         */
        public Staff(List <MusicSymbol> symbols, KeySignature key,
                     MidiOptions options,
                     int tracknum, int totaltracks)
        {
            keysigWidth      = SheetMusic.KeySignatureWidth(key);
            this.tracknum    = tracknum;
            this.totaltracks = totaltracks;
            showMeasures     = (options.showMeasures && tracknum == 0);
            measureLength    = options.time.Measure;
            Clef clef = FindClef(symbols);

            clefsym      = new ClefSymbol(clef, 0, false);
            keys         = key.GetSymbols(clef);
            this.symbols = symbols;
            CalculateWidth(options.scrollVert);
            CalculateHeight();
            CalculateStartEndTime();
            FullJustify();
        }
Ejemplo n.º 4
0
    public static void Main(string[] argv)
    {
        if (argv.Length < 2) {
            Console.WriteLine("Usage: sheet input.mid output_prefix(_[page_number].png)");
            return;
        }
        string filename = argv[0];
        SheetMusic sheet = new SheetMusic(filename, null);

        int numpages = sheet.GetTotalPages();
        string image_filename = argv[1];
        for (int page = 1; page <= numpages; page++) {
            Bitmap bitmap = new Bitmap(SheetMusic.PageWidth+40,
                                       SheetMusic.PageHeight+40);
            Graphics g = Graphics.FromImage(bitmap);
            sheet.DoPrint(g, page);
            bitmap.Save(image_filename + "_" + page + ".png",
                        System.Drawing.Imaging.ImageFormat.Png);
            g.Dispose();
            bitmap.Dispose();
        }
    }
Ejemplo n.º 5
0
        private SheetMusic sheetmusic;      /** Used to get colors and other options */


        /** Create a new Chord Symbol from the given list of midi notes.
         * All the midi notes will have the same start time.  Use the
         * key signature to get the white key and accidental symbol for
         * each note.  Use the time signature to calculate the duration
         * of the notes. Use the clef when drawing the chord.
         */
        public ChordSymbol(List <MidiNote> midinotes, KeySignature key,
                           TimeSignature time, Clef c, SheetMusic sheet)
        {
            int len = midinotes.Count;
            int i;

            hastwostems = false;
            clef        = c;
            sheetmusic  = sheet;

            starttime = midinotes[0].StartTime;
            endtime   = midinotes[0].EndTime;

            for (i = 0; i < midinotes.Count; i++)
            {
                if (i > 1)
                {
                    if (midinotes[i].Number < midinotes[i - 1].Number)
                    {
                        throw new System.ArgumentException("Chord notes not in increasing order by number");
                    }
                }
                endtime = Math.Max(endtime, midinotes[i].EndTime);
            }

            notedata     = CreateNoteData(midinotes, key, time);
            accidsymbols = CreateAccidSymbols(notedata, clef);


            /* Find out how many stems we need (1 or 2) */
            NoteDuration dur1   = notedata[0].duration;
            NoteDuration dur2   = dur1;
            int          change = -1;

            for (i = 0; i < notedata.Length; i++)
            {
                dur2 = notedata[i].duration;
                if (dur1 != dur2)
                {
                    change = i;
                    break;
                }
            }

            if (dur1 != dur2)
            {
                /* We have notes with different durations.  So we will need
                 * two stems.  The first stem points down, and contains the
                 * bottom note up to the note with the different duration.
                 *
                 * The second stem points up, and contains the note with the
                 * different duration up to the top note.
                 */
                hastwostems = true;
                stem1       = new Stem(notedata[0].whitenote,
                                       notedata[change - 1].whitenote,
                                       dur1,
                                       Stem.Down,
                                       NotesOverlap(notedata, 0, change)
                                       );

                stem2 = new Stem(notedata[change].whitenote,
                                 notedata[notedata.Length - 1].whitenote,
                                 dur2,
                                 Stem.Up,
                                 NotesOverlap(notedata, change, notedata.Length)
                                 );
            }
            else
            {
                /* All notes have the same duration, so we only need one stem. */
                int direction = StemDirection(notedata[0].whitenote,
                                              notedata[notedata.Length - 1].whitenote,
                                              clef);

                stem1 = new Stem(notedata[0].whitenote,
                                 notedata[notedata.Length - 1].whitenote,
                                 dur1,
                                 direction,
                                 NotesOverlap(notedata, 0, notedata.Length)
                                 );
                stem2 = null;
            }

            /* For whole notes, no stem is drawn. */
            if (dur1 == NoteDuration.Whole)
            {
                stem1 = null;
            }
            if (dur2 == NoteDuration.Whole)
            {
                stem2 = null;
            }

            width = MinWidth;
        }
Ejemplo n.º 6
0
        /** Create a new MidiPlayer, displaying the play/stop buttons, the
         *  speed bar, and volume bar.  The midifile and sheetmusic are initially null.
         */
        public MidiPlayer()
        {
            this.Font = new Font("Arial", 10, FontStyle.Bold);
            loadButtonImages();
            int buttonheight = this.Font.Height * 2;

            this.midifile    = null;
            this.options     = null;
            this.sheet       = null;
            playstate        = stopped;
            startTime        = DateTime.Now.TimeOfDay;
            startPulseTime   = 0;
            currentPulseTime = 0;
            prevPulseTime    = -10;
            errormsg         = new StringBuilder(256);
            ToolTip tip;

            /* Create the rewind button */
            rewindButton            = new Button();
            rewindButton.Parent     = this;
            rewindButton.Image      = rewindImage;
            rewindButton.ImageAlign = ContentAlignment.MiddleCenter;
            rewindButton.Size       = new Size(buttonheight, buttonheight);
            rewindButton.Location   = new Point(buttonheight / 2, buttonheight / 2);
            rewindButton.Click     += new EventHandler(Rewind);
            tip = new ToolTip();
            tip.SetToolTip(rewindButton, Resources.Localization.Strings.rewind);

            /* Create the play button */
            playButton            = new Button();
            playButton.Parent     = this;
            playButton.Image      = playImage;
            playButton.ImageAlign = ContentAlignment.MiddleCenter;
            playButton.Size       = new Size(buttonheight, buttonheight);
            playButton.Location   = new Point(buttonheight / 2, buttonheight / 2);
            playButton.Location   = new Point(rewindButton.Location.X + rewindButton.Width + buttonheight / 2,
                                              rewindButton.Location.Y);
            playButton.Click += new EventHandler(PlayPause);
            playTip           = new ToolTip();
            playTip.SetToolTip(playButton, Resources.Localization.Strings.play);

            /* Create the stop button */
            stopButton            = new Button();
            stopButton.Parent     = this;
            stopButton.Image      = stopImage;
            stopButton.ImageAlign = ContentAlignment.MiddleCenter;
            stopButton.Size       = new Size(buttonheight, buttonheight);
            stopButton.Location   = new Point(playButton.Location.X + playButton.Width + buttonheight / 2,
                                              playButton.Location.Y);
            stopButton.Click += new EventHandler(Stop);
            tip = new ToolTip();
            tip.SetToolTip(stopButton, Resources.Localization.Strings.stop);

            /* Create the fastFwd button */
            fastFwdButton            = new Button();
            fastFwdButton.Parent     = this;
            fastFwdButton.Image      = fastFwdImage;
            fastFwdButton.ImageAlign = ContentAlignment.MiddleCenter;
            fastFwdButton.Size       = new Size(buttonheight, buttonheight);
            fastFwdButton.Location   = new Point(stopButton.Location.X + stopButton.Width + buttonheight / 2,
                                                 stopButton.Location.Y);
            fastFwdButton.Click += new EventHandler(FastForward);
            tip = new ToolTip();
            tip.SetToolTip(fastFwdButton, Resources.Localization.Strings.fastForward);



            /* Create the Speed bar */
            speedLabel           = new Label();
            speedLabel.Parent    = this;
            speedLabel.Text      = Resources.Localization.Strings.speed + " : 100%";
            speedLabel.TextAlign = ContentAlignment.MiddleLeft;
            speedLabel.Height    = buttonheight;
            speedLabel.Width     = buttonheight * 3;
            speedLabel.Location  = new Point(fastFwdButton.Location.X + fastFwdButton.Width + buttonheight / 2,
                                             fastFwdButton.Location.Y);

            speedBar               = new TrackBar();
            speedBar.Parent        = this;
            speedBar.Minimum       = 1;
            speedBar.Maximum       = 150;
            speedBar.TickFrequency = 10;
            speedBar.TickStyle     = TickStyle.BottomRight;
            speedBar.LargeChange   = 10;
            speedBar.Value         = 100;
            speedBar.Width         = buttonheight * 6;
            speedBar.Location      = new Point(speedLabel.Location.X + speedLabel.Width + 2,
                                               speedLabel.Location.Y);
            speedBar.Scroll += new EventHandler(SpeedBarChanged);

            tip = new ToolTip();
            tip.SetToolTip(speedBar, Resources.Localization.Strings.speed);

            /* Create the Volume bar */
            Label volumeLabel = new Label();

            volumeLabel.Parent     = this;
            volumeLabel.Image      = volumeImage;
            volumeLabel.ImageAlign = ContentAlignment.MiddleRight;
            volumeLabel.Height     = buttonheight;
            volumeLabel.Width      = buttonheight * 2;
            volumeLabel.Location   = new Point(speedBar.Location.X + speedBar.Width + buttonheight / 2,
                                               speedBar.Location.Y);

            volumeBar               = new TrackBar();
            volumeBar.Parent        = this;
            volumeBar.Minimum       = 1;
            volumeBar.Maximum       = 100;
            volumeBar.TickFrequency = 10;
            volumeBar.TickStyle     = TickStyle.BottomRight;
            volumeBar.LargeChange   = 10;
            volumeBar.Value         = 100;
            volumeBar.Width         = buttonheight * 6;
            volumeBar.Location      = new Point(volumeLabel.Location.X + volumeLabel.Width + 2,
                                                volumeLabel.Location.Y);
            volumeBar.Scroll += new EventHandler(ChangeVolume);
            tip = new ToolTip();
            tip.SetToolTip(volumeBar, Resources.Localization.Strings.volume);

            Height = buttonheight * 2;

            /* Initialize the timer used for playback, but don't start
             * the timer yet (enabled = false).
             */
            timer          = new Timer();
            timer.Enabled  = false;
            timer.Interval = 100; /* 100 millisec */
            timer.Tick    += new EventHandler(TimerCallback);

            tempSoundFile = "";
        }
Ejemplo n.º 7
0
        /** Create a new MidiPlayer, displaying the play/stop buttons, the
         *  speed bar, and volume bar.  The midifile and sheetmusic are initially null.
         */
        public MidiPlayer()
        {
            this.Font = new Font("Arial", 10, FontStyle.Bold);
            loadButtonImages();
            int buttonheight = this.Font.Height * 2;

            this.midifile                  = null;
            this.options                   = null;
            this.sheet                     = null;
            playstate                      = stopped;
            scoreFollowingState            = stopped;
            startTime                      = DateTime.Now.TimeOfDay;
            startPulseTime                 = 0;
            currentPulseTime               = 0;
            currentPulseTimeScoreFollowing = 0;
            prevPulseTime                  = -10;
            prevPulseTimeScoreFollowing    = -10;
            errormsg = new StringBuilder(256);
            ToolTip tip;

            /* Create the rewind button */
            rewindButton            = new Button();
            rewindButton.Parent     = this;
            rewindButton.Image      = rewindImage;
            rewindButton.ImageAlign = ContentAlignment.MiddleCenter;
            rewindButton.Size       = new Size(buttonheight, buttonheight);
            rewindButton.Location   = new Point(buttonheight / 2, buttonheight / 2);
            rewindButton.Click     += new EventHandler(Rewind);
            tip = new ToolTip();
            tip.SetToolTip(rewindButton, Strings.rewind);

            /* Create the play button */
            playButton            = new Button();
            playButton.Parent     = this;
            playButton.Image      = playImage;
            playButton.ImageAlign = ContentAlignment.MiddleCenter;
            playButton.Size       = new Size(buttonheight, buttonheight);
            playButton.Location   = new Point(buttonheight / 2, buttonheight / 2);
            playButton.Location   = new Point(rewindButton.Location.X + rewindButton.Width + buttonheight / 2,
                                              rewindButton.Location.Y);
            playButton.Click += new EventHandler(PlayPause);
            playTip           = new ToolTip();
            playTip.SetToolTip(playButton, Strings.play);

            /* Create the stop button */
            stopButton            = new Button();
            stopButton.Parent     = this;
            stopButton.Image      = stopImage;
            stopButton.ImageAlign = ContentAlignment.MiddleCenter;
            stopButton.Size       = new Size(buttonheight, buttonheight);
            stopButton.Location   = new Point(playButton.Location.X + playButton.Width + buttonheight / 2,
                                              playButton.Location.Y);
            stopButton.Click += new EventHandler(Stop);
            tip = new ToolTip();
            tip.SetToolTip(stopButton, Strings.stop);

            /* Create the fastFwd button */
            fastFwdButton            = new Button();
            fastFwdButton.Parent     = this;
            fastFwdButton.Image      = fastFwdImage;
            fastFwdButton.ImageAlign = ContentAlignment.MiddleCenter;
            fastFwdButton.Size       = new Size(buttonheight, buttonheight);
            fastFwdButton.Location   = new Point(stopButton.Location.X + stopButton.Width + buttonheight / 2,
                                                 stopButton.Location.Y);
            fastFwdButton.Click += new EventHandler(FastForward);
            tip = new ToolTip();
            tip.SetToolTip(fastFwdButton, Strings.fastForward);

            /* Create the score follower button */
            scoreFollowingButton            = new Button();
            scoreFollowingButton.Parent     = this;
            scoreFollowingButton.Image      = playImage;
            scoreFollowingButton.ImageAlign = ContentAlignment.MiddleCenter;
            scoreFollowingButton.Size       = new Size(buttonheight, buttonheight);
            scoreFollowingButton.Location   = new Point(fastFwdButton.Location.X + fastFwdButton.Width + buttonheight / 2,
                                                        fastFwdButton.Location.Y);

            scoreFollowingButton.Click += new EventHandler(StartStopScoreFollowing);
            tip = new ToolTip();
            tip.SetToolTip(scoreFollowingButton, "Start score following");

            /* Create the Speed bar */
            speedLabel           = new Label();
            speedLabel.Parent    = this;
            speedLabel.Text      = Strings.speed + " : 100%";
            speedLabel.TextAlign = ContentAlignment.MiddleLeft;
            speedLabel.Height    = buttonheight;
            speedLabel.Width     = buttonheight * 3;
            speedLabel.Location  = new Point(scoreFollowingButton.Location.X + scoreFollowingButton.Width + buttonheight / 2,
                                             scoreFollowingButton.Location.Y);

            speedBar               = new TrackBar();
            speedBar.Parent        = this;
            speedBar.Minimum       = 1;
            speedBar.Maximum       = 150;
            speedBar.TickFrequency = 10;
            speedBar.TickStyle     = TickStyle.BottomRight;
            speedBar.LargeChange   = 10;
            speedBar.Value         = 100;
            speedBar.Width         = buttonheight * 6;
            speedBar.Location      = new Point(speedLabel.Location.X + speedLabel.Width + 2,
                                               speedLabel.Location.Y);
            speedBar.Scroll += new EventHandler(SpeedBarChanged);

            tip = new ToolTip();
            tip.SetToolTip(speedBar, Strings.speed);

            /* Create the Volume bar */
            Label volumeLabel = new Label();

            volumeLabel.Parent     = this;
            volumeLabel.Image      = volumeImage;
            volumeLabel.ImageAlign = ContentAlignment.MiddleRight;
            volumeLabel.Height     = buttonheight;
            volumeLabel.Width      = buttonheight * 2;
            volumeLabel.Location   = new Point(speedBar.Location.X + speedBar.Width + buttonheight / 2,
                                               speedBar.Location.Y);

            volumeBar               = new TrackBar();
            volumeBar.Parent        = this;
            volumeBar.Minimum       = 1;
            volumeBar.Maximum       = 100;
            volumeBar.TickFrequency = 10;
            volumeBar.TickStyle     = TickStyle.BottomRight;
            volumeBar.LargeChange   = 10;
            volumeBar.Value         = 100;
            volumeBar.Width         = buttonheight * 6;
            volumeBar.Location      = new Point(volumeLabel.Location.X + volumeLabel.Width + 2,
                                                volumeLabel.Location.Y);
            volumeBar.Scroll += new EventHandler(ChangeVolume);
            tip = new ToolTip();
            tip.SetToolTip(volumeBar, Strings.volume);

            Height = buttonheight * 2;

            textBox          = new TextBox();
            textBox.Parent   = this;
            textBox.Height   = buttonheight * 3;
            textBox.Width    = buttonheight * 20;
            textBox.Location = new Point(volumeBar.Location.X + volumeBar.Width + 2,
                                         volumeBar.Location.Y);

            /* Initialize the timer used for playback, but don't start
             * the timer yet (enabled = false).
             */
            timer          = new Timer();
            timer.Enabled  = false;
            timer.Interval = 100; /* 100 millisec */
            timer.Tick    += new EventHandler(TimerCallback);

            tempSoundFile = "";

            ///////////////////////////////////////////////////////////////////

            /* Initialize the timer used for score following */
            timerScoreFollowing         = new Timer();
            timerScoreFollowing.Enabled = false;
            // Need to run at a higher frquency than the backend (otherwise,
            // we may not capute teh instructions).
            timerScoreFollowing.Interval = 50;
            timerScoreFollowing.Tick    += new EventHandler(TimerCallbackScoreFollowing);

            // Create the ZQM sockets, open the TCP ports
            context    = new ZContext();
            subscriber = new ZSocket(context, ZSocketType.SUB);
            subscriber.Subscribe("");
            subscriber.Conflate = true; // Keep only the last message
            subscriber.Connect("tcp://127.0.0.1:5555");

            publisher = new ZSocket(context, ZSocketType.PUB);
            publisher.Bind("tcp://127.0.0.1:5556");

            ///////////////////////////////////////////////////////////////////
        }
Ejemplo n.º 8
0
        private int width; /** The width of the chord */

        #endregion Fields

        #region Constructors

        /** Create a new Chord Symbol from the given list of midi notes.
         * All the midi notes will have the same start time.  Use the
         * key signature to get the white key and accidental symbol for
         * each note.  Use the time signature to calculate the duration
         * of the notes. Use the clef when drawing the chord.
         */
        public ChordSymbol(List<MidiNote> midinotes, KeySignature key, 
            TimeSignature time, Clef c, SheetMusic sheet)
        {
            int len = midinotes.Count;
            int i;

            hastwostems = false;
            clef = c;
            sheetmusic = sheet;

            starttime = midinotes[0].StartTime;
            endtime = midinotes[0].EndTime;

            for (i = 0; i < midinotes.Count; i++) {
            if (i > 1) {
                if (midinotes[i].Number < midinotes[i-1].Number) {
                    throw new System.ArgumentException("Chord notes not in increasing order by number");
                }
            }
            endtime = Math.Max(endtime, midinotes[i].EndTime);
            }

            notedata = CreateNoteData(midinotes, key, time);
            accidsymbols = CreateAccidSymbols(notedata, clef);

            /* Find out how many stems we need (1 or 2) */
            NoteDuration dur1 = notedata[0].duration;
            NoteDuration dur2 = dur1;
            int change = -1;
            for (i = 0; i < notedata.Length; i++) {
            dur2 = notedata[i].duration;
            if (dur1 != dur2) {
                change = i;
                break;
            }
            }

            if (dur1 != dur2) {
            /* We have notes with different durations.  So we will need
             * two stems.  The first stem points down, and contains the
             * bottom note up to the note with the different duration.
             *
             * The second stem points up, and contains the note with the
             * different duration up to the top note.
             */
            hastwostems = true;
            stem1 = new Stem(notedata[0].whitenote,
                             notedata[change-1].whitenote,
                             dur1,
                             Stem.Down,
                             NotesOverlap(notedata, 0, change)
                            );

            stem2 = new Stem(notedata[change].whitenote,
                             notedata[notedata.Length-1].whitenote,
                             dur2,
                             Stem.Up,
                             NotesOverlap(notedata, change, notedata.Length)
                            );
            }
            else {
            /* All notes have the same duration, so we only need one stem. */
            int direction = StemDirection(notedata[0].whitenote,
                                          notedata[notedata.Length-1].whitenote,
                                          clef);

            stem1 = new Stem(notedata[0].whitenote,
                             notedata[notedata.Length-1].whitenote,
                             dur1,
                             direction,
                             NotesOverlap(notedata, 0, notedata.Length)
                            );
            stem2 = null;
            }

            /* For whole notes, no stem is drawn. */
            if (dur1 == NoteDuration.Whole)
            stem1 = null;
            if (dur2 == NoteDuration.Whole)
            stem2 = null;

            width = MinWidth;
        }
Ejemplo n.º 9
0
        private Image volumeImage; /** The volume image */

        #endregion Fields

        #region Constructors

        /** Create a new MidiPlayer, displaying the play/stop buttons, the
         *  speed bar, and volume bar.  The midifile and sheetmusic are initially null.
         */
        public MidiPlayer()
        {
            this.Font = new Font("Arial", 10, FontStyle.Bold);
            loadButtonImages();
            int buttonheight = this.Font.Height * 2;

            this.midifile = null;
            this.options = null;
            this.sheet = null;
            playstate = stopped;
            startTime = DateTime.Now.TimeOfDay;
            startPulseTime = 0;
            currentPulseTime = 0;
            prevPulseTime = -10;
            errormsg = new StringBuilder(256);
            ToolTip tip;

            /* Create the rewind button */
            rewindButton = new Button();
            rewindButton.Parent = this;
            rewindButton.Image = rewindImage;
            rewindButton.ImageAlign = ContentAlignment.MiddleCenter;
            rewindButton.Size = new Size(buttonheight, buttonheight);
            rewindButton.Location = new Point(buttonheight/2, buttonheight/2);
            rewindButton.Click += new EventHandler(Rewind);
            tip = new ToolTip();
            tip.SetToolTip(rewindButton, "Rewind");

            /* Create the play button */
            playButton = new Button();
            playButton.Parent = this;
            playButton.Image = playImage;
            playButton.ImageAlign = ContentAlignment.MiddleCenter;
            playButton.Size = new Size(buttonheight, buttonheight);
            playButton.Location = new Point(buttonheight/2, buttonheight/2);
            playButton.Location = new Point(rewindButton.Location.X + rewindButton.Width + buttonheight/2,
                                        rewindButton.Location.Y);
            playButton.Click += new EventHandler(PlayPause);
            playTip = new ToolTip();
            playTip.SetToolTip(playButton, "Play");

            /* Create the stop button */
            stopButton = new Button();
            stopButton.Parent = this;
            stopButton.Image = stopImage;
            stopButton.ImageAlign = ContentAlignment.MiddleCenter;
            stopButton.Size = new Size(buttonheight, buttonheight);
            stopButton.Location = new Point(playButton.Location.X + playButton.Width + buttonheight/2,
                                        playButton.Location.Y);
            stopButton.Click += new EventHandler(Stop);
            tip = new ToolTip();
            tip.SetToolTip(stopButton, "Stop");

            /* Create the fastFwd button */
            fastFwdButton = new Button();
            fastFwdButton.Parent = this;
            fastFwdButton.Image = fastFwdImage;
            fastFwdButton.ImageAlign = ContentAlignment.MiddleCenter;
            fastFwdButton.Size = new Size(buttonheight, buttonheight);
            fastFwdButton.Location = new Point(stopButton.Location.X + stopButton.Width + buttonheight/2,
                                          stopButton.Location.Y);
            fastFwdButton.Click += new EventHandler(FastForward);
            tip = new ToolTip();
            tip.SetToolTip(fastFwdButton, "Fast Forward");

            /* Create the Speed bar */
            Label speedLabel = new Label();
            speedLabel.Parent = this;
            speedLabel.Text = "Speed: ";
            speedLabel.TextAlign = ContentAlignment.MiddleRight;
            speedLabel.Height = buttonheight;
            speedLabel.Width = buttonheight*2;
            speedLabel.Location = new Point(fastFwdButton.Location.X + fastFwdButton.Width + buttonheight/2,
                                        fastFwdButton.Location.Y);

            speedBar = new TrackBar();
            speedBar.Parent = this;
            speedBar.Minimum = 1;
            speedBar.Maximum = 100;
            speedBar.TickFrequency = 10;
            speedBar.TickStyle = TickStyle.BottomRight;
            speedBar.LargeChange = 10;
            speedBar.Value = 100;
            speedBar.Width = buttonheight * 5;
            speedBar.Location = new Point(speedLabel.Location.X + speedLabel.Width + 2,
                                      speedLabel.Location.Y);
            tip = new ToolTip();
            tip.SetToolTip(speedBar, "Adjust the speed");

            /* Create the Volume bar */
            Label volumeLabel = new Label();
            volumeLabel.Parent = this;
            volumeLabel.Image = volumeImage;
            volumeLabel.ImageAlign = ContentAlignment.MiddleRight;
            volumeLabel.Height = buttonheight;
            volumeLabel.Width = buttonheight*2;
            volumeLabel.Location = new Point(speedBar.Location.X + speedBar.Width + buttonheight/2,
                                         speedBar.Location.Y);

            volumeBar = new TrackBar();
            volumeBar.Parent = this;
            volumeBar.Minimum = 1;
            volumeBar.Maximum = 100;
            volumeBar.TickFrequency = 10;
            volumeBar.TickStyle = TickStyle.BottomRight;
            volumeBar.LargeChange = 10;
            volumeBar.Value = 100;
            volumeBar.Width = buttonheight * 5;
            volumeBar.Location = new Point(volumeLabel.Location.X + volumeLabel.Width + 2,
                                       volumeLabel.Location.Y);
            volumeBar.Scroll += new EventHandler(ChangeVolume);
            tip = new ToolTip();
            tip.SetToolTip(volumeBar, "Adjust the volume");

            Height = buttonheight*2;

            /* Initialize the timer used for playback, but don't start
             * the timer yet (enabled = false).
             */
            timer = new Timer();
            timer.Enabled = false;
            timer.Interval = 100;  /* 100 millisec */
            timer.Tick += new EventHandler(TimerCallback);

            tempSoundFile = "";
        }
Ejemplo n.º 10
0
        /** The MidiFile and/or SheetMusic has changed. Stop any playback sound,
         *  and store the current midifile and sheet music.
         */
        public void SetMidiFile(MidiFile file, MidiOptions opt, SheetMusic s)
        {
            /* If we're paused, and using the same midi file, redraw the
             * highlighted notes.
             */
            if ((file == midifile && midifile != null && playstate == paused)) {
            options = opt;
            sheet = s;
            sheet.ShadeNotes((int)currentPulseTime, (int)-10, false);

            /* We have to wait some time (200 msec) for the sheet music
             * to scroll and redraw, before we can re-shade.
             */
            Timer redrawTimer = new Timer();
            redrawTimer.Interval = 200;
            redrawTimer.Tick += new EventHandler(ReShade);
            redrawTimer.Enabled = true;
            redrawTimer.Start();
            }
            else {
            this.Stop(null, null);
            midifile = file;
            options = opt;
            sheet = s;
            }
            this.DeleteSoundFile();
        }
Ejemplo n.º 11
0
 /** The callback function for the "Close" menu.
  * When invoked this will
  * - Dispose of the SheetMusic Control
  * - Disable the relevant menu items.
  */
 void Close(object obj, EventArgs args)
 {
     if (sheetmusic == null) {
     return;
     }
     player.SetMidiFile(null, null, null);
     sheetmusic.Dispose();
     sheetmusic = null;
     DisableMenus();
     BackColor = Color.Gray;
     scrollView.BackColor = Color.Gray;
     Text = "Midi Sheet Music";
     instrumentDialog.Dispose();
     playMeasuresDialog.Dispose();
 }
Ejemplo n.º 12
0
        /** The Sheet Music needs to be redrawn.  Gather the sheet music
         * options from the menu items.  Then create the sheetmusic
         * control, and add it to this form. Update the MidiPlayer with
         * the new midi file.
         */
        void RedrawSheetMusic()
        {
            if (selectMidi != null) {
            selectMidi.Dispose();
            }

            if (sheetmusic != null) {
            sheetmusic.Dispose();
            }

            MidiOptions options = GetMidiOptions();

            /* Create a new SheetMusic Control from the midifile */
            sheetmusic = new SheetMusic(midifile, options);
            sheetmusic.SetZoom(zoom);
            sheetmusic.Parent = scrollView;

            BackColor = Color.White;
            scrollView.BackColor = Color.White;

            /* Update the Midi Player and piano */
            piano.SetMidiFile(midifile, options);
            piano.SetShadeColors(colordialog.ShadeColor, colordialog.Shade2Color);
            player.SetMidiFile(midifile, options, sheetmusic);
        }