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

Sonification
Like visualization, sonification of complex data and processes may make them easier to comprehend.

The VOTRAX speech synthesizer can talk.

Plain vanilla code examples:

Beep(frequency in cycles per second or Hertz, duration in milliseconds)
Beep() is a "legacy" Windows API function. It is easy to use but doesn't offer any elaboration.
Your code will wait for
Beep() to finish before continuing to execute.
In older operating systems,
Beep()played through the internal 2" speaker without a sound card.
In newer operating systems,
Beep() plays through the sound card.

beepRamp()Equal Interval Scale Optimized for Windows 7
This code is buggy...

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
There is a different range of playable notes for each instrument.
The applications that follow assume the same range of 47 notes for each instrument.

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 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
This is a proof-of-concept application.
The tracking is off and the image is distorted.
We also do not know the code for matching a hole with a note.

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...

mciSendString()
Allows you to play .mid files

For Windows 8, try:

Type this in with the other "include.h" commands:
#include <mmsystem.h>

The following files should already be on your Windows installation:
To start the music:

mciSendString(TEXT("play C:\\WINDOWS\\Media\\onestop.mid"), NULL, 0, NULL);
To stop the music:
mciSendString(TEXT("stop C:\\WINDOWS\\Media\\onestop.mid"), NULL, 0, NULL);


Note:
onestop.mid plays for 4:08
flourish.mid plays for 1:28
town.mid plays for 1:19

PlaySound()
Allows you to play .wav files

Library of professionally recorded commercial aviation .wav files. Free Sound Project

These examples assume that your .wav files are NOT part of your executable
To make them part of your executable, see the yellow box below.


Type this in with the other "include.h" commands:

#include <mmsystem.h>

For Windows 8 the format has changed. The path must be the parameter in the function call TEXT():
PlaySound(TEXT("C:\\WINDOWS\\Media\\Windows Notify Calendar.wav"), NULL, SND_ASYNC);

If your .wav file is in the same folder as your executable, try:
PlaySound ("badges.wav",NULL, SND_ASYNC);

If your .wav file is somewhere else, specify the pathway, try:
PlaySound ("C:\\WINDOWS\\Media\\tada.wav", NULL, SND_ASYNC);

A double quote was valid prior to Windows 7:
PlaySound ("mysound.wav", "", SND_ASYNC);
For Windows 7, you must use a NULL instead:
PlaySound ("mysound.wav", NULL, SND_ASYNC);

SND_SYNC means "synchronous play" and will halt program execution until the sound stops playing.
SND_ASYNC means "asynchronous play" and will continue program execution while the sound plays.

PlaySound(NULL, NULL, SND_ASYNC)will stop any playing sound.

 

Bogey - a simple demonstration

To import your .wav files into your executable:

Put your .wav files in with your Project and Unit files.

In the Embarcadero IDE:
Go to: File / New / Other / Text File and click OK
Select the resource type .rc
A new tab will appear with the default name New1.rc

Under the New1.rc tab enter your file names:
100 WAVE "treasure_badges.wav"
200 WAVE "need_dough.wav"
300 WAVE "gin_joints.wav"

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);

Thanks to Antonio Estevez and Remy Lebeau for this information.

A Dice Roll with Voice Output

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.


Standard .wav files available in Window 7

Thematic .wav files available in Window 7

Wave Sound Sampler for Windows 7
This application plays some of the built-in .wav files installed on the Duke Link Classroom #6 Windows 7 PCs.
These sounds typically accompany common Windows events.
The calls included in this application are of the form:.

PlaySound ("C:\\WINDOWS\\Media\\Windows tada.wav", "", SND_ASYNC);

Windows Speech API (SAPI)
x

Windows Speech API
This is a simple implementation that works courtesy of Remy Lebeau (Team B) and Coder12345.
Clearly it needs explanation, documentation and enhancement.

Votrax Speech Synthesizer (not updated to Windows 7)

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 not the voice of WOPR in the 1983 Sci-Fi movie WAR GAMES, but it seemed to be a fitting comparison. The text may be mangled away from proper English spelling to refine the pronunciation, or phonemes may be inserted into the stream (delimited between a "~" and a "?") to modify pronunciation.

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

Other Sonified Applications (not necessarily updated to Windows 7)

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