Skip to content Skip to navigation

Connexions

You are here: Home » Content » Implementation: Detecting a hit

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of a lens

      Lenses

      A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

      What is in a lens?

      Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

      Who can create a lens?

      Any individual Connexions member, a community, or a respected organization.

    • External bookmarks
  • E-mail the authors

Recently Viewed

Implementation: Detecting a hit

Module by: Kriti Charan, Tanwee Misra, Janice Chow

Summary: This module describes how we determined when the user hit a drum and which drum s/he hit.

Hitting the Drums: A Velocity Computational Approach

You now have the positions of the LEDs in every frame. Our goal here is to detect when and which drums were hit so that the corresponding drums can produce their sounds.

Determining when a drum was hit

There are various innovative ways of tracking when the drums are hit. We chose to use a velocity computational approach due to its speed. Using this approach, you can look at the displacement of the LEDs in consecutive frames and calculate the velocity. Using basic physics, if the velocity changes from positive to negative (note that our coordinate system has the positive side of the y-axis pointing downwards) it implies a change in direction of the drumstick, or that a drum was hit. You should be able to figure out approximately which frame the drum was hit in. Since the hit point is returned in terms of two-dimensional coordinates, you can figure out which drum(s) are hit.

Figure 1
A plot of the variation in velocity with the movement of the LEDs. See if you can guess when drums were hit
 A plot of the variation in velocity with the movement of the LEDs. See if you can guess when drums were hit  (velocity.gif)

Determining which drum was hit

Figure 2
The positions of the drums [1: Cymbal; 2: BigTom; 3: Small Tom; 4: Floor Tom; 4: Snare]
 The positions of the drums [1: Cymbal; 2: BigTom; 3: Small Tom; 4: Floor Tom; 4: Snare] (window.jpg)

The frame should be broken down into rectangles with assigned x and y coordinates where the drums are positioned. Our drum kit consists of the Crash Cymbal, the Big Tom, the Small Tom, the Floor Tom and the Snare. We check to see if the hit-point falls in the space assigned for any of the drums, and if it does, we move on to producing the sound and displaying the image on the computer screen. However, if the hit point is outside the frame, it is taken as a missed hit.

Comments, questions, feedback, criticisms?

Send feedback