Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 10 DEC 1998 01:38:12PM Ted Archibald - Parsec Sys wrote:

In the old days long ago on systems that are ancient now, I used to have the ability to create various tones from the CPU speaker that would indicate various level of edit acceptance or rejection.

I want to have a short dual tone of say 3kHz .25sec + 4kHz .25 sec to indicate acceptance and the reverse for rejection.

I now have an application where store staff are using a barcode scanner attached to the KB to scan in serial numbers of telephones and cannot or do not want to look at the monitor to see a visual message of acceptance or rejection. I cannot use the BELL or standard tone because CHAR(7) is used to open the cash drawer. I really want to have a dual tone ok or reject.

Do you know of any way to generate tones of various frequence and duration from AREV?

Cheers….Ted


At 10 DEC 1998 04:55PM Steve Smith wrote:

I remember using the OUT command to send character values direct to the speaker port (port 20?) at various frequencies.

If I recall, this was on 286/3868 class PCs so the routines may not work on later faster PCs

I'll try to dig up some old assembler code, or an old GWBASIC manual to find more detail.

Steve


At 15 DEC 1998 06:21AM [email protected] - [url=http://www.sprezzatura.com]Sprezzatura, Inc.[/url] wrote:

From you're helpful friends at Sprezzatura, fountains of all archane Revelation knowledge, comes this little tidbit from our vast archive of information. This piece comes from a Revemedia article that first appeared in Revemdia, Volume 2, Issue 5.

[email protected]

Sprezzatura, Inc.

www.sprezzatura.com_zz.jpg

Cameron Christie, who has contributed several routines to the REVMEDIA

library, now looks at some little used R/BASIC statements and a possible application for them.

I've been running R/BASIC programming courses for some time now, and the most frequent question arising is not about system subroutines or

WINDOW_COMMON%; instead I get "Is R/BASIC any good for writing games?". Unfortunately, the short answer is: No. The main differences between games and 'ordinary' programs (such as reports) are usually graphics and sound. Since ARev uses a character graphics screen there's not much we can do about fast and fancy graphics. VIDEO.RW can be used to achieve some rudimentary animation (if you're more adventurous, try dabbling with VSPACE!), but the bottom line is that R/BASIC is pretty much useless unless it's used to call C or Assembler routines.

Sound, however, is a more realistic proposition altogether. Using standard R/BASIC, the only sound available is the short, monotone beep, achieved by printing CHAR(7). With just a little knowledge of the PC's internal workings, some musical theory, and a few lesser-used R/BASIC statements, your AREV system could soon play anything from Sibelius to Springsteen.

A routine called PLAY, which mimics the functionality of the GW-BASIC PLAY statement, will be available on the next REVMEDIA diskette. In anticipation of this, the theory behind the program is as follows.

The timer chip within the PC (the 8253-5) generates clock ticks based on a 1.193 MHz base frequency. To produce an audible tone, the chip's behaviour can be manipulated using the R/BASIC OUT statement - see the Technical Reference Manual for more details. An initialising value of 182 is sent to port 67, followed by the low & high order bytes which are sent to port 66.

(FIG. 1). A general warning applies to use of the OUT statement: if your PC is not fully IBM compatible, or you send bits to the wrong address, then unpredictable and nasty side effects may occur - be careful!

Now we must go directly to the speaker and activate it for the duration of the tone we have established. (FIG 2) The speaker is controlled by the programmable peripheral interface and is accessed via port 97. If the first two bytes at this location are on then the sound will be heard ; if they are off the speaker will be deactivated. To manipulate the bits within a byte we use here the BITOR and BITAND functions, along with OUT and its opposite number, INP - again, see the Technical Reference Manual. (Those among you

who like to use obscure code might like to try X=- BITNOT(X) instead of X += 1; it's three times slower, but you can't fault its opacity!)

Finally, a quick word about FIG 3, which calculates the frequency required for a given musical note. An octave is actually defined as a twelve note scale (including semitones) where the first note of an octave has a frequency twice that of the corresponding note in the previous octave. Therefore, given the frequency of one note, we can work out the frequency of any other note by knowing the interval between them.

An alternative method would be to actually hold an array of all the required frequencies in the program; this is actually much more efficient!

For more details on sound generation, see The Peter Norton Programmer's Guide to the IBM PC (Microsoft Press)

<code>

FIGURE 1.

  • For a given FREQUENCY in Hz.
   VALUE=1193180/FREQUENCY
   LOW =INT(MOD(VALUE,256))
   HIGH=INT(VALUE/256)
   OUT 67,182
   OUT 66,LOW
   OUT 66,HIGH

FIGURE 2.

  • For a given DURATION in seconds.
  • Set first 2 bits at speaker address to begin sound.
   LAST.SETTING=INP(97)
   NEW.SETTING=BITOR(LAST.SETTING,03)
   OUT 97,NEW.SETTING
   * Timing Control Loop - DURATION is set elsewhere in the program.
   * See REVMEDIA passim for documentation on the DOSTIME subroutine.
   DOSTIME(START)
   LOOP
      DOSTIME(FINISH)
   UNTIL (FINISH-START) ] DURATION
   REPEAT
   * Reset first 2 bits at speaker address to end sound.
   NEW.SETTING=BITAND(LAST.SETTING,252)
   OUT 97,NEW.SETTING

FIGURE 3.

  • For a given NOTE and OCTAVE (derived, e.g, from a passed parameter),
  • calculate the FREQUENCY used by FIG 1.

NOTES=C,Cs,Db,D,Ds,Eb,E,F,Fs,Gb,G,Gs,Ab,A,

   NOTES := "As,Bb,B"
   POSITIONS=1,2,2,3,4,4,5,6,7,7,8,9,9,10,11,11,12"
   CONVERT "," TO @FM IN NOTES
   CONVERT "," TO @FM IN POSITIONS
   * Note A4 is defined as the root note, frequency=440.00 Hz.
   BASE.FREQUENCY=440
   * Set A4 note position within scale.  (4 full octaves of 12, plus 10).
   BASE.POS=58
   LOCATE NOTE IN NOTES USING @FM SETTING POS THEN
      POSITION=POSITIONS + OCTAVE*12
      OFFSET=POSITION - BASE.POS
      FREQUENCY=(BASE.FREQUENCY * (2**(0FFSET/12)))
   END

(Volume 2, Issue 5, Pages 4,5)

<code>

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/39b02efb12cbaf92852566d60066600a.txt
  • Last modified: 2024/01/04 21:00
  • by 127.0.0.1