home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscSoundPalette / MiscSoundUtil.subproj / MiscVolumeMeter.h < prev    next >
Encoding:
Text File  |  1995-03-25  |  4.5 KB  |  170 lines

  1. /*
  2.  
  3. MiscVolumeMeter
  4. Version 1.2
  5. Copyright (c) 1995 by Sean Luke
  6. Donated to the MiscKit
  7.  
  8. Permission to use, copy, modify, and distribute this material 
  9. for any purpose and without fee, under the restrictions as noted 
  10. in the MiscKit copyright notice, is hereby granted, provided that
  11. the MiscKit copyright notice and this permission notice 
  12. appear in all source copies, and that the author's name shall not
  13. be used in advertising or publicity pertaining to this 
  14. material without the specific, prior written permission 
  15. of the author.  SEAN O. LUKE  MAKES NO REPRESENTATIONS ABOUT THE
  16. ACCURACY OR SUITABILITY OF THIS MATERIAL FOR ANY PURPOSE.  
  17. IT IS PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  18.  
  19. */
  20.  
  21.  
  22. #import <appkit/appkit.h>
  23. #import <soundkit/soundkit.h>
  24.  
  25.  
  26.  
  27. // Defines
  28.  
  29. #define VOLUMEMETER_DISPLAYTYPE_NONE        0
  30. #define VOLUMEMETER_DISPLAYTYPE_BEZEL        1
  31.  
  32. #define VOLUMEMETER_BACKGROUND_INSET     2.0
  33. #define VOLUMEMETER_VALUE_INSET            6.0
  34. #define VOLUMEMETER_LEFT_END            0.4
  35. #define VOLUMEMETER_RIGHT_BEGIN            0.6
  36.  
  37. #define VOLUMEMETER_TIMED_ENTRY_SPEED    0.1
  38. #define VOLUMEMETER_MAX_REFRESHES        256
  39. #define VOLUMEMETER_STD_REFRESHES        4
  40.  
  41.  
  42.  
  43. // Public Convenience Functions
  44.  
  45. BOOL VOLUMEMETER_can_draw(const NXRect* aRect);
  46.     // given aRect, determines if there's enough space to draw a meter
  47.  
  48. BOOL VOLUMEMETER_draw_wide(const NXRect* aRect);
  49.     // given aRect, determines if the meter should draw wide
  50.     // (as opposed to tall)
  51.  
  52.  
  53. @interface MiscVolumeMeter:View
  54. {
  55.     NXSoundIn*         input_device;
  56.     NXSoundOut*     output_device;
  57.     id                sound;                    // can be a sound or soundview
  58.     id                delegate;
  59.     BOOL            input;                    // set to input.  Default is NO
  60.     BOOL            running;                // set running.  Default is NO
  61.     BOOL            bezeled;
  62.     BOOL            peak_bubble_displayed;
  63.     BOOL            stereo;
  64.     float            background_gray;
  65.     float            value_gray;
  66.     float            bubble_gray;
  67.     float            refresh;
  68.     int                refreshes_per_new_peak_bubble;
  69.     int                refresh_tally;
  70.     float            refreshes_left[VOLUMEMETER_MAX_REFRESHES];
  71.     float            refreshes_right[VOLUMEMETER_MAX_REFRESHES];
  72.     int                current_max_refresh_left;
  73.     int                current_max_refresh_right;
  74.     DPSTimedEntry    teNum;                    // timed entry which displays
  75. }
  76.  
  77.  
  78. // constructors and destructors
  79.  
  80. - initFrame:(const NXRect*) frameRect;
  81. - free;
  82. - awake;
  83.  
  84. // drawing
  85.  
  86. - drawSelf:(const NXRect*) rects:(int) rectCount;
  87.  
  88. // Setting parameters
  89.  
  90. - setDelegate:this_delegate;
  91. - setMono;
  92. - setStereo;
  93. - setBackgroundGray:(float) this_value;    // 0 <= this_value <= 1
  94. - setValueGray:(float) this_value;        // 0 <= this_value <= 1
  95. - setBubbleGray:(float) this_value;        // 0 <= this_value <= 1
  96. - setBezeled:(BOOL) yes_or_no;
  97. - setPeakBubbleDisplayed:(BOOL) yes_or_no;
  98. - setToInput;                            // returns self if usable, NULL if not
  99. - setToOutput;                            // returns self if usable, NULL if not
  100. - setRefresh:(float) number_seconds;    // sets update speed in fraction of 
  101.                                         // seconds or whole seconds.
  102.                                         // default is .1 second
  103. - setRefreshesPerNewPeakBubble:(int) number_refreshes;        
  104.                                         // VOLUMEMETER_MAX_REFRESHES max, 1 min
  105. // Querying the object
  106.  
  107. - delegate;
  108. - (BOOL) isStereo:sender;
  109. - (float) backgroundGray;
  110. - (float) valueGray;
  111. - (float) bubbleGray;
  112. - (BOOL) isBezeled:sender;
  113. - (BOOL) peakBubbleDisplayed:sender;
  114. - (BOOL) isInput:sender;
  115. - (float) refresh:sender;
  116. - (int) refreshesPerPeakBubble:sender;
  117.  
  118. // Operating the meter
  119.  
  120. - reclaim;                                // tries to reclaim devices
  121. - run;
  122. - stop;
  123.  
  124. // Archiving
  125.  
  126. - read:(NXTypedStream*) stream;
  127. - write:(NXTypedStream*) stream;
  128.  
  129. // Locking Methods.  This locks the meter to only 
  130. // display when a certain sound or soundview is recording or playing
  131.  
  132. - setSound:this_sound;                    // can be a sound or a soundview
  133. - sound;
  134.  
  135. // Action versions of above methods
  136.  
  137. - setMono:sender;
  138. - setStereo:sender;
  139. - setToInput:sender;
  140. - setToOutput:sender;
  141. - run:sender;
  142. - stop:sender;
  143.  
  144. // Convenience methods responding to window action.
  145. // This allows a window to open/close and start up / shut down the meter
  146.  
  147. - windowDidBecomeKey:sender;
  148. - windowDidBecomeMain:sender;
  149. - windowDidDeminiaturize:sender;
  150. - windowDidMiniaturize:sender;
  151. - windowWillClose:sender;
  152.  
  153.  
  154.  
  155.  
  156.  
  157. // Methods implementable by delegates of VolumeMeter:
  158. // (VolumeMeter itself only defines them here--it doesn't do a thing with 'em)
  159.  
  160. - meterWillUpdateOnOwn:sender;    // ...the volume meter will update/display
  161.                                 // (called before meterWillUpdate and before
  162.                                 // the display method is called (so meter
  163.                                 // has not locked focus yet))
  164. - meterWillUpdate:sender;        //    ...the volume meter will update/display
  165.                                 // (possibly on its own)
  166. - meterDidUpdate:sender;        //    ...the volume meter updated/displayed
  167.                                 // (possibly on its own)
  168.  
  169. @end
  170.