0
0

[size=150:akeji682]See the code in white color[/size:akeji682]

[color=yellow:akeji682]Option Explicit
Dim sample As Long ‘ we have a sample ? / on a un échantillon ?
Dim chan As Long ‘ Our channel handle / notre pointeur sur le canal
Dim SongPath As String ‘ the complete path of the song / chemin complet de la musique
Private Const SONG = “Test.mp3” ‘ the song to load / la musique a charger
Private Const outputfreq = 44100 ‘ default frequency / frenquence par défaut

‘ EQ : wéééééééééé !!!!
Dim Eq(0 To 10) As Long ‘ 10 bands EQ like winamp (10 = PREAMP) / EQ à 10 bandes, comme winamp
Dim Gain As Single
Dim Center As Single

Public SlideFlag As Boolean ‘ slider is moving ? / le slider est en mouvement ?
Public IX, IY, tx, ty, fx, fy As Integer ‘ remember some usefull positions / permet de se souvenir de diverses positions
Dim mousex As Long ‘ x position of the mouse / position de la souris en x
Dim mousey As Long ‘ y position of the mouse / position de la souris en y
Dim frame As Single

‘—————————————————————————————————-
‘ Pemet de bouger la form sans bordure
‘ Let the form moving without a border
‘—————————————————————————————————-
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function ReleaseCapture Lib “user32” () As Long

‘—————————————————————————————————-
‘ Deplace une forme meme sans caption
‘ Move a form even without caption
‘—————————————————————————————————-
Public Sub MoveWindow(ByVal handle As Long)
Call ReleaseCapture
Call SendMessage(handle, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End Sub

‘—————————————————————————————————-
‘ Retourne VRAI si ‘filename’ existe
‘ Return TRUE if the file ‘filename’ exists
‘—————————————————————————————————-
Private Function Exists(filename As String) As Boolean

On Local Error GoTo ExErr

Exists = False
If filename$ <> "" Then
    If Dir$(filename$) <> "" Then Exists = True
End If
Exit Function

ExErr:
End Function

‘—————————————————————————————————-
‘ Libere la memoire et ferme FMOD
‘ Free memory and shutdown FMOD
‘—————————————————————————————————-
Public Sub CloseSound()

' nous arretons et liberons la musique de la memoire
' we stop and free the sample
If sample Then
     Call FSOUND_Stream_Close(sample)
End If

' ferme FMOD
' close FMOD
Call FSOUND_Close

End Sub

‘—————————————————————————————————-
‘ Prepare et initialise le son
‘ Setup and initialise the sound
‘—————————————————————————————————-
Public Function InitSound() As Boolean

Call FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND)
Call FSOUND_SetDriver(0)
Call FSOUND_SetMixer(FSOUND_MIXER_QUALITY_AUTODETECT)
Call FSOUND_SetHWND(Me.hwnd)

InitSound = FSOUND_Init(outputfreq, 64, 0) > 0

End Function

‘—————————————————————————————————-
‘ Joue la musique
‘ Play the song
‘—————————————————————————————————-
Public Sub Play()

If Exists(SongPath) = False Then
    MsgBox "Put a song and rename it to Test.mp3 to the current directory.", vbInformation
    Exit Sub
End If

sample = FSOUND_Stream_OpenFile(SongPath, FSOUND_HW2D Or FSOUND_ENABLEFX Or FSOUND_MPEGACCURATE, 0)

If sample Then
    chan = FSOUND_Stream_PlayEx(FSOUND_FREE, sample, vbEmpty, True)
    Call InitEq(chan)
    Call FSOUND_SetPaused(chan, False)
End If

End Sub

‘—————————————————————————————————-
‘ Active le pointeur de chanque bande de l’EQ
‘ Activate the handle for each EQ band
‘—————————————————————————————————-
Private Sub InitEq(ByVal chan As Long)

If chan Then[/color:akeji682]

[color=white:akeji682] ‘ here is the point where i am getting the error saying 0x00000h memmory error tryed to access something blab blab blab
Eq(0) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(1) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)[/color:akeji682]
[color=yellow:akeji682]
Eq(2) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(3) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(4) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(5) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(6) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(7) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(8) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(9) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
Eq(10) = FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)

    Call FSOUND_FX_SetParamEQ(Eq(0), 80, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(1), 170, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(2), 310, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(3), 600, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(4), 1000, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(5), 3000, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(6), 6000, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(7), 12000, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(8), 14000, 18, 0)
    Call FSOUND_FX_SetParamEQ(Eq(9), 16000, 18, 0)

End If

End Sub

‘—————————————————————————————————-
‘ Nous quittons lorsque la touche ECHAP est enfoncee
‘ Exit when the ESC key is pressed
‘—————————————————————————————————-
Private Sub Form_KeyPress(KeyAscii As Integer)

If KeyAscii = 27 Then End

End Sub

