MusicKit  0.0.0
SndOnDisk.h
00001 
00002 //
00003 //  $Id$
00004 //
00005 //  Description:
00006 //    This class is to be regarded as HIGHLY EXPERIMENTAL.
00007 //    Don't use it for general Snd use!!!
00008 //
00009 //    Current experimental activity - stream from disk behaviour.
00010 //    Should be safe to use for playback ONLY!!
00011 //
00012 //  Original Author: SKoT McDonald, <skot@tomandandy.com>
00013 //
00014 //  Copyright (c) 2002, The MusicKit Project.  All rights reserved.
00015 //
00016 //  Permission is granted to use and modify this code for commercial and
00017 //  non-commercial purposes so long as the author attribution and copyright
00018 //  messages remain intact and accompany all relevant code.
00019 //
00021 
00022 #ifndef __SNDKIT_
00023 
00024 #import <Foundation/Foundation.h>
00025 
00026 #import "Snd.h"
00027 
00029 
00038 @interface SndOnDisk : Snd {
00039   BOOL             bImageInMemory;
00040   NSString        *theFileName;
00041   
00042   SndAudioBuffer  *cachedBuffer;
00043   NSRange          cachedBufferRange;
00044   NSLock          *cacheLock;
00045 
00046   NSConditionLock *readAheadLock;
00047   SndAudioBuffer  *readAheadBuffer;
00048   NSRange          readAheadRange;
00049 }
00050 
00051 - init;
00052 - (void) dealloc;
00053 - (unsigned char*) data;
00054 - (int) dataSize;
00055 - (int) readSoundfile:(NSString *)filename startFrame: (int) startFrame frameCount: (int) frameCount;
00056 - (int) readSoundfile: (NSString*) filename;
00057 - (SndAudioBuffer*) audioBufferForSamplesInRange: (NSRange) playRegion;
00058 - (long) fillAudioBuffer: (SndAudioBuffer *) buff
00059                 toLength: (long) fillLength
00060           samplesInRange: (NSRange) sndSampleReadRange;
00061 
00062 - (NSString*) filename;
00063 
00064 - requestNextBufferWithRange: (NSRange) range;
00065 - receiveRequestedBuffer: (SndAudioBuffer*) aBuffer;
00066 
00067 @end
00068 
00069 @interface SndOnDiskAudioBufferServerJob : NSObject {
00070   SndOnDisk        *clientSndOnDisk;
00071   NSRange         audioBufferRange;
00072   SndAudioBuffer *audioBuffer;
00073 }
00074 
00075 - initWithSndOnDisk: (SndOnDisk*) sndExpt bufferRange: (NSRange) range;
00076 - (SndOnDisk*) snd;
00077 - (NSRange) range;
00078 - (SndAudioBuffer*) buffer;
00079 
00080 @end
00081 
00082 @interface SndOnDiskAudioBufferServer : NSObject {
00083   NSMutableArray  *pendingJobsArray;
00084   NSConditionLock *pendingJobsArrayLock;
00085   BOOL bGo;
00086   SndOnDiskAudioBufferServerJob *activeJob;
00087 }
00088 
00089 + (void) initialize;
00090 + defaultServer;
00091 + (SndAudioBuffer*) readRange: (NSRange) range ofSoundFile: (NSString*) theFileName;
00092 - addJob: (SndOnDiskAudioBufferServerJob*) aJob;
00093 - (void) serverThread;
00094 @end
00095 
00097 
00098 #endif