# How can I use a constant Q transform to detect low frequencies without making the buffer size too large?

I am trying to write code to detect musical notes within a signal. I have been reading up on different methods for extracting frequency information out of a signal to determine which notes were played at a given time and I came across the "constant Q transform" which seems to be very well suited for this application. The main thing that appealed to me with the constant Q transform is that it is supposed to be able to achieve higher resolution for low frequencies than a normal FFT.

I just finished implementing a basic constant Q transform in C++ after reading through this paper and I ran into one major problem.

My code can be found here: https://godbolt.org/z/43b8vohs3

The problem primarily arises from this part of the paper:

If I am understanding what it says here correctly, this means in order to detect a frequency of 27.5Hz (A0, the lowest note on an 88 key piano) in a signal sampled at 44100Hz, The constant Q transform would require the input to have a minimum buffer size of N[k] = (S/f)Q = 44100/27.5*34 = 54523. That is over one full second of audio which is WAY too large to be practical considering notes can be played much faster than that.

I feel like I must be missing something critical here because requiring a buffer size that large would make this algorithm effectively useless for detecting notes in most pieces of music. How can the constant Q transform be used to detect low frequencies like this without increasing the buffer size to a completely unrealistic size?

Ideally I would like to keep the buffer size small enough to work on 100ms of audio or less (around 4096) or even smaller as long as it is possible to achieve a high enough resolution for the output to be useful.

• The paper Sliding With A Constant Q by Bradford et. at. addresses the issue of your concern.
– AHT
Commented Apr 28 at 22:25
• Thank you! I will read it over :) Commented Apr 28 at 22:52