?? main.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5175
ClientLeft = 60
ClientTop = 345
ClientWidth = 8520
FillColor = &H00C0C0C0&
FillStyle = 0 'Solid
LinkTopic = "Form1"
ScaleHeight = 5175
ScaleWidth = 8520
StartUpPosition = 3 'Windows Default
Begin VB.Timer RateTimer
Left = 0
Top = 4320
End
Begin VB.TextBox Comment
Height = 525
Left = 6000
MultiLine = -1 'True
TabIndex = 10
Text = "Main.frx":0000
Top = 360
Width = 2175
End
Begin VB.CheckBox AutoTrigger
Caption = "AutoSet"
Height = 315
Left = 3360
TabIndex = 9
Top = 600
Value = 1 'Checked
Width = 975
End
Begin VB.TextBox HeartRate
Height = 285
Left = 4800
TabIndex = 6
Text = "Text3"
Top = 360
Width = 975
End
Begin VB.TextBox TriggerLevel
Enabled = 0 'False
Height = 285
Left = 3360
TabIndex = 5
Text = ".5"
Top = 360
Width = 975
End
Begin VB.PictureBox Picture1
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H8000000A&
ForeColor = &H80000008&
Height = 3975
Left = 240
ScaleHeight = 263
ScaleMode = 3 'Pixel
ScaleWidth = 527
TabIndex = 4
Top = 960
Width = 7935
End
Begin VB.TextBox Text1
Height = 285
Left = 4800
TabIndex = 3
Text = "Text1"
Top = 600
Width = 975
End
Begin VB.Timer Timer1
Left = 0
Top = 3840
End
Begin VB.TextBox Buffer
Height = 285
Left = 2040
TabIndex = 1
Text = "6"
Top = 360
Width = 855
End
Begin VB.CommandButton Command1
Caption = "Start Recording"
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 1575
End
Begin VB.Label Label3
Caption = "Heart Rate"
Height = 255
Left = 4800
TabIndex = 8
Top = 120
Width = 975
End
Begin VB.Label Label2
Caption = "Trigger Level"
Height = 255
Left = 3360
TabIndex = 7
Top = 120
Width = 975
End
Begin VB.Label Label1
Caption = "Graph time (sec)"
Height = 255
Left = 2040
TabIndex = 2
Top = 120
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' ---------------------------------------------------------------------------
' Constants that may be user-setable in the future
' ---------------------------------------------------------------------------
' You can set these. Changing number of channels and bits per sample will
' sort of screw up the oscilloscope, though. Actually, changing the bits
' per sample may screw up some other things too, though nothing that'd be
' particularly hard to fix.
' Number of channels to record (1 = mono, 2 = stereo)
Private Const pcNumberOfChannels As Long = 1
' Sample rate (Hz)
Private Const pcSamplesPerSecond As Long = 44100
' Maximum number of seconds to buffer the input
Private Const pcMaxSeconds As Integer = 20
' The amount of gap to put in the graph
Private Const pcGap As Integer = 20
' ---------------------------------------------------------------------------
' Various global variables - not user setable
' Bits per sample
Private Const pcBitsPerSample As Long = 16
' Handle of the open audio device. 0 when not capturing.
Private pDevHandle As Long
' Pointer to the memory heap containing the wave from the input
'Private pWaveHeap As Long
' Pointer to the memory block in the heap that I can use
'Private pWaveMem As Long
' The wave input header
Private pWaveHeader As WAVEHDR
' The data of the input wave
Private data(pcSamplesPerSecond * pcMaxSeconds) As Integer
' Pointer to the data
Private pData As Long
' The maximum value of Y for the sweep
Private maxY As Long
Private Sub AutoTrigger_Click()
If (AutoTrigger.Value = 1) Then
TriggerLevel.Enabled = False
Else
TriggerLevel.Enabled = True
End If
End Sub
Private Sub Buffer_LostFocus()
' This sets the number of seconds to buffer the input
If (Buffer.Text > pcMaxSeconds) Or (Buffer.Text < 0.5) Then
MsgBox "Value must be between 1 and" + Str(pcMaxSeconds) + " seconds", vbExclamation
Buffer.Text = 6
End If
End Sub
Private Sub Form_Load()
Picture1.FillColor = Form1.BackColor
Picture1.FillStyle = 0
prevX = 0
End Sub
Private Sub Form_Resize()
If (Form1.ScaleWidth > 490) Then
Picture1.Width = Form1.ScaleWidth - 480
End If
If (Form1.ScaleHeight > 960 + 250) Then
Picture1.Height = Form1.ScaleHeight - 960 - 240
End If
Picture1.ScaleTop = -(Picture1.ScaleHeight / 2)
'Picture1.Line (0, 0)-(Picture1.ScaleWidth / 2, Picture1.ScaleHeight / 2)
End Sub
Private Sub Command1_Click()
If (Command1.Caption = "Start Recording") Then
Start_recording 'Caption gets changed in the subroutine
Buffer.Enabled = False
Else
Command1.Caption = "Start Recording"
Stop_Recording
Buffer.Enabled = True
End If
End Sub
Private Sub Start_recording()
' Set some variables
Dim msg As String * 255 ' Error messages go here
Dim WF As WAVEFORMAT
With WF
.wFormatTag = WAVE_FORMAT_PCM
.nChannels = pcNumberOfChannels
.nSamplesPerSec = pcSamplesPerSecond
.wBitsPerSample = pcBitsPerSample
.nBlockAlign = (.nChannels * .wBitsPerSample) \ 8
.nAvgBytesPerSec = .nBlockAlign * .nSamplesPerSec
.cbSize = 0
End With
'Obsolete - I found another way to save the memory
' Allocate the amount of memory needed to store the data (add a little for all the headroom)
' pWaveHeap = HeapCreate(0, pcSamplesPerSecond * 2 * Buffer.Text + 1000, 0)
' If (pWaveHeap = Null) Then
' MsgBox "Could not allocate " + Str(pcSamplesPerSecond * 2 * Buffer.Text + 1000) + "bytes of memory", vbExclamation
' Exit Sub
' End If
' pWaveMem = HeapAlloc(pWaveHeap, HEAP_ZERO_MEMORY, pcSamplesPerSecond * 2 * Buffer.Text)
' If (pWaveMem = Null) Then
' MsgBox "Error allocating the memory in the heap", vbExclamation
' Exit Sub
' End If
'An easier way to create and access the memory
pData = VarPtr(data(0))
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -