Audio Retrieval¶
Basics of Audio¶
- Origin: Audio, latin for I hear
- Types of data:
- Music
- Spoken Text (e.g., Podcast, Speech)
- Noise (e.g., laughter, sounds of gears of cars, sound effects earcons)
Perception¶
- Information flow
- Pressure fluctuation in air (longitudinal wave)
- Eardrum (Trommelfell) vibrates
- Ear bones amplify + transmit vibration
- Hair cells in ear cochlea (Hörschnecke) are stimulated
- Neurons produce electrical impulse
- Brain interprets two properties of sound
- Pitch (Tonhöhe)
- Volume (Lautstärke) measured in Dezibel

Physics¶
- Amplitude as volume
- Logarithmic perception
- Tenfold increase of Amplitude –> Double perceived loudness
- Usually measured in Dezibel (dB)
- Frequency as pitch
- Hearing range: 20 Hz - 20 kHz
- Audio signal is time-dependent
Sound Creation¶
- Vibration generator:
- Instruments are Vibration generator
- Used to classify instruments
- e.g., String, Blow, Percussion
- Creates acoustic
- Oscillator
- Used for synthetic sound creation
- Generates periodic voltage oscillations
- Speaker
- Purpose: Transmit voltage change to membrane
- Voltage change moves membrane
- Membrane moves air
- Pitch: Higher voltage => Higher frequency
- Volume: Amplifier amplifies wave
- Sound modeled by ADSR envelope
- ADSR envelope
- Curve describing the amplitude over time
- Influence loudness of sound over time (until key is released)
- Phases:
- Attack:
- Time to reach maximum amplitude
- Speed of signal rise
- Starts with key press
- Decay:
- Time in which the signal decreases to sustain
- Starts immediately after end of attack phase
- Sustain value:
- Amplitude while the key is pressed
- Starts after decay phase
- Release:
- Time in which the signal decreases to zero
- Time in which sound is going on sounding
- Attack:
Digitalization¶
- Task: Transform continuous wave into discrete representation
Sampling¶
- Take current amplitude at regular intervals
- Components
- Sampling rate:
- Frequency of taking samples
- e.g., CD 44.1 kHz, Phone 8 kHz
- Resolution:
- Accuracy to record the values
- e.g., 16 bit
- Sampling rate:
- Goal:
- Uniquely reconstruct the original oscillation
- Minimal but sufficient number of samples (to save memory)
- Sampling theorem
- Nyquist, 1928
- Sampling rate must be at least twice as large as the highest occurring frequency in the signal
- \( f_{ny} \geq \frac{1}{2} \cdot f_{max} \)
- Example CD
- Sampling rate: 44100 Hz
- Resolution: 16 bit
- 2 channels
- \( 44100 * 16 * 2 = 176400 \frac{B}{s} \approx 635 \frac{MB}{h} \)
Formats¶
- Idea: Use compression to save space
- Uncompressed formats
- AIFF: Apple Inter-opportunity File Format
- Wave
- IRCAM (
*.snd): Institut de Recherche et Coordination Acoustique et Musique - AU: Sun Audio
- Reduction types
- Lossy
- Lossless
- MIDI Format
- Musical Instrument Digital Interface
- Purpose: Transmission, recording, playing musical control information
- Statements are commands (e.g. from keyboard for synthesizer)
- No original sound
- Output via synthesizer
Lossless Reduction¶
- Formats
- Free Lossless Audio Codec (FLAC): 50%-60% reduction
- Apple Lossless
- WavPack
- Factors:
- Compression speed
- Compression rate (effectivity)
Lossy Reduction¶
- Usually, based on simple transformations
- Modified Discrete Cosine Transformation (MDCT)
- Wavelets
- Encoding: Transform wave into frequency sequences (sampling)
- Decoding: Reconstruct original oscillation
- Idea: Change data without changing subjective perception
- Omit very high/low frequencies (which can not be heard)
- Use other effects of psycho-acoustic model
- Low tones after very loud tones
- Extremely small frequency changes
- Formats
- MPEG-1 Audio Layers (MP3)
- Versions I, II, II
- Cut un-hearable frequencies
- Channel coupling (compress stereo by using the difference)
- Huffman encoding for compression
- CD quality with 128 kb/s
- Advanced Audio Coding (AAC)
- Industry-driven MP3 improvement
- Used in TV-/radio, iTunes Store
- Better quality compared to MP3
- Support Multi-channel audio
- Ogg Vorbis
- WMA 9
- MPEG-1 Audio Layers (MP3)
- Factors:
- Compression speed
- Compression rate
- Compressed audio quality (most important)
Audio Information In Databases¶
- Audio information is mostly information transfer (e.g., speeches, recording of phone calls/conversations)
- Storage
- Compressed audio files in (smart) BLOBs
- Metadata and feature vectors are stored for search functionality
- Additional information, e.g., transcription as text, musical notation, MIDI
- Applications:
- Identification (audio as query)
- e.g., Shazam (find title for music piece), Legal services (GEMA)
- State of the art: Successful research
- Classification/similarity search (matching)
- Find perceptional similar audio signals
- e.g., similar songs, same quotation
- Recommendation (e.g., similar songs)
- Classification (e.g., rock, techno)
- State of the art:
- Manual annotations
- Classification only works on small collections
- Matching largely unresolved
- Phonetic synchronization
- e.g., Speech to text, notes to audio
- Retrieve text from speech (speech to text, text retrieval)
- Follow audio scores
- State of the art:
- Tolerable error rates (language to text)
- Identification (audio as query)
Basics¶
Metadata-based search
- Semantic metadata: Hard to generate (e.g., title, artist, speaker)
- File information: Automatically generated (e.g., time of recording, location, size, length)
- Problems:
- Manual indexing is expensive
- Incomplete/partial information
- Subjective information (e.g., genre)
- No query-by-example
Content-based search
- Naive: Compare sample-by-sample (not possible)
- Differentiate by (perceptual) characteristics
- Low-level features (e.g. properties of sounds)
- Logical/acoustic features (e.g., pitch, melody)
- Usually, audio is split into windows
Further reading:
Query-By-Example¶
- Goal:
- Melody is central importance
- Use Query-By-Example (query the melody)
- Limitation:
- We do not consider features like rhythm
- Query inputs:
- Sample audio files
- Humming
- Whistling
- Singing
- Major problems:
- Definition of melody (pitches, musical scales, variations, intervals, frequency jumps)
- Formulation of query
- Idea: Use characteristic melody (not complete song)
- What is it?
- How to represent?
- How do queries look like?
- Model-based approach
- Formulate query (humming, whistling, audio file)
- Melody extraction (Fourier analysis, noise reduction, pitch tracking)
- Encode melody (e.g., Parsons code, Differential code)
- Similarity search in database
- Return results
Architecture¶

