0
0

Please waveform return come back strange…
Does have as using GetWaveData?
Help – me…

Excuse for English.

[code:2kk28qsi]
Dim System As Long
Dim Sound As Long
Dim result As FMOD_RESULT

Dim Data(0 To 4095) As Byte

Dim XPos As Integer 'Drawing x position
Dim minL, maxL, minR, maxR As Integer 'Min and max channel levels

Dim Length As Long
Dim Read As Long

' Create a System object and initialize.
result = FMOD_System_Create(System)


result = FMOD_System_Init(System, 1, FMOD_INIT_NORMAL, 0)

result = FMOD_System_CreateStream(System, "./Test.mp3", FMOD_OPENONLY Or FMOD_ACCURATETIME, Sound)

'
'   Decode the sound and write it to a .raw file.
'
result = FMOD_Sound_GetLength(Sound, Length, FMOD_TIMEUNIT_PCMBYTES)

Do

    minL = 0 ' Reset vars
    maxL = 0
    minR = 0
    maxR = 0

    result = FMOD_Sound_ReadData(Sound, GetAddrOf(Data(0)), 4096, Read)

    minL = -(Data(0) * 10)
    maxL = Data(0) * 10
    minR = -(Data(0) * 10)
    maxR = Data(0) * 10

    Picture1.Line (XPos, Picture1.Height / 2 - (minL / 3))-(XPos, Picture1.Height / 2 + (-maxL / 3))

    XPos = XPos + 10

    DoEvents ' Yield to the system

Loop While (result = FMOD_OK And Read = 4096)

' Shut down
result = FMOD_Sound_Release(Sound)

result = FMOD_System_Close(System)

result = FMOD_System_Release(System)

[/code:2kk28qsi]

Lindomar

  • You must to post comments
0
0

[quote="brett":dt02640i]Hi there
Please read the documentation if you are not sure about a function. It specifically says

[quote:dt02640i]
Do not use this function to try and display the whole waveform of the sound, as this is more of a ‘snapshot’ of the current waveform at the time it is called, and could return the same data if it is called very quickly in succession.
[/quote:dt02640i]

You would be better off using Sound::lock or Sound::readData[/quote:dt02640i]

But I used the readData.

Has some demonstration for Sound::lock?

  • You must to post comments
0
0

Would you have some example

Lindomar

  • You must to post comments
0
0

Yes, any example?

  • You must to post comments
0
0

Problem persist, not return values -32768 to 32767…

Excuse, I don’t understand a lot of C#

Converted in Basic…

[code:tm989ium]
Private Sub cmdStart_Click()
Dim System As Long
Dim Sound As Long
Dim result As FMOD_RESULT
Dim Version As Long
Dim Count As Long

Dim Data(0 To 4095) As Byte
Dim Length As Long
Dim Read As Long
Dim bytesread As Long
Dim outfp As Long

' Create a System object and initialize.
result = FMOD_System_Create(System)



result = FMOD_System_Init(System, 1, FMOD_INIT_NORMAL, 0)

result = FMOD_System_CreateStream(System, "./Test.mp3", FMOD_OPENONLY Or FMOD_ACCURATETIME, Sound)

'
'   Decode the sound and write it to a .raw file.
'
result = FMOD_Sound_GetLength(Sound, Length, FMOD_TIMEUNIT_PCMBYTES)

bytesread = 0

Dim Y As Single

For Count = 0 To Length

    Xpos = Count

    result = FMOD_Sound_ReadData(Sound, GetAddrOf(Data(0)), 4096, Read)

    Y = ((Data(0) / 65536#) + 1#) * Picture1.Height

    minL = 0 ' Reset vars
    maxL = 0
    minR = 0
    maxR = 0

    minL = -Y
    maxL = Y
    minR = -Y
    maxR = Y

    'Draw Wave Form
    Picture1.Line (Xpos, Picture1.Height / 2 - (minL / 10))-(Xpos, Picture1.Height / 2 + (-maxL / 10))

Next Count

' Shut down
result = FMOD_Sound_Release(Sound)

result = FMOD_System_Close(System)

result = FMOD_System_Release(System)

End Sub
[/code:tm989ium]

  • You must to post comments
0
0

[quote="brett":avd5zxpv]just do a for loop

short *wptr = (short *)buff;

for (count = 0; count < length_samples; count++)
{
putpixel(count, (wptr[count] / 65536.0f) + 1.0f) * windowheight); // assuming mono
}

etc, its not too hard, just scan the buffer and plot it according to what format it is. The stereo is interleaved lrlrlrlrlr so you have to use wptr[count*channels + offset] where offset = 0 for left, 1 for right.[/quote:avd5zxpv]

Hi Brett,
in case of stereo in this example you used the formula:

[code:avd5zxpv]wptr[count*channels + offset] where offset = 0 for left, 1 for right.[/code:avd5zxpv]

In this formula channel which value has?
Best,
Franco

  • You must to post comments
0
0

[quote="brett":3egypwuw]just do a for loop

short *wptr = (short *)buff;

for (count = 0; count < length_samples; count++)
{
putpixel(count, (wptr[count] / 65536.0f) + 1.0f) * windowheight); // assuming mono
}

etc, its not too hard, just scan the buffer and plot it according to what format it is. The stereo is interleaved lrlrlrlrlr so you have to use wptr[count*channels + offset] where offset = 0 for left, 1 for right.[/quote:3egypwuw]

I don’t understand well this formula.
[code:3egypwuw]for (count = 0; count < length_samples; count++)
{
putpixel(count, (wptr[count*channels + offset] / 65536.0f) + 1.0f) * windowheight); // in case of stereo
}[/code:3egypwuw]

For every count I have to compute it for L and R channel? A sort of nested loop? Or how can I plot every channel?

Best,
Franco

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.