ArticleslgStudy

science

Constant-Q transform

Constant-Q transform is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Constant-Q transform rather than just read about it. In short: In mathematics and signal processing, the constant-Q transform and variable-Q transform, simply known as CQT and VQT, transforms a data series to the frequency domain. It is related to the Fourier transform and very closely related to the complex Morlet wavelet transform.

Constant-Q transform — main illustration
Constant-Q transform — illustration

Key takeaways

  • Constant-Q transform belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Constant-Q transform to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Constant-Q transform from memory before moving on to harder problems.

Reference excerpt

In mathematics and signal processing, the constant-Q transform and variable-Q transform, simply known as CQT and VQT, transforms a data series to the frequency domain. It is related to the Fourier transform and very closely related to the complex Morlet wavelet transform. Its design is suited for musical representation.

The transform can be thought of as a series of filters fk, logarithmically spaced in frequency, with the k-th filter having a spectral width δfk equal to a multiple of the previous filter's width:

δfk=21/n⋅δfk−1=(21/n)k⋅δfmin, where δfk is the bandwidth of the k-th filter, fmin is the central frequency of the lowest filter, and n is the number of filters per octave.

Calculation The short-time Fourier transform of x[n] for a frame shifted to sample m is calculated as follows:

X[k,m]=∑n=0N−1W[n−m]x[n]e−j2πkn/N. Given a data series at sampling frequency fs = 1/T, T being the sampling period of our data, for each frequency bin we can define the following:

Filter width, δfk. Q, the "quality factor": Q=fkδfk. For geometrically spaced bands, δfk=fk(21/n−1), so Q=(21/n−1)−1 is the same for every band and is in general not a whole number, being about 16.8 for n = 12 bins per octave. It is the number of cycles of the sinusoid spanned by the analysis window at fk, and so fixes the duration of that window.

Window length for the k-th bin: N[k]=fsδfk=fsfkQ. Since fs/fk is the number of samples processed per cycle at frequency fk, Q is the number of integer cycles processed at this central frequency, which need not be a whole number. The equivalent transform kernel can be found by using the following substitutions:

The window length of each bin is now a function of the bin number: N=N[k]=Qfsfk. The relative power of each bin will decrease at higher frequencies, as these sum over fewer terms. To compensate for this, we normalize by N[k]. Any windowing function will be a function of window length, and likewise a function of window number. For example, the equivalent Hamming window would be W[k,n]=α−(1−α)cos⁡2πnN[k]−1,α=25/46,0⩽n⩽N[k]−1. Our digital frequency, 2πkN, becomes 2πQN[k]. After these modifications, we are left with

X[k]=1N[k]∑n=0N[k]−1W[k,n]x[n]e−j2πQnN[k].

Variable-Q bandwidth calculation The variable-Q transform is the same as constant-Q transform, but the only difference is the filter Q is variable, hence the name variable-Q transform. The variable-Q transform is useful where time resolution on low frequencies is important. There are ways to calculate the bandwidth of the VQT, one of them using equivalent rectangular bandwidth as a value for VQT bin's bandwidth.

The variable-Q transform is usually obtained by adding a bandwidth offset γ, so that the bandwidth of the k-th band becomes

δfk=αfk+γ, where α = 1/Q is fixed by the number of bands per octave. Setting γ = 0 recovers the constant-Q transform, while γ > 0 widens the lower bands, which lowers their Q and shortens their windows, improving time resolution at low frequencies at the cost of frequency resolution. Choosing γ so that each bandwidth is a fixed fraction of the equivalent rectangular bandwidth at the corresponding centre frequency gives bands following an auditory scale, and is the default in some implementations.

Fast calculation The direct calculation of the constant-Q transform (either using naive discrete Fourier transform or slightly faster Goertzel algorithm) is slow when compared against the fast Fourier transform. However, the fast Fourier transform can itself be employed, in conjunction with the use of a kernel, to perform the equivalent calculation but much faster. An approximate inverse to such an implementation was proposed in 2006; it works by going back to the discrete Fourier transform, and is only suitable for pitch instruments. A development on this method with improved invertibility involves performing CQT (via fast Fourier transform) octave-by-octave, using lowpass filtered and downsampled results for consecutively lower pitches. Implementations of this method include the MATLAB implementation and LibROSA's Python implementation. LibROSA combines the subsampled method with the direct fast Fourier transform method (which it dubs "pseudo-CQT") by having the latter process higher frequencies as a whole. The sliding discrete Fourier transform can be used for faster calculation of constant-Q transform, since the sliding discrete Fourier transform does not have to be linear-frequency spacing and same window size per bin. Alternatively, the constant-Q transform can be approximated by using multiple fast Fourier transforms of different window sizes and/or sampling rate at different frequency ranges then stitch it together. This is called multiresolution short-time Fourier transform, however the window sizes for multiresolution fast Fourier transforms are different per-octave, rather than per-bin.

