home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8vbsdk.exe / samples / multimedia / vbsamples / directsound / effectsbuffers / frmfx.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-10-17  |  22.5 KB  |  621 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  3. Begin VB.Form frmEffects 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Audio Effects using DirectSound Buffers"
  6.    ClientHeight    =   5790
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   4770
  10.    Icon            =   "frmFX.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    ScaleHeight     =   5790
  14.    ScaleWidth      =   4770
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.Timer tmrUpdate 
  17.       Interval        =   50
  18.       Left            =   5760
  19.       Top             =   900
  20.    End
  21.    Begin VB.CheckBox chkLoop 
  22.       Caption         =   "Loop Sound"
  23.       Height          =   315
  24.       Left            =   840
  25.       TabIndex        =   16
  26.       Top             =   5340
  27.       Width           =   1455
  28.    End
  29.    Begin VB.CommandButton cmdStop 
  30.       Caption         =   "&Stop"
  31.       Height          =   375
  32.       Left            =   3600
  33.       TabIndex        =   14
  34.       Top             =   5340
  35.       Width           =   1095
  36.    End
  37.    Begin VB.CommandButton cmdPlay 
  38.       Caption         =   "&Play"
  39.       Height          =   375
  40.       Left            =   2400
  41.       TabIndex        =   13
  42.       Top             =   5340
  43.       Width           =   1095
  44.    End
  45.    Begin VB.Frame fraEffects 
  46.       Caption         =   "Effects Information"
  47.       Height          =   3675
  48.       Left            =   120
  49.       TabIndex        =   2
  50.       Top             =   1560
  51.       Width           =   4515
  52.       Begin VB.CommandButton cmdModify 
  53.          Caption         =   "Modify Selected Effects"
  54.          Enabled         =   0   'False
  55.          Height          =   315
  56.          Left            =   120
  57.          TabIndex        =   17
  58.          Top             =   3240
  59.          Width           =   2235
  60.       End
  61.       Begin VB.TextBox txtFile 
  62.          Height          =   285
  63.          Left            =   120
  64.          Locked          =   -1  'True
  65.          TabIndex        =   9
  66.          Text            =   "No file loaded..."
  67.          Top             =   480
  68.          Width           =   3915
  69.       End
  70.       Begin VB.CommandButton cmdBrowse 
  71.          Caption         =   "..."
  72.          Height          =   285
  73.          Left            =   4020
  74.          TabIndex        =   8
  75.          ToolTipText     =   "Open a new audio file..."
  76.          Top             =   480
  77.          Width           =   315
  78.       End
  79.       Begin VB.ListBox lstAvail 
  80.          Height          =   840
  81.          ItemData        =   "frmFX.frx":0442
  82.          Left            =   120
  83.          List            =   "frmFX.frx":045E
  84.          TabIndex        =   7
  85.          Top             =   1080
  86.          Width           =   4275
  87.       End
  88.       Begin VB.ListBox lstUse 
  89.          Height          =   840
  90.          Left            =   120
  91.          TabIndex        =   6
  92.          Top             =   2280
  93.          Width           =   4275
  94.       End
  95.       Begin VB.CommandButton cmdAdd 
  96.          Height          =   285
  97.          Left            =   2040
  98.          MaskColor       =   &H000000FF&
  99.          Picture         =   "frmFX.frx":04AF
  100.          Style           =   1  'Graphical
  101.          TabIndex        =   5
  102.          Top             =   1980
  103.          UseMaskColor    =   -1  'True
  104.          Width           =   315
  105.       End
  106.       Begin VB.CommandButton cmdRemove 
  107.          Height          =   285
  108.          Left            =   2400
  109.          MaskColor       =   &H000000FF&
  110.          Picture         =   "frmFX.frx":09F1
  111.          Style           =   1  'Graphical
  112.          TabIndex        =   4
  113.          Top             =   1980
  114.          UseMaskColor    =   -1  'True
  115.          Width           =   315
  116.       End
  117.       Begin VB.CommandButton cmdApply 
  118.          Caption         =   "Apply Effects"
  119.          Height          =   315
  120.          Left            =   2460
  121.          TabIndex        =   3
  122.          Top             =   3240
  123.          Width           =   1875
  124.       End
  125.       Begin VB.Label lbl 
  126.          BackStyle       =   0  'Transparent
  127.          Caption         =   "Currently loaded sound file:"
  128.          Height          =   195
  129.          Index           =   0
  130.          Left            =   120
  131.          TabIndex        =   12
  132.          Top             =   240
  133.          Width           =   4515
  134.       End
  135.       Begin VB.Label lbl 
  136.          BackStyle       =   0  'Transparent
  137.          Caption         =   "Available Effects"
  138.          Height          =   195
  139.          Index           =   1
  140.          Left            =   120
  141.          TabIndex        =   11
  142.          Top             =   840
  143.          Width           =   1215
  144.       End
  145.       Begin VB.Label lbl 
  146.          BackStyle       =   0  'Transparent
  147.          Caption         =   "Effects in use"
  148.          Height          =   195
  149.          Index           =   2
  150.          Left            =   120
  151.          TabIndex        =   10
  152.          Top             =   2040
  153.          Width           =   1215
  154.       End
  155.    End
  156.    Begin MSComDlg.CommonDialog cdlOpen 
  157.       Left            =   300
  158.       Top             =   3720
  159.       _ExtentX        =   847
  160.       _ExtentY        =   847
  161.       _Version        =   393216
  162.    End
  163.    Begin VB.Label lbl 
  164.       BackStyle       =   0  'Transparent
  165.       Caption         =   $"frmFX.frx":0F33
  166.       Height          =   675
  167.       Index           =   5
  168.       Left            =   120
  169.       TabIndex        =   15
  170.       Top             =   840
  171.       Width           =   4575
  172.    End
  173.    Begin VB.Label lbl 
  174.       BackStyle       =   0  'Transparent
  175.       Caption         =   "Audio Effects using DirectSoundBuffers"
  176.       Height          =   255
  177.       Index           =   4
  178.       Left            =   660
  179.       TabIndex        =   1
  180.       Top             =   60
  181.       Width           =   3195
  182.    End
  183.    Begin VB.Label lbl 
  184.       BackStyle       =   0  'Transparent
  185.       Caption         =   "Copyright 
  186.  2000, Microsoft Corporation, All Rights Reserved."
  187.       Height          =   435
  188.       Index           =   3
  189.       Left            =   660
  190.       TabIndex        =   0
  191.       Top             =   300
  192.       Width           =   3555
  193.    End
  194.    Begin VB.Image Image1 
  195.       Height          =   480
  196.       Left            =   120
  197.       Picture         =   "frmFX.frx":0FCA
  198.       Top             =   180
  199.       Width           =   480
  200.    End
  201.    Begin VB.Menu mnuPop 
  202.       Caption         =   "pop"
  203.       Visible         =   0   'False
  204.       Begin VB.Menu mnuRemove 
  205.          Caption         =   "Remove"
  206.       End
  207.       Begin VB.Menu mnuChange 
  208.          Caption         =   "Change Settings..."
  209.       End
  210.    End
  211. Attribute VB_Name = "frmEffects"
  212. Attribute VB_GlobalNameSpace = False
  213. Attribute VB_Creatable = False
  214. Attribute VB_PredeclaredId = True
  215. Attribute VB_Exposed = False
  216. Option Explicit
  217. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  218. '  Copyright (C) 2000 Microsoft Corporation.  All Rights Reserved.
  219. '  File:       frmFX.frm
  220. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  221. 'API declare for windows folder
  222. Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  223. Private Const mlMaxEffects As Long = 20
  224. 'Private declares for our DirectX objects
  225. Private dx As DirectX8
  226. Private ds As DirectSound8
  227. Private dsb As DirectSoundSecondaryBuffer8
  228. Private mlEffectKey As Long
  229. Private Sub cmdAdd_Click()
  230.     If lstAvail.ListIndex = -1 Then 'Nothing is selected
  231.         MsgBox "Please select an available effect before attempting to add it.", vbOKOnly Or vbInformation, "Nothing selected."
  232.         Exit Sub
  233.     End If
  234.     If Not (dsb Is Nothing) Then
  235.         'Yup, now is there a sound already playing?
  236.         If (dsb.GetStatus And DSBSTATUS_PLAYING) = DSBSTATUS_PLAYING Then
  237.             MsgBox "Stop the currently playing sound before adding any effects.", vbOKOnly Or vbInformation, "Sound is playing"
  238.             Exit Sub
  239.         End If
  240.     End If
  241.     If lstUse.ListCount >= mlMaxEffects Then
  242.         MsgBox "You cannot add more than " & CStr(mlMaxEffects) & " effects in this sample.", vbOKOnly Or vbInformation, "No more effects."
  243.         Exit Sub
  244.     End If
  245.     'Add this item to our list of effects
  246.     lstUse.AddItem lstAvail.List(lstAvail.ListIndex) & " (Unallocated)"
  247.     RemoveAllForms
  248. End Sub
  249. Private Sub cmdApply_Click()
  250.     ApplySettings
  251. End Sub
  252. Private Sub cmdBrowse_Click()
  253.     Static sCurDir As String
  254.     Dim desc As DSBUFFERDESC
  255.     'We want to open a file now
  256.     cdlOpen.flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist
  257.     cdlOpen.Filter = "Wave Files (*.wav)|*.wav"
  258.     cdlOpen.FileName = vbNullString
  259.     If sCurDir = vbNullString Then
  260.         'Set the init folder to \windows\media if it exists.  If not, set it to the \windows folder
  261.         Dim sWindir As String
  262.         sWindir = Space$(255)
  263.         If GetWindowsDirectory(sWindir, 255) = 0 Then
  264.             'We couldn't get the windows folder for some reason, use the c:\
  265.             cdlOpen.InitDir = "C:\"
  266.         Else
  267.             Dim sMedia As String
  268.             sWindir = Left$(sWindir, InStr(sWindir, Chr$(0)) - 1)
  269.             If Right$(sWindir, 1) = "\" Then
  270.                 sMedia = sWindir & "Media"
  271.             Else
  272.                 sMedia = sWindir & "\Media"
  273.             End If
  274.             'We are trying to find the windows\media directory.  If it
  275.             'doesn't exist, then use the windows folder as a default
  276.             If Dir$(sMedia, vbDirectory) <> vbNullString Then
  277.                 cdlOpen.InitDir = sMedia
  278.             Else
  279.                 cdlOpen.InitDir = sWindir
  280.             End If
  281.         End If
  282.     Else
  283.         'No need to move folders.  Stay where they picked the last file
  284.         cdlOpen.InitDir = sCurDir
  285.     End If
  286.     On Local Error GoTo ClickedCancel
  287.     cdlOpen.CancelError = True
  288.     cdlOpen.ShowOpen   ' Display the Open dialog box
  289.     'Save the current information
  290.     sCurDir = GetFolder(cdlOpen.FileName)
  291.             
  292.     On Local Error GoTo NoLoadSegment
  293.     'Before we load the buffer stop one if it's playing
  294.     If Not (dsb Is Nothing) Then If dsb.GetStatus = DSBSTATUS_PLAYING Then dsb.Stop
  295.     'We need to set the CTRLFX flag so we can control the effects on this object
  296.     desc.lFlags = DSBCAPS_CTRLFX
  297.     'Now let's load the segment
  298.     RemoveAllForms
  299.     Set dsb = ds.CreateSoundBufferFromFile(cdlOpen.FileName, desc)
  300.     mlEffectKey = 0
  301.     txtFile.Text = cdlOpen.FileName
  302.     Exit Sub
  303. NoLoadSegment:
  304.     If Err.Number = DSERR_BUFFERTOOSMALL Then 'This buffer isn't big enough to control effects on
  305.         MsgBox "This file isn't long enough to control effects.  Please choose a longer audio file.", vbOKOnly Or vbCritical, "Couldn't load"
  306.     Else 'Some other error
  307.         MsgBox "Couldn't load this file", vbOKOnly Or vbCritical, "Couldn't load"
  308.     End If
  309. ClickedCancel:
  310. End Sub
  311. Private Sub cmdModify_Click()
  312.     ChangeSettings
  313. End Sub
  314. Private Sub cmdPlay_Click()
  315.     If dsb Is Nothing Then
  316.         MsgBox "You must first load a wave file into a sound buffer before you can play it.", vbOKOnly Or vbInformation, "No buffer"
  317.         Exit Sub
  318.     End If
  319.     'We need to pre-roll any effects parameter changes that occurred since the last
  320.     'call to an API that does pre-rolling (ie, Stop or SetCurrentPosition)
  321.     dsb.SetCurrentPosition 0
  322.     dsb.Play chkLoop.Value
  323.     EnablePlayUI False
  324. End Sub
  325. Private Sub cmdRemove_Click()
  326.     Dim lLastIndex As Long
  327.     If lstUse.ListIndex = -1 Then 'Nothing is selected
  328.         MsgBox "Please select an effect that's being used before attempting to remove it.", vbOKOnly Or vbInformation, "Nothing selected."
  329.         Exit Sub
  330.     End If
  331.     If Not (dsb Is Nothing) Then
  332.         'Yup, now is there a sound already playing?
  333.         If (dsb.GetStatus And DSBSTATUS_PLAYING) = DSBSTATUS_PLAYING Then
  334.             MsgBox "Stop the currently playing sound before removing any effects.", vbOKOnly Or vbInformation, "Sound is playing"
  335.             Exit Sub
  336.         End If
  337.     End If
  338.     lLastIndex = lstUse.ListIndex
  339.     'Add this item to our list of effects
  340.     lstUse.RemoveItem lstUse.ListIndex
  341.     If (lstUse.ListCount > 0) Then
  342.         If lstUse.ListCount > lLastIndex Then
  343.             lstUse.ListIndex = lLastIndex
  344.         Else
  345.             lstUse.ListIndex = 0
  346.         End If
  347.     End If
  348.     'Enable the menus
  349.     If lstUse.ListCount < 1 Or lstUse.ListIndex < 0 Then
  350.         EnableMenus False
  351.     Else
  352.         EnableMenus True
  353.     End If
  354.     mlEffectKey = 0
  355.     RemoveAllForms
  356. End Sub
  357. Private Sub cmdStop_Click()
  358.     If dsb Is Nothing Then
  359.         MsgBox "You must first load a wave file into a sound buffer before you can stop it.", vbOKOnly Or vbInformation, "No buffer"
  360.         Exit Sub
  361.     End If
  362.     dsb.Stop
  363.     'Stop doesn't reset the current position
  364.     dsb.SetCurrentPosition 0
  365.     EnablePlayUI True
  366. End Sub
  367. Private Sub Form_Load()
  368.     EnablePlayUI True
  369.     InitDSound
  370. End Sub
  371. Private Sub Form_Unload(Cancel As Integer)
  372.     RemoveAllForms
  373.     CleanupDSound
  374. End Sub
  375. Private Sub InitDSound()
  376.     On Error GoTo FailedInit
  377.     Set dx = New DirectX8
  378.     'Create our default DirectSound object
  379.     Set ds = dx.DirectSoundCreate(vbNullString)
  380.     ds.SetCooperativeLevel Me.hWnd, DSSCL_NORMAL
  381.     Exit Sub
  382. FailedInit:
  383.     MsgBox "Could not initialize DirectSound." & vbCrLf & "This sample will exit.", vbOKOnly Or vbInformation, "Exiting..."
  384.     Unload Me
  385. End Sub
  386. Private Sub CleanupDSound()
  387.     'Let's clean up now
  388.     If Not dsb Is Nothing Then
  389.         'If we are playing our file, stop it
  390.         If dsb.GetStatus = DSBSTATUS_PLAYING Then dsb.Stop
  391.         'Destroy our objects
  392.         Set dsb = Nothing
  393.     End If
  394.     Set ds = Nothing
  395.     Set dx = Nothing
  396. End Sub
  397. Private Function GetFolder(ByVal sFile As String) As String
  398.     Dim lCount As Long
  399.     For lCount = Len(sFile) To 1 Step -1
  400.         If Mid$(sFile, lCount, 1) = "\" Then
  401.             GetFolder = Left$(sFile, lCount)
  402.             Exit Function
  403.         End If
  404.     Next
  405.     GetFolder = vbNullString
  406. End Function
  407. Private Sub lstAvail_DblClick()
  408.     'Double clicking should be the same as clicking the 'Add' button
  409.     cmdAdd_Click
  410. End Sub
  411. Private Sub lstUse_Click()
  412.     'Enable the menu
  413.     If lstUse.ListCount < 1 Or lstUse.ListIndex < 0 Then
  414.         EnableMenus False
  415.     Else
  416.         EnableMenus True
  417.     End If
  418. End Sub
  419. Private Sub lstUse_DblClick()
  420.     'Double clicking should be the same as clicking the 'Remove' button
  421.     cmdRemove_Click
  422. End Sub
  423. Private Sub lstUse_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  424.     If Button = vbRightButton Then
  425.         'Show the popup menu
  426.         If lstUse.ListCount < 1 Or lstUse.ListIndex < 0 Then
  427.             EnableMenus False
  428.         Else
  429.             EnableMenus True
  430.         End If
  431.         PopupMenu mnuPop, , X + lstUse.Left, Y + lstUse.Top + fraEffects.Top, mnuRemove
  432.     End If
  433. End Sub
  434. Private Sub EnableMenus(ByVal fEnable As Boolean)
  435.     mnuChange.Enabled = fEnable
  436.     mnuRemove.Enabled = fEnable
  437.     cmdModify.Enabled = fEnable
  438. End Sub
  439. Private Sub mnuChange_Click()
  440.     ChangeSettings
  441. End Sub
  442. Private Sub mnuRemove_Click()
  443.     cmdRemove_Click
  444. End Sub
  445. Private Sub ChangeSettings()
  446.     Dim fGargle As frmGargle, fCompressor As frmCompressor
  447.     Dim fEcho As frmEcho, fDistortion As frmDistortion
  448.     Dim fChorus As frmChorus, fFlanger As frmFlanger
  449.     Dim fParam As frmParamEQ, fWave As frmWaves
  450.     Dim lIndex As Long, lCount As Long
  451.     On Error GoTo LeaveSub
  452.     'First we need to force the effects to be applied
  453.     If Not ApplySettings(True) Then Exit Sub
  454.     'No need to continue if the sound is playing or there is no sound buffer
  455.     If dsb Is Nothing Then Exit Sub
  456.     'Now we need to get the index of this effect
  457.     lIndex = -1
  458.     For lCount = 0 To lstUse.ListIndex
  459.         If LCase(lstUse.List(lstUse.ListIndex)) = LCase(lstUse.List(lCount)) Then lIndex = lIndex + 1
  460.     Next
  461.     'Now show the correct screen based on the info
  462.     Select Case Left$(LCase(lstUse.List(lstUse.ListIndex)), InStr(lstUse.List(lstUse.ListIndex), " ") - 1)
  463.     Case "distortion"
  464.         Set fDistortion = New frmDistortion
  465.         fDistortion.SetBuffer dsb, lIndex
  466.         fDistortion.Show vbModeless, Me
  467.     Case "echo"
  468.         Set fEcho = New frmEcho
  469.         fEcho.SetBuffer dsb, lIndex
  470.         fEcho.Show vbModeless, Me
  471.     Case "chorus"
  472.         Set fChorus = New frmChorus
  473.         fChorus.SetBuffer dsb, lIndex
  474.         fChorus.Show vbModeless, Me
  475.     Case "flanger"
  476.         Set fFlanger = New frmFlanger
  477.         fFlanger.SetBuffer dsb, lIndex
  478.         fFlanger.Show vbModeless, Me
  479.     Case "compressor"
  480.         Set fCompressor = New frmCompressor
  481.         fCompressor.SetBuffer dsb, lIndex
  482.         fCompressor.Show vbModeless, Me
  483.     Case "gargle"
  484.         Set fGargle = New frmGargle
  485.         fGargle.SetBuffer dsb, lIndex
  486.         fGargle.Show vbModeless, Me
  487.     Case "parameq"
  488.         Set fParam = New frmParamEQ
  489.         fParam.SetBuffer dsb, lIndex
  490.         fParam.Show vbModeless, Me
  491.     Case "wavesreverb"
  492.         Set fWave = New frmWaves
  493.         fWave.SetBuffer dsb, lIndex
  494.         fWave.Show vbModeless, Me
  495.     End Select
  496. LeaveSub:
  497. End Sub
  498. Private Sub EnablePlayUI(ByVal fEnable As Boolean)
  499.     On Error Resume Next
  500.     If fEnable Then
  501.         chkLoop.Enabled = True
  502.         cmdPlay.Enabled = True
  503.         cmdStop.Enabled = False
  504.         cmdBrowse.Enabled = True
  505.         cmdPlay.SetFocus
  506.     Else
  507.         chkLoop.Enabled = False
  508.         cmdPlay.Enabled = False
  509.         cmdStop.Enabled = True
  510.         cmdBrowse.Enabled = False
  511.         cmdStop.SetFocus
  512.     End If
  513. End Sub
  514. Private Sub tmrUpdate_Timer()
  515.     If Not (dsb Is Nothing) Then
  516.         If (dsb.GetStatus And DSBSTATUS_PLAYING) <> DSBSTATUS_PLAYING Then
  517.             If cmdPlay.Enabled = False Then
  518.                 EnablePlayUI True
  519.             End If
  520.         End If
  521.     End If
  522. End Sub
  523. Private Function ApplySettings(Optional ByVal fIgnoreSoundPlaying As Boolean = False) As Boolean
  524.     On Local Error GoTo NoFX
  525.     Dim DSEffects() As DSEFFECTDESC
  526.     Dim lResults() As Long
  527.     Dim lCount As Long
  528.     Dim lTempEffect As Long
  529.     'Do we have a sound buffer
  530.     If dsb Is Nothing Then
  531.         MsgBox "You must first load a wave file into a sound buffer before you can apply effects to it.", vbOKOnly Or vbInformation, "No buffer"
  532.         Exit Function
  533.     End If
  534.     If Not fIgnoreSoundPlaying Then
  535.         'Yup, now is there a sound already playing?
  536.         If (dsb.GetStatus And DSBSTATUS_PLAYING) = DSBSTATUS_PLAYING Then
  537.             MsgBox "Stop the currently playing sound before adding effects.", vbOKOnly Or vbInformation, "Sound is playing"
  538.             Exit Function
  539.         End If
  540.     End If
  541.     'Yes we do, do we have effects selected?
  542.     If lstUse.ListCount = 0 Then
  543.         If MsgBox("Do you want to turn off effects for this buffer?", vbYesNo Or vbQuestion, "No effects") = vbYes Then
  544.             dsb.SetFX 0, DSEffects, lResults
  545.             Exit Function
  546.         Else
  547.             MsgBox "You must first select some effects to use.", vbOKOnly Or vbInformation, "No effects"
  548.             Exit Function
  549.         End If
  550.     End If
  551.     'Ok, let's apply our effects info here
  552.     'First get an array of effects structs the right size
  553.     ReDim DSEffects(lstUse.ListCount - 1)
  554.     ReDim lResults(lstUse.ListCount - 1)
  555.     'Now we don't want to apply the effects if they've already been applied.  So,
  556.     'through our list, and create a 'unique' number to describe this set of effects
  557.     'and only apply them if the number is different form our stored one.
  558.     For lCount = 0 To lstUse.ListCount - 1
  559.         Select Case Left$(LCase(lstUse.List(lCount)), InStr(lstUse.List(lCount), " ") - 1)
  560.         Case "distortion"
  561.             lTempEffect = lTempEffect + (lCount + &H10)
  562.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_DISTORTION
  563.         Case "echo"
  564.             lTempEffect = lTempEffect + (lCount + &H20)
  565.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_ECHO
  566.         Case "chorus"
  567.             lTempEffect = lTempEffect + (lCount + &H40)
  568.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_CHORUS
  569.         Case "flanger"
  570.             lTempEffect = lTempEffect + (lCount + &H80)
  571.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_FLANGER
  572.         Case "compressor"
  573.             lTempEffect = lTempEffect + (lCount + &H100)
  574.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_COMPRESSOR
  575.         Case "gargle"
  576.             lTempEffect = lTempEffect + (lCount + &H200)
  577.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_GARGLE
  578.         Case "parameq"
  579.             lTempEffect = lTempEffect + (lCount + &H400)
  580.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_PARAMEQ
  581.         Case "wavesreverb"
  582.             lTempEffect = lTempEffect + (lCount + &H800)
  583.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_WAVES_REVERB
  584.         End Select
  585.     Next
  586.     If mlEffectKey <> lTempEffect Then 'They don't match, set the fx.
  587.         dsb.SetFX lstUse.ListCount, DSEffects, lResults
  588.         Dim sNewItem As String
  589.         For lCount = 0 To lstUse.ListCount - 1
  590.             sNewItem = Left$(lstUse.List(lCount), InStr(lstUse.List(lCount), " ") - 1)
  591.             Select Case lResults(lCount)
  592.             Case DSFXR_FAILED
  593.                 lstUse.List(lCount) = sNewItem & " - Failed"
  594.             Case DSFXR_LOCHARDWARE
  595.                 lstUse.List(lCount) = sNewItem & " - Hardware"
  596.             Case DSFXR_LOCSOFTWARE
  597.                 lstUse.List(lCount) = sNewItem & " - Software"
  598.             Case DSFXR_UNALLOCATED
  599.                 lstUse.List(lCount) = sNewItem & " - Unallocated"
  600.             Case DSFXR_UNKNOWN
  601.                 lstUse.List(lCount) = sNewItem & " - Unknown"
  602.             Case DSFXR_PRESENT
  603.                 lstUse.List(lCount) = sNewItem & " - Present"
  604.             End Select
  605.         Next
  606.     End If
  607.     mlEffectKey = lTempEffect
  608.     ApplySettings = True
  609.     Exit Function
  610. NoFX:
  611.     MsgBox "This set of effects could not be set on this audio file.", vbOKOnly Or vbInformation, "Cannot set"
  612.     ApplySettings = False
  613. End Function
  614. Private Sub RemoveAllForms()
  615.     'Get rid of all forms
  616.     Dim f As Form
  617.     For Each f In Forms
  618.         If Not (f Is Me) Then Unload f
  619.     Next
  620. End Sub
  621.