Digital tempometer

By William C.

WORK IN PROGRESS

Overview

Please refer to the .Music Terminology. section at the bottom of the page for definitions of music-related terms used throughout this description.

The digital tempometer is a metronome with a special feature - the ability to detect the tempo of rhythmic sounds produced by the user, using the device.s built-in microphone. This allows the user to measure and store an imagined tempo (whose precise measurement in beats per minute (BPM) is not yet known) automatically, without having to figure out the BPM, by activating the device and clapping hands, playing a drum, or otherwise producing audibly distinguishable beats. This tempometer is based on the Atmel Atmel ATtiny2313 microcontroller.

Device in operation

The tempometer programming is currently in a basic form which can be expanded upon with additional code. The current version of the code sets the number of beats per measure at four. (The ability to change the time signature, and thus the number of beats per measure, will be added in the future.) As a result, the beat pattern is always DOWNBEAT, BEAT, BEAT, BEAT, DOWNBEAT, BEAT, BEAT, BEAT, etc. Every fourth beat represents a downbeat and sounds different from the other beats.

The device has an LCD display consisting of two rows of 16 characters. The information displayed depends on the mode the device is in. The device has four buttons . one for powering it on or off, two for adjusting the volume or tempo settings up or down, and one for switching the mode.

The device currently features three modes (besides the .Power Off. Mode). The device powers on in Volume Set Mode, in which the .Up. and .Down. buttons adjust the volume in increments [of 6%]. Each adjustment produces a beep at the new volume setting for the user.s reference. The LCD display shows the current volume setting [in ??? units]. [DETAILED DESCRIPTION OF HOW VOLUME SET MODE WORKS]

Tapping the .Mode. button switches the device to Metronome Mode, in which the device continuously produces audible beats according to the current tempo setting. The first line of the LCD display shows the current tempo setting in BPM. The second line of the display shows Italian tempo notation for the current tempo setting . this is derived from a table in the device memory that associates tempo values with corresponding Italian terms. The Italian terms were assigned to tempo ranges somewhat arbitrarily . in reality, the BPM interpretation of an Italian tempo term can vary widely among composers, songwriters, conductors, and performers, and among songs. The Italian notation / BPM correspondence used in the device is based on information from Wikipedia.

In Metronome Mode, the Up and Down buttons adjust the tempo in increments of 1 BPM. The displayed BPM value actually corresponds to a stored value indicating the number of CPU clocks that will occur between beats. Tapping the Mode button switches the device back to Volume Set Mode.

Metronome Mode uses the current tempo setting to set one of the microcontroller.s internal timers. This timer produces a brief signal for each beat. During this signal, another timer is activated, which is programmed to produce signals at a high frequency. These signals create the sound wave emitted by the device.s built-in buzzer.

The third mode, Tempo Input Mode, is accessed by holding the Mode button for at least 1/2 second during either Volume Set Mode or Metronome Mode. This mode is exited by holding the Mode button again.

In this mode, the tempo of the beats detected by the microphone is measured and stored for use in Metronome Mode. The device recognizes a beat when the microphone picks up a sound loud enough to produce [1 volt???]. The device is programmed to begin counting CPU clocks (which are regulated by the built-in quartz crystal) when the first beat is detected, and a value of zero is stored to represent the clock count at the moment the beat was detected (which is zero because the timer begins on the first beat). When the second beat is detected, the value of the counter at that moment is stored. The difference between the new counter value and the previous counter value (zero), which indicates the number of CPU clocks that passed between the detected beats, is calculated and stored. Then, the new counter value replaces the previous counter value in the memory. When the third beat is detected, the value of the counter is again stored, the difference between the new counter value and the previous counter value is calculated and stored, and then the new counter value replace the previous counter value in the memory. This is repeated for all subsequent beats.

Tempo Input Mode continues calculating the counter change between beats, using the counter values stored at each detected beat, and continues storing these counter change values. Once four counter change values are stored (after the first five beats), they are added (along with the .previously calculated. sum, which is currently zero because no sum has been calculated yet), and the sum is stored. The process is repeated for the next four beats. When the second sum is calculated (after the first nine beats), it includes the previously calculated sum; when the third sum is calculated (after the first 13 beats), it includes the previously calculated sum; and so on. Therefore, at any given moment, the sum is a running total of the number of CPU clocks that have occurred since the first beat, as of the most recent calculation.

Simultaneously, another counter registers the number of beats that have been detected thus far, increasing by one for each detected beat. When Tempo Input Mode is eventually exited, any remaining CPU clock counter change values are summed with the running total of CPU clocks, and the total is divided by the beat count to produce an average of the number of CPU clocks that occurred between beats. This value will be used as the tempo setting in Metronome Mode, where it will determine the number of CPU clocks between beats emitted by the buzzer. As with any tempo setting in Metronome Mode, this value will be converted to BPM for the LCD display, will be used to derive the Italian tempo notation from the table in the device memory (for the LCD display), and can be changed incrementally using the Up and Down buttons.

During Tempo Input Mode, if no more beats are detected within 5 seconds after any beat is detected, the device will automatically switch to Metronome Mode, using the current tempo measurement. Thus, the absolute minimum tempo that can be measured in Tempo Input Mode is 20 BPM (one beat every 5 seconds). As is always the case in Metronome Mode, the device will immediately begin producing an audible beat output from the buzzer using the current tempo setting.

The device has the potential to include additional modes in the future. One idea is a .Set Time Signature Mode., in which the number of beats per measure (downbeat frequency) is set as well as a factor that modifies the beat output, representing, for example, a change from quarter note beats to eighth note beats. Another idea is to add a Tap Tempo Input option to the Tempo Input Mode. This would allow the device to register taps of the Mode button as beats, instead of sounds detected with the microphone. A third idea is a .Misc. Settings Mode. in which the user can select from a list of four options: .No Change. would allow the user to exit Misc. Settings Mode without changing anything; .bpmIncrements=.1. or .bpmIncrements=1. would allow the user to select the increments by which BPM is adjusted in Metronome Mode; and .Restore Defaults. would allow the user to restore the BPM increments setting (1 BPM) and all other modes. settings to default.

Hardware

To appear soon...

Schematic Front view Back view

Software

To appear soon...

Some music terminology

Beats
Counts used to measure the passage of time when writing or performing music.
Tempo
The rate at which beats occur when a song is performed, or its speed. The tempo may be expressed in beats per minute (BPM), or in more-flexible Italian terminology if a precise BPM isn.t deemed necessary by the composer.
Measure
A grouping of beats in written music (set by the song.s .time signature.). All measures in a song contain the same number of beats unless the time signature changes in the middle of the song.
Downbeat
The first beat of a measure.
Metronome
A device that produces audible clicks or beeps that represent beats at a tempo set by the user so the user can practice performing music at that tempo. Downbeats and non-downbeats sound different from each other so that the user can tell when a new measure begins.
Italian Tempo MarkingBPM
Larghissimo4-40
Largo 40-60
Larghetto 60-66
Adagio 66-76
Andante 76-101
Moderato 101-112
Allegro moderato12-120
Allegro 120-139
Vivace 140-168
Presto 168-200
Prestissimo200-300

Downloads


Last modified:Mon, Jan 23, 2023.

01402