- It is intended for VB.Net programs running under Windows and it is unlikely to work on IOS, Android, Linux ...
- There may be old versions of Windows which throw an exception
- Early versions of Windows (pre Win 7) create the tone using an Interval Chip. Windows 7 and later versions use the soundcard.
- DotNet will flag an exception with any frequency outside the range 32 to 32767 Hz
-
Most Interval Chips/Soundcards will be silent or unpredictable when attempting to reproduce very high/low frequencies.
- Soundcards usually have a lower limit between 32 Hz and 100 Hz
- Soundcards usually have an upper limit between 10000 Hz and 30000 Hz
- Human hearing varies and a person with "normal" hearing may not be able to detect some of the playable frequencies
- Keep the beep duration short - it is difficult to stop the tone until it's time is up
Private NotePlaying As Boolean = False
Private Sub PlayNote(f As Integer, t As Integer)
If NotePlaying Then Exit Sub
NotePlaying = True
System.Console.Beep(f, t)
NotePlaying = False
End Sub
You can call the Sub using
PlayNote(frequenc, tim)
Where Frequenc is the required frequency (pitch) for the note in Hertz (Hz)and t is the duration (time) that the note should play in Milliseconds (mS)
Use f=512, t=1000 for a "Middle C" tone lasting 1 second
DigitalDan.co.uk