GL Studio API
sound_legacy.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::SoundSystem class. Allows playback of digitized audio.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2015 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 
41 #ifndef _SOUND_LEGACY_H
42 #define _SOUND_LEGACY_H
43 
44 #include "disti_include.h"
45 
46 namespace disti
47 {
48 
49 #ifdef SGI
50 typedef struct
51 {
52  char *name;
53  short *sampleBuffer;
54  long samplesPerFrame;
55  long numberSamples;
56  long samplesPerBuffer;
57  long audioRate;
58  int bitsPerSample;
59  int sampleFormat;
60  int byteOrder;
61 } SoundBuffer;
62 #endif
63 
64 #if defined(LINUX) || defined(SUNOS)
65 typedef struct
66 {
67  char *file_name;
68  void *sample_buffer; /** Preloaded sound to play faster */
69  int frame_count; /** How many frames in the sound */
70  int channel_count; /** Mono (1), or Stereo (2) */
71  int sample_format; /** Format of the sound, A Law, U Law, etc... */
72  int sample_width; /** 8 bit, or 16 bits per sound sample */
73  int frame_size; /** How many bytes per frame, Channels times
74  * width, e.g. (mono (1)) * (8 bit (1)) = 1 bytes
75  * (Stereo (2)) * (16 bit (2)) = 4 bytes */
76  double rate; /** Sampling frequency of the sound in Hz */
77 } SoundBuffer;
78 #endif
79 
81 {
82  int _maxSounds; /** Maximum number of supported sounds */
83 
84 #ifndef _WIN32
85  SoundBuffer *_sounds; /** A dynamically allocated array of SoundBuffers */
86 #endif
87  char **audioptr;
88 
89  public:
90 
91  /** Creates a new sound system
92  * \param maxSounds Maximum number of soundfiles in the sound system
93  */
94  DISTI_EXPORT SoundSystem(int maxSounds);
95  DISTI_EXPORT ~SoundSystem(void);
96 
97  /** Plays the sound at the given index
98  * \param which The zero based index of the sound to play
99  */
100  DISTI_EXPORT void Play(int which);
101 
102  /** Plays the sound at the given index, attenuated for distancec
103  * \param which The zero based index of the sound to play
104  * \param distance The distance in meters of the sound
105  */
106  DISTI_EXPORT void Play(int which,float distance);
107 
108  /** Loads the sound from a file into a slot in the sound system
109  * \param fn The name of the file to load from
110  * \param index The zero based index to load the file into
111  */
112  DISTI_EXPORT void LoadSound(char *fn,int index);
113 
114  /** Loads a number of sounds from files into the sound system
115  * The sounds are loaded sequentially starting at slot zero
116  * \param firstArg Filenames to load, followed by a NULL
117  */
118  DISTI_EXPORT void LoadSounds(char *firstArg, ...);
119 
120  /** Deletes the sound from the given index
121  * \param index Zero based index to clear
122  */
123  DISTI_EXPORT void ClearSound(int index);
124 };
125 
126 } // namespace disti
127 
128 #endif
SoundSystem(int maxSounds)
A file for all GL Studio files to include.
void LoadSound(char *fn, int index)
void Play(int which)
Definition: sound_legacy.h:80
void ClearSound(int index)
Definition: bmpimage.h:46
void LoadSounds(char *firstArg,...)