home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / soundkit / NXSoundDevice.h < prev    next >
Text File  |  1992-04-27  |  3KB  |  131 lines

  1. /*
  2.  * NXSoundDevice.h
  3.  *
  4.  * Abstract superclass for sound devices.
  5.  *
  6.  * Copyright (c) 1991, NeXT Computer, Inc.  All rights reserved. 
  7.  */
  8.  
  9. #import <objc/Object.h>
  10. #import <mach/cthreads.h>
  11. #import <mach/mach.h>
  12. #import <limits.h>
  13.  
  14. /*
  15.  * Default message timeout.
  16.  */
  17. #define NX_SOUNDDEVICE_TIMEOUT_MAX    UINT_MAX;
  18.  
  19. /*
  20.  * Error codes for devices.
  21.  */
  22. #define NX_SOUNDDEVICE_ERROR_MIN    300
  23. #define NX_SOUNDDEVICE_ERROR_MAX    399
  24.  
  25. typedef enum _NXSoundDeviceError {
  26.     NX_SoundDeviceErrorNone = 0,
  27.     NX_SoundDeviceErrorKernel = NX_SOUNDDEVICE_ERROR_MIN,
  28.     NX_SoundDeviceErrorTimeout,
  29.     NX_SoundDeviceErrorLookUp,
  30.     NX_SoundDeviceErrorHost,
  31.     NX_SoundDeviceErrorNoDevice,
  32.     NX_SoundDeviceErrorNotActive,
  33.     NX_SoundDeviceErrorTag,
  34.     NX_SoundDeviceErrorMax = NX_SOUNDDEVICE_ERROR_MAX
  35. } NXSoundDeviceError;
  36.  
  37. /*
  38.  * Convert dB to linear, and linear to dB.
  39. 4Q extern float SNDConvertDecibelsToLinear(float dB);
  40. extern float SNDConvertLinearToDecibels(float linear);
  41.  
  42. @interface NXSoundDevice:Object
  43. {
  44.     const char        *_host;
  45.     port_t        _devicePort;
  46.     port_t        _streamOwnerPort;
  47.     unsigned int    _bufferSize;
  48.     unsigned int    _bufferCount;
  49.     unsigned int    _isDetectingPeaks;
  50.     unsigned int    _peakHistory;
  51.     kern_return_t    _kernelError;
  52.     NXSoundDeviceError    _lastError;
  53.     int            _reserved;
  54. }
  55.  
  56. /*
  57.  * Factory methods.
  58.  */
  59. + (const char *)textForError:(NXSoundDeviceError)errorCode;
  60. + (unsigned int)timeout;
  61. + setTimeout:(unsigned int)milliseconds;
  62. + (port_t)replyPort;
  63. + (BOOL)isUsingSeparateThread;
  64. + setUseSeparateThread:(BOOL)flag;
  65. + (cthread_t)replyThread;
  66. + (int)threadThreshold;
  67. + setThreadThreshold:(int)threshold;
  68.  
  69. /*
  70.  * Initialize on local or remote host.
  71.  * Returns nil if sound resources cannot be accessed.
  72.  */
  73. - init;
  74. - initOnHost:(const char *)hostName;
  75.  
  76. /*
  77.  * Get host name.
  78.  */
  79. - (const char *)host;
  80.  
  81. /*
  82.  * Get ports.
  83.  */
  84. - (port_t)devicePort;
  85. - (port_t)streamOwnerPort;
  86.  
  87. /*
  88.  * Reserve for exclusive use.
  89.  * Default is NO.
  90.  */
  91. - (BOOL)isReserved;
  92. - (NXSoundDeviceError)setReserved:(BOOL)flag;
  93.  
  94. /*
  95.  * Get and set buffer options.
  96.  */
  97. - (unsigned int)bufferSize;
  98. - (NXSoundDeviceError)setBufferSize:(unsigned int)bytes;
  99. - (unsigned int)bufferCount;
  100. - (NXSoundDeviceError)setBufferCount:(unsigned int)count;
  101.  
  102. /*
  103.  * Synchronized stream control.
  104.  */
  105. - pauseStreams:sender;
  106. - resumeStreams:sender;
  107. - abortStreams:sender;
  108.  
  109. /*
  110.  * Peak detection.
  111.  * Default is NO peak detection.
  112.  */
  113. - (BOOL)isDetectingPeaks;
  114. - (NXSoundDeviceError)setDetectPeaks:(BOOL)flag;
  115. - (unsigned int)peakHistory;
  116. - (NXSoundDeviceError)setPeakHistory:(unsigned int)bufferCount;
  117. - (NXSoundDeviceError)getPeakLeft:(float *)leftAmp
  118.                             right:(float *)rightAmp;
  119.  
  120. /*
  121.  * Error handling.
  122.  */
  123. - (NXSoundDeviceError)lastError;
  124.  
  125. /*
  126.  * Release resources and free object.
  127.  */
  128. - free;
  129.  
  130. @end
  131.