home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / midiin1a / midiecho.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-21  |  4.3 KB  |  151 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Midi Echo"
  4.    ClientHeight    =   4650
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   6480
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   4650
  10.    ScaleWidth      =   6480
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.TextBox Text1 
  13.       Height          =   285
  14.       Left            =   2640
  15.       TabIndex        =   7
  16.       Top             =   2400
  17.       Width           =   1215
  18.    End
  19.    Begin VB.ListBox List3 
  20.       Height          =   1425
  21.       ItemData        =   "Midiecho.frx":0000
  22.       Left            =   3360
  23.       List            =   "Midiecho.frx":0002
  24.       TabIndex        =   4
  25.       Top             =   360
  26.       Width           =   2895
  27.    End
  28.    Begin VB.ListBox List2 
  29.       Height          =   1425
  30.       ItemData        =   "Midiecho.frx":0004
  31.       Left            =   240
  32.       List            =   "Midiecho.frx":0006
  33.       TabIndex        =   3
  34.       Top             =   360
  35.       Width           =   2895
  36.    End
  37.    Begin VB.CommandButton Command3 
  38.       Caption         =   "Exit"
  39.       Height          =   495
  40.       Left            =   240
  41.       TabIndex        =   2
  42.       Top             =   3960
  43.       Width           =   6015
  44.    End
  45.    Begin VB.CommandButton Command2 
  46.       Caption         =   "Stop Recording"
  47.       Height          =   495
  48.       Left            =   3360
  49.       TabIndex        =   1
  50.       Top             =   3360
  51.       Width           =   2895
  52.    End
  53.    Begin VB.CommandButton Command1 
  54.       Caption         =   "Start Recording"
  55.       Height          =   495
  56.       Left            =   240
  57.       TabIndex        =   0
  58.       Top             =   3360
  59.       Width           =   3015
  60.    End
  61.    Begin VB.Label Label3 
  62.       Caption         =   "Data passed:"
  63.       Height          =   255
  64.       Left            =   1440
  65.       TabIndex        =   8
  66.       Top             =   2520
  67.       Width           =   975
  68.    End
  69.    Begin VB.Label Label2 
  70.       Caption         =   "Select Output Device"
  71.       Height          =   255
  72.       Left            =   3360
  73.       TabIndex        =   6
  74.       Top             =   120
  75.       Width           =   2055
  76.    End
  77.    Begin VB.Label Label1 
  78.       Caption         =   "Select Input Device"
  79.       Height          =   255
  80.       Left            =   240
  81.       TabIndex        =   5
  82.       Top             =   120
  83.       Width           =   2055
  84.    End
  85. Attribute VB_Name = "Form1"
  86. Attribute VB_GlobalNameSpace = False
  87. Attribute VB_Creatable = False
  88. Attribute VB_PredeclaredId = True
  89. Attribute VB_Exposed = False
  90. Option Explicit
  91. Dim i As Long
  92. Private Sub Command1_Click()
  93. 'Here, tmp1 is the handle for the MidiIn device
  94. 'and tmp2 is the handle for the MidiOut device
  95. 'First, open the Input device if one is selected
  96. If List2.ListIndex >= 0 Then
  97.    tmp = midiInOpen(tmp1, List2.ListIndex, AddressOf Memorize_Event, 0, CALLBACK_FUNCTION)
  98.    MsgBox "Please select an Input Device"
  99.    Exit Sub
  100. End If
  101. 'Then the output device
  102. If List3.ListIndex >= 0 Then
  103.    tmp = midiOutOpen(tmp2, List3.ListIndex, 0, 0, 0)
  104.    MsgBox "Please select an Output Device"
  105.    midiInClose (tmp1)
  106.    Exit Sub
  107. End If
  108. List2.Enabled = False
  109. List3.Enabled = False
  110. Command1.Enabled = False
  111. Command2.Enabled = True
  112. 'Start the recording. This resets the timer to 0
  113. tmp = midiInStart(tmp1)
  114. End Sub
  115. Private Sub Command2_Click()
  116. List2.Enabled = True
  117. List3.Enabled = True
  118. Command2.Enabled = False
  119. Command1.Enabled = True
  120. 'Stop the recording, and close the midi in device
  121. tmp = midiInReset(tmp1)
  122. tmp = midiInStop(tmp1)
  123. tmp = midiInClose(tmp1)
  124. tmp = midiOutClose(tmp2)
  125. End Sub
  126. Private Sub Command3_Click()
  127. Visible = False
  128. Unload Me
  129. End Sub
  130. Private Sub Form_Load()
  131. 'Disable the 'stop recording' button
  132. Command2.Enabled = False
  133. 'Here, first getting the number of midi in devices
  134. tmp = midiInGetNumDevs
  135. tmp1 = tmp
  136. 'Then examining the capabilities of the devices
  137. For i = 0 To tmp1 - 1
  138.    tmp = midiInGetDevCaps(i, oxMIC, Len(oxMIC))
  139.    If tmp <> 0 Then End
  140. List2.AddItem oxMIC.szPname
  141. Next i
  142. tmp = midiOutGetNumDevs
  143. tmp1 = tmp
  144. 'Then examining the capabilities of the devices
  145. For i = 0 To tmp1 - 1
  146.    tmp = midiOutGetDevCaps(i, oxMOC, Len(oxMOC))
  147.    If tmp <> 0 Then End
  148. List3.AddItem oxMOC.szPname
  149. Next i
  150. End Sub
  151.