‘—————————————————————————————————-
‘ Cuisinons ce qu’on a à faire :)
‘ Cook what we have to do :)
‘—————————————————————————————————-
Private Sub Form_Load()

SongPath = App.Path & "\" & SONG
Call InitSound
Call Play
Call LoadEQSkin(App.Path)
'Call LoadFromWinampEQF(App.Path & "\VBtest.eqf")

End Sub

‘—————————————————————————————————-
‘ Dessine l’etat du bouton enfonce
‘ Blit the pressed button
‘—————————————————————————————————-
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

Select Case y

    Case Is < 10

        Select Case x

            Case 262 To 271:
                Call Blit(EqPic, 263, 2, 9, 9, 0, 123, 9, 9)         ' close pushed

        End Select

    Case Else
        Call MoveWindow(Me.hwnd)

End Select

End Sub

‘—————————————————————————————————-
‘ Infos pour le debug
‘ Debug infos
‘—————————————————————————————————-
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

mousex = x
mousey = y

'Debug.Print X & " " & Y

End Sub

‘—————————————————————————————————-
‘ Dessine l’etat du bouton relache
‘ Blit the unpressed button
‘—————————————————————————————————-
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)

Select Case y

    Case Is < 10

        Select Case x

            Case 262 To 271:
                Call Blit(EqPic, 263, 2, 9, 9, 0, 114, 9, 9)       ' close pushed
                Unload Me

        End Select

End Select

End Sub

‘—————————————————————————————————-
‘ Libere, ferme FMOD et quitte l’application
‘ Free, close FMOD and exit
‘—————————————————————————————————-
Private Sub Form_Unload(Cancel As Integer)

'Call SaveToWinampEQF(App.Path & "\VBtest.eqf")
Call CloseSound
Set Form1 = Nothing ' force VB to really free the memory
End

End Sub

‘—————————————————————————————————-
‘ Dessine l’etat du bouton enfonce
‘ Blit the pressed button
‘—————————————————————————————————-
Private Sub sldEq_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)

If SlideFlag = False Then
    IX = y: fx = sldEq(Index).Top
    tx = Screen.TwipsPerPixelX
    SlideFlag = True
End If

End Sub

‘—————————————————————————————————-
‘ Deplace la fenetre
‘ Move the window
‘—————————————————————————————————-
Private Sub sldEq_MouseMove(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)

Call MoveSlider(Index, x, y, False)

End Sub

‘—————————————————————————————————-
‘ Deplace les sliders et change les paramettres de ParamEQ
‘ Move the sliders and change the ParamEQ settings
‘—————————————————————————————————-
Private Sub MoveSlider(ByVal Index As Integer, x As Single, y As Single, ByVal setpos As Boolean)
Dim Pos As Long

IX = y: fx = sldEq(Index).Top
tx = Screen.TwipsPerPixelX

If SlideFlag = True Then
    Pos = fx + (y - 5) - IX / tx
   If Pos < 38 Then Pos = 38
    If Pos > 92 Then Pos = 92
    fx = Pos: sldEq(Index).Top = Pos

    frame = (Pos - 38) / 1.8

    ' we only need to set the frame position for the opened EQF file
    If setpos = True Then
        Pos = y
        sldEq(Index).Top = Pos
        frame = (Pos - 38) / 1.8
    End If

    Select Case Index
        Case 0: Center = 80
        Case 1: Center = 170
        Case 2: Center = 310
        Case 3: Center = 600
        Case 4: Center = 1000
        Case 5: Center = 3000
        Case 6: Center = 6000
        Case 7: Center = 12000
        Case 8: Center = 14000
        Case 9: Center = 16000
    End Select


    ' redessine les sliders
    ' redraw the sliders
    Select Case Pos:
        Case 38, 39:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 208, 229, 14, 63
        Case 40, 41:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 193, 229, 14, 63
        Case 42, 43:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 178, 229, 14, 63
        Case 44, 45:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 163, 229, 14, 63
        Case 46, 47:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 148, 229, 14, 63
        Case 48, 49:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 133, 229, 14, 63
        Case 50, 51:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 118, 229, 14, 63
        Case 52, 53:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 103, 229, 14, 63
        Case 54, 55:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 88, 229, 14, 63
        Case 56, 57:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 73, 229, 14, 63
        Case 58, 59:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 58, 229, 14, 63
        Case 60, 61:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 43, 229, 14, 63
        Case 62, 63:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 28, 229, 14, 63
        Case 64, 65:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 13, 229, 14, 63
        Case 66, 67:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 208, 164, 14, 63
        Case 68, 69:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 193, 164, 14, 63
        Case 70, 71:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 178, 164, 14, 63
        Case 72, 73:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 163, 164, 14, 63
        Case 74, 75:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 148, 164, 14, 63
        Case 76, 77:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 133, 164, 14, 63
        Case 78, 79:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 118, 164, 14, 63
        Case 80, 81:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 103, 164, 14, 63
        Case 82, 83:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 88, 164, 14, 63
        Case 84, 85:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 73, 164, 14, 63
        Case 86, 87:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 58, 164, 14, 63
        Case 88, 89:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 43, 164, 14, 63
        Case 90, 91:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 28, 164, 14, 63
        Case 92, 93:
            Form1.PaintPicture Form1.EqPic, sldEq(Index).Left, 38, 14, 63, 13, 164, 14, 63

    End Select

    ' calcule les bords du gain entre -15 et 15
    ' Clip the gaim from -15 to 15
    Gain = 15 - frame

    ' applique les nouveaux paramettres
    ' apply new settings
    Call FSOUND_FX_SetParamEQ(Eq(Index), Center, 18, Gain)


