MusicKit
0.0.0
|
00001 /* 00002 $Id$ 00003 Defined In: The MusicKit 00004 00005 Description: 00006 A MKSamples object is a type of MKWaveTable that uses a Snd object (from 00007 the SndKit) as its data. The Snd itself can only contain sampled 00008 data; each sample in the Snd corresponds to an array entry in the 00009 MKSamples object. The Snd object can be set directly by invoking the 00010 method setSound:, or you can read it from a soundfile, through the 00011 readSoundfile: method. 00012 00013 Note that the MKSamples object currently does not resample (except in 00014 one special case, when the sound is evenly divisible by the access 00015 length). Except in this special case, the length of the sound must be 00016 the same as the length you ask for with the access methods. 00017 00018 Note also that for use with the MusicKit oscillator unit generators, 00019 the length must be a power of 2 and must fit in DSP memory (1024 or 00020 less is a good length). 00021 00022 Original Author: David A. Jaffe 00023 00024 Copyright (c) 1988-1992, NeXT Computer, Inc. 00025 Portions Copyright (c) 1994 NeXT Computer, Inc. and reproduced under license from NeXT 00026 Portions Copyright (c) 1994 Stanford University. 00027 Portions Copyright (c) 1999-2001, The MusicKit Project. 00028 */ 00099 #ifndef __MK_Samples_H___ 00100 #define __MK_Samples_H___ 00101 00102 #import "MKWaveTable.h" 00103 #import <SndKit/SndKit.h> 00104 00105 @interface MKSamples : MKWaveTable 00106 { 00108 Snd *sound; 00110 NSString *soundfile; 00112 SndAudioProcessorChain *audioProcessorChain; 00113 int tableType; 00115 int curLoc; 00117 double amplitude; 00119 double panBearing; 00121 unsigned int startSampleLoc; 00123 unsigned int lastSampleLoc; 00124 } 00125 00126 00137 - init; 00138 00139 /* Frees the receiver and its instance variables. 00140 */ 00141 - (void) dealloc; 00142 00149 - copyWithZone: (NSZone *) zone; 00150 00156 - (BOOL) setSound: (Snd *) aSound; 00157 00169 - (BOOL) readSoundfile: (NSString *) aSoundfile; 00170 00175 - (Snd *) sound; 00176 00184 - (NSString *) soundfile; 00185 00199 - writeScorefileStream: (NSMutableData *) aStream; 00200 /* 00201 * A 00202 * MKSamples object is written by the name of the soundfile from which its 00203 * Snd was read, surrounded by braces: 00204 * 00205 * { "soundfileName" } 00206 * 00207 */ 00208 00217 - (void) encodeWithCoder: (NSCoder *) aCoder; 00218 00225 - (id) initWithCoder: (NSCoder *) aDecoder; 00226 00234 - (int) tableType; 00235 00239 - (void) setProcessingStartSample: (unsigned int) sampleNum; 00240 00244 - (unsigned int) processingStartSample; 00245 00249 - (void) setProcessingEndSample: (unsigned int) sampleNum; 00250 00254 - (unsigned int) processingEndSample; 00255 00259 - (unsigned int) currentSample; 00260 00264 - (void) setCurrentSample: (unsigned int) sampleNum; 00265 00269 - (double) amplitude; 00270 00274 - (void) setAmplitude: (double) amp; 00275 00279 - (void) setPanBearing: (double) newBearing; 00280 00284 - (double) panBearing; 00285 00290 - (SndAudioProcessorChain *) audioProcessorChain; 00291 00299 - setAudioProcessorChain: (SndAudioProcessorChain *) anAudioProcessorChain; 00300 00301 /* Private method that supports both OscTable and ExcitationTable */ 00302 - _fillTableLength: (int) aLength scale: (double) aScaling ; 00303 00304 @end 00305 00306 @interface MKSamples(OscTable) 00307 00325 - (DSPDatum *) dataDSPAsOscTableLength: (int) aLength; 00326 00344 - (double *) dataDoubleAsOscTableLength: (int) aLength; 00345 00346 /* The following methods are minor variations of 00347 dataDoubleAsOscTableScaling:length: and 00348 dataDSPAsOscTableScaling:length: and are implemented in terms 00349 of them. They use default or previously specified length, scaling or both. 00350 00351 Same as corresponding superclass methods. 00352 */ 00361 - (DSPDatum *) dataDSPAsOscTable; 00362 00372 - (double *) dataDoubleAsOscTable; 00373 00388 - fillOscTableLength: (int) aLength scale: (double) aScaling; 00389 00408 - fillTableLength: (int) aLength scale:(double)aScaling ; 00409 00410 @end 00411 00412 @interface MKSamples(ExcitationTable) 00413 00432 - (DSPDatum *) dataDSPAsExcitationTableLength: (unsigned int) aLength scale: (double) aScaling; 00433 00452 - (double *) dataDoubleAsExcitationTableLength: (unsigned int) aLength scale: (double) aScaling; 00453 00454 /* The following methods are minor variations of 00455 dataDoubleAsExcitationTableScaling:length: and 00456 dataDSPAsExcitationTableScaling:length: and are implemented in terms 00457 of them. They use default or previously specified length, scaling or both. 00458 */ 00459 00472 - (DSPDatum *) dataDSPAsExcitationTable; 00473 00487 - (DSPDatum *) dataDSPAsExcitationTableLength: (int) aLength; 00488 00502 - (DSPDatum *) dataDSPAsExcitationTableScale: (double) aScaling; 00503 00516 - (double *) dataDoubleAsExcitationTable; 00517 00531 - (double *) dataDoubleAsExcitationTableLength: (int) aLength; 00532 00546 - (double *) dataDoubleAsExcitationTableScale: (double) aScaling; 00547 00566 - fillExcitationTableLength: (int) aLength scale: (double) aScaling; 00567 00568 @end 00569 00570 00571 #endif