Advertisement

VB Mp3 Player, Help! :)

Started by May 10, 2001 10:06 AM
1 comment, last by CoiN 23 years, 9 months ago
Lo All, Sorry for posting again it''s just that I''m totally stuck. I have to do a project for college and I have decided to do an Mp3 player. So far I have just been using the Media Player OCX but I want to add things like Graphic Equalisers and stuff. I know this isn''t going to be easy but I have a couple of months to do the project and I was wondering if anyone could point me towards any good websites or books on this subject? Also would it be possible (or easier) to make a Mp3 player using visual basic directx which would allow me to add graphic equalizers and stuff? Any suggestions about how I could do this would be appreciated, as you can probably tell I don''t really know much about this stuff. Thanks in Advance... Coin.
Do you know C or C++ (at all)?

'cause there ain't no way in hell you're doing an eq with VB - unless you find (or make) an activeX control written C to use.

Can you get at the playbuffer with the media player OCX?
If you can, or if you can write a plug-in for the mpocx, then you're in business. It's important to make sure that you queue up the data, and process chunks of equal size, and that you process the entire stream.

...
1) In order to create an graphics eq you need to take the audio stream (which is packed shorts left/right/left/right) and turn it into two arrays of the lefts & rights.

2) Then you need to perform an Auto Power Spectrum analysis.
2.1) Window
2.2) FFT
2.3) |FFT[j]|^2 / lengthof(FFT)^2
An APS requires an FFT to be performed on each array, and an absolute value of the complex FFT result needs to be taken - actually it's the absolute value squared divided by the number of samples in the FFT. The FFT takes the time based audio stream and converts it into the frequency domain. Taking the absolute value and squaring (multiply by the complex conjugate in practice) and dividing by the number of points (squared) used to calculate the FFT yields a relative power measurement - i.e. how much strength of the waveform signal is within that frequency range.
However, before you do all that, you need to 'window' the audio stream. A window is a function that starts & ends at zero while going from 0 to 1 (it generally has a bump in the middle). A sine wave, from 0 to pi/4r is a decent window, I think that's the called the Hamming window. Experts recommend the Bartlett window, but the Hanning window is oftened used in the field. Windowing the data removes FFT frequency spikes due to the sudden changes at the begining & end of the audio sample (from and to zero).
Download the Signal Processing Library from Intel. I'm not sure if it can be used from VB or not.

4) Rolling Sum; eq[j] = APS[1][j] + APS[2][j] + APS[3][j] + ...
In order for the eq to look right, it needs to roll with the music. That means you need to keep around the last three to nine (or so) APSs and add them together each time you calculate a new APS. This way peaks will 'wash' in and out, and not instantly pop up & down.
Due to the nature of APSs it is desirable to add the spectrums, and not average them.

5) eq[j] = log(APS[j])
Often a slew of other tweaking is done to make the APS look better. For starters, drawing it on a logarithmic is essential (this factor alone precludes the use of VB to do the number crunching; if this operation takes longer than 200us it's too damn slow)
Download the Math Kernel Library from Intel.

6) Combine frequencies the way the human ear hears them
The human ear hear different frequencies at different relative volumes, and with differing levels of distrinction. If you look at the eq on WinAmp, the frequencies are bunched together more on the higher end. Note that this is not a mathematical scale - it's not linear, it's not logarithmic, it's not squared... it's the human ear scale.
They also don't show anything below about 40dB, so it's a logrithm scale on the y axis, but it doesn't start at 1 (it can't start at 0...)
PS dB = 20*log(APS[j])
(use the MKL)

7) Draw pretty colors with DirectX, 'cause nothing else stands a chance.
[j]

Magmai Kai Holmlor
- The disgruntled & disillusioned


Edited by - Magmai Kai Holmlor on May 10, 2001 11:02:30 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
Thanks for the reply man....

I didn''t know it was gonna be this hard.

This topic is closed to new replies.

Advertisement