00001 /* 00002 $Id: MKWaveTable.h 3251 2005-05-11 07:59:04Z leighsmith $ 00003 Defined In: The MusicKit 00004 00005 Description: 00006 See discussion below. 00007 00008 Original Author: David A. Jaffe 00009 00010 Copyright (c) 1988-1992, NeXT Computer, Inc. 00011 Portions Copyright (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT 00012 Portions Copyright (c) 1994 Stanford University 00013 Portions Copyright (c) 1999-2001, The MusicKit Project. 00014 */ 00074 #ifndef __MK_WaveTable_H___ 00075 #define __MK_WaveTable_H___ 00076 00077 #import <Foundation/NSObject.h> 00078 //sb: 00079 #import "dsp_types.h" /* for DSPDatum */ 00080 00081 @interface MKWaveTable : NSObject 00082 { 00083 unsigned int length; /* Non-0 if a data table exists, 0 otherwise */ 00084 double scaling; /* 0.0 = normalization scaling */ 00085 DSPDatum *dataDSP; /* Loaded or computed 24-bit signed data */ 00086 double *dataDouble; /* Loaded or computed floating-point data */ 00087 } 00088 00094 - copyWithZone: (NSZone *) zone; 00095 00106 - init; 00107 00113 - (void)dealloc; 00114 00124 - (unsigned int)length; 00125 /* Length returns the length in samples of the data buffers. If it is 0, 00126 neither the DSPDatum or real buffer has been allocated. */ 00127 00128 00138 - (double)scaling; 00139 /* Scaling returns the current scaling of the data buffers. If it is 0, 00140 normalization scaling is specified. Normalization is the default. */ 00141 00142 00160 - (DSPDatum *) dataDSPLength: (unsigned int) aLength scale: (double) aScaling; 00161 00162 00180 - (double *) dataDoubleLength: (unsigned int) aLength scale: (double) aScaling; 00181 00182 /* The following methods are minor variations of 00183 dataDSPScaling:length: and are implemented in terms of it. 00184 They use default or previously specified length, scaling or both. */ 00185 00195 - (DSPDatum *) dataDSP; 00196 00207 - (DSPDatum *) dataDSPLength:(int)aLength; 00208 00219 - (DSPDatum *) dataDSPScale:(double)aScaling; 00220 00221 /* The following methods are minor variations of 00222 dataDoubleScaling:length: and are implemented in terms of it. 00223 They use default or previously specified length, scaling or both. */ 00224 00234 - (double *) dataDouble; 00235 00246 - (double *) dataDoubleLength:(int)aLength; 00247 00258 - (double *) dataDoubleScale:(double)aScaling; 00259 00260 00278 - fillTableLength:(int)aLength scale:(double)aScaling ; 00279 /* This method is a subclass responsibility. It must do the following: 00280 00281 This method computes the data. It allocates or reuses either (or 00282 both) of the data arrays with the specified length and fills it with data, 00283 appropriately scaled. 00284 00285 If only one of data arrays is computed, frees the other and sets 00286 its pointer to NULL. If data cannot be computed, 00287 returns nil with both buffers freed and set to NULL. 00288 00289 Note that the scaling and length instance variables must be set by the 00290 subclass' fillTableLength: method. 00291 */ 00292 00293 /* 00294 Archives itself by writing its name (using MKGetObjectName()), if any. 00295 All other data archiving is left to the subclass. 00296 */ 00297 - (void)encodeWithCoder:(NSCoder *)aCoder; 00298 00299 /* 00300 Archives itself by reading its name, if any, and naming the 00301 object using MKGetObjectName(). 00302 Note that -init is not sent to newly unarchived objects. 00303 */ 00304 - (id)initWithCoder:(NSCoder *)aDecoder; 00305 00306 @end 00307 00308 00309 00310 #endif