User Tools

Site Tools


using_20the_20internal_20speaker

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
using_20the_20internal_20speaker [2018/03/31 13:19] – external edit 127.0.0.1using_20the_20internal_20speaker [2024/01/05 00:21] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Using the internal speaker===== =====Using the internal speaker=====
  
-//by Richard Russell, November 2007//\\ \\ **The code in this article requires Windows NT4, Windows 2000, Windows XP or Windows Vista.**\\ \\  Even if your PC has a sound card (or integrated audio) it is still possible to use the internal speaker (if fitted) to produce simple sounds. You can do that using the **Beep** API function, as follows:\\ \\ +//by Richard Russell, November 2007//\\ \\ **The code in this article requires Windows NT4, Windows 2000, Windows XP or Windows Vista.**\\ \\  Even if your PC has a sound card (or integrated audio) it is still possible to use the internal speaker (if fitted) to produce simple sounds. You can do that using the **Beep** API function, as follows: 
 + 
 +<code bb4w> 
         SYS "Beep", frequency%, duration%         SYS "Beep", frequency%, duration%
-Here **frequency%** is the approximate frequency of the sound in Hertz and **duration%** is the approximate duration in milliseconds; **frequency%** must be in the range 37 Hz to 32767 Hz. Note that Windows does not return control to your BASIC program until the sound is finished.\\ \\  If you prefer to specify the frequency and duration using the same parameters as the BBC BASIC [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin7.html#sound|SOUND]] statement you can do that using a simple calculation. The two statements listed below produce (nearly) the same results, but the second outputs the sound using the internal speaker:\\ \\ +</code> 
 + 
 +Here **frequency%** is the approximate frequency of the sound in Hertz and **duration%** is the approximate duration in milliseconds; **frequency%** must be in the range 37 Hz to 32767 Hz. Note that Windows does not return control to your BASIC program until the sound is finished.\\ \\  If you prefer to specify the frequency and duration using the same parameters as the BBC BASIC [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin7.html#sound|SOUND]] statement you can do that using a simple calculation. The two statements listed below produce (nearly) the same results, but the second outputs the sound using the internal speaker: 
 + 
 +<code bb4w>
         SOUND 1, -15, pitch%, dur%         SOUND 1, -15, pitch%, dur%
         IF pitch% SYS "Beep", 61.7354*2^(pitch%/48), dur%*50 ELSE WAIT dur%*5         IF pitch% SYS "Beep", 61.7354*2^(pitch%/48), dur%*50 ELSE WAIT dur%*5
 +</code>
using_20the_20internal_20speaker.1522502390.txt.gz · Last modified: 2024/01/05 00:16 (external edit)