home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectSound / Tutorials / Tut1 / audtut1.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-10-08  |  4.3 KB  |  121 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAudTut1 
  3.    Caption         =   "Audio Tutorial 1"
  4.    ClientHeight    =   1320
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5460
  8.    Icon            =   "audtut1.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   1320
  11.    ScaleWidth      =   5460
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.CommandButton cmdClose 
  14.       Caption         =   "Close"
  15.       Default         =   -1  'True
  16.       Height          =   375
  17.       Left            =   4260
  18.       TabIndex        =   0
  19.       Top             =   900
  20.       Width           =   1035
  21.    End
  22.    Begin VB.Image Image1 
  23.       Height          =   480
  24.       Left            =   120
  25.       Picture         =   "audtut1.frx":0442
  26.       Top             =   120
  27.       Width           =   480
  28.    End
  29.    Begin VB.Label lbl 
  30.       BackStyle       =   0  'Transparent
  31.       Caption         =   "Copyright (C) 1999-2001 Microsoft Corporation, All Rights Reserved."
  32.       Height          =   255
  33.       Index           =   2
  34.       Left            =   600
  35.       TabIndex        =   3
  36.       Top             =   300
  37.       Width           =   4800
  38.    End
  39.    Begin VB.Label lbl 
  40.       BackStyle       =   0  'Transparent
  41.       Caption         =   "GM/GS
  42.  Sound Set Copyright 
  43. 1996, Roland Corporation U.S."
  44.       Height          =   255
  45.       Index           =   1
  46.       Left            =   600
  47.       TabIndex        =   2
  48.       Top             =   540
  49.       Width           =   4755
  50.    End
  51.    Begin VB.Label lbl 
  52.       BackStyle       =   0  'Transparent
  53.       Caption         =   "DirectMusic Segment Tutorial"
  54.       Height          =   255
  55.       Index           =   0
  56.       Left            =   600
  57.       TabIndex        =   1
  58.       Top             =   60
  59.       Width           =   2655
  60.    End
  61. Attribute VB_Name = "frmAudTut1"
  62. Attribute VB_GlobalNameSpace = False
  63. Attribute VB_Creatable = False
  64. Attribute VB_PredeclaredId = True
  65. Attribute VB_Exposed = False
  66. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  67. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  68. '  File:       audTut1.frm
  69. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  70. Option Explicit
  71. ' Our DX variables
  72. Private dx As New DirectX8
  73. 'We need a loader variable
  74. Private dml As DirectMusicLoader8
  75. 'We need our performance object
  76. Private dmp As DirectMusicPerformance8
  77. 'We also need our DMusic segment
  78. Private seg As DirectMusicSegment8
  79. Private Sub cmdClose_Click()
  80.     Unload Me
  81. End Sub
  82. Private Sub Form_Load()
  83.     Dim dmA As DMUS_AUDIOPARAMS
  84.     'Get our loader and performance
  85.     Set dml = dx.DirectMusicLoaderCreate
  86.     Set dmp = dx.DirectMusicPerformanceCreate
  87.     'We will put in error checking here in case we can't init DMusic
  88.     'ie, if there is no sound card
  89.     On Error GoTo FailedInit
  90.     'Initialize our DMusic Audio with a default environment
  91.     dmp.InitAudio Me.hWnd, DMUS_AUDIOF_ALL, dmA, Nothing, DMUS_APATH_SHARED_STEREOPLUSREVERB, 64
  92.     'Here we will load our audio file.  We could load a wave file,
  93.     'a midi file, and rmi file, or a DMusic segment.  For this
  94.     'tutorial we will load a segment.
  95.     'Before we load our segment, set our search directory
  96.     dml.SetSearchDirectory FindMediaDir("sample.sgt")
  97.     'Now we can load our segment
  98.     Set seg = dml.LoadSegment("sample.sgt")
  99.     'Download our segment to the default audio path (created during our call to InitAudio)
  100.     seg.Download dmp.GetDefaultAudioPath
  101.     'Play our segment from the beginning
  102.     dmp.PlaySegmentEx seg, 0, 0
  103.     Exit Sub
  104. FailedInit:
  105.     MsgBox "Could not initialize DirectMusic." & vbCrLf & "This sample will exit.", vbOKOnly Or vbInformation, "Exiting..."
  106.     Unload Me
  107. End Sub
  108. Private Sub Form_Unload(Cancel As Integer)
  109.     On Error Resume Next
  110.     'Stops everything playing on the audio path
  111.     dmp.StopEx dmp.GetDefaultAudioPath, 0, 0
  112.     'Destroy all of our objects
  113.     Set seg = Nothing
  114.     'Closedown the performance object (we should always do this).
  115.     dmp.CloseDown
  116.     'Destroy the rest of our objects
  117.     Set dmp = Nothing
  118.     Set dml = Nothing
  119.     Set dx = Nothing
  120. End Sub
  121.