private void button1_MouseUp(object sender, MouseEventArgs e)
        {
            BlackMusKey bmk = new BlackMusKey(2, 1, 1);

            foreach (MusKey mk in this.Controls)
            {
                if (sender == mk)
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        timer1.Enabled = false;
                        sp.Stop();
                        string bNoteShape = null;
                        int    duration   = 0;
                        if (count >= 11)
                        {
                            bNoteShape = "SemiBreve";
                            duration   = 11;
                        }
                        else if (count >= 9 && count <= 10)
                        {
                            bNoteShape = "DotMinim";
                            duration   = (9 + 10) / 2;
                        }
                        else if (count >= 7 && count <= 8)
                        {
                            bNoteShape = "minim";
                            duration   = (7 + 8) / 2;
                        }
                        else if (count >= 4 && count <= 6)
                        {
                            bNoteShape = "Crotchet";
                            duration   = (4 + 6) / 2;
                        }
                        else if (count >= 2 && count <= 3)
                        {
                            bNoteShape = "Quaver";
                            duration   = (2 + 3) / 2;
                        }
                        else
                        {
                            bNoteShape = "SemiQuaver";
                            duration   = 1;
                        }

                        if (mk.GetType() == bmk.GetType())
                        {
                            bNoteShape += "Sharp";
                        }
                        MusicNote mn = new MusicNote(mk.MusicNote, duration, bNoteShape);
                        mn.Location = new Point(xLoc, yLoc);
                        AddNote(mn);
                        xLoc = xLoc + 40;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void Play_MouseClick(object sender, MouseEventArgs e)
        {
            String      folderpath = "C:\\Users\\Ezek_\\source\\repos\\lakbarmazzataghawdex2\\Notes-Sound files\\mapped\\";
            SoundPlayer sp         = new SoundPlayer();

            foreach (Object obj in this.Controls)
            {
                if (obj.GetType() == mn.GetType())
                {
                    MusicNote musicNote = (MusicNote)obj;
                    sp.SoundLocation = folderpath + musicNote.NotePitch + ".wav";
                    sp.Play();
                    Thread.Sleep(musicNote.Duration);
                }
            }
        }
Ejemplo n.º 3
0
 public void AddNote(MusicNote musicNote)
 {
     musicNotes.Add(musicNote);
     this.Controls.Add(musicNote);
 }
        //enum Try { Q,W,E, R, T, Y, U, I, O, P, A, S, D, F, G, H, J, K, L, Z, X, C, V, B };
        public void button1_KeyUp(object sender, KeyEventArgs e)
        {
            BlackMusKey bmk = new BlackMusKey(2, 1, 1);

            foreach (MusKey mk in this.Controls)
            {
                if (sender == mk)
                {
                    for (int i = 1; i < 24; i++)
                    {
                        if (e.KeyCode == Keys.Q || e.KeyCode == Keys.W || e.KeyCode == Keys.E || e.KeyCode == Keys.R || e.KeyCode == Keys.T || e.KeyCode == Keys.Y || e.KeyCode == Keys.U || e.KeyCode == Keys.I || e.KeyCode == Keys.O || e.KeyCode == Keys.P ||
                            e.KeyCode == Keys.A || e.KeyCode == Keys.S || e.KeyCode == Keys.D || e.KeyCode == Keys.F || e.KeyCode == Keys.G || e.KeyCode == Keys.H || e.KeyCode == Keys.J ||
                            e.KeyCode == Keys.K || e.KeyCode == Keys.L || e.KeyCode == Keys.Z || e.KeyCode == Keys.X || e.KeyCode == Keys.C || e.KeyCode == Keys.V || e.KeyCode == Keys.B)
                        {
                            timer.Enabled = false;
                            sp.Stop();
                            string bNoteShape = null;
                            int    duration   = 0;
                            if (count >= 11)
                            {
                                bNoteShape = "SemiBreve";
                                duration   = 11;
                            }
                            else if (count >= 9 && count <= 10)
                            {
                                bNoteShape = "DotMinim";
                                duration   = (9 + 10) / 2;
                            }
                            else if (count >= 7 && count <= 8)
                            {
                                bNoteShape = "minim";
                                duration   = (7 + 8) / 2;
                            }
                            else if (count >= 4 && count <= 6)
                            {
                                bNoteShape = "Crotchet";
                                duration   = (4 + 6) / 2;
                            }
                            else if (count >= 2 && count <= 3)
                            {
                                bNoteShape = "Quaver";
                                duration   = (2 + 3) / 2;
                            }
                            else
                            {
                                bNoteShape = "SemiQuaver";
                                duration   = 1;
                            }

                            if (mk.GetType() == bmk.GetType())
                            {
                                bNoteShape += "Sharp";
                            }
                            MusicNote mn = new MusicNote(mk.MusicNote, duration, bNoteShape);
                            mn.Location = new Point(xLoc, yLoc);

                            xLoc = xLoc + 40;
                        }
                    }
                }
            }
        }