Input¶
- Singing:
- Difficult (strong individuality of users)
- Humming:
- Idea from Ghia et al., 1995
- Separate notes with sound for better detection
- e.g., ta
- Whistling:
- Little individuality
- Good note separation
- Virtual instrument:
- e.g., provide virtual piano
- Greenstone library, NZ
Melody Extraction¶
- Sampling (of Digital Recording):
- Low sampling rate is sufficient (low quality of input)
- Requires noise reduction
- Group samples by overlapping (sliding window)
- Frame size: 50 ms
- Frames are half-overlapping
- Conversion:
- Compute spectral sample (spectrum) of each frame
- e.g., Short-Time Fourier Transform (STFT)
- Pitch per spectrum (Volume: avg. amplitude)
- Mark as silent frame if volume too low
- Find note boundaries:
- Note boundary marked by silent frames or frequency jumps
- Heuristics:
- Between two frames with a frequency jump: Add new silent frame (e.g., 3 % ratio of two frequencies)
- Between two frames with same frequency and a single frame with different frequency in between: Replace with neighboring frequency (called Smoothing)
- Between silent frames the frequency varies: Replace with average frequency
- Connect the same pitches to notes:
- Connect equal/same pitches between silent frames to one note with higher duration
- Remove notes with a length below a threshold (this is Noise)
- Remove all silent frames
- Output: Melody with note pitch and duration
Spectrograms¶
- Motivation:
- Time-domain doesn’t contain frequency components
- Frequency-domain doesn’t contain time of frequencies ocurring
- Solution: Combine time- and frequency domain
- Computation:
- Perform Fourier Transform on time windows
- 3-dimensional diagram
- X-axis: Time
- Y-axis: Frequency
- Gray-value of pixel: Intensity of frequency at time
- Can be used to analyze the regularity of occurring frequencies
Low-level Features¶
- Acoustic features
- Describe signal by statistical properties of characteristic values (compare to image database)
- Use time-dependent vector function (instead of feature vector)
- Measurements
- Time domain (amplitude vs. time)
- Frequency domain (intensity vs. frequency, e.g. Fourier transformation)
- Notation: Signal consists of \( N \) points \( x_N \)
Time domain¶
- Mean amplitude:
- \( \frac{1}{N} \sum_{i=1}^N |x_i| \)
- Fluctuation around zero (silence equals 0 amplitude)
- Average Energy
- Average volume of signal
- \( \frac{1}{N} \sum_{i=1}^N x_i^2 \)
- Zero-crossing rate
- Frequency of sign change
- \( \frac{1}{2N} \sum_{i=1}^{N-1} |sgn(x_{i+1}) - sgn(x_i)| \)
- Sometimes, the variance of the zero-crossing rate is used (audio is split in windows)
- Silence ratio
- Also called Portion of silence
- Proportion of values belonging to period of complete silence
- Requirements:
- Amplitude threshold (When is a sound silent?)
- Number of consecutive measurements that are considered as silence period
Frequency Domain¶
- Foundation: Fourier transform
- Decompose audio into frequency components with coefficients
- Frequency spectrum
- Coefficient: Its size represents the amount of energy per frequency (usually measure in decibels)
- Bandwidth
- Interval/range of occurring frequencies
- \( f_{min}-f_{max} \)
- \( f_{min} \) is first frequency above silence-frequency (threshold)
- Use for classification: Bandwidth of music is greater than bandwidth of voice
- Brightness
- Center-of-gravity/expected value of frequency distribution
- Power distribution
- Also called Energy distribution (distribution of the Fourier coefficients over the frequencies)
- This is no direct measure
- Other measures can be derived (such as brightness)
- ~~Calculate frequency bands with high/low energy~~
- Harmony
- Harmony is a perceptional property describing the well-sounding of a melody
- Definition Fundamental frequency: Minimal (lowest) loud frequency
- Harmony is given if the dominant components of the spectrum (frequencies) are multiples of the fundamental frequency
- Harmony is continuous measure
- Pitch
- Pitch is an perceptual property (Tonhöhe)
- Calculate from frequencies and amplitudes of peaks (e.g., using the Harmonic Product Spectrum, MLE, etc.)
- Pitch is not the fundamental frequency
- Pitch is related to frequencies (often used as approximation; not the same)
Classification¶
- Goal: Differentiate between music and noise
- Different audio classes have typical values for these features
- Features must differentiate enough
- e.g., speech, techno, classic, ambient, electronic)
- Training:
- Use a perceptional model
- Compute a reference vector for each class
- Classification:
- Classify based on the minimal distance (e.g., 1-NN)
- Evaluation:
- Works good as coarse classification (speech vs. music)
- Works bad to classify musical pieces into genres
Approach Lu et al.¶
- Lu/Hankinson (1998)
- Use case: Distinguish between speech and music
- Idea: Use complete signal
- Combine these features:
- Bandwidth
- Speech: 100 Hz - 7000 Hz
- Music: 16 Hz - 20000 Hz
- Brightness
- Speech: Low
- Music: High
- Proportion of silence
- Speech: Frequent
- Music: Low (except solo instruments)
- Variance of zero-crossing rate
- Speech: Characteristic structure in syllables (fluctuating zero-crossing rate)
- Music: Consistent rhythm (rather constant zero-crossing rate)
- Bandwidth
- Algorithm:
- Note: Estimates of low and high are collection-dependent (determine by training examples)

