You are on page 1of 17

Jia Zhu and Ye Wang

Department of Computer Science


Complexity-Scalable Beat
National University of Singapore
3 Science Drive 2, Singapore 117543
Detection with MP3 Audio
{zhujia, wangye}@comp.nus.edu.sg
Bitstreams

With the growing popularity of the MPEG-1 Audio to handheld devices, where soundtrack tempo plays
Layer 3 (MP3) format, handheld devices such as a key role in controlling relevant game parameters,
personal digital assistants (PDAs) and mobile such as the speed of the game (Holm et al. 2005). For
phones have become important entertainment content-based audio / video synchronization (Den-
platforms. Unlike conventional audio equipment, man et al. 2005), the musical beat is the primary
mobile devices are characterized by limited pro- information source used as the anchor for timing.
cessing power, battery life, and memory, as well as The beat of a piece of pop music is defined as the
other constraints. Therefore, music-processing sequence of almost equally spaced phenomenal
tasks like beat detection must be implemented impulses. The beat is the simplest yet fundamental
using low-complexity algorithms to cope with the semantic information we perceive when listening
constraints of these mobile devices. to pop music. Groupings and strong / weak relation-
This article presents a scheme of complexity- ships form the rhythm and meter of the music
scalable beat detection of popular (pop) music (Scheirer 1998).
recordings that can run on different platforms, The beat-tracking process typically organizes mu-
particularly battery-powered handheld devices. We sical audio signals into a hierarchical beat structure
show a user-friendly and platform-adaptive scheme of three levels: quarter note, half note, and measure
such that the detector complexity can be adjusted to (Goto 2001), as shown in Figure 1. Beats at the
match the constraints of the device and user re- quarter-note level correspond to periodic beats or
quirements. The proposed algorithm provides both pulses at a simple level, and those at the half-note
theoretical and practical contributions, because we level and the measure level correspond to the over-
use the number of Huffman bits from the com- all rhythm, which is associated with grouping,
pressed bitstream without requiring any decoding as hierarchy, and a strong / weak dichotomy. Pop-music
the sole feature for onset detection. Furthermore, beat detection is a subset of the beat-detection prob-
we provide an efficient and robust graph-based beat- lem, which has been solved with detection accuracy
induction algorithm. By applying the beat detector as the primary if not the sole objective. In this ar-
to compressed rather than uncompressed audio, the ticle, we focus on beat detection in recorded audio
system execution time can be reduced by almost rather than real-time beat tracking.
three orders of magnitude. Currently, most beat-detection methods are im-
We have implemented and tested the algorithm plemented on a personal computer or server. Based
on a PDA platform. Experimental results show that on our experiments, we find that it is difficult to
our beat detector offers significant advantages over scale down the complexity of existing methods to
other existing methods in execution time while run on portable platforms such as PDAs and mobile
maintaining satisfactory detection accuracy. phones, where processing power, memory, and
battery life become critical constraints. Although
some recent results show that beat tracking can be
Motivation implemented in a mobile phone after major optimi-
zations (Seppanen et al. 2006), running such a
After a decade of explosive growth, mobile devices complex algorithm taxes battery life, which is not
today have become important entertainment plat- desirable. Because software applications running on
forms alongside desktop computers and servers. battery-powered portable platforms are gaining
Many applications such as games have been moved popularity, algorithms for content processing such
as beat detection must be designed to match both
Computer Music Journal, 32:1, pp. 7187, Spring 2008 the constraints of the device resources and the users
2008 Massachusetts Institute of Technology. expectations.

Zhu and Wang 71


Figure 1. Hierarchical beat
structure. (The 4 / 4 time
signature prevalent in
popular music is assumed.)

greatly limits their application, because it is not


easy to obtain complete MIDI representations of
real-world acoustic signals. Such models suffer from
the scaling-up problem (Kitano 1993). Recent sys-
tems work with PCM audio bitstreams. Representa-
tive works in this category include Scheirer (1998),
Goto (2001), Dixon (2001; 2003), and Shenoy et al.
(2004). Some of these algorithms are able to track
the whole hierarchical beat structure in pop music.
To identify users requirements, we conducted Owing to the popularity of compressed audio for-
surveys of students from schools and universities; mats such as MP3, a beat-detection technique using
these students constitute an important segment of features from partially decoded compressed audio
the mobile-entertainment market. Our initial sur- has been proposed in Wang and Vilermo (2001).
vey results indicate that system-execution time, Other related works on compressed-domain audio /
detection accuracy, and battery life are critical per- video processing can be found in Tzanetakis and
formance criteria for mobile-device users. This im- Cook (2000) and Pfeiffer and Vincent (2001). The
plies that existing methods, which generally focus work presented in Tzanetakis and Cook (2000) uses
on detection accuracy at the cost of computational sub-band samples extracted prior to the synthesize
complexity, are apparently unable to meet users filterbank in an MPEG-2 Audio Layer 3 decoder to
expectations of mobile platforms. In addition, our calculate features such as spectral centroid, spectral
survey showed that execution time, defined as the rolloff, and so on, which are used in audio classifica-
interval between program start and the reception of tion and segmentation. To the best of our knowl-
beat information, should not be more than a few edge, our work is the first to achieve beat detection
seconds, preferably less than 2 sec. Furthermore, without decoding; that is, the beat detection is
many users complained about having to process based on features computed directly from the com-
music on a desktop platform before beat informa- pressed bitstream without even performing entropy
tion could be used on portable devices. Our tech- decoding. [Editors note: The initial manuscript was
niques have been designed with considerations of submitted on 12 November 2006.]
the tradeoff between users requirements (e.g.,
detection accuracy and execution speed) and device
resource constraints. We show in this article that System Overview
the compressed and transform domains are both
excellent alternatives to the domain of uncom- A diagram of our system is shown in Figure 2.
pressed, pulse-code-modulated (PCM) audio, be- Depending on the decoding level, we have imple-
cause they allow low complexity and high detection mented the proposed beat detectors in three do-
accuracy in beat detection on a mobile platform. mains: the compressed-domain beat detector
(CBD), which is the main focus of this article; the
transform-domain beat detector (TBD); and the
Related Work PCM-domain beat detector (PBD). In comparison to
existing work, our system allows an automatic se-
Automatic beat detection has a history of almost lection of beat detector (CBD, TBD, or PBD) based
two decades; a fairly comprehensive review is given on the availability of computing resources, as well
in Gouyon and Dixon (2005). Early beat-detection as manual selection by the user. We have imple-
systems such as those of Povel and Essens (1985), mented our scheme to operate on the MP3 audio
Rosenthal (1992), and Large and Kolen (1994) do not format because of its popularity.
operate on real-world acoustic signals, but rather on Extracting features from PCM audio or transform-
symbolic data such as MIDI. Their reliance on MIDI domain data has been proposed in previous work

