@@ -13,7 +13,7 @@ Type PlayPayload
13
13
frequency As Single
14
14
End Type
15
15
16
- Function PlayCallback (InputBuff as Const Any Ptr, OutputBuff as Any Ptr, _
16
+ Function PlayCallback cdecl (InputBuff as Const Any Ptr, OutputBuff as Any Ptr, _
17
17
FrameCount as CUlong, TimeInfo as Const PaStreamCallbackTimeInfo Ptr, _
18
18
StatusFlags as PaStreamCallbackFlags, UserData as Any ptr) as Long
19
19
@@ -35,14 +35,14 @@ Sub Play(Frequency as Single, Duration as Single)
35
35
36
36
pe = Pa_OpenDefaultStream( @stream, 0 , 1 , paInt32, SampleRate, SineSamples, @PlayCallback, @payload)
37
37
If pe <> paNoError Then
38
- Print "Error: " ; Pa_GetErrorText(pe)
38
+ Print "Error: " ; * Pa_GetErrorText(pe)
39
39
End 1
40
40
End If
41
41
42
42
Print "Playing " ; Frequency ; "Hz for " ; Duration ; "ms"
43
43
pe = Pa_StartStream(stream)
44
44
If pe <> paNoError Then
45
- Print "Error: " ; Pa_GetErrorText(pe)
45
+ Print "Error: " ; * Pa_GetErrorText(pe)
46
46
End 1
47
47
End If
48
48
@@ -51,13 +51,13 @@ Sub Play(Frequency as Single, Duration as Single)
51
51
52
52
pe = Pa_StopStream(stream)
53
53
If pe <> paNoError Then
54
- Print "Error: " ; Pa_GetErrorText(pe)
54
+ Print "Error: " ; * Pa_GetErrorText(pe)
55
55
End 1
56
56
End If
57
57
58
58
pe = Pa_CloseStream(stream)
59
59
If pe <> paNoError Then
60
- Print "Error: " ; Pa_GetErrorText(pe)
60
+ Print "Error: " ; * Pa_GetErrorText(pe)
61
61
End 1
62
62
End If
63
63
End Sub
@@ -67,13 +67,23 @@ Print "Initialize PortAudio ("; *Pa_GetVersionText(); ")"
67
67
68
68
pe = Pa_Initialize()
69
69
If pe <> paNoError Then
70
- Print "Error: " ; Pa_GetErrorText(pe)
70
+ Print "Error: " ; * Pa_GetErrorText(pe)
71
71
End 1
72
72
End If
73
73
74
- '' Play from A4 (440Hz) for 44ms until A2 (220Hz) for 22ms
75
- For i as Integer = 440 to 220 Step - 10
76
- Play(i, i / 10 )
74
+ Dim defdevice as Integer = Pa_GetDefaultOutputDevice()
75
+ If defdevice = paNoDevice Then
76
+ Print "Error: no default output device"
77
+ End 1
78
+ End If
79
+
80
+ Dim devinfo as const PaDeviceInfo Ptr = Pa_GetDeviceInfo(defdevice)
81
+ Dim apiinfo as const PaHostApiInfo Ptr = Pa_GetHostApiInfo(Pa_GetDefaultHostApi())
82
+ Print "Using " ; *apiinfo->name ; " api on default output device: " ; *devinfo->name
83
+
84
+ '' Play from A4 (440Hz) for 440ms until A3 (220Hz) for 220ms
85
+ For i as Integer = 440 to 220 Step - 110
86
+ Play(i, i)
77
87
Next
78
88
79
89
Print "Shutdown PortAudio"
0 commit comments