cqt#

diffsptk.CQT#

alias of ConstantQTransform

class diffsptk.ConstantQTransform(frame_period, sample_rate, f_min=32.7, f_max=None, n_bin_per_octave=12)[source]#

Perform constant-Q transform. The implementation is based on the simple matrix multiplication.

Parameters:
frame_peirodint >= 1 [scalar]

Frame period in samples.

sample_rateint >= 1 [scalar]

Sample rate in Hz.

f_minfloat > 0 [scalar]

Minimum center frequency in Hz.

f_maxfloat <= sample_rate // 2 [scalar]

Maximum center frequency in Hz.

n_bin_per_octaveint >= 1 [scalar]

number of bins per octave, \(B\).

References

[1]

J. C. Brown and M. S. Puckette, “An efficient algorithm for the calculation of a constant Q transform,” Journal of the Acoustical Society of America, vol. 92, no. 5, pp. 2698-2701, 1992.

forward(x)[source]#

Apply CQT to signal.

Parameters:
xTensor [shape=(…, T)]

Signal.

Returns:
XTensor [shape=(…, N, K)]

CQT complex output, where N is the number of frames and K is CQ-bin.

Examples

>>> x = diffsptk.sin(99)
>>> cqt = diffsptk.CQT(100, 8000, n_bin_per_octave=1)
>>> X = cqt(x).abs()
>>> X
tensor([[0.1054, 0.1479, 0.1113, 0.0604, 0.0327, 0.0160, 0.0076]])

See also

stft