72 Computer Music Journal


Figure 2. A systematic detector (CBD), transform-
overview of complexity- domain beat detector
scalable beat detectors in (TBD), and PCM-domain
three different domains: beat detector (PBD).
compressed-domain beat

(Scheirer 1998; Dixon 2001; Goto 2001). A system Compressed-Domain Beat Detection
presented in Wang and Vilermo (2001) tracks beats
at the quarter-note level in the transform domain. In an MP3 bitstream, some parameters are readily
However, it has remained unknown whether it is available without decoding, including window type,
possible to directly detect beats from a compressed part2_3_length (Huffman code length), global gain,
bitstream without partial decoding. In this article, etc. (Wang et al. 2003). Figure 3 shows different
we investigate the possibility of detecting the whole features extracted from a compressed bitstream and
hierarchical beat structure. the corresponding waveform.
As with most beat detectors dealing with pop Because our objective was to design beat detection
music, we assume that the time signature is 4 / 4 and for pop music, we selected certain of these param-
the tempo is almost constant across the entire piece eters on the basis of the following criteria: (1) the
of music and roughly between 70 and 160 beats per feature is well correlated to signal energy; (2) the
minute (BPM). Our test data is music from commer- feature exhibits good self-similarities; (3) the feature
cial compact discs with a sampling rate of 44.1 kHz. depends mainly on the music or the acoustic signals

Zhu and Wang 73


Figure 3. Extracted waveform; (b) window
compressed-domain data types; (c) part2_3_length;
from a pop-music excerpt (d) scale factor bits;
sampled from a commer- (e) global gain; and (f)
cial CD: (a) original annotated beat times.

waveform
1

0.5

(a) 0

0.5

1
7.85 7.9 7.95 8 8.05
4
time (ms) x 10
window type
4

(b) 2

0
6020 6040 6060 6080 6100 6120 6140 6160 6180
MP3 granule index

part2_3_length
1600

1400

(c) 1200

1000

800

6020 6040 6060 6080 6100 6120 6140 6160 6180


MP3 granule index
sclf bits
70

60

50

(d) 40

30

20

10

0
6020 6040 6060 6080 6100 6120 6140 6160 6180
MP3 granule index

global gain
190

185

180

(e) 175

170

165

160
6020 6040 6060 6080 6100 6120 6140 6160 6180
MP3 granule index
annotated beats

0.8

(f) 0.6

0.4

0.2

0
7.85 7.9 7.95 8 8.05
4
time (ms) x 10

74 Computer Music Journal


Figure 4. Locations of
part2_3_length in a
compressed bitstream for
(a) single-channel and
(b) dual-channel audio.
For dual-channel audio,
we extract part2_3_length
from only the left channel.

12 bits
s ynch. pattern 38 bits 12 bits 47 bits 12 bits
part2_3_length part2_3_length
"111111111111"
(granule 1) (granule 2)

(a)

12 bits
s ynch. pattern 40 bits 12 bits 106 bits 12 bits
part2_3_length part2_3_length
"111111111111"
(granule 1) (granule 2)

(b)

that are compressed, and not on the encoder that Table 1. Results of the Cross-Correlation Method
has produced the data, which renders window type
Global Part2_3_ Full-Band
data unsuitable for beat detection, for example; Song No. Gain Length Energy
and (4) the features MP3 data field has separate
values for each granule. (In an MP3 bitstream, the 1 0.002 0.228 0.326
primary temporal unit is a frame, which is further 2 0.036 0.194 0.253
divided into two granules. Some data fields are 3 0.043 0.184 0.184
shared by both granules in an MP3 frame, whereas 4 0.004 0.217 0.188
5 0.009 0.218 0.264
others have separate values for each granule. We
Average 0.002 0.208 0.243
prefer the latter type because it gives a better time
resolution.)
In practice, we have used the following quantita- consist of multi-band data, whereas compressed-
tive measures for feature selection. For each data domain data seem to reveal only full-band charac-
type in the compressed domain, we created a se- teristics. In other words, we can achieve better
quence s by extracting the value from each granule. detection accuracy by using multi-band processing
Then another sequence b was generated as follows: with increased complexity. However, if instant
results are needed, a single-band approach can offer
bi k = 1 if there is an annotated beat at granule i, k = {0,1, 2}
significantly reduced complexity with reduced de-
bi = 0 if there is no annotated beat at granule i k, k = {0,1, 2} tection accuracy.

