Heres a screenshot of my new proggy made with FMOD 3.6. It should show how to utilize all of the new functions in vb.
Download it here:
- Paranoid_Android asked 14 years ago
Ok, I have a new build of my program. This new build supports module files. But, I’m having some problems and before I upload it I want to ask some questions. I have everything working (play, pause, stop, etc.) for module files but, how do I get the total length of the file??? Because in order to make a progress bar of the file I need to kinow the length of the file. Also, do modules support Stereo VU?? because for some reason I am only getting the left channel VU for module files. And, is there any way to have Spectrum analysis on Module files??
It is looking quite good, but I have a few comments :
It is not necessary to copy dll’s and ocx’s to the windows/system directory.
I think brett even recommended once to keep the fmod.dll in the same directory as the application, so you are sure the fmod.dll version is the same as you expect.
When dll’s and ocx’s are in the application (.exe) directory they will also be found. (when I open the sample in VB, and press play, it works withouth any problems, and I haven’t used register.bat)
When you don’t have any tag information about a song (so it is Unknown – Unknown) it might be usefull to display the filename.
For the spectrum analyser, it might be a little bit faster if you also use FillRect for the peaks, instead of 5 SetPixelV calls. (Not really that important, and probably won’t give you a large speed increase)
Everything else looks nice about it.
Hehe! Getting length of modules isn’t as easy as it is with stream files! Modules are much more complex than simple stream files. KarLKoX gave me a dll file which was able to calculate (this is the right term) the length of a mod/s3m/xm or it file. However you can’t implement a progess bar just with knowing the length of module, because you can’t give FMOD an absolute value in ms. However you can use patterns. For every pattern the slide may drop a position, so you can also use it for seeking.
So, what would this DLL do? Will it give me the length in ms or in something else? And how could I use this for seeking? I wish FMOD had more functions for modules, and spectrum analysis is working for modules now but I found that in order to have spectrum analysis you must load a stream into FMOD first. This might be a bug but I’m not sure. Thanks.
A new screenshot with the updated Spectrum Analyzer:
Wow, thanks for the great comments. Adion, so, do I really need the register.bat file??? I only put it there because I thought that those files might need to be copied to the system folder, but if they dont then I will get rid of it alltogether. I’ll add the filename for no tag info too. Brett, that would be great if you did that, thansk for the good comments.
I haven’t used the register.bat and I can run the example withouth any problem (and I didn’t have those ocx’s)
Some more suggestions:
1)Maybe you can add a total time of the song as well?
2)Now you only use the first 22 numbers of the spectrum data, which means it doesn’t show the higher frequency sounds.
What you need to do if you want to show spectrum data in bands is to add more values for the higher bands.
(So the first band is the first spectrum value, the second band is the second spectrum value + the third,…)
I’ll send you some code that I’ve written to do this that looks good.
You don’t have a e-mail adress in your profile, so I’ll post the code here[/edit]
Public Function vis_GetSpectrumCount(ByVal a As Long, Optional ByVal Width = 32)
If Width = 32 Then
If a = 0 Then d = 1
If a = 1 Then d = 1
If a = 2 Then d = 1
If a = 3 Then d = 1
If a = 4 Then d = 1
If a = 5 Then d = 2
If a = 6 Then d = 2
If a = 7 Then d = 2
If a = 8 Then d = 2
If a = 9 Then d = 3
If a = 10 Then d = 3
If a = 11 Then d = 4
If a = 12 Then d = 4
If a = 13 Then d = 5
If a = 14 Then d = 5
If a = 15 Then d = 6
If a = 16 Then d = 6
If a = 17 Then d = 8
If a = 18 Then d = 8
If a = 19 Then d = 9
If a = 20 Then d = 10
If a = 21 Then d = 11
If a = 22 Then d = 12
If a = 23 Then d = 14
If a = 24 Then d = 15
If a = 25 Then d = 17
If a = 26 Then d = 18
If a = 27 Then d = 20
If a = 28 Then d = 21
If a = 29 Then d = 24
If a = 30 Then d = 25
If a = 31 Then d = 27
ElseIf Width = 16 Then
If a = 0 Then d = 2
If a = 1 Then d = 2
If a = 2 Then d = 3
If a = 3 Then d = 4
If a = 4 Then d = 5
If a = 5 Then d = 7
If a = 6 Then d = 9
If a = 7 Then d = 11
If a = 8 Then d = 14
If a = 9 Then d = 17
If a = 10 Then d = 21
If a = 11 Then d = 30 ’26
If a = 12 Then d = 35 ’32
If a = 13 Then d = 40 ’38
If a = 14 Then d = 50 ’45
If a = 15 Then d = 60 ’52
vis_GetSpectrumCount = d
Public Sub vis_SimplifySpectrum(ByRef src() As Single, ByRef dst() As Single)
Dim up As Long, a As Long, d As Long, c As Long, cnt As Double, wdth As Long
Static max16(15) As Double
Static max32(31) As Double
Dim tmpDbl As Double
up = UBound(dst)
If up >= 31 Then
wdth = 32
ElseIf up >= 15 Then
wdth = 16
For a = 0 To UBound(dst)
d = vis_GetSpectrumCount(a, wdth)
cnt = 0 For c = 1 To d If UBound(src) >= b Then cnt = cnt + src(b) End If b = b + 1 Next If cnt > 0 Then If cnt > 0 Then tmpDbl = sqr(cnt) If wdth = 16 Then If tmpDbl > max16(a) Then max16(a) = tmpDbl If max16(a) > 0 Then tmpDbl = tmpDbl / max16(a) Else tmpDbl = 0 End If ElseIf wdth = 32 Then If tmpDbl > max32(a) Then max32(a) = tmpDbl If max32(a) > 0 Then tmpDbl = tmpDbl / max32(a) Else tmpDbl = 0 End If End If Else tmpDbl = 0 End If dst(a) = tmpDbl
Simply pass two arrays to the vis_SimplifySpectrum function :
One declared like
Dim src_spectrum(500) As Single
Which you have already send to GetSpectrum
And a second one like
Dim dst_spectrum(15) As Single, with either 16 or 32 elements
After you have passed it to vis_SimplifySpectrum, you will get dst_spectrum with values between 0 and 1 which you can draw.
[edit2] This function does not yet smooth the spectrum, so you could change
dst(a) = tmpDbl
dst(a) = (dst(a) + tmpDbl) / 2
Oh, I see, I might implement that. Also, if you click the time display it should give you total time for the song and remaining time. And if you click on the song in the playlist it will give you the approximate time of the file from the ID3, so I am a little bit confused on what you mean about the total time of the song, because I already have it. But I will take a look at your code and see what I can do.
Hello… I was playing around with your project example and was curious how I’d increase the thickness of the bars and peak bar used in the visual spectrum? So if I were to use a picturebox of greater width, I’d have the bars fill up the spectrum appropriately.
- Anonymous answered 14 years ago
You could try to edit the GetrSpectrumCount function to allow for more bars, but that would be hard. And since I didnt write that function I dont know how you would do it. You could just try to plot the raw spectrum data without going through the simplified spectrum, but it wouldn’t be as precise.
Please login first to submit.