我正在创建一个用于间隔识别的程序,我真的希望输出的声音稍微......比 console.bleep 输出的声音更好 - 最好是钢琴声音或类似的声音。这就是我对 console.bleep 所做的,因此您可以了解我需要做什么:
Imports System.Threading
Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
IntervalClass.PlayInterval(11, 5)
End Sub
End Class
Class IntervalClass
Protected Shared Sub Play(interval() As Note)
Dim n As Note
For Each n In interval
If n.NoteTone = Tone.REST Then
Thread.Sleep(CInt(n.NoteDuration))
Else
Console.Beep(CInt(n.NoteTone), CInt(n.NoteDuration))
End If
Next n
End Sub
Public Shared Sub PlayInterval(ByRef StartingNote As Integer, ByRef EndingNote As Integer)
Dim Notes() As String = {Tone.C3, Tone.Cs3, Tone.D3, Tone.Ds3, Tone.E3, Tone.F3, Tone.Fs3, Tone.G3, Tone.Gs3, Tone.A3, Tone.As3, Tone.B3, Tone.C4, Tone.Cs4, Tone.D4, Tone.Ds4, Tone.E4, Tone.F4, Tone.Fs4, Tone.G4, Tone.Gs4, Tone.A4, Tone.As4, Tone.B4, Tone.C5, Tone.Cs5, Tone.D5, Tone.Ds5, Tone.E5, Tone.F5, Tone.Fs5, Tone.G5, Tone.Gs5, Tone.A5, Tone.As5, Tone.B5, Tone.C6}
Dim PlayInterval As Note() = {
New Note(Notes(StartingNote), Duration.HALF), New Note(Notes(EndingNote), Duration.HALF)}
Play(PlayInterval)
End Sub
Protected Enum Tone
REST = 0
C3 = 130.81
Cs3 = 138.59
D3 = 146.83
Ds3 = 155.56
E3 = 164.81
F3 = 174.61
Fs3 = 185
G3 = 196
Gs3 = 207.65
A3 = 220
As3 = 233.08
B3 = 246.94
C4 = 261.63
Cs4 = 277.18
D4 = 293.66
Ds4 = 311.13
E4 = 329.63
F4 = 349.23
Fs4 = 369.99
G4 = 392
Gs4 = 415.3
A4 = 440
As4 = 466.16
B4 = 493.88
C5 = 523.25
Cs5 = 554.37
D5 = 587.33
Ds5 = 622.25
E5 = 659.25
F5 = 698.46
Fs5 = 739.99
G5 = 783.99
Gs5 = 830.61
A5 = 880
As5 = 932.33
B5 = 987.77
C6 = 1046.5
End Enum
Protected Enum Duration
WHOLE = 1600
HALF = WHOLE / 2
QUARTER = HALF / 2
EIGHTH = QUARTER / 2
SIXTEENTH = EIGHTH / 2
End Enum
Protected Structure Note
Private toneVal As Tone
Private durVal As Duration
Public Sub New(frequency As Tone, time As Duration)
toneVal = frequency
durVal = time
End Sub
Public ReadOnly Property NoteTone() As Tone
Get
Return toneVal
End Get
End Property
Public ReadOnly Property NoteDuration() As Duration
Get
Return durVal
End Get
End Property
End Structure
End Class
是否有任何方法可以使用 console.bleep 或其他方法获得更好的声音?(最好我也可以将它们放在一个数组中,因为需要索引来调用正确的注释)谢谢