(An annotated beat is one that has been previously


specified by a human listener, as explained later.) Onset Detection
We calculated the cross-correlations rb,s between b
and s at delay 0. Table 1 lists the results of this The CBD calculates the input data length from
method for five songs. After checking all the pos- part2_3_length. Onset candidates are selected using
sible parameters in the compressed MP3 bitstream, a simple threshold thr:
we found that the part2_3_length is well correlated
thri = a mean
with the onsets and is therefore a good proxy for
onset, because it is a high-level indication of the where i is the granule index, and a is an empirically
innovation or uniqueness in each data unit (i.e., determined constant value. During the system
granule). The CBD uses part2_3_length (see Figure evaluation, we noted that the beat-detection accu-
4) as input data. All beat detectors have two main racy is not particularly sensitive to the choice of a,
blocks: onset detection and beat induction, which because the proposed beat-induction algorithm is
are presented next. robust to the inaccuracy of onset detector. The
Transform-domain features are generally more window for calculation is {i 34, i + 34}. Thus, the
reliable for beat detection than are compressed- window size is 69 granules, which corresponds to
domain features, because transform-domain features approximately 900 msec. The selected window size

Zhu and Wang 75


is the same as the one used in Wang et al. (2003) for Table 2. Formulation of the Beat-Induction Problem
onset detection. Granule i is considered to contain
Input: An ordered event set O
an onset if the following conditions are met:
Output: A pair (d, B) that satisfies three conditions
fi > thri (condition 1)
f > f (condition 2) Condition 1: d is a real number and QMIN d QMAX,
i i k
where QMIN and QMAX are constants; B is
where fi is the ith feature obtained from half-wave an ordered event set
rectification, and k {1 . . . 17}. Condition 2 ensures
Condition 2: For every consecutive pair (i, j) of B,
that any two onsets are at least two granules (ap-
diff(i, j) [d , d + ]
proximately 26 msec) apart from each other. This
implies at most one onset can be detected within Condition 3: For any pair (d', B') that satisfies condi-
any period of 50 msec. We denote this property as tions 1 and 2 and is not identical to (d, B),
onset property and use it in beat induction. |O B'| < |O B|
It should be noted that the onset detector is
selected mainly for its simplicity and for the char-
acteristics of the feature. Many of the methods in tion rank(ES, e); this function returns the rank of e
Bello et al. (2005) are simply not applicable to if e ES, and 1 otherwise. If e is the head of ES,
compressed-domain features. that is, e = head(ES), then rank(ES, e) returns 1; if e
is the tail of ES, that is, e = tail(ES), then rank(ES, e)
returns the size of ES. A reverse operation get
Beat Induction returns the element given a rank, namely, get(ES,
rank(ES, e)) = e if e ES. Succ(ES, e) returns the
The beat-induction process determines beat times successive element of e in ES. We formulate the
based on onset times from the previous step. Our beat-induction problem as shown in Table 2.
beat-induction algorithm is designed to be robust Intuitively, the input set O contains all the
enough to work with input onsets that have low detected onsets of a piece of music, the output
accuracy. Unlike the onsets detected from a PCM value d is the anticipated quarter-note length, and
bitstream, features extracted from a compressed the output set B contains all the beats. QMIN and
bitstream are generally much noisier. QMAX are the smallest and largest possible
We use a data structure called an Ordered Event quarter-note lengths allowed by the algorithm,
Set, which is composed of an ordered set of distinct respectively. In our current implementation, QMIN =
events, denoted (S, R), to store onsets or beats. Two 375 msec, and QMAX = 923 msec, which correspond
events are distinct if and only if they do not occur to tempi ranging from 65 to 160 BPM. The devia-
simultaneously. The relation R is defined as fol- tion, , is set to 25 msec. Because we work with
lows: i R j if and only if event i occurs earlier than MP3 granules instead of units of msec in the com-
or at the same time as event j. It is obvious that pressed domain, the corresponding parameters in
relation R is anti-symmetric and transitive. An the compressed domain (for a sampling rate of
ordered pair (i, j) of an ordered event set ES satisfies 44.1 KHz) are QMIN = 28 granules, QMAX = 72 gran-
i, j ES i R j i j. A pair (i, j) of ES is a consecu- ules, and = 2 granules.
tive pair if (i, j) is an ordered pair and there is no Next, we introduce another data structure called
element e such that (i, e) and (e, j) are ordered pairs a pattern. A pattern is defined to be an ordered
of ES. The difference of an ordered pair (i, j), denoted event set with an associated pair (s, d). A pattern P
by diff(i, j), is the absolute value of the time differ- meets the following conditions: (1) P O, where O
ence between the occurrence of event i and that of is the ordered event set containing all the onsets; (2)
event j. |P| 1 and head(P) = s; (3) for every consecutive pair
Because elements in ES are distinct and ordered, (i, j) of P, if there is any, diff(i, j) {d , d + }; and
we can get the rank of an element e with the opera- (4) there does not exist another ordered event set S

