MusicKit
0.0.0
|
00001 00002 // 00003 // $Id$ 00004 // SndKit 00005 // 00006 // Description: 00007 // Snd subclass reading MP3 compressed files. 00008 // 00009 // Original Author: SKoT McDonald <skot@tomandandy.com> 00010 // 00011 // Copyright (c) 2002, The MusicKit Project. All rights reserved. 00012 // 00013 // Permission is granted to use and modify this code for commercial and 00014 // non-commercial purposes so long as the author attribution and copyright 00015 // messages remain intact and accompany all relevant code. 00016 // 00018 00019 #ifndef __SND_MP3_H__ 00020 #define __SND_MP3_H__ 00021 00022 #import "SndKitConfig.h" 00023 00024 #if HAVE_LIBMP3HIP 00025 00026 #import <Foundation/Foundation.h> 00027 #import "Snd.h" 00028 #import <hip.h> 00029 00045 00046 00047 @interface SndMP3 : Snd 00048 { 00050 NSData *mp3Data; 00052 HIP_File mp3DataDescription; 00054 long *encodedFrameLocations; 00056 long encodedFrameLocationsCount; 00059 int currentMP3FrameID; 00062 NSMutableDictionary *decodedBufferCache; /* TODO this should become SndAgedDictionary */ 00063 00064 NSMutableDictionary *decodedBufferAccessCount; 00065 int accessTime; 00066 00068 SndAudioBuffer *pcmBufferToAccess; 00069 00072 double duration; 00073 00075 NSLock *pcmDataLock; 00076 00077 // Variables used in separate threaded predecoding. 00079 NSMutableData *pcmData; 00081 long decodedSampleCount; 00083 BOOL bDecoding; 00084 } 00085 00100 + (void) setPreDecode: (BOOL) yesOrNo; 00101 00106 + (BOOL) preDecode; 00107 00108 - (int) readSoundURL: (NSURL *) soundURL; 00109 - initFromSoundURL: (NSURL *) url; 00110 - (void) dealloc; 00111 00115 - (double) duration; 00116 00120 - (long) lengthInSampleFrames; 00121 00125 - (int) channelCount; 00126 00130 - (double) samplingRate; 00131 00135 - (SndSampleFormat) dataFormat; 00136 00140 - (int) convertToSampleFormat: (SndSampleFormat) toFormat 00141 samplingRate: (double) toRate 00142 channelCount: (int) toChannelCount; 00143 00147 - (int) convertToNativeFormat; 00148 00171 - (long) insertIntoAudioBuffer: (SndAudioBuffer *) anAudioBuffer 00172 intoFrameRange: (NSRange) bufferRange 00173 samplesInRange: (NSRange) sndReadingRange; 00174 00177 - (int) readSoundfile: (NSString*) filename; 00178 00181 - (int) readSoundURL: (NSURL*) soundURL 00182 startTimePosition: (double) segmentStartTime 00183 duration: (double) segmentDuration; 00184 00192 + (NSArray *) soundFileExtensions; 00193 00202 - (void *) fragmentOfFrame: (int) frame 00203 indexInFragment: (unsigned int *) currentFrame 00204 fragmentLength: (unsigned int *) lastFrameInBlock 00205 dataFormat: (SndSampleFormat *) dataFormat; 00206 00213 - (Snd *) soundFromSamplesInRange: (NSRange) frameRange; 00214 00215 @end 00216 00218 00219 #endif 00220 00221 #endif