#import <SndView.h>
Public Member Functions | |
(id) | - showCursor |
Displays the SndView's cursor. | |
(BOOL) | - resignFirstResponder |
Resigns the position of first responder. | |
(BOOL) | - becomeFirstResponder |
Promotes the SndView to first responder, and returns YES. | |
(void) | - copy: |
Copies the current selection to the pasteboard. | |
(void) | - cut: |
Deletes the current selection from the SndView, copies it to the pasteboard, and sends a soundDidChange: message to the delegate. | |
(void) | - delete: |
Deletes the current selection from the SndView's Snd and sends the soundDidChange: message to the delegate. | |
(void) | - paste: |
Replaces the current selection with a copy of the sound data currently on the pasteboard. | |
(void) | - selectAll: |
Creates a selection over the SndView's entire Snd. | |
(id) | - delegate |
Returns the SndView's delegate object. | |
(id) | - didPlay:duringPerformance: |
Sent to the delegate just after the SndView's sound is played. | |
(id) | - didRecord: |
Sent to the delegate just after the SndView's sound is recorded into. | |
(int) | - displayMode |
Returns the SndView's display mode, one of SND_SOUNDVIEW_WAVE (oscilloscopic display) or SND_SOUNDVIEW_MINMAX (minimum/maximum display; this is the default). | |
(void) | - drawRect: |
Displays the SndView's sound data. | |
(void) | - getSelection:size: |
Returns the selection by reference. | |
(void) | - setSelection:size: |
Sets the selection to be sampleCount samples wide, starting with sample firstSample (samples are counted from 0). | |
(id) | - hadError: |
Sent to the delegate if an error is encountered during recording or playback of the SndView's sound. | |
(id) | - initWithFrame: |
Initializes the SndView, fitting the object within the rectangle given by frameRect. | |
(BOOL) | - isAutoScale |
Returns YES if the SndView is in autoscaling mode, otherwise returns NO. | |
(BOOL) | - isBezeled |
Returns YES if the SndView has a bezeled border, otherwise returns NO (the default). | |
(BOOL) | - isContinuousSelectionUpdates |
Returns YES if the SndView responds to mouse-dragged events (as set through setContinuousSelectionUpdates:). | |
(BOOL) | - isEditable |
Returns YES if the SndView's sound data can be edited. | |
(BOOL) | - isEnabled |
Returns YES if the SndView is enabled, otherwise returns NO. | |
(BOOL) | - isOptimizedForSpeed |
Returns YES if the SndView is optimized for speedy display. | |
(BOOL) | - isPlayable |
Returns YES if the SndView's sound data can be played without first being converted. | |
(BOOL) | - isEntireSoundVisible |
Returns YES if the receiver is displaying the entire sound within the visible rectangle of it's enclosing scrollview. | |
(void) | - selectionChanged |
Not normally messaged directly by a client class, it's default operation is to inform the delegate that the selection changed if setContinuousSelectionUpdates was set to YES. | |
(void) | - mouseDown: |
Allows a selection to be defined by clicking and dragging the mouse. | |
(void) | - pasteboard:provideDataForType: |
Places the SndView's entire sound on the given pasteboard. | |
(void) | - pause: |
Pauses the current playback or recording session by invoking Snd's pause: method. | |
(void) | - play: |
Play the current selection by invoking Snd's play: method. | |
(void) | - resume: |
Resumes the current playback or recording session by invoking Snd's resume: method. | |
(void) | - record: |
Replaces the SndView's current selection with newly recorded material. | |
(void) | - stop: |
Stops the SndView's current recording or playback. | |
(BOOL) | - readSelectionFromPasteboard: |
Replaces the SndView's current selection with the sound data on the given pasteboard. | |
(void) | - setAmplitudeZoom: |
Sets the current vertical amplitude axis zoom factor. | |
(float) | - amplitudeZoom |
Returns the current vertical amplitude axis zoom factor. | |
(float) | - reductionFactor |
Returns the SndView's reduction factor in the horizontal time axis. | |
(BOOL) | - setReductionFactor: |
Assigns the reduction factor in the horizontal time axis. | |
(void) | - scaleTo: |
Sets the proportion of the sound displayed within the SndView frame. | |
(void) | - scaleToFit |
Recomputes the SndView's reduction factor to fit the sound data (horizontally) within the current frame. | |
(void) | - resizeToFit |
Resizes the SndView's frame (horizontally) to maintain a constant reduction factor. | |
(void) | - resizeToFit: |
Resizes the SndView's frame (horizontally) to maintain a constant reduction factor. | |
(void) | - resizeToScale: |
Resizes the sound within the frame to a normalized scale. | |
(id) | - setAutoscale: |
Sets the SndView's automatic scaling mode, used to determine how the SndView is redisplayed when its data changes. | |
(void) | - setBezeled: |
If aFlag is YES, the display is given a bezeled border. | |
(void) | - setContinuousSelectionUpdates: |
Sets the state of continuous action messages. | |
(void) | - setDelegate: |
Sets the SndView's delegate to anObject. | |
(void) | - setDisplayMode: |
Sets the SndView's display mode, either SND_SOUNDVIEW_WAVE or SND_SOUNDVIEW_MINMAX (the default). | |
(void) | - setEditable: |
Enables or disables editing in the SndView as aFlag is YES or NO. | |
(void) | - setEnabled: |
Enables or disables the SndView as aFlag is YES or NO. | |
(void) | - setOptimizedForSpeed: |
Sets the SndView to optimize its display mechanism. | |
(void) | - setSound: |
Sets the SndView's Snd object to aSound. | |
(Snd *) | - sound |
Returns the SndView's Snd object being displayed. | |
(void) | - setFrameSize: |
Sets the width and height of the SndView's frame. | |
(Snd *) | - soundBeingProcessed |
Returns the Snd object that's currently being played or recorded into. | |
(void) | - tellDelegate: |
Sends theMessage to the SndView's delegate with the SndView as the argument. | |
(void) | - tellDelegate:duringPerformance: |
Sends theMessage to the SndView's delegate with the SndView as the argument. | |
(id) | - validRequestorForSendType:returnType: |
You never invoke this method; it's implemented to support services that act on sound data. | |
(void) | - willPlay:duringPerformance: |
Sent to the delegate just before the SndView's sound is played. | |
(void) | - willRecord: |
Sent to the delegate just before the SndView's sound is recorded into. | |
(BOOL) | - writeSelectionToPasteboard:types: |
write the selected region of sound to the pasteboard. | |
(void) | - invalidateCache |
Used if you change the data of a sound which is being used in a SndView in any way, to inform the SndView. | |
(void) | - setDrawsCrosses: |
Determines whether individual samples should be drawn as crosses when displaying sounds at extreme magnification. | |
(BOOL) | - drawsCrosses |
Returns whether individual samples are drawn as crosses at extreme magnification. | |
(BOOL) | - setStereoMode: |
Determines how to draw multichannel sounds. | |
(enum SndViewStereoMode) | - getStereoMode |
Returns the mode of drawing multichannel sounds. | |
(void) | - setSelectionColor: |
Sets the selection colour. | |
(NSColor *) | - selectionColor |
Returns the current selection colour. | |
(void) | - setBackgroundColor: |
Sets the background colour. | |
(NSColor *) | - backgroundColor |
Returns the current background colour. | |
(void) | - setForegroundColor: |
Sets the foreground colour. | |
(NSColor *) | - foregroundColor |
Returns the current foreground colour. | |
(void) | - setDragIcon: |
Sets the icon used when dragging selections from the SndView. | |
(NSImage *) | - dragIcon |
Returns the current NSImage instance used when dragging a selection from the receiver. |
A SndView object provides a graphical representation of sound data. This data is taken from an associated Snd object. In addition to displaying a Snd object's data, a SndView provides methods that let you play and record into the Snd object, and perform simple cut, copy, and paste editing of its data. A cursor into the display is provided, allowing the user to set the insertion point and to create a selection over the sound data.
Sound Display
Sounds are displayed on a two-dimensional graph. The amplitudes of individual samples are measured vertically and plotted against time, which proceeds left to right along the horizontal axis. A SndView's coordinate system is scaled and translated (vertically) so full amplitude fits within the bounds rectangle with 0.0 amplitude running through the center of the view.
For many sounds, the length of the sound data in samples is greater than the horizontal measure of the bounds rectangle. A SndView employs a reduction factor to determine the ratio of samples to display units and plots the minimum and maximum amplitude values of the samples within that ratio. For example, a reduction factor of 10.0 means that the minimum and maximum values among the first ten samples are plotted in the first display unit, the minimum and maximum values of the next ten samples are displayed in the second display unit and so on.
Lines are drawn between the chosen values to yield a continuous shape. Two drawing modes are provided:
As you zoom in (as the reduction factor decreases), the two drawing modes become indistinguishable.
Autoscaling the Display
When a SndView's sound data changes (due to editing or recording), the manner in which the SndView is redisplayed depends on its autoscale flag. With autoscaling disabled, the SndView's frame grows or shrinks (horizontally) to fit the new sound data and the reduction factor is unchanged. If autoscaling is enabled, the reduction factor is automatically recomputed to maintain a constant frame size. By default, autoscaling is disabled; this is to accommodate the use of a SndView object as the document of an NSScrollView.
When the reductionFactor starts to climb, more samples are crammed into each horizontal pixel in the view. Each pixel shows the maximum and minimum value represented within that number of samples.
To display a very large sound in a small view, the reductionFactor may be in the 1000's. This means that eg 10,000 samples may need to be read, times the width of the view (perhaps 300). SndView seeks to reduce this number of reads by skipping samples when they are nowhere near its current maximum or minimum.
- (BOOL) resignFirstResponder |
Resigns the position of first responder.
- (BOOL) becomeFirstResponder |
Promotes the SndView to first responder, and returns YES.
- (void) copy: | (id) | sender |
Copies the current selection to the pasteboard.
sender | is an id. |
- (void) cut: | (id) | sender |
Deletes the current selection from the SndView, copies it to the pasteboard, and sends a soundDidChange: message to the delegate.
sender | is an id. The insertion point is positioned to where the selection used to start. |
- (void) delete: | (id) | sender |
Deletes the current selection from the SndView's Snd and sends the soundDidChange: message to the delegate.
sender | is an id. The deletion isn't placed on the pasteboard. |
- (void) paste: | (id) | sender |
Replaces the current selection with a copy of the sound data currently on the pasteboard.
sender | is an id. If there is no selection the pasteboard data is inserted at the cursor position. The pasteboard data must be compatible with the SndView's data, as determined by the Snd method compatibleWithSound:. If the paste is successful, the soundDidChange: message is sent to the delegate. |
- (void) selectAll: | (id) | sender |
- (id) delegate |
Returns the SndView's delegate object.
- (id) didPlay: | (id) | sender | ||
duringPerformance: | (SndPerformance *) | performance | ||
Sent to the delegate just after the SndView's sound is played.
Method implemented by the delegate. Used to redirect delegate messages from the SndView's Snd object; you never invoke this method directly.
sender | is an id. | |
performance | is a SndPerformance. |
- (id) didRecord: | (id) | sender |
Sent to the delegate just after the SndView's sound is recorded into.
Method implemented by the delegate. Used to redirect delegate messages from the SndView's Snd object; you never invoke this method directly.
sender | is an id. |
- (int) displayMode |
Returns the SndView's display mode, one of SND_SOUNDVIEW_WAVE (oscilloscopic display) or SND_SOUNDVIEW_MINMAX (minimum/maximum display; this is the default).
- (void) drawRect: | (NSRect) | rects |
Displays the SndView's sound data.
rects | is a NSRect. The selection is highlighted and the cursor is drawn (if it isn't currently hidden). |
- (void) getSelection: | (unsigned int *) | firstSample | ||
size: | (unsigned int *) | sampleCount | ||
Returns the selection by reference.
firstSample | is an unsigned int *. | |
sampleCount | is an unsigned int *. The index of the selection's first sample (counting from 0) is returned in firstSample. The size of the selection in samples is returned in sampleCount. |
- (void) setSelection: | (int) | firstSample | ||
size: | (int) | sampleCount | ||
Sets the selection to be sampleCount samples wide, starting with sample firstSample (samples are counted from 0).
firstSample | is an int. | |
sampleCount | is an int. |
- (id) hadError: | (id) | sender |
Sent to the delegate if an error is encountered during recording or playback of the SndView's sound.
Used to redirect delegate messages from the SndView's Snd object; you never invoke this method directly.
sender | is an id. |
- (id) initWithFrame: | (NSRect) | frameRect |
- (BOOL) isAutoScale |
- (BOOL) isBezeled |
Returns YES if the SndView has a bezeled border, otherwise returns NO (the default).
- (BOOL) isContinuousSelectionUpdates |
Returns YES if the SndView responds to mouse-dragged events (as set through setContinuousSelectionUpdates:).
- (BOOL) isEditable |
Returns YES if the SndView's sound data can be edited.
- (BOOL) isEnabled |
- (BOOL) isOptimizedForSpeed |
Returns YES if the SndView is optimized for speedy display.
- (BOOL) isPlayable |
Returns YES if the SndView's sound data can be played without first being converted.
- (BOOL) isEntireSoundVisible |
Returns YES if the receiver is displaying the entire sound within the visible rectangle of it's enclosing scrollview.
- (void) selectionChanged |
Not normally messaged directly by a client class, it's default operation is to inform the delegate that the selection changed if setContinuousSelectionUpdates was set to YES.
This allows subclasses to know when selections change and override default behaviour.
- (void) mouseDown: | (NSEvent *) | theEvent |
Allows a selection to be defined by clicking and dragging the mouse.
theEvent | is an NSEvent instance. This method takes control until a mouse-up occurs. While dragging, the selected region is highlighted. On mouse up, the delegate is sent the selectionChanged: message. If isContinuous is YES, selectionChanged: messages are also sent while the mouse is being dragged. You never invoke this method; it's invoked automatically in response to the user's actions. |
- (void) pasteboard: | (NSPasteboard *) | thePasteboard | ||
provideDataForType: | (NSString *) | pboardType | ||
Places the SndView's entire sound on the given pasteboard.
thePasteboard | is a NSPasteboard instance. | |
pboardType | is a NSString instance. Currently, the type argument must be “SndPasteboardType”, the pasteboard type that represents sound data. |
- (void) pause: | (id) | sender |
Pauses the current playback or recording session by invoking Snd's pause: method.
sender | is an id. |
- (void) play: | (id) | sender |
Play the current selection by invoking Snd's play: method.
If there is no selection, the SndView's entire Snd is played. The willPlay: message is sent to the delegate before the selection is played; didPlay: is sent when the selection is done playing.
sender | is an id. |
- (void) resume: | (id) | sender |
Resumes the current playback or recording session by invoking Snd's resume: method.
sender | is an id. |
- (void) record: | (id) | sender |
Replaces the SndView's current selection with newly recorded material.
sender | is an id. If there is no selection, the recording is inserted at the cursor. The willRecord: message is sent to the delegate before the recording is started; didRecord: is sent after the recording has completed. Recorded data is always taken from the CODEC microphone input. |
- (void) stop: | (id) | sender |
Stops the SndView's current recording or playback.
sender | is an id. |
- (BOOL) readSelectionFromPasteboard: | (NSPasteboard *) | thePasteboard |
Replaces the SndView's current selection with the sound data on the given pasteboard.
thePasteboard | is a NSPasteboard instance. |
- (void) setAmplitudeZoom: | (float) | newAmplitudeZoom |
Sets the current vertical amplitude axis zoom factor.
newAmplitudeZoom | The new amplitude zoom factor. If 1.0, this displays a full amplitude signal in the maximum vertical view width. If greater than 1.0 a signal will be zoomed and clipped against the view. If less than 1.0 the signal will be reduced within the view. Values less than or equal to zero are not set. |
- (float) amplitudeZoom |
Returns the current vertical amplitude axis zoom factor.
- (float) reductionFactor |
Returns the SndView's reduction factor in the horizontal time axis.
reductionFactor = sampleCount / displayUnits
- (BOOL) setReductionFactor: | (float) | reductionFactor |
Assigns the reduction factor in the horizontal time axis.
reductionFactor | is a float. |
displayUnits = sampleCount / reductionFactor
Increasing the reduction factor zooms out, decreasing zooms in on the data. If autodisplaying is enabled, the Snd is automatically redisplayed.
If the SndView is in autoscaling mode, or reductionFactor is less than 1.0, the method avoids computing the frame size and returns NO. (In autoscaling mode, the reduction factor is automatically recomputed when the sound data changes - see scaleToFit:.) Otherwise, the method returns YES. If reductionFactor is the same as the current reduction factor, the method returns immediately without recomputing the frame size.
- (void) scaleTo: | (float) | scaleRatio |
Sets the proportion of the sound displayed within the SndView frame.
Recomputes the SndViews reduction factor to fit a portion of the sound data (horizontally) within the views frame.
scaleRatio | The ratio of displayed content within the frame 1.0 = entire sound, 0.5 = half the sound etc. |
- (void) scaleToFit |
Recomputes the SndView's reduction factor to fit the sound data (horizontally) within the current frame.
Invoked automatically when the SndView's data changes and the SndView is in autoscale mode. If the SndView isn't in autoscale mode, resizeToFit is invoked when the data changes. You never invoke this method directly; a subclass can reimplement this method to provide specialized behavior.
- (void) resizeToFit |
Resizes the SndView's frame (horizontally) to maintain a constant reduction factor.
This method is invoked automatically when the SndView's data changes and the SndView isn't in autoscale mode. If the SndView is in autoscale mode, scaleToFit is invoked when the data changes. You never invoke this method directly; a subclass can reimplement this method to provide specialized behavior.
- (void) resizeToFit: | (BOOL) | withAutoscaling |
Resizes the SndView's frame (horizontally) to maintain a constant reduction factor.
withAutoscaling | is a BOOL. This method is invoked automatically when the SndView's data changes and the SndView isn't in autoscale mode. If the SndView is in autoscale mode, scaleToFit is invoked when the data changes. You never invoke this method directly; a subclass can reimplement this method to provide specialized behavior. |
- (void) resizeToScale: | (float) | scaleRatio |
Resizes the sound within the frame to a normalized scale.
scaleRatio | Scaling of the sound within the frame: 0 > scaleRatio <= 1.0 |
- (id) setAutoscale: | (BOOL) | aFlag |
Sets the SndView's automatic scaling mode, used to determine how the SndView is redisplayed when its data changes.
aFlag | is a BOOL. With autoscaling enabled (aFlag is YES), the SndView's reduction factor is recomputed so the sound data fits within the view frame. If it's disabled (aFlag is NO), the frame is resized and the reduction factor is unchanged. If the SndView is in an NSScrollView, autoscaling should be disabled (autoscaling is disabled by default). |
- (void) setBezeled: | (BOOL) | aFlag |
- (void) setContinuousSelectionUpdates: | (BOOL) | aFlag |
Sets the state of continuous action messages.
aFlag | is a BOOL. If aFlag is YES, selectionChanged: messages are sent to the delegate as the mouse is being dragged. If NO, the message is sent only on mouse up. The default is NO. |
- (void) setDelegate: | (id) | anObject |
Sets the SndView's delegate to anObject.
anObject | is an id. The delegate is sent messages when the user changes or acts on the selection. |
- (void) setDisplayMode: | (int) | aMode |
Sets the SndView's display mode, either SND_SOUNDVIEW_WAVE or SND_SOUNDVIEW_MINMAX (the default).
aMode | is an int. If autodisplaying is enabled, the Snd is automatically redisplayed. |
- (void) setEditable: | (BOOL) | aFlag |
- (void) setEnabled: | (BOOL) | aFlag |
- (void) setOptimizedForSpeed: | (BOOL) | flag |
Sets the SndView to optimize its display mechanism.
flag | is a BOOL. Optimization greatly increases the speed with which data can be drawn, particularly for large sounds. It does so at the loss of some precision in representing the sound data; however, these inaccuracies are corrected as you zoom in on the data. All SndView's are optimized by default. |
- (void) setFrameSize: | (NSSize) | newSize |
Sets the width and height of the SndView's frame.
If autodisplaying is enabled, the SndView is automatically redisplayed.
newSize | is a NSSize. |
- (Snd *) soundBeingProcessed |
Returns the Snd object that's currently being played or recorded into.
- (void) tellDelegate: | (SEL) | theMessage |
Sends theMessage to the SndView's delegate with the SndView as the argument.
theMessage | is a SEL. If the delegate doesn't respond to the message, then it isn't sent. You normally never invoke this method; it's invoked automatically when an action, such as playing or editing, is performed. However, you can invoke it in the design of a SndView subclass. |
- (void) tellDelegate: | (SEL) | theMessage | ||
duringPerformance: | (SndPerformance *) | performance | ||
Sends theMessage to the SndView's delegate with the SndView as the argument.
If the delegate doesn't respond to the message, then it isn't sent. You normally never invoke this method; it's invoked automatically when an action, such as playing or editing, is performed. However, you can invoke it in the design of a SndView subclass.
theMessage | is a SEL. | |
performance | The SndPerformance instance performing when the message is sent. |
- (id) validRequestorForSendType: | (NSString *) | sendType | ||
returnType: | (NSString *) | returnType | ||
You never invoke this method; it's implemented to support services that act on sound data.
sendType | is a NSString instance. | |
returnType | is a NSString instance. |
- (void) willPlay: | (id) | sender | ||
duringPerformance: | (SndPerformance *) | performance | ||
Sent to the delegate just before the SndView's sound is played.
sender | is an id. | |
performance | A SndPerformance instance indicating which performance is about to play. |
- (void) willRecord: | (id) | sender |
Sent to the delegate just before the SndView's sound is recorded into.
sender | is an id. |
- (BOOL) writeSelectionToPasteboard: | (NSPasteboard *) | thePasteboard | ||
types: | (NSArray *) | pboardTypes | ||
write the selected region of sound to the pasteboard.
thePasteboard | The pasteboard to receive the sound region. | |
pboardTypes | An array of ? sound formats? |
- (void) invalidateCache |
- (void) setDrawsCrosses: | (BOOL) | aFlag |
Determines whether individual samples should be drawn as crosses when displaying sounds at extreme magnification.
Defaults to YES.
aFlag | YES to draw crosses linked by line segments, NO to draw samples as points linked by line segments. |
- (BOOL) drawsCrosses |
Returns whether individual samples are drawn as crosses at extreme magnification.
- (BOOL) setStereoMode: | (enum SndViewStereoMode) | stereoMode |
Determines how to draw multichannel sounds.
stereoMode | one of the values SV_LEFTONLY, SV_RIGHTONLY, SV_STEREOMODE |
- (enum SndViewStereoMode) getStereoMode |
Returns the mode of drawing multichannel sounds.
- (void) setSelectionColor: | (NSColor *) | color |
Sets the selection colour.
color | An NSColor. |
- (NSColor *) selectionColor |
Returns the current selection colour.
- (void) setBackgroundColor: | (NSColor *) | color |
Sets the background colour.
color | An NSColor. |
- (NSColor *) backgroundColor |
Returns the current background colour.
- (void) setForegroundColor: | (NSColor *) | color |
Sets the foreground colour.
color | An NSColor instance. |
- (NSColor *) foregroundColor |
Returns the current foreground colour.
- (void) setDragIcon: | (NSImage *) | newDragIcon |
Sets the icon used when dragging selections from the SndView.
If the default workspace image icon is desired, use: [sndView setDragIcon: [[NSWorkspace sharedWorkspace] iconForFileType: [Snd defaultFileExtension]]];
newDragIcon | An NSImage instance to be used as the drag image. If nil, the icon to appear will be the visible region of the selected SndView. |
- (NSImage *) dragIcon |
Returns the current NSImage instance used when dragging a selection from the receiver.
If nil, the icon to appear will be the visible region of the selected SndView.