Skip to content

Tap-Along Beat Tapping in Time with Audio

Store each key press or screen tap with the tap's time in the audio, using one key per tap type, such as beats on the space bar and downbeats on d.

New in v2.15.0

The tap_along scheme records taps in time with audio as the audio plays. Annotators press Play and tap a key, or a button on a touch screen, along with the music. Potato stores each tap with the audio's playback position, in seconds, at the moment the key went down. Each tap type is bound to a different key.

In a beat tapping study, listeners tap along with the pulse of a piece of music. Downbeat tapping adds a mark on the first beat of each bar. For a downbeat study, the scheme can give beats the space bar and downbeats the d key.

Configuration

The config below plays one clip per item and asks for a tap on every beat and on every downbeat. min_taps: 4 asks for at least one bar of four beats before the item counts as answered:

yaml
annotation_task_name: "Tap along"
task_dir: .
data_files:
  - data/clips.jsonl
item_properties:
  id_key: id
  text_key: text
output_annotation_dir: annotation_output
media_directory: media
user_config:
  allow_all_users: true
 
annotation_schemes:
  - annotation_type: tap_along
    name: beats
    description: "Tap the space bar on every beat, and d on the first beat of each bar"
    source_field: audio
    tap_types:
      - name: beat
        key: space
      - name: downbeat
        key: d
    min_taps: 4
    allow_restart: true
    label_requirement:
      required: true

Each line of data/clips.jsonl names one audio file under media/:

json
{"id": "clip_1", "text": "Click track, 120 bpm", "audio": "click_120bpm.wav"}

Options

tap_along optionDefaultMeaning
namerequiredScheme name, also the key the answer is stored under
descriptionrequiredThe instruction shown above the buttons
source_fieldaudioItem field holding the audio. The value may be an http(s) URL, a path rooted at /, or a file name under media_directory
tap_typesone type, tap, on the space barThe kinds of tap, each a {name, key} pair. A key is one character, space, or enter. Names must be unique, and each type needs a different key
min_taps0Taps needed before the scheme counts as answered, a whole number from 0 to 20,000. At 0, one tap is enough
allow_restarttrueWith false, the Start over button is hidden
label_requirementnonerequired: true keeps the annotator on the item until the scheme counts as answered

A letter key matches in either case, and a key pressed with Ctrl, Alt, or Cmd is not a tap. Potato refuses to start when tap_types repeats a name or a key.

Tapping

The scheme shows a play button, one button per tap type labeled with the type's name and key, and a strip that marks each tap. One attempt goes through three steps:

  1. The annotator presses Play and tap, and the clip plays from the start.
  2. The annotator presses a tap type's key, or the type's button, in time with the audio. A tap counts when the key goes down, and holding the key does not repeat the tap. Keys pressed while nothing plays are not taps.
  3. When the clip ends or the annotator presses Stop, Potato saves the taps and marks each tap on the strip, with one row per tap type.

Play again plays the clip once more and keeps the taps already made. Taps from the second hearing fall into place by time, and the list stays in time order. To tap from scratch, the annotator first presses Start over to clear the taps. With min_taps set, an attempt with too few taps leaves the answer saved earlier in place, and the status line says how many more taps are needed.

While a clip plays, the tap keys reach only the scheme. The tap keys trigger none of Potato's keyboard shortcuts, and the space bar does not scroll the page.

Stored answer

The answer is a JSON string stored under the label taps:

json
{"beats": {"taps": "{\"taps\": [{\"t\": 0.512, \"type\": \"downbeat\"}, {\"t\": 1.004, \"type\": \"beat\"}], \"duration\": 6.0, \"plays\": 1}"}}

t is the playback position in seconds when the key went down, and type names the tap type. duration is the clip's length in seconds, and plays counts how many times the clip was started. The server refuses a saved answer in five cases:

  • A tap names a type the scheme does not have.
  • A tap has a negative time.
  • The taps are out of time order.
  • A tap falls more than half a second after the end of the clip.
  • The answer has fewer than min_taps taps.

Timing accuracy

Potato times each tap against the audio element's playback position. Browsers report the position to the millisecond, but update the position in steps of a few milliseconds that depend on the browser and the audio output. Output latency also delays the sound the listener hears relative to the reported position, above all with Bluetooth headphones. For a timing study, ask annotators to use wired headphones. Add a calibration item whose beat times you know, and subtract each annotator's mean offset on the calibration item from the annotator's other taps.

Example

Potato's release includes a tapping example that plays a 120 bpm click track with an accent every four beats. Start the example from the root of a Potato checkout:

bash
potato start examples/audio/tap-along/config.yaml -p 8000

Further reading

For implementation details, see the source documentation.