ScratchData LogoScratchData
Back to nembence's profile

Playing PCM audio with constant Q transform demo1

NEnembence•Created June 17, 2024
Playing PCM audio with constant Q transform demo1
15
10
241 views
View on Scratch

Instructions

If you don't hear the sound or it's lagging, try turning on reduced mode by clicking the stage (less quality). Then it will only try to play ~124 sounds instead of ~266 at once. Also close anything that could play or record a sound if it wanted. I included 90 seconds of precomputed music. The project has to precompute more to play more of it on Scratch, because my constant Q transform needs a compiler to run in real time. https://turbowarp.org/1038391268 You can press the green flag while it's precomputing to hear what it has done so far, but that pauses the precomputing process until it stops playing the sound. You can import your own audio - see inside and go to Stage for instructions. With other music: https://scratch.mit.edu/projects/1039396371/ Lighter version: https://scratch.mit.edu/projects/1063437488/

Description

Music: Four Beers' Polka by Kevin MacLeod I used the FFT by @SpinningCube to implement the constant Q transform (CQT). (https://scratch.mit.edu/projects/941518411/) I read about the constant Q transform and about Gabor wavelets on the Wikipedia. The Q in my implementation is not exactly the Q on Wikipedia. How does this work? What is a constant Q transform? My CQT implementation's is described in the next block of text. All other answers: See the original project's description, but the differences from the original project are: This project doesn't use an external program to calculate the spectrogram. I divided the octave into 24 bands instead of 16. I replaced the sine waves with narrow-band noise (it sounds similar to a sine wave) for the sound reconstruction. That fixed noise sounds. I made the new sounds start with silence, that fixed the sound spike at the start, however it made the loudness wobbling a bit. (every clone plays 2 sounds alternately that overlap in 3/8 of the time) How does your constant Q implementation work? I choose a Gabor wavelet for the frequency I'm checking. Then I calculate the length of the wavelet and of its Fourier transform where they are bigger than 0.001. I choose the shorter and then multiply it point by point with the waveform or with its Fourier transform and sum the results. This gives a complex number. Then I set the intensity of the frequency to the absolute value of the sum. Change log: 2024. September 04. - Replaced sound components, reduced mode now plays a slice of the spectrogram instead of playing 12 bands/octave.

Project Details

Project ID1038391268
CreatedJune 17, 2024
Last ModifiedSeptember 4, 2024
SharedJune 18, 2024
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root