End If

End Sub

‘—————————————————————————————————-
‘ Dit que nous ne bougeons plus le slider
‘ Tell that we are not movine the slider anymore
‘—————————————————————————————————-
Private Sub sldEq_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)

SlideFlag = False

End Sub

‘—————————————————————————————————-
‘ Juste au cas ou …
‘ Just in case …
‘—————————————————————————————————-
Private Sub Slider7_Scroll(Index As Integer)

Gain = -Slider7(Index).Value

Select Case Index
    Case 0: Center = 80
    Case 1: Center = 170
    Case 2: Center = 310
    Case 3: Center = 600
    Case 4: Center = 1000
    Case 5: Center = 3000
    Case 6: Center = 6000
    Case 7: Center = 12000
    Case 8: Center = 14000
    Case 9: Center = 16000
End Select

Call FSOUND_FX_SetParamEQ(chan, Center, 18, Gain)

End Sub

‘—————————————————————————————————-
‘ Charge les preset EQF de winamp
‘ Load winamp EQF preset
‘—————————————————————————————————-
Private Sub SaveToWinampEQF(ByVal EQF As String)
Dim FIO As Integer
Dim NullStr As String
Dim i As Integer
Dim MAGIC As String

Dim position As Long

Close
FIO = FreeFile

NullStr = String$(251, Chr$(0))
MAGIC = "Winamp EQ library file v1.1" & "" & Chr$(&H1A) & "!--"

Open EQF For Binary Access Write As FIO
Put #FIO, , MAGIC
Put #FIO, , "Entry1"
Put #FIO, , NullStr
For i = 0 To 9
    position = (sldEq(i).Top - 38) / 0.86
    Put #FIO, , Chr$(position)
Next i
' Master Gain
position = (sldEq(10).Top - 38) / 0.86
Put #FIO, , Chr$(position)
Close #FIO

End Sub

‘—————————————————————————————————-
‘ Ecrit les preset EQF de winamp
‘ Write winamp EQF preset
‘—————————————————————————————————-
Private Sub LoadFromWinampEQF(ByVal EQF As String)
Dim FIO As Integer
Dim NullStr As String
Dim i As Integer
Dim MAGIC As String
Dim buffer As String

Dim position As Long
Dim bands As String
Dim Gain As String

If Exists(EQF) = False Then Exit Sub
Close
FIO = FreeFile

NullStr = String$(251, Chr$(0))
MAGIC = "Winamp EQ library file v1.1"

Open EQF For Binary Access Read As FIO

buffer = Space$(27)
Get #FIO, , buffer
If buffer <> MAGIC Then Exit Sub
' skip name
Seek #FIO, 288

bands = Space$(11)
Get #FIO, , bands

SlideFlag = True
For i = 0 To 9
    position = Fix(HexToDecimal(Hex(Asc(Mid$(bands, i + 2, 1)))) + 38) * 0.86
    Call MoveSlider(i, sldEq(i).Left, position + 5, True)
Next i
' Master Gain
Gain = Space$(2)
Get #FIO, , Gain
    position = Fix(HexToDecimal(Hex(Asc(Gain))) + 38) * 0.86
    Call MoveSlider(i, sldEq(10).Left, position + 5, True)

SlideFlag = False
Close #FIO

End Sub

Public Function HexToDecimal(ByVal pValue As String) As Long
Dim C As Integer
Dim Value As Long
Dim PosValue As Long
Dim CharVal As Byte

On Error GoTo ErrorHandler

For C = Len(pValue) To 1 Step -1
Select Case Mid(pValue, C, 1)
Case “0” To “9”: CharVal = CInt(Mid(pValue, C, 1))
Case Else: CharVal = Asc(Mid(pValue, C, 1)) – 55
End Select
Value = Value + ((16 ^ PosValue) * CharVal)
PosValue = PosValue + 1
Next C

HexToDecimal = Value
Exit Function

ErrorHandler:
HexToDecimal = 0

End Function[/color:akeji682]

in the above code when i call
FSOUND_FX_Enable(chan, FSOUND_FX_PARAMEQ)
function i get the following error
saying 0x00000h memmory error tried to access something blab blab blab

what is the problem help me

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.