[image of digits] Borland C++ Builder - Sound

Sonification
Like visualization, sonification of the data and complex processes in a simulation can make it easier to understand.

The following examples use one or more of the following:
Beep(frequencey in Hz, duration in milliseconds), which is a legacy command generating tones on the internal speaker.
The MIDI Synthesizer, which allows you to dynamically play notes on a variety of instruments.
PlaySound(), which allows you to play pre-recorded .wav files.
The VOTRAX speech synthesizer, which can talk.

Cut-and-paste sonification functions:

Beep(frequency, milliseconds) a retro function which plays 155 primitive notes on the internal speaker
 

beepPianoScale()Piano Scale Optimized for Windows 7
This application invokes the Western piano scale with the primitive Windows function Beep(hertz, milliseconds) in an effort to construct a beepPianoScale(part, whole, milliseconds) function which can be used to sonify a data set. The derived beepPianoScale() function allocates 155 notes to the scale, and in that sense it is more finely grained than the midiRamp(whole, part, milliseconds) function. Although beepPianoScale() does not offer the range of voices available in midiRamp(), the sound envelope it produces is unique. Each call t obeepPianoScale()produces a sharp spike before the not is played, thus by varying the duration of each note one can actually hear two frequencies superimposed. Some of the sound effects are similar to those generated by the early computer games. Since Beep()and beepPianoScale()sounds are emitted from a 2" speaker inside the computer chassis, they cannot be amplified.

beepRamp()Equal Interval Scale Optimized for Windows 7
This application explores the primitive Windows function Beep(hertz, milliseconds) in an effort to construct a beepRamp(part, whole, milliseconds) function which can be used to sonify a data set. The derived beepRamp() function allocates 100 notes to the scale, and in that sense it is more finely grained than the midiRamp(whole, part, milliseconds) function. Although beepRamp() does not offer the range of voices available in midiRamp(), the sound envelope it produces is unique. Each call to beepRamp() produces a sharp spike or click at the beginning of the note, This is sometimes louder than the note itself and and for short note durations, can be disturbing. Beep() works differently in Windows7 and in WindowsXP. In Windows7 it appears to be sent through the system sound card, producing a softer tone, limiting its range and limiting its speed of execution. In Windows XP it is sent through the primmitive 2" speaker inside (and is not subject to volume control) the box and produces a more mechanical and raspier tone. Some of the sound effects are similar to those generated by the early computer games.

The MIDI Synthesizer a contemporary built-in Windows function which plays 47 notes on 100 instruments through the sound card

MIDI KEYBOARD COMPATIBLE WITH WINDOWS 7 - 2011
There has been a change in the way midiOutShortMsg() works.
It is now required to take the parameters (device, message.word) and cannot take (message.data[x]).

  1. Microsoft's MIDI Library
  2. Index MIDI Keyboard
  3. Index MIDI Patch (Instrument) Assignments
  4. Index MIDI Newer Patch (Instrument) Assignments
  5. Index MIDI Raw Data

MIDI - 2005
MIDI is capable of synthesizing 47 notes, on 100+ musical instruments. Consult Microsoft's documentation or our Topical Index pages for information:

  1. Microsoft's MIDI Library
  2. Index MIDI Keyboard
  3. Index MIDI Patch (Instrument) Assignments
  4. Index MIDI Newer Patch (Instrument) Assignments
  5. Index MIDI Raw Data

MIDI Timer - 2009
Three TTimer components are used to play three instruments at three intervals. The instruments (all 128) and intervals (up to 3 seconds) are user selectable but the notes are fixed at "C", "E", and "G." Apparently, if the three timers strike notes at the same instant, the MIDI device becomes confused and plays a note from a "random" instrument. To avoid collisions, keep the intervals relatively long and avoid using perfect multiples of intervals.

Mini MIDI - 2005
A minimal implementation. All the commands you need to connect to the MIDI device, play and silence a note and select an instrument.

MUSIC BOX
A century-old steel compact disk was photographed and the photo converted to black or white using the threshold function. Imported as a bitmap, the software scans the digital tracks and analog sectors and converts the perforations into MIDI notes according to the midiRamp() function. There are 61 notes on the disk but only 47 MIDI notes, so the 61 have been compressed to 47. The application has been set to play the disk clockwise with the low notes at the outside of the disk. It is not known if this is correct, but the settings can be changed. It is also not known which tracks are intended to play which notes, or even if some of the tracks may be for drums or cymbals. Also, the image of the disk is slightly distorted which interferes with tracking. This is a proof-of-concept application, so there is much more to be done...

PlaySound() a contemporary function capable of playing .wav files
Library of professionally recorded generic voice prompts. Free Sound Project

Rolling a Pair of Dice

A simple challenge to simulate the roll of a pair of dice provides the opportunity to exercise some of the AnsiString capabilities of the Visual Component Library. Invoked are the Caption, TextOut, Text and Lines properties as well as string concatenation. Images of each of the two dice appear after each roll. A voice gives the sum of the two dice using a suite of number .wav files imported into the application.