Approach Wold et al.¶
- Wold et al., 1996
- Goal: Perceptional comparison of audio files
- Idea:
- Divide audio signals in time slots
- e.g., due to different sounding slots in music
- Compute feature vector and statistical properties for each window
- Feature vector:
- Compute statistical features over the four coefficients
- Compute statistics over (1) the windows and (2) the whole signal
- Coefficients:
- Loudness
- Brightness
- Bandwidth
- Pitch
- Statistical features:
- Expected value (average value)
- Variance (mean square deviation)
- Autocorrelation (self-similarity)
- Results in a 12-dimensional feature vector
- Approach implemented in:
- DB2 AIV Extender
- Oracle multimedia

Statistical Characteristics¶
- Loudness / Perceived volume
- Root mean square (RMS) of amplitude values (in dB)
- Root mean square:
- \( RMS=\sqrt{\frac{1}{n} \sum_{i=1}^n x_i^2} \)
- Weight higher values higher than lower
- Other methods: Take different perception of frequencies into account (e.g., lower 50 Hz, above 20 kHz)
- Brightness / Perceived brightness
- Definition: Expected value of Fourier spectrum
- Logarithmic scale
- Describes the amount of high frequencies in signal
- Bandwidth / Frequency bandwidth
- Variance of the signal:
- Weighted average of differences of Fourier coefficients of center-of-gravity (expected value) of spectrum
- Weights: Amplitudes
- Variance of the signal:
- Pitch
- Perceived pitch (pitch is usually different from frequency)
- Calculate: Frequencies and amplitudes of peaks in each interval (by pitch tracking)
- Pitch tracking is difficult (simply, approximate by fundamental frequency)
Static Classification¶
- Training:
- Input: Group of sounds of one class
- Compute the mean vector \( \mu=\frac{1}{N}\sum_{i=1}^N x_i \)
- Compute covariance matrix \( R=\frac{1}{N}\sum (x_i-\mu)(x_i-\mu)^T \)
- Classification:
- New item \( x \)
- Compute Mahalanobis distance to each class, i.e., 1-NN classification
- \( D=\sqrt{(x-\mu)^T R^{-1}(x-\mu)} \)
- Compute probability of correct classification:
- \( L=e^{-\frac{D^2}{2}} \)
- Higher distance –> lower probability of correctness
- Order the distances by these values and select the one with highest probability