76 Computer Music Journal


Figure 5. Two patterns can
be identified from the
onsets on axis (a) and are
denoted on axis (b) and
axis (c).

detects a coarse QNL, and the second stage detects a


(a)
fine QNL. In the first stage, we use nine bins that
cover the interval {QMIN, QMAX}, each of which spans
(b) five granules. After the normal histogram proce-
dure, the center of the bin with the maximum num-
(c) ber of elements is taken as the coarse QNL, cqnl. In
the second stage, we only consider inter-onset inter-
vals in the range {cqnl 2, cqnl + 2}. We use five bins,
such that P S, and S also meets conditions 1, 2, each of which spans one granule, and then perform
and 3. the histogram procedure again. The granule index
Figure 5 provides an intuitive illustration of a represented by the bin with the maximum number
pattern. We claim that the associated pair (s, d) of a of elements is taken as the fine QNL. An example of
pattern uniquely identifies the specific pattern. the histogram method is shown in Figure 6.
This can be proved as follows. Suppose there are To further speed up this procedure, we can use
two patterns P1 and P2 with the same associated just a small segment, for example, the first half-
pair (s, d). Then head(P1) = head(P2) = s, according minute, of the whole song as an input to the histo-
to condition 2. Because there is at most one onset gram. However, we did not use this method in our
within the interval {t , t + ], where t is arbitrary, experiment, because it might fail if there are large
according to the onset property, we have diff(s, x) gaps between successive onsets over the whole song.
{d , d + } diff(s, y) {d , d + ] x = y, which Furthermore, experimental results have shown that
implies that the second element of P1 is identical to our two-stage histogram method is fast enough.
that of P2 according to condition 3. After the quarter-note length is detected, the next
If |P1| = |P2|, then using the same argument in- step is to compute beat times based on the quarter
ductively for the rest of the elements in P1 and P2, note length qnl. Our objective is to create an or-
we can infer that all of them are identical, that is, dered event set B such that for every consecutive
get(P1, k) is identical to get(P2, k) for k {1, 2, . . . , pair (i, j) of B, diff(i, j) {qnl , qnl + ], and |B O|
|P1|}, and thus P1 and P2 have the same pattern. If is maximum. To solve this problem, we propose a
|P1| |P2|, we can assume |P1| < |P2| without loss of graph-based approach. We first introduce the con-
generality. Then get(P1, k) is identical to get(P2, k) cept of compatibility.
for k {1, 2, . . . , |P1|}. This implies that P1 P2, A pattern A is defined to be compatible with
which contradicts condition 4. Hence, a pattern can pattern B with lapse d (d > ) if and only if the
be uniquely identified by its associated pair. If a following condition holds:
pattern P has an associated pair (s, d), we denote d
tail(B) R head(A), lapse(A) = lapse(B) = d, and
as the lapse of P, that is, lapse(P) = d. The procedure
for extracting the pattern given the associated pair diff (tail(B), head(A))
(s, d) is straightforward. The initial status of the [d , d + ].
ROUND(diff (tail(B), head(A)) / d)
pattern P is {s}. For each onset o, if diff(tail(P), o)
{d , d + }, we add o into P, that is, P P {o}. Here, ROUND is an operation that rounds its
The beat-induction algorithm begins by detecting parameter to the nearest integer. If A is compatible
the anticipated quarter-note length (QNL). The with B with lapse d, we denote AdcB. The compat-
procedure is an inter-onset interval, histogram- ibility relation satisfies the following property:
based method, commonly used in beat detectors Ad cB Bd c A never holds
like those described by Gouyon et al. (2006). We
improve these methods with emphasis on speed and This property can be proved using contradiction;
tolerance of inaccurate onsets. To achieve prompt the proof is straightforward and is hence omitted
detection of the anticipated QNL, we carry out the here. Figure 7 gives an example of compatibility.
histogram method in two stages. The first stage The graph-based approach starts with the collection

Zhu and Wang 77


Figure 6. The two-stage In the PCM domain, the quarter-note length de- Figure 7. Pattern II is
histogram method is first histogram has 10 bins, tected in the compressed compatible with pattern I.
carried out in the com- with a resolution of 50 domain is 54 granules Neither pattern I nor
pressed domain and in the msec, and the second his- (707.4 msec), whereas pattern II is compatible
PCM domain, respectively, togram has 50 bins, with a that in the PCM domain with pattern III.
with the same input song. resolution of 1 msec. The is 709 msec.

Compressed domain, first stage Compressed domain, second stage


350 200

300
150
250

200
100
150

100
50
50

0 0
30 35 40 45 50 55 60 65 70 53 54 55 56 57
granules granules

PCM domain, first stage PCM domain, second stage


500 100

400 80

300 60

200 40

100 20

0 0
400 550 700 850 660 680 700 720 740
msec msec
Figure 6

of all patterns with lapse qnl from the onsets, where Length of a quarter note:
qnl is the quarter-note length. The procedure shown
below extracts all patterns with a prescribed lapse
Pattern I
by a single iteration through the ordered set of all
onsets. In that procedure, we use another ordered Pattern II
event set (L, R'), which has the same properties and
Pattern III
operations as (S, R) as the data structure to store all
the patterns. The relation R' is defined by Li R' Lj if Figure 7
and only if head(Li) R head(Lj). The algorithm is
shown in Figure 8.

78 Computer Music Journal


Figure 8. Procedure for
collecting patterns.

Procedure: CollectAllPatterns(O, qnl)


Input: The ordered event set O containing all the

onsets, and the detected quarter-note length qnl.


Output: An ordered event set L containing all the
patterns with lapse qnl.
L

Initialize a flag array F of the same size as O, with

all elements being 0

for each element e in O


e e

if F[rank(O, e)] = 0
then initialize a new empty pattern P
P P {e}

F[rank(O, e)] 1

es succ(O, e)

while diff(es, tail(O)) > 0


do if diff(es, e) [qnl , qnl + ]
then P P {es}

F[rank(O, es)] 1
e es
if diff(es, e) > qnl +

then break
es succ(O, es)

L L {P}

Zhu and Wang 79


Figure 9. (a) Part2_3_length
(solid line) and threshold
(dashed line); (b) detected
onsets; (c) detected beats
after beat induction.

After collecting the patterns, we create a compat- 2000

ibility matrix CM with dimension |L| |L| as follows:


1500
1 if get(L, i)qnl
c get(L, j); , for any 1 i, j | L|
CM[i][j] = (a)

0 otherwise, 1000

CM can be viewed as the adjacent matrix of a


graph G = (V, E), where V[G] ={x | x x 0 p, 500
3000 3100 3200 3300 3400 3500 3600

x = rank(L, p)}, E[G] = {(j, k) | j, k V[G] CM[j, k] =


1}. By the compatibility property, the graph is 1

directed and acyclic: (i, j) E[G] if and only if (b) 0.5

get(L, i)qnlc get(L, j). 0


The problem is transformed to finding a path p = 3000
1
3100 3200 3300 3400 3500 3600

{v0, v1, . . . , vk}, where v0, v1, . . . , vk V[G], such


that ki= 0 pattern_count(get(L, vi)) is maximized. To (c) 0.5

solve the problem, we first convert graph G into 0


3000 3100 3200 3300 3400 3500 3600
another directed acyclic but weighted graph G' = (V, MP3 granule index

E), on which we can apply the Bellman-Ford algo-


rithm. The new graph G' is obtained by adding a and y such that diff(x, b1) = diff(b1, b2) = . . . = diff(bk,
dummy vertex dummy = |V[G]| + 1 to the vertex y) = d, we can infer that d [qnl , qnl + ]. This
set of G, and creating edges from the dummy vertex will ensure that the tempo is maintained across the
to every other vertex in G'. Thus, V[G'] = V[G] interpolated beats.
{dummy}, and E[G'] = E[G] {(dummy, k) | k The worst-case running time of our beat-induction
V[G]}. The weight of an edge (j, k) in G', denoted by algorithm is O(n13), where n1 is the total number of
w(j, k), is assigned by pattern_count(get(L, k)). The detected onsets. However, in practice, the algo-
negation allows us to apply the Bellman-Ford algo- rithm usually performs much faster than O(n13). The
rithm, which finds the path that originates from the actual running time is max(O(n12), O(n23)), where n2 is
dummy vertex with minimal total weights instead the total number of patterns, because the Bellman-
of maximum total weights. Based on the output Ford algorithm has a cubic time complexity. Be-
path of the Bellman-Ford algorithm, we collect the cause n1 >> n2 in almost all cases, and n13 >> n12 when
patterns represented by the vertices on the path and n1 is large, it follows that max(O(n12), O(n23)) << O(n13).
store the elements of those patterns in an ordered Hence, the actual running time is much less than
event set B. Then B contains partial beats. O(n13). The memory consumption of our beat-
The next step is to obtain the complete beats. The induction algorithm is max(O(n1), O(n22)). We use a
rest of the beats are interpolated based on the partial bit array to implement the compatibility matrix. A
beats in B. Interpolation is done as follows. For every 16-bit integer is used to represent each onset. (Note
consecutive pair (x, y) in B, if diff(x, y) [qnl , that in the compressed domain, we work with MP3
qnl + ], then x and y do not appear in the same granule indices, which can be represented as 16-bit
pattern; x is the tail of one pattern P1, and y is the integers.) Thus, the hidden constant in the Big-O
head of another pattern P2. We can also infer P2 is notation of memory consumption is small.
compatible with P1 with lapse qnl. Based on the Our onset detection and beat induction are illus-
definition of compatibility, we have trated in Figure 9.

diff (x, y)
[qnl , qnl + ]
ROUND(diff (x, y) / qnl) Transform / PCM-Domain Beat Detection
Therefore, if we insert k = (ROUND(diff(x, y) / Both TBD and PBD have three general steps: onset
qnl) 1) number of beats b1, b2, . . . , bk between x detection, beat induction, and bar detection. The

80 Computer Music Journal


first two of these steps are analogous to the corre- the jth MDCT coefficient decoded in the ath short
sponding steps of CBD, which does not include bar window of granule n (when granule n contains three
detection. The onset detector is different in each of short windows), N1 is the lower bound index, and N2
these three domains, although the onset detectors is the upper bound index of band b. Full-band en-
for TBD and PBD are similar. In comparison with ergy is calculated by adding all the sub-band ener-
the onset detector for TBD, the onset detector for gies for each granule.
PBD requires an additional fast Fourier transform Energy values of the four sub-bands and the full-
(FFT) operation for frequency analysis, which is band form five vectors of features. We carry out a
detailed in Shenoy et al. (2004). We use the same procedure similar to that described in Wang et al.
beat-induction algorithm for beat detectors in all (2003) on the five vectors of features to detect on-
three domains. The onset detection and bar detec- sets. The procedure chooses onset candidates from
tion for TBD are discussed in this section. each feature vector using a threshold-based method,
and the onset candidates from the five feature
vectors are converged using a weighted-average
Onset Detection method.
Note that the onsets detected by this method,
The onset detector for TBD uses the threshold-by- like those detected by CBD, have the onset prop-
band method. It first divides the modified discrete erty, which renders them valid as input to the beat-
cosine transform (MDCT) frequency lines into four induction algorithm presented earlier.
sub-bands. The division for long windows is 13,
425, 2685, and 86576. (These numbers indicate
the indices of MDCT frequency lines.) The corre- Bar Detection
sponding frequency intervals are thus 0115 Hz,
116957 Hz, 9583,254 Hz, and 3,25522,050 Hz. Our bar-detection algorithm uses the idea of de-
For short windows, we try to match the frequency tecting chord changes, similar to the algorithm
intervals with those for long windows as closely as described in Goto (2001), which detects bar infor-
possible. The division for short windows is 1, 29, mation in the PCM domain. We have modified that
1029, and 30192, corresponding to frequency in- algorithm to work in the transform domain. Our
tervals of 0114 Hz, 1151,033 Hz, 1,0343,330 Hz, TBD calculates chord-change probabilities at each
and 3,33122,050 Hz. This approach is similar to quarter-note boundary. The calculation of chord-
that described by Wang and Vilermo (2001); how- change probabilities at each eighth-note boundary
ever, unlike that approach, we employ all sub-band is omitted in our implementation. A histogram is
information. formed by
Next, energy from each band is calculated for
q (n + 1) gap (n)
each granule. The energy Eb[n] of band b (b = 1, 2, 3, H(n, f ) = (Xf [i])2
or 4) in granule n is calculated as i = q (n) + gap (n)

N2
( )
2
where Xf [i] is the fth MDCT coefficient decoded at
j Xj[n]
=N
Eb[n] = 3 1 N2 granule i, q(n) is the granule index mapped from the
2
(
Xa,j[n]
a = 1 j = N1
)
nth beat time, q(n + 1) is the granule index mapped
from beat time (n + 1), and gap(n) = (q(n + 1) q(n))/5.
We consider only the frequency range of 11,000
where the first relation applies to granules that con- Hz, which is supposed to contain the frequencies of
tain a long window, and the second relation applies dominant tones (Goto 2001). Thus, only the first 27
to granules that contain short windows. Also, Xj[n] MDCT frequency lines for long windows and the
is the jth MDCT coefficient decoded at granule n first nine MDCT frequency lines for short windows
(when granule n contains a long window), Xa,j[n] is are used to create the histogram.

Zhu and Wang 81


Figure 10. In this example,
the first two beat times
and the last beat time in ts
are removed so that ts is
matched with ta.

To solve the mismatch of different frequency res- ta


olutions between long and short windows, a com- sf
promise method is applied, as follows. Because
ts
there are three windows in a granule of short win-
dow type, we pick the first nine MDCT frequency
lines in each of the three windows, and we order Evaluation Method
them as follows:
The test music for the all three detectorsCBD,
X [3 (n 1) + a] = w a[n], a {1, 2, 3} and 1 n 9
TBD, and PBDis identical and is all sampled from
where wa[n] is the nth MDCT frequency line in commercial CDs. Three music students from our
short window a in one granule. The ordered fre- university manually annotated beat times. They
quency lines constitute 27 lines, which are used in first worked individually on all the test samples,
our histogram calculation in the same way as the and then the individual annotations were averaged
first 27 frequency lines are in a long window. to get the final annotations. The annotated beat
After calculating the histogram, we follow the times and system-generated beat times were sent to
same procedure described in Goto (2001) to calcu- an evaluator program. The evaluator program used a
late the chord-change probabilities at each beat variation of the evaluation method proposed in Goto
time. The chord-change probabilities are used to and Muraoka (1997), which we briefly summarize as
infer bar boundaries. In particular, we calculate four follows.
values, S1, S2, S3, and S4: A system-generated beat time sequence is de-
bn/4 1 noted as ts, and an annotated beat-time sequence is
Si = T(4 k + i), i {1, 2, 3, 4} denoted as ta. Before we calculate the normalized
k=0
deviation at each detected beat, we carry out the
In the above equation, bn is the total number of following procedure to match ts with ta. First, we
beats, and function T is defined recursively as find in ts the element sf that is closest to the first
element of ta. Suppose the index of sf in ts is , the
W1 T (n 4) + W2 C(n) n > 4
T(n) = length of ta is la, and that of ts is ls. We remove the
0 otherwise
first 1 elements and the last ls la + 1 ele-
where the C(n) are the chord-change probabilities cal- ments from ts. Figure 10 gives a simple example of
culated at beat n, and W1 and W2 are two constants. this procedure.
Suppose ix is an integer such that ix = arg1 i 4 max(Si); The normalized deviation at detected beat n, d(n),
then beat 4k + ix marks the start of bar (k + 1), where is calculated as
k {0, 1, 2, . . . , bn / 41}. 2 (Ts[n] Ta[n])
if Ts[n] Ta[n]
d[n] = Ta[n + 1] Ta[n]
Evaluation 2 (Ta[n] Ts[n]) if Ts[n] < Ta[n]
Ta[n] Ta[n 1]
We use libmad, a highly optimized, open-source The mean and standard deviation of the se-
MP3 decoder, for our system implementation and quence formed by d[2], . . . , d[size 1], where size
evaluation. We carefully selected 25 pop songs to is the size of sequence Ta, are then calculated. We
provide sufficient sampling variety, and we encoded also calculate
each song at a bit rate of 128 kbps. Pop-music beat ! = max(d[i])
1< i < size
detection in the PCM domain is a relatively
straightforward task; we investigated the perfor- We accept Ts as a correct beat sequence if < 0.1,
mance degradation of the TBD and CBT relative to < 0.15, and < 0.5.
our PBD baseline (Shenoy et al. 2004), which can For TBD, the correctness of detected bars is also
detect beats in the selected 25 songs correctly. examined. If the detected quarter-note information

