home *** CD-ROM | disk | FTP | other *** search
- //**********************************************************************
- // DIVE Laboratories, Inc.
- // Copyright(c) 1995
- // All rights reserved.
- // FILE: AUDIO.HPP
- //
- // DESCRIPTION
- // This file provides the function prototypes for playing both WAV and
- // MIDI songs and effects.
- //
- // Author: P. Cattrone
- //
- // Modification History:
- // 8/25/95 Created
- //
- //**********************************************************************
- #ifndef _AUDIO_HPP
- #define _AUDIO_HPP
-
- #ifdef AMBER_DEBUG_LIB
- #define _DEBUG
- #endif
- #ifdef WIN32
- //Standard Windows Includes
- #include "windows.h"
- #include "math.h"
- #include "mmsystem.h"
- #endif
- #ifdef AMBER_DEBUG_LIB
- #undef _DEBUG
- #endif
-
- //Amber Includes
- #include "messages.hpp"
-
- //audioClass
- //The audioClass incorporates sound into a Amber application.
- //It currently supports both Wave and MIDI sounds effects as
- //well as MIDI songs.
-
- //In the current version of the audioClass:
- //
- //You can play either a MIDI song or MIDI triggered sound
- //effects but not both at the same time.
- //
- //Only one Wave file can be played at a time.
-
- class audioClass {
-
- private:
-
- HMIDIOUT midiDev;
- WORD mciDev;
-
- public:
- //
- //Wave sound file commands
- //
-
- //Plays a .wav file once from disk
- //filename: filename of the .wav file
- //flag: FALSE to halt application while sound is playing
- // TRUE to return control to application while sound
- // is playing.
- BOOL wavPlayD(LPCTSTR filename, BOOL flag);
-
- //Plays and loops a .wav file from disk until it receives
- // a wavStop() call.
- //filename: filename of the .wav file
- //flag: FALSE to halt application while sound is playing
- // TRUE to return control to application while sound
- // is playing.
- BOOL wavLoopD(LPCTSTR filename, BOOL flag);
-
- //Plays a .wav file once from memory
- //memloc: Memory location of a .wav file loaded into memory.
- //flag: FALSE to halt application while sound is playing
- // TRUE to return control to application while sound
- // is playing.
- BOOL wavPlayM(LPCTSTR memloc, BOOL flag);
-
- //Plays and loops a .wav file from memory until it receives
- // a wavStop() call.
- //memloc: memory location of a .wav file loaded into memory.
- //flag: FALSE to halt application while sound is playing
- // TRUE to return control to application while sound
- // is playing.
- BOOL wavLoopM(LPCTSTR memloc, BOOL flag);
-
- //Stops the current .wav file being played.
- BOOL wavStop(void);
-
- //
- //Midi triggered effect commands
- //
-
- //Attempts to gain control of the MIDIMAPPER device so
- // Midi events can be sent to the device. The MIDIMAPPER
- // device must be free from other processes for this to
- // succeed.
- void midiOpenFX(void);
-
- //Releases control of the MIDIMAPPER device
- void midiCloseFX(void);
-
- //Turns off all notes being played on the Midi device.
- void midiResetFX(void);
-
- //Controls the mixing and volume of the left and right
- //audio outputs.
- //left: a value from 0 (lowest) to 127 (highest).
- //right: a value from 0 (lowest) to 127 (highest).
- void midiMasterVolume(int left, int right);
-
- //Sends a Note On event to the midi device
- //channel: a value between 0 and 15.
- //note: a value between 0 and 127.
- //velocity: a value between 0 and 127.
- void midiNoteOn(int channel, int note, int velocity);
-
- //Sends a Note Off event to the midi device
- //channel: a value between 0 and 15.
- //note: a value between 0 and 127.
- //velocity: a value between 0 and 127.
- void midiNoteOff(int channel, int note, int velocity);
-
- //Changes the sound patch on a midi channel
- //channel: a value between 0 and 15.
- //patch: a value between 0 and 127.
- void midiChangePatch(int channel, int patch);
-
- //Changes the pitch on all notes being played on a midi
- // channel.
- //channel: a value between 0 and 15.
- //pitch: a value between 0 and 16,384.
- // *note- a value of 8192 (middle value) signifies no
- // pitch bend
- void midiPitchBend(int channel, int pitch);
-
- //Changes the value of a midi controller on a midi channel.
- //channel: a value between 0 and 15.
- //controller: a value between 0 and 127.
- //value: a value between 0 and 127.
- void midiController(int channel, int controller, int value);
-
- //Sends a midi System Exclusive message. This function
- // currently does nothing but will be supported in a near
- // future release
- //sysmessage: a pointer to a midi sysex message string
- //legth: length of the message string
- void midiSysex(LPSTR sysmessage, int length);
-
- //
- //Midi song commands
- //
-
- //Opens and readies a .mid song to be played on the midi
- // device.
- //file: file name of the .mid song to be loaded.
- DWORD midiOpenSong(LPTSTR filename);
-
- //Plays a song previously opened by midiOpenSong. The
- // midi device must free of control from other applications
- // and the midi triggered effect functionality.
- DWORD midiPlaySong();
-
- //Stops a song currently being played by midiPlaySong.
- DWORD midiStopSong();
-
- //Releases control of the midi device claimed by midiPlaySong().
- DWORD midiCloseSong();
-
- //
- //Misc sound functions
- //
-
- //Finds the distance of a sound relative to 0,0,0.
- //pos_x: x position value of the sound relative to 0,0,0
- //pos_y: y position value of the sound relative to 0,0,0
- //pos_z: z position value of the sound relative to 0,0,0
- double findDistance(double pos_x, double pos_y, double pos_z);
-
- //This function returns a velocity value based on the
- // the distance from the sound.
- int distanceCueVolume(double distance);
-
- //This function returns a time to wait before playing a
- // sound based on its distance.
- double distanceCueTime(double distance);
-
- //
- //Constructor and Destructor
- //
- audioClass(void);
-
- ~audioClass(void);
-
- };
-
- #endif
-