Evaluation¶
- Works quite well for short audio
- e.g., sounds, speech
- Differentiate between speech and music/laughter and music
- Advantages:
- Parameters statically represent human perception
- Easy to use
- Easy to index
- Query-by-example
- Disadvantage:
- Statistical values are bad for musical pieces
- Bad to classify musical pieces
- Pitch determination does not work well
Melody Recognition¶
- Goal: Detect melody of music/recognize notes from signal (trivial for MIDI file)
- Definition Melody:
- Sequence of musical notes (sequence of differences)
- Requirements for querying:
- Query-by-Humming
- Invariant under pitch shift (soprano/bass)
- Invariant under time shift
- Invariant under slight variations (users are not singers)
- Problems:
- Different instruments overlap
- Detecting the dominant pitch is difficult due to interference
- Pitch is not the fundamental frequency
- Pitch has something to do the the frequencies
- Human perception differs from physical measurements
- Harmonics:
- One main oscillation, several multiples overtones
Difference Limen¶
- Definition Difference Limen:
- Also called just-noticeable difference
- Smallest change in frequency that can be reliably perceived
- Depends on pitch, duration and volume
- Psychological Tests
- Jesteadt et al., 1977
- They created perceptual scale of pitches
- Play two tones (each 500 ms) with small change
- Results in a psychometric function
- Normally difference limen: 0.2 %
- Influences:
- Frequency: Not uniform (possibly logarithmic)
- Duration: increasing from 0 - 100 ms, then constant
- Volume: increasing from 5 - 40 dB, then constant