82 Computer Music Journal


Table 3. Experimental Results
Song Title Artist CBD TBD

q q h w

Back to You Bryan Adams


Breathless The Corrs
Burn Tina Arena
Crush Jennifer Paige
Drops of Jupiter Train
Heal the World Michael Jackson
I Cant Tell You Why Eagles
It Must Have Been Love Roxette
I Want to Know What Love Is Foreigner
Losing My Religion R.E.M.
Mmmbop Hanson
One U2
One of Us Joan Osborne
Road to Hell Chris Rea
Seasons in the Sun Westlife
Smooth Santana
Someday Michael Learns To Rock
Stayin Alive Bee Gees
The Way It Is Bruce Hornsby
Time of Your Life Green Day
I Knew I Loved You Savage Garden
Viva Forever Spice Girls
Walking Away Craig David
Whenever, Wherever Shakira
You Make Loving Fun Fleetwood Mac
Number of songs tracked, from a total of 25 21 23 19 16

fails in the evaluation, then the detected half notes to detection accuracy and the corresponding execu-
and bars are all rejected; otherwise, we find in se- tion time.
quence Ta a beat b1 that marks the start of a bar and
in sequence Ts, as well as a beat b2 that also marks
the start of a bar. Suppose the index of b1 in Ta is i1, Execution Time
and the index of b2 in Ts is i2. If (i1 i2) modulo 4 is
0, we accept the detected half notes and bars; other- The three beat detectors were implemented on an
wise, if (i1 i2) modulo 4 is 2, we accept the detected HP iPAQ hx4700 PDA running Microsoft Windows
half notes and reject the detected bars; if not, both Mobile 2003 SE. (The iPAQ hx4700 uses the Intel
the detected half notes and bars are rejected. PXA270 processor with a clock speed of 624 MHz
and has 64 MB of SDRAM and 128 MB of ROM.)
Owing to the low quality of compressed-domain
Detection Accuracy features, the proposed beat detector must be per-
formed offline in the compressed domain. The
The evaluation results are listed in Table 3. Fig- average execution times in the three domains are
ure 11 shows the average performance with respect presented in Figure 12. We normalize the execution

Zhu and Wang 83


Figure 11. Performance
comparison: execution
time of (a) CBD, (b) TBD,
and (c) PBD as compared
to MP3 decoding time; (d)
detection accuracy versus
execution time in the three
domains.

MP3 decoding Onset detection MP3 decoding Onset detection

Beat Induction Beat Induction

5 5
Normalized execution

Normalized execution
4 4
time (sec)

time (sec)
3 3

2 2

1 1

0 0
(a) (b)

MP3 decoding Onset detection Detection accuracy Normalized execution time


Beat Induction

1
0.9
3 0.8
Normalized execution

2.5 0.7
2 0.6
time (min)

0.5
1.5 0.4
1 0.3
0.5 0.2
0.1
0
0
(c) P BD TB D C BD

(d)

time by dividing the actual execution time by the onds. The average beat detection time is about
duration of the input song (in minutes). 1 second for CBD, 12 seconds for TBD, and 13
The experimental results show that beat induc- minutes for PBD. These results show that the
tion takes roughly the same amount of time in the compressed- or transform-domain processing
three operation domains. The main difference lies provides a significant advantage for mobile plat-
in the onset detection, which is the dominant factor forms, whereas PBD is more suitable for desktop
that causes the vast difference between CBD and or server platforms.
PDB in terms of execution time. The execution
time of CBD is negligible in comparison to MP3
decoding. The execution time of TBD is comparable Applicability to Other Formats
to MP3 decoding. PBD requires a significantly
longer execution time compared to MP3 decoding, To evaluate dependency on the input audio format,
mainly due to an extra time-frequency transform. we also implemented the proposed algorithm with
In summary, the average duration of the 25 test the Advanced Audio Coding (AAC) decoder at a
songs is about 4 minutes. The average decoding constant bit rate of 128 kbps. The detection perfor-
time per song from MP3 to PCM is about 21 sec- mance is significantly lower than that with MP3.

84 Computer Music Journal


Figure 12. Normalized
execution time for each
song by the three
detectors.

4
x 10

18

16
Compresseddomain beat detector
Transformdomain beat detector
Normalized execution time (unit: msec/min)

14 PCMdomain beat detector

12

10

0
0 5 10 15 20 25
Song index

