Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Dance beat/rythm/tempo detector

  1. #1
    Junior Member
    Join Date
    Mar 2017
    Posts
    12

    Dance beat/rythm/tempo detector

    Hi All,

    I want to create a dance beat detector. That means that I want a device that can tell the rhythm of music by observing dance movement.

    Notice that dancing doesn't always translate into stepping, and the foot might never leave the ground.

    I thought about attaching such a device to the belt.

    My inclining is to use an accelerometer for that. I still have no idea how to actually detect the rhythm of the accelerometer reading.
    My guess:
    * Sample every 10 ms
    * create a vector of the last 10 readings
    * down pointing vector is if it points to 135 to 225 degrees.
    * a beat is detected whenever the vector stops pointing down.

    Any suggestions?

    Thanks!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,096
    I'd start by logging all the data to a SD card. Maybe build up a few test devices and collect several sessions of data from people dancing.

    As a very first step, I'd bring the data into something like Matlab and do a huge FFT over many minutes or even hours (if possible) of data collected, assuming they were dancing to similar music the whole time. Maybe there will be spectral peaks or other recognizable shapes that correspond with the beat of the music?

    Maybe experimentation will give you some way to find the beat without the complexity of FFT. But Teensy 3.2 can compute a 1024 point FFT in just a couple milliseconds (if you use arm_math.h), so just putting the data into a big buffer and regularly running FFTs is a very practical approach. There may be some numerical issues to sort out, perhaps you might use a weird window algorithm before the FFT, to give more weighting to the most recent data, but of course tapered on both ends so you don't get spectral leakage issues.

    Of course, this all assumes a FFT will show some sort of recognizable features corresponding to the beat, and you can craft code to pick out those features from all the other junk you'll measure. I'd start by just collecting some data sets, so you can do the analysis from the comfort of your PC and favorite scripting language or numerical analysis software.

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,459
    Quote Originally Posted by danshtr View Post
    My inclining is to use an accelerometer for that. I still have no idea how to actually detect the rhythm of the accelerometer reading.
    Let me assume, you wanted a procedural approach.
    First you should realize that what you wanted to do is detection of an event and classification of this event as dance beat or even dance theme.
    I would first make recording of Audio AND accelerometer. several sessions from multiple dance styles as Paul indicated.
    Then you have to figure out what you mean by beat (in terms of recorded data). what I mean is you should determine something like this:
    on the beat (you hear acoustically) you see a spine in the vertical axis of the accelerometer, or a two spikes in close repetition. These classification cues should be characteristic for each dance theme. If all dance on 1 and 3 you can find the beat not identify the dance theme.
    this phase needs lot of patience and data. One you are then the expert in classifying dance beat/theme from the accelerometer, you program the teensy to do this for you.

  4. #4
    Junior Member
    Join Date
    Mar 2017
    Posts
    12
    Thank you guys!

    I took notes...

    I am interested in the beat detection for freestyle electronic music dancing. From many samples I took (dancing throughout the years...), a heap movement of up and down will normally be synced to the music beat.

    I am inclined just to dive in and do average of reading, but maybe it is an opportunity to go deeper and log analasys and maybe learn fft once and for all...

  5. #5
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,265
    I'd say the beat is where the accelerometer changes sign from zero/negative to positive (assuming up acceleration is positive) and delta value between samples is greater than some threshold. Then track the putative 'beat' events over time (drop any too close together to be real - i.e. have a maximum beat limit to help remove noise events).

    You can calculate the implied tempo on each event or use a moving average or other filter to stabilize the output somewhat (assuming you want tempo and not just events).

    If the actual movements are too chaotic for this to work then a data-analysis approach as suggested might be required to figure out how to get usable output.

    edit- I'm assuming you would limit accelerometer readings to vertical axis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •