Home | Download | Screen shots | Discussion | Documentation | Links |
---|
00001 /* 00002 00003 OpenVRML 00004 00005 Copyright (C) 1999 Kumaran Santhanam 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 */ 00022 00023 /* Play sound files without tying up system resources. */ 00024 00025 #ifndef _SOUND_ 00026 #define _SOUND_ 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 00033 // Open the sound device for playing. 00034 // 00035 // This function returns an audio file descriptor for usage as 'fd' 00036 // in the other functions. The number of audio channels that may be 00037 // opened is dependent on system hardware. 00038 int openSound (int channels, 00039 int bits_per_sample, 00040 int speed); 00041 00042 00043 // Output a chunk of sound to the audio device 00044 // 00045 // This function outputs enough sound to fill the audio device's DMA 00046 // buffer. The byte_index is a current counter within the sample buffer. 00047 // The new byte_index is returned as the function's return value. 00048 // 00049 // If loop is non-zero, the sample is treated as a continuous loop. 00050 // 00051 // The intensity value specifies what type of scaling should be performed. 00052 // It ranges from 0 to 1.0 and is a floating point value. 0 signifies 00053 // no sound at all, while 1.0 signifies that the sound be played at the 00054 // full recorded volume. 00055 // 00056 // Keep in mind that only a CHUNK of the sample is output at a time. 00057 // To output the whole sample, use something like this: 00058 // 00059 // int byte_index = 0; 00060 // while (byte_index < num_sample_bytes) 00061 // outputSoundChunk (num_sample_bytes, samples, byte_index, 00062 // false, 1.0, audio_fd, 0); 00063 // 00064 // In practice, this isn't used, since the whole points of this function 00065 // is to provide a way to output a chunk of sound and process some other 00066 // events before outputting the next chunk. 00067 int outputSoundChunk (int num_sample_bytes, 00068 const unsigned char *samples, 00069 int bits_per_sample, 00070 int byte_index, 00071 int loop, 00072 double intensity, 00073 int fd); 00074 00075 00076 // Close the sound device 00077 // 00078 // This closes the sound device associated with the audio file descriptor. 00079 // This function always returns -1. 00080 int closeSound (int audio_fd); 00081 00082 00083 00084 #ifdef __cplusplus 00085 } 00086 #endif 00087 00088 00089 #endif /* _SOUND_ */