Most of the errors with AAC bitstreams are -errors Concluding Remarks
(Goto and Muraoka 1997). We believe that the main
reason for the difference is that the time resolution We have presented a complexity-scalable beat-
of AAC is much lower, which results in a lower detection method that considers user expectations
feature quality. The difference is illustrated in and the resource constraints of mobile devices. The
Figure 13. This implies that the proposed method algorithm was implemented and tested on a tar-
may not be directly applicable to other audio for- geted PDA platform. Experimental results show
mats. Given the popularity of MP3, this is not that the compressed- and transform-domain pro-
overly restrictive. It will be interesting to investi- cessing are particularly suitable for mobile applica-
gate how sensitive the algorithm is to the bitrate of tions, providing a satisfactory tradeoff between
MP3 files. detection accuracy and execution speed.

Zhu and Wang 85


Figure 13.
Compressed-domain
feature comparison
between MP3 and AAC.

2500

2000
#bits per frame

1500

1000

500

0
0 50 100 150 200 250 300 350 400 450
AAC frame index

2000

1500
#bits per granule

1000

500

0
0 100 200 300 400 500 600 700 800
MP3 granule index

Because the TBD can provide a good tradeoff be- Denman, H., et al. 2005. Exploiting Temporal Discon-
tween detection accuracy (comparable to the PBD) tinuities for Event Detection and Manipulation in
and execution speed (comparable to the CBD), we Video Streams. Proceedings of the 2005 International
are working on optimizing the TBD to make it more Workshop on Multimedia Information Retrieval.
suitable for mobile devices. In the future, we plan to New York: Association for Computing Machinery,
pp. 183192.
transport our beat detectors to different hardware
Dixon, S. 2001. Automatic Extraction of Tempo and Beat
(e.g., mobile phones) and software platforms (e.g., from Expressive Performances. Journal of New Music
Symbian). Another avenue of future work is to de- Research 30(1):3958.
sign algorithms by taking into account the con- Dixon, S. 2003. On the Analysis of Musical Expressions
straints of power consumption of mobile platforms. in Audio Signals. International Society for Optical
Engineering 5021(2):122132.
Goto, M. 2001. An Audio-Based Real-Time Beat Track-
References ing System for Music With or Without Drum-Sounds.
Journal of New Music Research 30(2):159171.
Bello, J. P., et al. 2005. A Tutorial on Onset Detection Goto, M., and Y. Muraoka. 1997. Issues in Evaluating
in Music Signals. IEEE Transactions on Speech and Beat Tracking Systems. Working Notes of the 1997 In-
Audio Processing 13(5):10351047. ternational Joint Conference on Artificial Intelligence

86 Computer Music Journal


Workshop on Issues in AI and MusicEvaluation and Scheirer, E. 1998. Tempo and Beat Analysis of Acoustic
Assessment, pp. 916. Musical Signals. Journal of the Acoustical Society of
Gouyon, F., and S. Dixon. 2005. A Review of Automatic America 103(1):588601.
Rhythm Description Systems. Computer Music Jour- Seppanen, J., et al. 2006. Joint Beat and Tatum Tracking
nal 29(1):3454. from Music Signals. Proceeding of the Seventh Inter-
Gouyon, F., et al. 2006. An Experimental Comparison national Conference on Music Information Retrieval.
of Audio Tempo Induction Algorithms. IEEE Trans- Victoria, Canada: University of Victoria, pp. 2328.
actions on Audio Speech and Language Processing Shenoy, A., et al. 2004. Key Determination of Acoustic
14(5):18321844. Musical Signals. Proceedings of the 2004 Interna-
Holm, J., et al. 2005. Personalizing Game Content tional Conference on Multimedia and Expo. New
Using Audio-Visual Media. Proceedings of the 2005 York: Institute of Electrical and Electronics Engineers,
International Conference on Advances in Computer pp. 17711774.
Entertainment Technology. New York: Association for Tzanetakis, G., and P. Cook. 2000. Sound Analysis Using
Computing Machinery, pp. 298301. MPEG Compressed Audio, Proceedings of the 2000
Kitano, H. 1993. Challenges of Massive Parallelism. International Conference on Acoustic, Speech, and
Proceedings of the 1993 International Joint Conference Signal Processing. New York: Institute of Electrical and
on Artificial Intelligence. San Francisco, California: Electronics Engineers, pp. 761764.
Morgan Kaufmann, pp. 813834. Wang, Y., and M. Vilermo. 2001. A Compressed Do-
Large, E., and J. F. Kolen. 1994. Resonance and the main Beat Detector Using MP3 Audio Bitstreams.
Perception of Musical Meter. Connection Science Proceedings of the 2001 ACM Multimedia Conference.
6:177208. New York: Association for Computing Machinery,
Pfeiffer, S., and T. Vincent. 2001. Formalisation of pp. 194202.
MPEG-1 Compressed Domain Audio Features. Wang, Y., et al. 2003. Parametric Vector Quantization
Technical Report 01 / 196, CSIRO Mathematical and for Coding Percussive Sounds in Music. Proceedings
Information Sciences, Australia. of the 2003 International Conference on Acoustic,
Povel, D. J., and P. Essens. 1985. Perception of Temporal Speech, and Signal Processing. New York: Institute of
Patterns. Music Perception 2:411440. Electrical and Electronics Engineers, pp. 652655.
Rosenthal, D. F. 1992. Machine Rhythm: Computer
Emulation of Human Rhythm Perception. PhD thesis,
Department of Architecture, MIT.

Zhu and Wang 87

You might also like