Invertible constant-Q transforms from nonstationary Gabor frames The constant-Q transform can be cast as a nonstationary Gabor system, in which the analysis window varies with frequency rather than with time. Each band is formed by multiplying the Fourier transform of the signal by a real window centred on that band, then taking an inverse Fourier transform whose length matches the bandwidth of that window, so each band carries its own number of time coefficients. If the windows satisfy a "painless" condition, so that at every frequency bin the sum of their squared magnitudes, each weighted by the number of coefficients in its band, is strictly positive, then the [[Frame (linear algebra)|frame]] operator is diagonal. It is then inverted by one division per bin, giving a dual window for each band, and synthesis from these dual windows recovers the signal exactly, with no iterative step; reconstruction is therefore exact up to numerical precision rather than approximate. Analysis and synthesis each cost one fast Fourier transform of the whole signal together with one short transform per band. A sliced variant cuts the signal into overlapping slices under a smooth window, transforms each slice, and overlap-adds the inverses, which lets the transform run on a continuous stream with bounded memory and an algorithmic delay of one slice. The same construction with bands spaced on an auditory scale instead of geometrically gives the ERBlet transform. Reference implementations are published by the authors and in MATLAB's Wavelet Toolbox.

… excerpt ends here. Continue reading the full article.

Illustrations

Constant-Q transform: Constant-Q transform applied to the waveform of a C major piano chord. The x-axis is frequency, mapped to standard musical pitches, from low (left) to high (right). The y-axis is time, starting from pressing the piano chord at the bottom, and releasing the piano chord at the top, 8 seconds later.

Darker pixels correspond to higher values of the Constant-Q transform. The peaks correspond closely to the precise frequencies of the vibrating piano strings. Thus the peaks can be used to detect the notes played on the piano. The lowest 3 peaks are the fundamental frequencies of the C major chord (C, E, G). Each string also vibrates at multiples of the fundamental, known as overtones, which correspond to the remaining smaller peaks to the right of the fundamental pitches. The overtones are smaller in intensity than the fundamental pitch.

Audio of the C Major piano chord used to generate the Constant-Q transform above.

Its waveform does not visually communicate pitch information like the Constant-Q transform is able to do.
Constant-Q transform applied to the waveform of a C major piano chord. The x-axis is frequency, mapped to standard musical pitches, from low (left) to high (right). The y-axis is time, starting from pressing the piano chord at the bottom, and releasing the piano chord at the top, 8 seconds later. Darker pixels correspond to higher values of the Constant-Q transform. The peaks correspond closely to the precise frequencies of the vibrating piano strings. Thus the peaks can be used to detect the notes played on the piano. The lowest 3 peaks are the fundamental frequencies of the C major chord (C, E, G). Each string also vibrates at multiples of the fundamental, known as overtones, which correspond to the remaining smaller peaks to the right of the fundamental pitches. The overtones are smaller in intensity than the fundamental pitch. Audio of the C Major piano chord used to generate the Constant-Q transform above. Its waveform does not visually communicate pitch information like the Constant-Q transform is able to do.
Constant-Q transform: Its waveform does not visually communicate pitch information like the Constant-Q transform is able to do.
Its waveform does not visually communicate pitch information like the Constant-Q transform is able to do.

Worked examples

Example 1 — a first encounter with Constant-Q transform

Start with the simplest possible case. Write down what Constant-Q transform claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Constant-Q transform before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Constant-Q transform ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Constant-Q transform

In research
Constant-Q transform appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Constant-Q transform in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Constant-Q transform is common in secondary-school and first-year university syllabi. It links to neighbouring topics Harmonic analysis, Integral transforms, Music information retrieval, so understanding it makes those chapters shorter.
In everyday life
Look for Constant-Q transform outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Constant-Q transform” →

How to study Constant-Q transform in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Constant-Q transform means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Constant-Q transform out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Constant-Q transform in simple terms?

In mathematics and signal processing, the constant-Q transform and variable-Q transform, simply known as CQT and VQT, transforms a data series to the frequency domain. It is related to the Fourier transform and very closely related to the complex Morlet wavelet transform.

Why does Constant-Q transform matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Constant-Q transform?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Constant-Q transform.

Tags

  • Harmonic analysis
  • Integral transforms
  • Music information retrieval

Keep exploring