home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8vbsdk.exe / samples / multimedia / vbsamples / directmusic / tutorials / tut1 / audtut1.frm (.txt) next >
Encoding:
Visual Basic Form  |  2000-10-02  |  4.3 KB  |  122 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 
  32.  2000, Microsoft Corporation, All Rights Reserved."
  33.       Height          =   255
  34.       Index           =   2
  35.       Left            =   780
  36.       TabIndex        =   3
  37.       Top             =   300
  38.       Width           =   4435
  39.    End
  40.    Begin VB.Label lbl 
  41.       BackStyle       =   0  'Transparent
  42.       Caption         =   "GM/GS
  43.  Sound Set Copyright 
  44. 1996, Roland Corporation U.S."
  45.       Height          =   255
  46.       Index           =   1
  47.       Left            =   780
  48.       TabIndex        =   2
  49.       Top             =   540
  50.       Width           =   4755
  51.    End
  52.    Begin VB.Label lbl 
  53.       BackStyle       =   0  'Transparent
  54.       Caption         =   "DirectMusic Segment Tutorial"
  55.       Height          =   255
  56.       Index           =   0
  57.       Left            =   780
  58.       TabIndex        =   1
  59.       Top             =   60
  60.       Width           =   2655
  61.    End
  62. Attribute VB_Name = "frmAudTut1"
  63. Attribute VB_GlobalNameSpace = False
  64. Attribute VB_Creatable = False
  65. Attribute VB_PredeclaredId = True
  66. Attribute VB_Exposed = False
  67. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  68. '  Copyright (C) 2000 Microsoft Corporation.  All Rights Reserved.
  69. '  File:       audTut1.frm
  70. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  71. Option Explicit
  72. ' Our DX variables
  73. Private dx As New DirectX8
  74. 'We need a loader variable
  75. Private dml As DirectMusicLoader8
  76. 'We need our performance object
  77. Private dmp As DirectMusicPerformance8
  78. 'We also need our DMusic segment
  79. Private seg As DirectMusicSegment8
  80. Private Sub cmdClose_Click()
  81.     Unload Me
  82. End Sub
  83. Private Sub Form_Load()
  84.     Dim dmA As DMUS_AUDIOPARAMS
  85.     'Get our loader and performance
  86.     Set dml = dx.DirectMusicLoaderCreate
  87.     Set dmp = dx.DirectMusicPerformanceCreate
  88.     'We will put in error checking here in case we can't init DMusic
  89.     'ie, if there is no sound card
  90.     On Error GoTo FailedInit
  91.     'Initialize our DMusic Audio with a default environment
  92.     dmp.InitAudio Me.hWnd, DMUS_AUDIOF_ALL, dmA, Nothing, DMUS_APATH_SHARED_STEREOPLUSREVERB, 64
  93.     'Here we will load our audio file.  We could load a wave file,
  94.     'a midi file, and rmi file, or a DMusic segment.  For this
  95.     'tutorial we will load a segment.
  96.     'Before we load our segment, set our search directory
  97.     dml.SetSearchDirectory FindMediaDir("sample.sgt", True)
  98.     'Now we can load our segment
  99.     Set seg = dml.LoadSegment("sample.sgt")
  100.     'Download our segment to the default audio path (created during our call to InitAudio)
  101.     seg.Download dmp.GetDefaultAudioPath
  102.     'Play our segment from the beginning
  103.     dmp.PlaySegmentEx seg, 0, 0
  104.     Exit Sub
  105. FailedInit:
  106.     MsgBox "Could not initialize DirectMusic." & vbCrLf & "This sample will exit.", vbOKOnly Or vbInformation, "Exiting..."
  107.     Unload Me
  108. End Sub
  109. Private Sub Form_Unload(Cancel As Integer)
  110.     On Error Resume Next
  111.     'Stops everything playing on the audio path
  112.     dmp.StopEx dmp.GetDefaultAudioPath, 0, 0
  113.     'Destroy all of our objects
  114.     Set seg = Nothing
  115.     'Closedown the performance object (we should always do this).
  116.     dmp.CloseDown
  117.     'Destroy the rest of our objects
  118.     Set dmp = Nothing
  119.     Set dml = Nothing
  120.     Set dx = Nothing
  121. End Sub
  122.