home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextLibrary / Frameworks / SoundKit.framework / Versions / A / Headers / Sound.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-29  |  4.7 KB  |  175 lines

  1. /*
  2.     Sound.h
  3.     Sound Kit, Release 2.0
  4.     Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #import <Foundation/Foundation.h>
  8. #import <sound/sound.h>
  9. #import <streams/streams.h>
  10.  
  11. @class NSPasteboard;
  12.  
  13. /* Define this for compatibility */
  14. #define NXSoundPboard NXSoundPboardType
  15.  
  16. extern NSString *NXSoundPboardType;
  17. /*
  18.  * This is the sound pasteboard type.
  19.  */
  20.  
  21. @interface Sound : NSObject
  22. /*
  23.  * The Sound object encapsulates a SNDSoundStruct, which represents a sound.
  24.  * It supports reading and writing to a soundfile, playback of sound,
  25.  * recording of sampled sound, conversion among various sampled formats, 
  26.  * basic editing of the sound, and name and storage management for sounds.
  27.  */
  28. {
  29.     SNDSoundStruct *soundStruct; /* the sound data structure */
  30.     int soundStructSize;     /* the length of the structure in bytes */
  31.     int priority;         /* the priority of the sound */
  32.     id delegate;         /* the target of notification messages */
  33.     int status;             /* what the object is currently doing */
  34.     NSString *name;         /* The name of the sound */
  35.     SNDSoundStruct *_scratchSound;
  36.     int _scratchSize;
  37. }
  38.  
  39. /*
  40.  * Status codes
  41.  */
  42. typedef enum {
  43.     NX_SoundStopped = 0,
  44.     NX_SoundRecording,
  45.     NX_SoundPlaying,
  46.     NX_SoundInitialized,
  47.     NX_SoundRecordingPaused,
  48.     NX_SoundPlayingPaused,
  49.     NX_SoundRecordingPending,
  50.     NX_SoundPlayingPending,
  51.     NX_SoundFreed = -1,
  52. } NXSoundStatus;
  53.  
  54. /*
  55.  * OBSOLETE status codes - use the NX ones above.
  56.  */
  57. typedef enum {
  58.     SK_STATUS_STOPPED = NX_SoundStopped,
  59.     SK_STATUS_RECORDING = NX_SoundRecording,
  60.     SK_STATUS_PLAYING = NX_SoundPlaying,
  61.     SK_STATUS_INITIALIZED = NX_SoundInitialized,
  62.     SK_STATUS_RECORDING_PAUSED = NX_SoundRecordingPaused,
  63.     SK_STATUS_PLAYING_PAUSED = NX_SoundPlayingPaused,
  64.     SK_STATUS_RECORDING_PENDING = NX_SoundRecordingPending,
  65.     SK_STATUS_PLAYING_PENDING = NX_SoundPlayingPending,
  66.     SK_STATUS_FREED = NX_SoundFreed,
  67. } SKStatus;
  68.  
  69. /*
  70.  * Macho segment name where sounds may be.
  71.  */
  72. #define NX_SOUND_SEGMENT_NAME @"__SND"
  73.  
  74. /*
  75.  * OBSOLETE macho segment name - use the NX one above.
  76.  */
  77. #define SK_SEGMENT_NAME @"__SND"
  78.  
  79.  
  80. /*
  81.  * --------------- Factory Methods
  82.  */
  83.  
  84. + (id)findSoundFor:(NSString *)aName;
  85.  
  86. + (Sound *)addName:(NSString *)name sound:(id)aSound;
  87. + (Sound *)addName:(NSString *)name fromSoundfile:(NSString *)filename;
  88. + (Sound *)addName:(NSString *)name fromSection:(NSString *)sectionName;
  89. + (Sound *)addName:(NSString *)aName fromBundle:(NSBundle *)aBundle;
  90.  
  91. + (Sound *)removeSoundForName:(NSString *)name;
  92.  
  93. + getVolume:(float *)left :(float *)right;
  94. + setVolume:(float)left :(float)right;
  95. + (BOOL)isMuted;
  96. + setMute:(BOOL)aFlag;
  97.  
  98. - (id)initFromSoundfile:(NSString *)filename;
  99. - (id)initFromSection:(NSString *)sectionName;
  100. - (id)initFromPasteboard:(NSPasteboard *)thePboard;
  101.  
  102. - (void)dealloc;
  103. - (BOOL)readSoundFromStream:(NXStream *)stream;
  104. - (void)writeSoundToStream:(NXStream *)stream;
  105. - (void)encodeWithCoder:(NSCoder *)stream;
  106. - (id)initWithCoder:(NSCoder *)stream;
  107. - (id)awakeAfterUsingCoder:(NSCoder *)coder;
  108. - (NSString *)name;
  109. - (BOOL)setName:(NSString *)theName;
  110. - (id)delegate;
  111. - (void)setDelegate:(id)anObject;
  112. - (double)samplingRate;
  113. - (int)sampleCount;
  114. - (double)duration;
  115. - (int)channelCount;
  116. - (char *)info;
  117. - (int)infoSize;
  118. - (void)play:sender;
  119. - (int)play;
  120. - (void)record:sender;
  121. - (int)record;
  122. - (int)samplesProcessed;
  123. - (int)status;
  124. - (int)waitUntilStopped;
  125. - (void)stop:(id)sender;
  126. - (int)stop;
  127. - (void)pause:sender;
  128. - (int)pause;
  129. - (void)resume:sender;
  130. - (int)resume;
  131. - (int)readSoundfile:(NSString *)filename;
  132. - (int)writeSoundfile:(NSString *)filename;
  133. - (int)writeToPasteboard:(NSPasteboard *)thePboard;
  134. - (BOOL)isEmpty;
  135. - (BOOL)isEditable;
  136. - (BOOL)compatibleWith:aSound;
  137. - (BOOL)isPlayable;
  138. - (int)convertToFormat:(int)aFormat
  139.        samplingRate:(double)aRate
  140.        channelCount:(int)aChannelCount;
  141. - (int)convertToFormat:(int)aFormat;
  142. - (int)deleteSamples;
  143. - (int)deleteSamplesAt:(int)startSample count:(int)sampleCount;
  144. - (int)insertSamples:aSound at:(int)startSample;
  145. - (int)copySound:aSound;
  146. - (int)copySamples:aSound at:(int)startSample count:(int)sampleCount;
  147. - (int)compactSamples;
  148. - (BOOL)needsCompacting;
  149. - (unsigned char *)data;
  150. - (int)dataSize;
  151. - (int)dataFormat;
  152. - (int)setDataSize:(int)newDataSize
  153.      dataFormat:(int)newDataFormat
  154.      samplingRate:(double)newSamplingRate
  155.      channelCount:(int)newChannelCount
  156.      infoSize:(int)newInfoSize;
  157. - (SNDSoundStruct *)soundStruct;
  158. - (int)soundStructSize;
  159. - (void)setSoundStruct:(SNDSoundStruct *)aStruct soundStructSize:(int)aSize;
  160. - (SNDSoundStruct *)soundStructBeingProcessed;
  161. - (int)processingError;
  162. - soundBeingProcessed;
  163. - (void)tellDelegate:(SEL)theMessage;
  164.  
  165. @end
  166.  
  167. @interface SoundDelegate : NSObject
  168. - (void)willRecord:sender;
  169. - (void)didRecord:sender;
  170. - (void)willPlay:sender;
  171. - (void)didPlay:sender;
  172. - (void)hadError:sender;
  173. @end
  174.  
  175.