Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code


    // this part of the code will play the sound in the recouces when the picurebox rolls over the new label
        System.Media.SoundPlayer player = new System.Media.SoundPlayer();
        private void BeatDetector_Move(object sender, EventArgs e)
        {
            //timeline timing
            if (timer1.Enabled == true)
            {




            }
            else
            {
                if (secs == 0)
                {
                    mins -= 1;
                    secs = 59;
                }
                else if (secs == 59)
                {
                    mins += 1;
                    secs = 0;
                }


                if (lastLocation.X > BeatDetector.Location.X)
                {
                    secs -= 1;
                    lastLocation.X = BeatDetector.Location.X;
                }
                if (lastLocation.X < BeatDetector.Location.X)
                {
                    secs += 1;
                    lastLocation.X = BeatDetector.Location.X;
                }
                TimeSong.Text = mins + ":" + secs + " / " + Mins.Text + ":" + Secs.Text;





            //making the label beats
            Label label = new Label();
            if (panel1.Contains(label))
            {
                if (BeatDetector.Location.X == label.Location.X)
                {


// this needs to be fixed
                    bool containsLetter = false;
                    string phoneNumber = label.Text.Trim();

                    for (int i = 0; i < phoneNumber.Length; i++)
                    {
                        if (!char.IsNumber(phoneNumber[i]))
                        {

                            int anInteger;
                            anInteger = Convert.ToInt32(label.Text);
                            anInteger = int.Parse(label.Text);

                            move = anInteger;
                            containsLetter = true;
                        }
                    }

                    if (containsLetter)
                    {
                        // do whatever you want with the error label


                    if (label.Text == "KICK2")
                    {
                   SoundPlayer player = new SoundPlayer(Properties.Resources.KICK2);
                   player.Play();
                    }

                    } 


            }









                }
            }


        }


This is whats meant to happen, the picturebox beatdetector is moving to the right doing X + 1, while its moving there's 2 diffident labels next to each other, the beatdetector hits the first label noticing it had a name on it ("KICK2") so then it will play that beat because it knows its a name not a number, when beat detctor rolls over the next label it says HEY! thats a number!, then it knows its a number so then if it is a number then take that number and then convert it into a int so then the int can be used if its not a number then it must be a a name so then if it is a number the following code with change

C#
// moves timer1 and timer2 and moves the betadetector
  int move = 1;
  private void timer2_Tick_1(object sender, EventArgs e)
  {
      BeatDetector.Location = new Point(BeatDetector.Location.X + move, BeatDetector.Location.Y);
  }



My error is, nothings happening, its meant to change how fast the beatdetector is moving, think of this as a music player or a music creator
Posted
Comments
milenalukic 3-May-12 5:23am    
If your beat detector is moving left I assume you want to trigger you code when the left side of the beatdetector hits the label. In this case you will meed to compare the beatdetector postion+its width for the trigger.
[no name] 3-May-12 7:15am    
I don"t understand, and didn't I already do that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900