#import <SndMeter.h>
Public Member Functions | |
(id) | - initWithFrame: |
Initializes the SndMeter, fitting its graphic components within frameRect. | |
(float) | - holdTime |
Returns the SndMeter's hold time - the amount of time during which a peak amplitude is detected and displayed by the peak bubble - in seconds. | |
(void) | - setHoldTime: |
Sets the SndMeter's peak value hold time in seconds. | |
(void) | - setBackgroundColor: |
Sets the SndMeter's background color. | |
(NSColor *) | - backgroundColor |
Returns the SndMeter's background color. | |
(void) | - setForegroundColor: |
Sets the SndMeter's running bar color. | |
(NSColor *) | - foregroundColor |
Returns the color of the running bar. | |
(void) | - setPeakColor: |
Sets the SndMeter's peak bubble color. | |
(NSColor *) | - peakColor |
Returns the SndMeter's peak bubble gray. | |
(Snd *) | - sound |
Returns the Snd object that the SndMeter is metering. | |
(void) | - setSound: |
Sets the SndMeter's Snd object. | |
(void) | - run: |
Starts the SndMeter running. | |
(void) | - stop: |
Stops the SndMeter's metering activity. | |
(BOOL) | - isRunning |
Returns YES if the SndMeter is currently running; otherwise, returns NO. | |
(BOOL) | - isBezeled |
Returns YES (the default) if the SndMeter has a border; otherwise, returns NO. | |
(void) | - setBezeled: |
If aFlag is YES, a bezeled border is drawn around the SndMeter. | |
(void) | - setFloatValue: |
Sets the current running value to aValue. | |
(float) | - floatValue |
Returns the current running amplitude value as a floating-point number between 0.0 and 1.0. | |
(float) | - peakValue |
Returns the most recently detected peak value as a floating-point number between 0.0 and 1.0. | |
(float) | - minValue |
Returns the minimum running value so far. | |
(float) | - maxValue |
Returns the maximum running value so far. | |
(void) | - drawRect: |
Draws all the components of the SndMeter (frame, running bar, and peak bubble). | |
(void) | - drawCurrentValue |
Draws the SndMeter's running bar and peak bubble. |
A SndMeter is a view that displays the amplitude level of a sound as it's being recorded or played back. There are two working parts to the meter: A continuously-updated “running bar” that lengthens ands shrinks to depict the current amplitude level, and a “peak bubble” that displays and holds the greatest amplitude that was detected within the last few samples. An optional bezeled border is drawn around the object's frame.
To use a SndMeter, you must first associate it with a Snd object, through the setSound: method, and then send the SndMeter a run: message. To stop the meter's display, you send the object a stop: message. Neither run:nor stop: affect the performance of the meter's sound.
You can retrieve a SndMeter's running and peak values through the floatValue and peakValue methods. The values that these methods return are valid only while the SndMeter is running. A SndMeter also keeps track of the minimum and maximum amplitude over the duration of a run; these can be retrieved through minValue and maxValue. All SndMeter amplitude levels are normalized to fit between 0.0 (inaudible) and 1.0 (maximum amplitude).
- (id) initWithFrame: | (NSRect) | frameRect |
Initializes the SndMeter, fitting its graphic components within frameRect.
frameRect | is a NSRect. |
Attribute | Value | ||
Peak hold time | 0.7 seconds | ||
Background gray | [NSColor darkGrayColor] | Running bar gray | [NSColor lightGrayColor] |
Peak bubble gray | [NSColor whiteColor] | Border | bezeled |
- (float) holdTime |
Returns the SndMeter's hold time - the amount of time during which a peak amplitude is detected and displayed by the peak bubble - in seconds.
The default is 0.7 seconds.
- (void) setHoldTime: | (float) | seconds |
Sets the SndMeter's peak value hold time in seconds.
This is the amount of time during which peak amplitudes are detected and held by the peak bubble.
seconds | is a float. |
- (void) setBackgroundColor: | (NSColor *) | aColor |
Sets the SndMeter's background color.
The default is NSColor's darkGrayColor.
aColor | is a NSColor instance. |
- (NSColor *) backgroundColor |
Returns the SndMeter's background color.
The default background color is NSColor's darkGrayColor.
- (void) setForegroundColor: | (NSColor *) | aColor |
Sets the SndMeter's running bar color.
The default is NSColor's lightGrayColor.
aColor | is a NSColor instance. |
- (NSColor *) foregroundColor |
Returns the color of the running bar.
The default foreground color is NSColor's lightGrayColor.
- (void) setPeakColor: | (NSColor *) | aColor |
Sets the SndMeter's peak bubble color.
The default is NSColor's whiteColor.
aColor | is a NSColor instance. |
- (NSColor *) peakColor |
Returns the SndMeter's peak bubble gray.
The default is NSColor's whiteColor.
- (Snd *) sound |
- (void) setSound: | (Snd *) | aSound |
- (void) run: | (id) | sender |
- (void) stop: | (id) | sender |
- (BOOL) isRunning |
- (BOOL) isBezeled |
- (void) setBezeled: | (BOOL) | aFlag |
- (void) setFloatValue: | (float) | aValue |
- (float) floatValue |
Returns the current running amplitude value as a floating-point number between 0.0 and 1.0.
This is the amplitude level that's displayed by the running bar.
- (float) peakValue |
Returns the most recently detected peak value as a floating-point number between 0.0 and 1.0.
This is the amplitude level that's displayed by the peak bubble.
- (float) minValue |
- (float) maxValue |
- (void) drawRect: | (NSRect) | rects |
Draws all the components of the SndMeter (frame, running bar, and peak bubble).
You never invoke this method directly; however, you can override it in a subclass to change the way the components are displayed.
rects | is a NSRect. |
- (void) drawCurrentValue |
Draws the SndMeter's running bar and peak bubble.
You never invoke this method directly; it's invoked automatically while the SndMeter is running. You can override this method to change the look of the running bar and peak bubble.