OK i have searched the forum repeatly for the information i want but have only managed to get myself more confused!!!

I would like to create the effects found in most media players and those found on HIFI equipment that give a graphical representation of say 8 vertical bars that give a rough (i am not looking for precision) look of the sound.

I have tried using getspectrum with different methods, from taking the first 256 values from a 512 array then attempting to group them in a number of different ways… Such as 2 then 4 then 8 then 16 values and so on adding them together to produce a number of values… This works but doesnt give a particularly good representation. I have tried a number of other ways but none seem to look good enough..

After going through the forums i got the idea to use getwavedata.. Not sure if this works however returning the values and noticing they are generally between -1 and +1 i decided to (In my infinite wizdom you understand) take the absolute value (make it positive) then use that and factor it up, in my case by 8 to give me values between 1 and 8!! this works but gives a very poor representation.

So my question is HOW DO YOU DO IT!!! I have searched and searched for the answers and have never found it… Is it a secret?? Can mere mortals like myself not be trusted?? Any help would be great i am using FMOD EX hence the post here??

Can someone help me… I have read so many post on this subject or similar subjects i am lost!!!!

Someone help me please!!!

Cheers

Tim

- Drinkyfish asked 12 years ago

- You must login to post comments

Thanks for the reply,

I notice Prabeesh or someone like that has posted a similar topic only he was looking for a handout… I am happy to do the coding and testing and will post the code back for all to use as it seems to be a fairly regular request for inexperience programmers with audio (Like Me!!!).

Am i right then in assuming.

If i take the first 256 values for example from a 512 array from each channel. Then Group these values in the form: –

1st value

2nd + 3rd value

4th + 5th + 6th + 7th value

and so on….

Will give a number of values between 0 and hopefully around 1 (Clip if needed??)

then to smooth the values and get a peak i could use something similar to

If new value is greater than last use it

else (last value * 4 + new value) / 5

to give a smooth drop but instant peaks??

I read a number of topics on this but never really found out (being inexperinced in understanding audio ie decibels nyquist theorem etc) how to use these value correctly. Thats what i need help with?? Should i be using some logarithmic equation?? As i said i am not looking for a code hand out but some understanding of how to use it… And i have read and reread the documentation and searched the forum.. I have used topics with vis_simplifyspectrum or something simialr and other topics…

Am i right with the idea above. I will post a sample when its done for all inexperienced VB programers to use.

Thanks again i am aware this is probably really easy for people who understand what the values return actually mean.. that is my problem not writing the code to use them!!

Cheers

Tim

- Drinkyfish answered 12 years ago

- You must login to post comments

OK well no one seems to be able to help me??? So i have tried using the method i expalined in the previous post however, the selection of 64 values from Value 63 to value 127 gives a huge value?? as an example scaled up by 8 i get values like

0 1 2 1 4 4 18 1

0 2 1 2 3 3 20 2

And so on….

So as no one will anser how to group the values will this work… If i use the generate tone, and generate a number of tones with the frequencies generally listed on a Graphical equaliser. Then look at the spectrum will i see a set of values for that tone?? Or how else could i do it i just need help understanding how to group them as the methods i have tried never seem to work??

Cheers

Tim

- Drinkyfish answered 12 years ago

- You must login to post comments

I posted about this simplifyspectrum thing once I think, which describes how to group the values to get a nice result.

Here is the code again that I used to get the number of values to group together for the a’th bar, if using 16 or if using 32 bars.

[code:2pkg1p34]Public Function vis_GetSpectrumCount(ByVal a As Long, Optional ByVal width = 32)

Dim d As Long

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

If a = 12 Then d = 35

If a = 13 Then d = 40

If a = 14 Then d = 50

If a = 15 Then d = 60

End If

vis_GetSpectrumCount = d

End Function[/code:2pkg1p34]

- Adion answered 12 years ago

- You must login to post comments

Thanks Adion thats really nice of you to post this. I have used that code before and it does give a good spectrum. I will give it another try and see what i can produce.

I would just really like to see how to use the values return from get spectrum properly. As in with some form of science behind it… I think this is somethign that many people have asked for, after searching for help myself.

Could this be added to the documentation. I am not a great coder but i can still read a user manual and create some code!!!

I know that there are bigger issues that Brett must be following but somebody must know how to put these values together with a structured reasoning behind it!!!

Cheers

Tim

Thanks again Adion for your post

- Drinkyfish answered 12 years ago

- You must login to post comments

Here is what I use.

Private Sub tmrJukeboxTimer2_Timer()

Dim X1 As Single

Dim X2 As Single

Dim Y1 As Single

Dim Y2 As Single

Dim SpecArr(512) As Single

Dim SpecArr1(512) As Single

Dim Spectrum As Single

Dim I As Long

Dim result As FMOD_RESULT

On Error GoTo ErrorTrap

result = FMOD_Channel_GetSpectrum(channel, SpecArr(0), 512, 0, FMOD_DSP_FFT_WINDOW_MAX)

result = FMOD_Channel_GetSpectrum(channel, SpecArr1(0), 512, 1, FMOD_DSP_FFT_WINDOW_MAX)

Do While I < 512

Spectrum = SpecArr(I) + SpecArr1(I)

X1 = picSpectrum.ScaleWidth * (I / picSpectrum.ScaleWidth)

Y1 = Int(picSpectrum.ScaleHeight – picSpectrum.ScaleHeight * (Spectrum * 10))

X2 = picSpectrum.ScaleWidth * (I / picSpectrum.ScaleWidth)

Y2 = -1

picSpectrum.Line (X1, Y1)-(X2, Y2), vbBlack

X1 = picSpectrum.ScaleWidth * (I / picSpectrum.ScaleWidth)

Y1 = Int(picSpectrum.ScaleHeight * (1 – Spectrum * 10))

X2 = picSpectrum.ScaleWidth * (I / picSpectrum.ScaleWidth)

Y2 = picSpectrum.ScaleHeight

picSpectrum.Line (X1, Y1)-(X2, Y2), vbYellow

I = I + 3

Loop

DoEvents

Exit Sub

ErrorTrap:

frmMsgBox.SMessageModal “Error Number: ” & Err.Number & vbNewLine & _

Err.description & vbNewLine & _

vbNewLine & _

“Debug Information:” & vbNewLine & _

“JukeBox.frmJukebox.tmrJukeboxTimer2_Timer” & IIf(Erl > 0, “.” & Erl, “”), vbCritical, “Error Occurred”

End Sub

- Radwen answered 12 years ago

- You must login to post comments

**Your Answer**

Please login first to submit.