GFWaveReadWrite/Testfrm.frm

VERSION 5.00
Begin VB.Form Testfrm
   Caption         =   "Testfrm"
   ClientHeight    =   3075
   ClientLeft      =   60
   ClientTop       =   435
   ClientWidth     =   6675
   LinkTopic       =   "Form1"
   ScaleHeight     =   3075
   ScaleWidth      =   6675
   StartUpPosition =   3 'Windows‑Standard
   Begin VB.CommandButton Command1
      Caption         =   "Check da Stuff !!!"
      Height          =   3075
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   6675
   End
End
Attribute VB_Name = "Testfrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'(c)2003 by Louis.
'GFPlayWaveFile
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As StringByVal uFlags As Long) As Long
'GFPlayWaveFile
Const SND_SYNC = &H0 'play synchronously (default)
Const SND_ASYNC = &H1 'play asynchronously
Const SND_NODEFAULT = &H2 'silence not default, if sound not found
'GFPlayWaveFile
Const SND_ABORT As String = "" 'self‑made
Const SND_SILENCE As String = SND_ABORT 'self‑made

Private Sub Command1_Click()
    'on error resume next
    Dim WaveDataArray() As Integer
    Dim WaveDataNumber As Long
    Dim WaveName As String
    Dim GFWRW1 As New GFWaveReadWritecls
    Dim Temp As Long
    Dim TempInt As Integer
    'preset
    WaveName = App.Path
    If Not (Right$(WaveName, 1) = "\") Then WaveName = WaveName + "\" 'verify
    WaveName = WaveName + "Stupid.wav"
    'begin
    Call GFWRW1.GFWaveReadWrite_GetWaveDataArray(WaveDataArray(), WaveDataNumber, WaveName)
    For Temp = 1 To (WaveDataNumber / 2) 'if not divisible by 2 then one value stays unchanged
        TempInt = WaveDataArray(Temp)
        'Debug.Print TempInt
        WaveDataArray(Temp) = WaveDataArray(WaveDataNumber ‑ Temp + 1)
        WaveDataArray(WaveDataNumber ‑ Temp + 1) = TempInt
    Next Temp
    Call GFWRW1.GFWaveReadWrite_SetWaveDataArray(WaveDataArray(), WaveDataNumber, WaveName)
    Call GFPlayWaveFile(WaveName)
End Sub

Private Sub GFPlayWaveFile(ByVal WaveName As String)
    On Error GoTo Error: 'if sound system not available
    '
    'NOTE: if playing an old wave file is not finished yet, another call of this
    'sub will abort playing the old file (use GFPlayWaveFile("") to abort playing).
    '
    If Not ((Dir(WaveName) = "") Or (Right$(WaveName, 1) = "\") Or (WaveName = "")) Then 'verify
        Call sndPlaySound(WaveName, SND_ASYNC)
    Else
        If WaveName = "" Then
            'abort playing a wave file
            Call sndPlaySound("", SND_ASYNC Or SND_NODEFAULT)
        Else
            'error
            MsgBox "internal error in GFPlayWaveFile(): file '" + Left$(WaveName, 512) + "' not found !", vbOKOnly + vbExclamation
        End If
    End If
    Exit Sub
Error:
    MsgBox "internal error in GFPlayWaveFile() !", vbOKOnly + vbExclamation
    Exit Sub
End Sub


[END OF FILE]