You can set up Embarcadero to import the .wav files you wish to use into your executable.
To do this, follow the procedure to the right.


Most, if not all, of the applications below do NOT make use of imported .wav files.
They require a .wav file to be present in addition to your executable.
That .wav file must either be present in the same folder, or at the end of a path specified by the PlaySound() function.

Thanks to Antonio Estevez for this information:

Instead of having to move .wav files into the same folder as your executable, you can import .wav files into your code and into your executable. The procedure is a little different than importing a picture as a TImage component.

In Notepad, create a file which lists the .wav files you wish to use:
100 WAVE "your_first_sound_file.wav"
200 WAVE "your_second_sound_file.wav"
300 WAVE "your_third_sound_file.wav"

Save it as "sound.rc" in the same folder as your Project and Unit files.

In the IDE, click "Project", select "Add to Project," and select that Resource "sound.rc" file.

In your Unit1.cpp source code, call the sounds with:

PlaySound(MAKEINTRESOURCE(100), HInstance, SND_RESOURCE);
PlaySound(MAKEINTRESOURCE(200), HInstance, SND_RESOURCE);
PlaySound(MAKEINTRESOURCE(300), HInstance, SND_RESOURCE);

Your executable will then contain those .wav files.

Notes (by Nick Gessler):
It does not appear to make any difference what the *.rc file is named.
It is possible to create the *.rc file while still in the IDE without using Notepad..

Wave Sounds Available in Windows XP Professional
This sampler accesses the built-in wave sound files currently installed on the Link Classroom #6 PC computers. These are the sounds which accompany Windows events and the FX available from the Pinball game. Some of these may be appropriate to signal special events which occur in a simulation.

Assuming you are calling PlaySound asynchronously, for example:
PlaySound ("C:\\WINDOWS\\Media\\Windows XP Startup.wav", "", SND_ASYNC);
You can STOP any wave file that is playing with the command:
PlaySound (NULL, "", SND_ASYNC);

There are NO spaces between the quote marks.

 

Votrax Speech Synthesizer a retro peripheral that can talk

The Votrax phoneme chart is based upon
the International Phonetic Alphabet (IPA).

VOTRAX
The Votrax, by Federal Screw Works, is one the earliest speech synthesizers. It offered both text-to-speech and phoneme-based synthesis. In this application, ASCII streams are sent out of the COMM1 RS-232 Serial Port at 9600 baud. Votrax was the voice (subsequently modified) of WOPR in the 1983 Sci-Fi movie WAR GAMES. The text may be mangled to refine the pronunciation or phonemes may be inserted into the stream delimited between a "~" and a "?"

Other Sonified Applications

Flocking Crowd Sonified
Using images to visualize and sounds to sonify a problem. Images are taken from the NASA Voyager plaque and DaVinci. Agents are distinguished as male or female and two new behaviors have been added taking advantage of those differences. In both behaviors, same-sex individuals will reverse direction on approaching one another while opposite sex individuals will adopt some of their nearest neighbor's behaviors. Of course, much more can be done...

2005 - Adam Skory's Evolutune
Evolutune is a program to evolve little musical loops. Each loop consists of four measures of beeps and boops. These loops are created based on sets of parameters, or genotypes, that define their characteristics. By selecting those loops that sound best, and reproducing them with slight mutations in their genotypes, a user can direct the evolution of the loops into being "more fit" for their environment (i.e. your ear).

The green triangle button is PLAY.
The black square button is STOP.
The red RECORD button is not implemented.

2005 - Theremin
Theremin is an EZIO-controlled interface to the MIDI synthesizer. It uses an EZIO real-world data acquisition module to convert infrared rangefinder data to notes on the keyboard. The raw sensor data and MIDI note are shown and the sensor data is plotted. The speed at which the sensor is interrogated is variable and the user may select any one of some 100 MIDI instruments.

Images and Sounds
This sampler accesses the sounds in the Windows and Office folders. It uses the transparency feature of .bmp images and moves them in several ways. The sounds, and the pathways to the sounds, may be different on different Windows installations.

A list of Wave files (wavefile.wav)
available on our CLICC PC XT computers.

Wave Harp
The screen is strung with a grid of strings, each of which when struck plays a Windows media wave file. An example of how to associate events with sounds to produce an auditory sonification of a simulation.

Midi Generator
and Borland Component

An updated Delphi & C++Builder MIDI component which allows the simple creation of sound effects and note sequences within an application without the need for external files or resources. TMidiGen achieves this by generating the MIDI data in memory. This update overcomes the memory allocation problems encountered with certain MIDI drivers.

Reproduced courtesy of Alan Warriner.
Please visit his website.

Executable

Tone Generator
and Borland Component

A Delphi & C++Builder component which allows the simple creation of sound effects within an application without the need for external audio files or resources. TToneGen achieves this by generating and processing WAV waveforms in memory.

Reproduced courtesy of Alan Warriner.
Please visit his website.

Executable