News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

tiny mci multimedia player

Started by avcaballero, July 28, 2014, 06:25:24 AM

Previous topic - Next topic

Gunther

Marinus,

Quote from: Siekmanski on August 14, 2014, 07:20:53 PM
Maybe i'll pick it up some day......

you should do that.

Quote from: Siekmanski on August 14, 2014, 07:20:53 PM
The wasteland mod was made by a german demo group called "Red Sector" in 1989, they had strong nerves. :lol: :lol: :lol:

That's pretty old. I didn't know that.

Gunther
You have to know the facts before you can distort them.

avcaballero

#31
Thank you, Marinus, very valuable example :t.... I've got "Unable to create Direct3D Object" though.
Quote from: Gunther on August 14, 2014, 11:53:41 AM
the wasteland file sounds very TECHNO
Aaaaahhh, techno, thats good for me :biggrin:

In this version, volume track bar works fine.

Regards

GoneFishing

Quote from: avcaballero on August 15, 2014, 01:17:32 AM
Thank you, Marinus, very valuable example :t.... I've got "Unable to create Direct3D Object" though.
Check the dependencies , some DX DLLs may be missing from your computer.

avcaballero

I cheated. Spectrum works... randomly, not with the music  :biggrin:

I've been playing a bit with this and i think that FFT is needed, that wouldn't be the problem in principle. To implement this formula we need to know samples, i guess that samples per second. I believe that we can retrieve this information from mci using "status" with a string like this:
 
  status mymci audio samplespersec notify
 
But i'm not sure, the prooves that i made give me values such as 16,776,960. Would we need to divide it by 1000?

FFT seems to be a bit slow, and when i have used it every second, the program crashed after a while. Maybe would be needed creating a thread to calculate this, and maybe not every second... ?

Any idea?
Thank you

dedndave

i would try to aim for 4, 8, or maybe even 16 updates per second

Siekmanski

Just synchronize to the screen refresh rate.
Let's say you have a screen refresh rate of 60 Hz and play the music at a sample rate of 44100 Hz.
Then you have 44100 / 60 = 735 audio samples per frame to use with your spectrum.
Now trigger the screen update and calculate the position in the audio buffer.

Important is to use all samples to present a full spectrum.

If you want to use FFT then you can cheat and do a 512 samples FFT discarding the remaining 223 samples.
You will lose spectrum information...
Or you do a 1024 samples FFT and fill it with the 735 audio samples and 289 null samples.
Now you get the full spectrum information out of the 735 audio samples.

Because the audio data stream is continue, it is not important how often you present your spectrum to the screen.
for example 30 times a second, then you have to process 1470 audio samples at once.

Alfonso, did you find a way to get access to the MCI audio buffer?

B.T.W. there are many ways to show the frequency spectrum.

for example: FFT DFT Goertzel IIR
And the FIR method i'm working on now. ( need a couple of more days to complete it )
Creative coders use backward thinking techniques as a strategy.

avcaballero

Quote from: Siekmanski on August 18, 2014, 05:08:45 AM
Alfonso, did you find a way to get access to the MCI audio buffer?
No. I'm studying MCI documentation and proving. There're many labels, much stuff, but poorly documented and very few resources in the net.

As i said before, it is possible that "status" mci command with some of its labels may help us, but i need prove.

Quote from: Siekmanski on August 18, 2014, 05:08:45 AM
And the FIR method i'm working on now. ( need a couple of more days to complete it )
I'm waiting for it :t

Regards

Siekmanski

Hi avcabalero,

This is how far i am now...
Wrote a timer interrupt which polls every 5 milliseconds the play cursor of the soundcard.
It's a double buffer system, 1 buffer is playing while the other buffer is filled with new audio data.
Fast sample type conversion from 16bit signed to float32 and vice versa is done with SSE2.
Drawing to the screen is done with Direct3D9 vertex programming.
As you can see i synchronized the audio that is playing with the oscilloscope on the screen.
You can load 44100 Hz 16bit stereo music wav files to test it.
In the attachment is a little wav sample.

This weekend i planned to implement the FIR audio spectrum analyzer.
When it's finished i will include all the source codes with some comments how things are done.

Marinus
Creative coders use backward thinking techniques as a strategy.

avcaballero

It has an excellent look, Marinus. I'm going a bit slowly, but keep on going and hope to have some news soon.

Thanks a lot.
Alfonso

Gunther

Hi Marinus,

looks good.  :t

Gunther
You have to know the facts before you can distort them.

dedndave

that looks more like an oscilloscope   :biggrin:

dedndave

some spectrum analyzer pics...

this is what a portion of the radio spectrum might look like (animated GIF)


http://www.bitscope.com/software/dso/guide/2.5/115.gif

for this application, it might look like this
the different "bands" could coincide with graphic equalizer bands (also an animated GIF)


http://www.animated-gifs.eu/avatars-100x100-music/0259.gif

this one demonstrates a sort of power-density graph (another animated GIF)
in RF and microwave work, we often use a storage display (CRT with very long persistance)


http://www.metageek.net/wp-content/uploads/2011/02/density-real-time.gif

this is an add-on for TotalRecorder for spectral display/graphic EQ

http://www.totalrecorder.com/addon1.htm

Gunther

Dave,

excuse me, but an oscilloscope looks a bit different.  :lol:

Gunther
You have to know the facts before you can distort them.

Siekmanski

Thanks Alfonso and Gunther.

Hi Dave,

Quotethat looks more like an oscilloscope   :biggrin:
Yes, but what's a spectrum analyzer without an oscilloscope.   :biggrin:   :biggrin:
The spectrum analyzer will be below the oscilloscope, in this case just as in Alfonso's request a 10 bar 1 octave pass band filter.
This weekend i hope to have it finnished.

Marinus
Creative coders use backward thinking techniques as a strategy.

dedndave

i have some idea what an oscilloscope looks like - lol
sometimes, i feel like i have one attached to my hip

a couple of the images above show linear divisions for frequency
for RF work, that's usually desirable (we want the sidebands to appear linear)
but, the audio spectrum might be best divided into log divisions
each band doesn't have to be an octave

let's say we want to cover 2 to 20,000 Hz in 12 bands
the width for each would be (20000/2)1/12 = 2.1544346900318837217592935665194

so, the bands would be
2 to 4.309 Hz
4.309 to 9.283 Hz
9.283 to 20 Hz
20 to 43.09 Hz
43.09 to 92.83 Hz
92.83 to 200 Hz
200 to 430.9 Hz
430.9 to 928.3 Hz
928.3 to 2000 Hz
2 to 4.309 KHz
4.309 to 9.283 KHz
9.283 to 20 KHz

probably, 20 to 20,000 is more common - i'll let you do the math   :P

the vertical scale is also log (decibels)