00001 00002 // 00003 // $Id: SndFunctions.h 3635 2009-10-20 11:20:56Z leighsmith $ 00004 // 00005 // Description: 00006 // A library of functions intended to be compatible with NeXTs now defunct SoundKit. 00007 // 00008 // Original Author: Stephen Brandon <stephen@brandonitconsulting.co.uk> 00009 // 00010 // This framework and all source code supplied with it, except where specified, 00011 // are Copyright Stephen Brandon and the University of Glasgow, 1999. You are 00012 // free to use the source code for any purpose, including commercial applications, 00013 // as long as you reproduce this notice on all such software. 00014 // 00015 // Software production is complex and we cannot warrant that the Software will be 00016 // error free. Further, we will not be liable to you if the Software is not fit 00017 // for the purpose for which you acquired it, or of satisfactory quality. 00018 // 00019 // WE SPECIFICALLY EXCLUDE TO THE FULLEST EXTENT PERMITTED BY THE COURTS ALL 00020 // WARRANTIES IMPLIED BY LAW INCLUDING (BUT NOT LIMITED TO) IMPLIED WARRANTIES 00021 // OF QUALITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF THIRD 00022 // PARTIES RIGHTS. 00023 // 00024 // If a court finds that we are liable for death or personal injury caused by our 00025 // negligence our liability shall be unlimited. 00026 // 00027 // WE SHALL HAVE NO LIABILITY TO YOU FOR LOSS OF PROFITS, LOSS OF CONTRACTS, LOSS 00028 // OF DATA, LOSS OF GOODWILL, OR WORK STOPPAGE, WHICH MAY ARISE FROM YOUR 00029 // POSSESSION OR USE OF THE SOFTWARE OR ASSOCIATED DOCUMENTATION. WE SHALL HAVE 00030 // NO LIABILITY IN RESPECT OF ANY USE OF THE SOFTWARE OR THE ASSOCIATED 00031 // DOCUMENTATION WHERE SUCH USE IS NOT IN COMPLIANCE WITH THE TERMS AND 00032 // CONDITIONS OF THIS AGREEMENT. 00033 // 00034 // Portions Copyright (c) 1999, The MusicKit Project. All rights reserved. 00035 // 00036 // Permission is granted to use and modify this code for commercial and 00037 // non-commercial purposes so long as the author attribution and copyright 00038 // messages remain intact and accompany all relevant code. 00039 // 00041 00050 /* We #import this file regardless of the setting of 00051 HAVE_CONFIG_H so that other applications compiling against this 00052 header don't have to define it. If you are seeing errors for 00053 SndKitConfig.h not found when compiling the MusicKit, you haven't 00054 run ./configure 00055 */ 00056 #import "SndKitConfig.h" 00057 #import "SndFormat.h" 00058 00059 #import <Foundation/Foundation.h> 00060 00061 #import "SndError.h" 00062 #import "SndEndianFunctions.h" 00063 00064 #if HAVE_LIBSNDFILE 00065 # import <sndfile.h> /* for libsndfile SNDFILE declaration */ 00066 #else 00067 #define SNDFILE void 00068 #endif 00069 00075 SNDKIT_API NSString *SndFormatDescription(SndFormat format); 00076 00083 SNDKIT_API NSString *SndFormatName(SndSampleFormat dataFormat, BOOL verbose); 00084 00090 SNDKIT_API int SndFrameSize(SndFormat sound); 00091 00097 SNDKIT_API double SndMaximumAmplitude(SndSampleFormat dataFormat); 00098 00104 SNDKIT_API int SndSampleWidth(SndSampleFormat dataFormat); 00105 00113 SNDKIT_API int SndBytesToFrames(int byteCount, 00114 int channelCount, 00115 SndSampleFormat dataFormat); 00116 00124 SNDKIT_API long SndFramesToBytes(long sampleCount, int channelCount, SndSampleFormat dataFormat); 00125 00131 SNDKIT_API SndFormat SndFormatOfSNDStreamBuffer(SNDStreamBuffer *streamBuffer); 00132 00138 SNDKIT_API long SndDataSize(SndFormat format); 00139 00145 SNDKIT_API float SndConvertDecibelsToLinear(float db); 00146 00152 SNDKIT_API float SndConvertLinearToDecibels(float linearAmplitude); 00153 00161 SNDKIT_API int SndWriteSampleData(SNDFILE *sfp, void *soundData, SndFormat soundDataFormat); 00162 00177 SNDKIT_API int SndSwapBigEndianSoundToHost(void *dest, 00178 void *src, 00179 int sampleCount, 00180 int channelCount, 00181 SndSampleFormat dataFormat); 00182 00197 SNDKIT_API int SndSwapHostToBigEndianSound(void *dest, 00198 void *src, 00199 int sampleCount, 00200 int channelCount, 00201 SndSampleFormat dataFormat);