Pitch Determination¶
- Definition Pitch (Tonhöhe):
- ANSI, 1994
- Perceptual property to order sounds from low to high
- Depends on mainly on frequency, pressure and waveform
- Distinguish pitch from timbre (Klangfarbe)
- ~~Pitch is feature of frequency at particular time (==What does that mean???==)~~
Biological Models¶
- Cochlea:
- Spiral with little hairs which are connected to neurons
- Apex: Center of the spiral
- Oval window: Entrance of spiral
- Basilar membrane: Membrane inside the Cochlea covered by the hairs
- Different frequencies are perceived at different places inside the Cochlea
- Frequencies are perceived from high to low from the oval window to the apex
- Temporal synchronization of neurons: Neurons fire randomly
- Problem of these models:
- Recognize only pitches of individual sounds
- Complex tones are more complicated
- Multiple frequencies lead to multiple triggered locations
- Multiple frequencies lead to interfering synchronization patterns
Location-dependent Model¶
- Idea: Detect pitch by perception location inside the cochlea
- Lower frequencies travel farther inside the cochlea
- Use function of excitation (distance from apex, in mm) as representation for pitch
- Greenwood, 1990:
- \( z = 7.24 \cdot \ln (1+f/165) \) (Greenwood et al., 1990)

Time-dependent Model¶
- Sound coding not only location-dependent, also temporal synchronization of neurons are important
- Refraction time: Cooldown of a neuron that has fired
- Neuron behavior: Neuron fires spontaneously and randomly
- Sound leads to synchronous fire rate which is detected by the brain
- Auto-correlation of this pattern (e.g., ACF and AMDF)
Pitch Tracking Algorithms¶
- Use time-dependent model
- Pitch of note can be perceived constant with and without fundamental frequency
- Removing fundamental frequency would change location in location-dependent model
- Synchrony of wave remains the same because of the harmonics
- Hearing
- Complex sounds are analyzed in frequency bands
- Idea:
- Match sound against harmonic templates to detect pitch (Goldstein, 1973)
- e.g., Harmonic Product Spectrum, MLE
- Pitch is synthesized by hearing
- Two distinct units on the ears are perceived as pitch
- Non-occurring frequency can be “heard”
- Ambient noise can influence perception (the brain is tricked
- Window size: twice as long as estimated period of wave
- Requirements for algorithms:
- Frequencies must be on the range of a semitone around its correct octave
- Instruments must have well-defined harmonies (e.g., Cello, Piano)
- Real-time conversion of the signal (for real-time applications, e.g., Shazam)
Harmonic Product Spectrum¶
- Schroeder, 1968 / Noll, 1969
- Idea:
- Use frequency domain
- Analyze certain frequency bands (application-dependent)
- Analyze all frequencies from this band for harmonics
- HPS of a frequency provides an indicator of the “harmonic-ness”
- Formally
- \( R \): Number of harmonics (e.g., 5)
- \( X(w) \): Strength of frequency \( w \) in current time window
- \( Y(w) \): Product spectrum of frequency \( w \)
- \( \hat{Y} \): Detected Pitch
- \( Y(w) = \Pi_{r=1}^R |X(wr)| \)
- \( \hat{Y} = \arg\max_{w_i} Y(w_i) \)
- Advantage:
- Simple/robust
- Problems:
- Noise below 50 Hz
- Octave errors:
- Overtones are detected as pitch as well
- Pitch may be recognized one or multiple octaves too high
- Solution: Rule-based
- If closest amplitude under the pitch candidate has half its frequency and an amplitude over a certain threshold, select this as pitch
Maximum Likelihood Estimator¶
- Noll, 1969
- Goal:
- Detect pitch and
- Remove artifacts (false high frequencies)
- Idea:
- Use frequency domain
- Convolute with an ideal specter, i.e., chain of pulses (convolution is done using a dampening function, to be more robust)
- Minimize error for the frequencies (minimal error corresponds to the pitch)
- Formal
- \( f \): Original signal
- Ideal specter
- \( W \): Dampening function (to remove artifacts)
- \( X \): Chain of pulses for the harmonics
- \( Y_w \) ideal specter for frequency \( w \)
- \( Y_w=X(w)*W(w) \) (convolute pulses with dampening function)
- Pitch (to detect) \( \hat{Y} \)
- \( \tilde{Y}_w = f*Y_w \): Convoluted signal for frequency \( w \)
- Error
- Use discrete functions (vectors)
- Goal: Minimize error between ideal specter and convoluted signal (Maximum likelihood method)
- \( E(w) = ||Y_w-\tilde{Y}_w||^2 = ||Y_w||^2 + ||\tilde{Y}_w||^2 - 2Y_w\tilde{Y}_w^T \)
- \( ||Y_w||^2 \), \( ||\tilde{Y}_w||^2 \) remain constant
- \( \hat{Y} = \min_w E(w) = \max_w Y_w\tilde{Y}_w^T \)
- Vector of different \( Y_w \) and the original signal \( f \)
- Take maximal component of resulting vector
- Good results if ideal specters are close to real specters

Auto Correlation Function¶
- Idea:
- Use time domain
- Harmonic signal is self-similar if shifted by the pitch (due to harmonics)
- Compute auto-correlation of signal as indicator
- Auto-correlation function (ACF)
- \( \phi(\tau) = \frac{1}{n}\sum_{i=0}^{n-1} x(i)x(i+\tau) \)
- \( \tau \) is the time of the shift
- Peaks in ACF are period length
- Pitch candidate is fundamental frequency which is 1/period length
- Problem: Multiplication expensive
- Use Average Magnitude Difference Function (AMDF)
- \( \psi(\tau) = \frac{1}{n}\sum_{i=1}^{n-1} |x(i)-x(i+\tau)| \)
- Minimums are peaks of ACF (therefore pitch candidate)
- Advantage: Efficient to compute
- Approach of Kobayashi and Shinamura, 2000
- ACF and AMDF are independent (==Why???==)
- Combine to robust estimator
- \( f(\tau) = \frac{\phi(\tau)}{\psi(\tau)+k} \)
- Advantage: Significantly better fault tolerance against noise
- Best results for \( k=1 \)
Problems and Post-Processing¶
- Pitch detection works good for time slots
- Problems:
- Windowing creates recognition errors for continuous pitch changes (e.g., cello)
- Attack frequency vs. sustain level (attack is higher than sustain)
- Polyphony (multiple instruments play different notes)
- Tuning of instrument changes (e.g., temperature, humidity, time)
- Hysteresis (==What is this???==)
- The more complex the music, the more complex the Pitch Recognition is
- Windowing creates recognition errors for continuous pitch changes (e.g., cello)
- Post-processing:
- Faults/octave jumps must be filtered (e.g., removed, merged)
- Inference of notes (see how they are developing; complicated and inefficient)
Melody Representation¶
- Only use a sufficient representation to save data (keep it simple)
- Types:
- Note-based/event-based (use individual tones): Parsons Code
- Frame-based (use points the input signal): Dynamic-time warping
- Stochastic: Hidden Markov Models
Parsons Codes¶
- Parsons, 1975
- Idea:
- Historical idea: Classify melody lines
- Melody is a sequence of note variations
- Disadvantages:
- Ignores rhythm
- Ignores note intervals/lengths
- Notes are hard to detect
- Advantage:
- High fault tolerance
- Pitch shift invariant
- Rhythm invariant
- Scale invariant (major/minor, no transposition required)
Representation¶
- Melody is represented by sequence of notes
- First note is reference: \( \Diamond \)
- Codes:
U(up): Higher noneR(repeat): Same noteD(down): Lower note
- e.g., \( \Diamond RRUURDDDDRURURUD \)
Matching¶
- Compare query to all codes in DB
- Use edit distance (e.g., Levenstein)
- Use substring matching
- We have no idea where the query melody appears
- Sliding window (start at any point of parsons code in DB)
- Personal idea: Analyse the audio files and detect the refrains. Start by matching the refrains because these are usually remembered.
- Typical errors in the query:
- Note is missing
- False note added
- Existing note has wrong pitch
- Short notes are combined
- Long notes are fragmented into short notes (breathing while humming)
- Goal: Intuitive measure of dissimilarity respecting the typical errors in the query
- Operations:
- Delete a character
- Insert a character
- Replace a character
- Consolidation: Replace a string with a character (e.g., combine multiple
D) - Fragmentation: Replace a string with a character (e.g., split
RintoRR)
- Optimization 1:
- Apply operations from left to right string
- \( O(mn) \) vertices in graph
- Costs are non-negative
- Use Dynamic programming:
- Mongeau/Sankoff, 1990
- Consider all possible nodes in graph regardless of costs
- Ignore nodes with very high cost
- Costs near the diagonal are candidates for the minimum
- Optimization 2:
- Adapt costs to typical errors
R...R -> Rtypical error (consolidation)
UD/DUis no typical error -> higher cost- Inserting
Rcheaper than insertingU/D - Replacement of
R->DandR->Ucheaper thanU->D/D->U(U/Dshould be treated the same) - Similar costs for fragmentation/consolidation
- Similar costs insertion/deletion
- Adapt costs to typical errors

Improvement: Difference Codes¶
- Problem with Parsons code:
- Ignore strength of pitch change
- Idea:
- Store interval information as number of semitones (12-tone scale)
- e.g., \( \Diamond,0,1,2,0,-2,-1,-2,-2 \)
- Kosugi et al., 2000
- Research of distribution of intervals in music
- Database with 10000 songs
- Result: Gaussian distribution
- \( \pm 2 \) semitones (1 whole tone) very often
- Tritones (\( \pm 6 \) semitones) very rare (very un-harmonic)
- Advantage
- Precise distinction
- Using weighted edit distance
- Weight: Size of the jump
- Precise distinction
- Disadvantage
- More expensive
- Depends on the audio collection (may not matter/humming may be too coarse)
Frame-based Representation¶
- Idea:
- Use contour of music
- e.g., pitch curve
- Match two series of different length
- Representations:
- Use time series of pitch values (frames)
- Frame should be equidistant (e.g., 50 ms)
- Advantage:
- No incorrect segmentation
- Rhythm information can be contained
- Disadvantage:
- Higher retrieval time
- Problem of point-wise comparison:
- Different speed of query
- Different rhythm in query
- Solution: Dynamic matching
- Dynamic Time Warping
Dynamic Time Warping¶
- Berndt/Clifford, 1994
- Distance measure for time series
- Same principle like edit edit (but no finite alphabet for operations)
- Operation cost: Depend on values
- Match pairs of points / assign each point in the one signal a point of the other signal
Formal¶
- Time series
- \( f(t) \) with \( N \) points: \( f_1,\ldots,f_N \)
- \( g(t) \) with \( M \) points: \( g_1,\ldots,g_M \)
- Warping diagram:
- Grid \( N\times M \)
- Axis:
- \( t_f =1,\ldots,N \)
- \( t_g=1,\ldots,M \)
- Each point \( (i,j) \) maps \( f_i \) to \( g_j \) (\( f(i) \) to \( g(j) \))
- Warping path \( W \):
- Series of points \( (i,j)\subsetneq \mathbb{N}_N\times\mathbb{N}_M \)
- \( K \) number of points
- \( W=((i_1,j_1),\ldots,(i_K,j_K)) \)
- Warping properties (of the warping path):
- \( 1\leq k \leq K \)
- Monotony
- Only move forward
- \( i_k \leq i_{k+1} \) (analog to \( j \))
- Continuity
- Do not leave points out
- \( i_{k+1}-i_k\leq 1 \) (analog to \( j \))
- Boundaries
- Match start and end
- \( i_1=j_1=1 \) (map \( f(1) \) to \( g(1) \))
- \( i_K=N \) (map \( f(N) \) to \( g(M) \))
- \( j_K=M \)
- Calculation
- Dynamic programming \( O(nm) \)

Uniform Time Warping¶
- Idea:
- Warping path as diagonal as possible
- Prefer consecutively matching of points (cf. edit distance)
- Uniformly match the series: Stretch series uniformly to \( mn \) points
- Generalization of time scaling
- Time series \( x_n \) and \( y_m \)
- Distance: \( d^2_{UTW}(x,y)=\frac{1}{mn} \sum_{i=1}^{mn} (x_{\lceil i/m \rceil}-y_{\lceil i/m \rceil})^2 \)
- Difference between every two points
- Each point \( x_i \) is replicated \( m \) times
- Each point \( y_i \) is replicated \( n \) times
- Problem: Variable speed of the time series ==Why???==
Local-dynamic Time Warping¶
- Idea:
- Extend series to same length (as in UTW)
- Compare point-wise with little warping intervals
- Prefer diagonal matrix
- Complexity \( O(kn) \)
- \( k \): Width of band around diagonal (called slope constraint)
- Slope constraint: Match a point to at most \( k \) other points
- Zhu/Shasha, 2003
- GEMINI approach
- Map the query into an envelope
- ==What was the contribution?==
