Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Getting sound frequency?

Author
Message
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 11th Oct 2014 02:42
Hey people
Just wondering, is there any way to get the frequency (in Hz or KHz) of a sound at any point in it's playthrough? I'm guessing you'd need to use either memblocks or a plugin, but I can't see any easy way to do it using memblocks, and I'm not sure if a plugin exists for this!
Any ideas? Thanks

The code never bothered me anyway...
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 11th Oct 2014 12:43
That depends, what type of sound are you planning to get the frequency of?
Is it just a pure waveform like a sine or triangle wave or something more complex?

You are right that if you want to do this in DBPro you would use a memblock as a means of reading the actual audio data. To extract the frequency of a pure waveform from this you could simply check at what interval the sampled values goes from 0 into the positives (or negatives); the samples will pass zero once on the way up and again on the way down so you want to make sure that you check where it has gone full circle, that is every two passes past zero.
If on the other hand you want to find the dominant frequency in a more complex waveform this approach won't be sufficient. You can google for pitch tracking which is the technical term for what you want to achieve in this case.

Finally, if you just want to know the fixed sampling frequency of the sound, this is stored as a DWORD at offset 8 in the sound memblock.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2026-07-18 09:24:57
Your offset time is: 2026-07-18 09:24:57