HP 40g hp 39g+ (39g & 40g)_mastering the hp 39g+_English_E_F2224-90010.pdf - Page 240
Prompt commands, BEEP, CHOOSE, BEEP <frequency>;<duration>
View all HP 40g manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 240 highlights
The Prompt commands BEEP ; This will use the piezo crystal in the calculator to create a sound of the specified frequency for the specified duration (in seconds). The resulting frequency is not terribly accurate, varying by up to 5% from one calculator to the next and depending also on the temperature. The frequencies of the twelve semi-tone jumps in the harmonic scale form a geometric sequence, and since the ratio from C to C' is 2, the ratio for each semi-tone must be 12 2 . The standard frequency used in tuning instruments is usually 440 cycle/sec for the note A. Since much of the simple music used by students is written using the scale of C, I use 440 / (12 2 )9 to find the frequency of C as 261.6 cycles/sec. We can use this to form a standard 'header' for any program we want to use to play music. The header shown right in the rounded box sets up the scale of C major. The code which then follows plays the first two bars of the tune "Strangers in the Night". In this header, the duration of a note (T) is set to 0.5 seconds. It is easy to change the tempo of the music by adjusting this. In this case you may find that the music sounds a little better with T set to 0.55 or 0.6 seconds. T is a crotchet, T/2 a quaver etc. CHOOSE ;;;.... This command pops up a menu with the title specified and with however many options follow. The number of the menu option highlighted when the user presses is returned in the variable. The initial value of the variable before the CHOOSE statement determines which option is initially highlighted. 240