home *** CD-ROM | disk | FTP | other *** search
/ VRML Tools for 3D Cyberspace / VRML_Tools_For_3D_Cyberspace.iso / amber / include / audio.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-01  |  5.7 KB  |  201 lines

  1. //**********************************************************************
  2. //  DIVE Laboratories, Inc.
  3. //  Copyright(c) 1995
  4. //  All rights reserved.
  5. //  FILE:   AUDIO.HPP
  6. //
  7. //  DESCRIPTION
  8. //  This file provides the function prototypes for playing both WAV and
  9. //      MIDI songs and effects.
  10. //
  11. //  Author: P. Cattrone
  12. //
  13. //  Modification History:
  14. //  8/25/95      Created
  15. //
  16. //**********************************************************************
  17. #ifndef _AUDIO_HPP
  18. #define _AUDIO_HPP
  19.  
  20. #ifdef AMBER_DEBUG_LIB
  21. #define _DEBUG
  22. #endif
  23. #ifdef WIN32
  24. //Standard Windows Includes
  25. #include "windows.h"
  26. #include "math.h"
  27. #include "mmsystem.h"
  28. #endif
  29. #ifdef AMBER_DEBUG_LIB
  30. #undef _DEBUG
  31. #endif
  32.  
  33. //Amber Includes
  34. #include "messages.hpp"
  35.  
  36. //audioClass
  37. //The audioClass incorporates sound into a Amber application.
  38. //It currently supports both Wave and MIDI sounds effects as
  39. //well as MIDI songs.  
  40.  
  41. //In the current version of the audioClass:
  42. //
  43. //You can play either a MIDI song or MIDI triggered sound 
  44. //effects but not both at the same time.
  45. //
  46. //Only one Wave file can be played at a time.
  47.  
  48. class audioClass {
  49.  
  50. private:
  51.  
  52.     HMIDIOUT     midiDev;
  53.     WORD         mciDev;
  54.  
  55. public:
  56.     //
  57.     //Wave sound file commands
  58.     //
  59.  
  60.     //Plays a .wav file once from disk
  61.     //filename: filename of the .wav file
  62.     //flag:    FALSE to halt application while sound is playing
  63.     //        TRUE to return control to application while sound
  64.     //            is playing.
  65.     BOOL wavPlayD(LPCTSTR filename, BOOL flag);
  66.  
  67.     //Plays and loops a .wav file from disk    until it receives
  68.     //    a wavStop() call.
  69.     //filename: filename of the .wav file
  70.     //flag:    FALSE to halt application while sound is playing
  71.     //        TRUE to return control to application while sound
  72.     //            is playing.
  73.     BOOL wavLoopD(LPCTSTR filename, BOOL flag);
  74.  
  75.     //Plays a .wav file once from memory
  76.     //memloc: Memory location of a .wav file loaded into memory.
  77.     //flag:    FALSE to halt application while sound is playing
  78.     //        TRUE to return control to application while sound
  79.     //            is playing.
  80.     BOOL wavPlayM(LPCTSTR memloc, BOOL flag);
  81.  
  82.     //Plays and loops a .wav file from memory until it receives
  83.     //    a wavStop() call.
  84.     //memloc: memory location of a .wav file loaded into memory.
  85.     //flag:    FALSE to halt application while sound is playing
  86.     //        TRUE to return control to application while sound
  87.     //            is playing.
  88.     BOOL wavLoopM(LPCTSTR memloc, BOOL flag);
  89.  
  90.     //Stops the current .wav file being played.
  91.     BOOL wavStop(void);
  92.  
  93.     //
  94.     //Midi triggered effect commands
  95.     //
  96.  
  97.     //Attempts to gain control of the MIDIMAPPER device so
  98.     //    Midi events can be sent to the device.  The MIDIMAPPER
  99.     //  device must be free from other processes for this to
  100.     //    succeed.
  101.     void midiOpenFX(void);
  102.  
  103.     //Releases control of the MIDIMAPPER device
  104.     void midiCloseFX(void);
  105.     
  106.     //Turns off all notes being played on the Midi device.
  107.     void midiResetFX(void);
  108.     
  109.     //Controls the mixing and volume of the left and right
  110.     //audio outputs.
  111.     //left:     a value from 0 (lowest) to 127 (highest).
  112.     //right:    a value from 0 (lowest) to 127 (highest).
  113.     void midiMasterVolume(int left, int right);
  114.  
  115.     //Sends a Note On event to the midi device
  116.     //channel:     a value between 0 and 15.
  117.     //note:        a value between 0 and 127.
  118.     //velocity: a value between 0 and 127.
  119.     void midiNoteOn(int channel, int note, int velocity);
  120.  
  121.     //Sends a Note Off event to the midi device
  122.     //channel:     a value between 0 and 15.
  123.     //note:        a value between 0 and 127.
  124.     //velocity: a value between 0 and 127.
  125.     void midiNoteOff(int channel, int note, int velocity);
  126.  
  127.     //Changes the sound patch on a midi channel
  128.     //channel:    a value between 0 and 15.
  129.     //patch:    a value between 0 and 127.
  130.     void midiChangePatch(int channel, int patch);
  131.  
  132.     //Changes the pitch on all notes being played on a midi
  133.     //    channel.
  134.     //channel:    a value between 0 and 15.
  135.     //pitch:    a value between 0 and 16,384.
  136.     //    *note- a value of 8192 (middle value) signifies no 
  137.     //        pitch bend
  138.     void midiPitchBend(int channel, int pitch);
  139.  
  140.     //Changes the value of a midi controller on a midi channel.
  141.     //channel:    a value between 0 and 15.
  142.     //controller:    a value between 0 and 127.
  143.     //value:    a value between 0 and 127.
  144.     void midiController(int channel, int controller, int value);
  145.  
  146.     //Sends a midi System Exclusive message.  This function
  147.     //    currently does nothing but will be supported in a near
  148.     //    future release
  149.     //sysmessage:    a pointer to a midi sysex message string
  150.     //legth:    length of the message string
  151.     void midiSysex(LPSTR sysmessage, int length);
  152.  
  153.     //
  154.     //Midi song commands
  155.     //
  156.  
  157.     //Opens and readies a .mid song to be played on the midi
  158.     //    device.
  159.     //file:  file name of the .mid song to be loaded.
  160.     DWORD midiOpenSong(LPTSTR filename);
  161.  
  162.     //Plays a song previously opened by midiOpenSong.  The
  163.     //    midi device must free of control from other applications
  164.     //    and the midi triggered effect functionality.
  165.     DWORD midiPlaySong();
  166.  
  167.     //Stops a song currently being played by midiPlaySong.
  168.     DWORD midiStopSong();
  169.  
  170.     //Releases control of the midi device claimed by midiPlaySong().
  171.     DWORD midiCloseSong();
  172.  
  173.     //
  174.     //Misc sound functions
  175.     //
  176.     
  177.     //Finds the distance of a sound relative to 0,0,0.
  178.     //pos_x: x position value of the sound relative to 0,0,0
  179.     //pos_y: y position value of the sound relative to 0,0,0
  180.     //pos_z: z position value of the sound relative to 0,0,0
  181.     double findDistance(double pos_x, double pos_y, double pos_z);
  182.  
  183.     //This function returns a velocity value based on the
  184.     //    the distance from the sound. 
  185.     int distanceCueVolume(double distance);
  186.  
  187.     //This function returns a time to wait before playing a 
  188.     //    sound based on its distance.
  189.     double distanceCueTime(double distance);
  190.  
  191.     //
  192.     //Constructor and Destructor
  193.     //        
  194.     audioClass(void);
  195.  
  196.     ~audioClass(void);
  197.  
  198. };
  199.  
  200. #endif
  201.