Skip to content Skip to navigation

OpenStax-CNX

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

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

Implementation: Detecting a hit

Module by: Kriti Charan, Tanwee Misra, Janice Chow. E-mail the authorsEdited 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.

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

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

What is in a lens?

Lens makers point to 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 member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks