MusicKit  0.0.0
SndView.h
00001 
00002 //
00003 //  $Id$
00004 //
00005 //  Description: Class defining an AppKit view of a Snd object.
00006 //
00007 //  Original Author: Stephen Brandon
00008 //
00009 //  Design substantially based on ideas from Sound Kit, Release 2.0, Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved.
00010 //  Additions Copyright (c) 1999 Stephen Brandon and the University of Glasgow
00011 //  Additions Copyright (c) 2001, The MusicKit Project.  All rights reserved.
00012 //
00013 //  Legal Statement Covering Additions by Stephen Brandon and the University of Glasgow:
00014 //
00015 //  This framework and all source code supplied with it, except where specified, are
00016 //  Copyright Stephen Brandon and the University of Glasgow, 1999. You are free to use
00017 //  the source code for any purpose, including commercial applications, as long as you
00018 //  reproduce this notice on all such software.
00019 //
00020 //  Software production is complex and we cannot warrant that the Software will be
00021 //  error free.  Further, we will not be liable to you if the Software is not fit
00022 //  for the purpose for which you acquired it, or of satisfactory quality. 
00023 //
00024 //  WE SPECIFICALLY EXCLUDE TO THE FULLEST EXTENT PERMITTED BY THE COURTS ALL
00025 //  WARRANTIES IMPLIED BY LAW INCLUDING (BUT NOT LIMITED TO) IMPLIED WARRANTIES
00026 //  OF QUALITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF THIRD
00027 //  PARTIES RIGHTS.
00028 //
00029 //  If a court finds that we are liable for death or personal injury caused by our
00030 //  negligence our liability shall be unlimited.  
00031 //
00032 //  WE SHALL HAVE NO LIABILITY TO YOU FOR LOSS OF PROFITS, LOSS OF CONTRACTS, LOSS
00033 //  OF DATA, LOSS OF GOODWILL, OR WORK STOPPAGE, WHICH MAY ARISE FROM YOUR POSSESSION
00034 //  OR USE OF THE SOFTWARE OR ASSOCIATED DOCUMENTATION.  WE SHALL HAVE NO LIABILITY
00035 //  IN RESPECT OF ANY USE OF THE SOFTWARE OR THE ASSOCIATED DOCUMENTATION WHERE SUCH
00036 //  USE IS NOT IN COMPLIANCE WITH THE TERMS AND CONDITIONS OF THIS AGREEMENT.
00037 //
00038 // Legal Statement Covering Additions by The MusicKit Project:
00039 //
00040 //    Permission is granted to use and modify this code for commercial and
00041 //    non-commercial purposes so long as the author attribution and copyright
00042 //    messages remain intact and accompany all relevant code.
00043 //
00045 
00211 #ifndef __SNDVIEW_H__
00212 #define __SNDVIEW_H__
00213 
00214 #import <AppKit/AppKit.h>
00215 
00216 #import "SndDisplayDataList.h"
00217 #import "SndDisplayData.h"
00218 #import "Snd.h"
00219 
00220 enum SndViewStereoMode {
00221     SNDVIEW_LEFTONLY = 0,
00222     SNDVIEW_RIGHTONLY = 1,
00223     SNDVIEW_STEREOMODE = 256  /* (open the way for up to 8 channel sound) */
00224 };
00225 
00226 #define SND_SOUNDVIEW_MINMAX 0
00227 #define SND_SOUNDVIEW_WAVE 1
00228 
00229 // Legacy definitions
00230 #define NX_SOUNDVIEW_MINMAX SND_SOUNDVIEW_MINMAX
00231 #define NX_SOUNDVIEW_WAVE SND_SOUNDVIEW_WAVE
00232 
00233 @interface SndView: NSView <NSCoding>
00234 {
00236     Snd         *sound;
00238     Snd         *pasteboardSound;
00240     id          delegate;
00242     NSRange     selectedFrames;
00244     int         displayMode;
00246     NSColor     *backgroundColour;
00248     NSColor     *foregroundColour;
00250     NSColor     *selectionColour;
00252     float       reductionFactor;
00254     float       amplitudeZoom;
00255 
00269     struct {
00270         unsigned int  disabled:1;
00271         unsigned int  continuousSelectionUpdates:1;
00272         unsigned int  cursorOn:1;
00273         unsigned int  drawsCrosses:1;
00274         unsigned int  autoscale:1;
00275         unsigned int  bezeled:1;
00276         unsigned int  notEditable:1;
00277         unsigned int  notOptimizedForSpeed:1;
00278     } svFlags;
00279     
00281     NSTimer     *cursorFlashTimer;
00283     NSImage     *dragIcon;
00284     
00285     int         optThreshold;
00286     int         optSkip;
00287     float       peakFraction;
00288 
00290     int         stereoMode;
00291 
00292     int         defaultRecordFormat;
00293     int         defaultRecordChannelCount;
00294     double      defaultRecordSampleRate;
00295     float       defaultRecordSeconds;
00297     Snd *recordingSound;
00298     
00301     NSRect      cachedSelectionRect;
00303     NSRange     previousSelectedFrames;
00304 
00305     int         lastPasteCount;
00306     int         lastCopyCount;
00307     BOOL        notProvidedData;
00308     BOOL        noSelectionDraw;
00309     BOOL        firstDraw; // flag indicating lack of initialisation within drawRect:
00310 
00312     SndDisplayDataList *dataList;
00313     
00314 @private
00315     float ampScaler;
00316     float amplitudeDisplayHeight;
00318     NSArray *validPasteboardSendTypes;
00320     NSArray *validPasteboardReturnTypes;
00321 }
00322 
00326 - hideCursor;
00327 
00331 - showCursor;
00332 
00339 - (BOOL) resignFirstResponder;
00340 
00347 - (BOOL) becomeFirstResponder;
00348 
00353 - (void) copy: (id) sender;
00354 
00363 - (void) cut: (id) sender;
00364 
00372 - (void) delete: (id) sender;
00373 
00384 - (void) paste: (id) sender;
00385 
00390 - (void) selectAll: (id) sender;
00391 
00396 - delegate;
00397 
00407 - didPlay: (id) sender duringPerformance: (SndPerformance *) performance;
00408 
00417 - didRecord: (id) sender;
00418 
00425 - (int) displayMode;
00426 
00438 - (void) drawRect: (NSRect) rects;
00439 
00448 - (void) getSelection: (unsigned int *) firstSample size: (unsigned int *) sampleCount;
00449 
00456 - (void) setSelection: (int) firstSample size: (int) sampleCount;
00457 
00464 - hadError: (id) sender;
00465 
00473 - initWithFrame: (NSRect) frameRect;
00474 
00479 - (BOOL) isAutoScale;
00480 
00485 - (BOOL) isBezeled;
00486 
00493 - (BOOL) isContinuousSelectionUpdates;
00494 
00499 - (BOOL) isEditable;
00500 
00507 - (BOOL) isEnabled;
00508 
00515 - (BOOL) isOptimizedForSpeed;
00516 
00521 - (BOOL) isPlayable;
00522 
00527 - (BOOL) isEntireSoundVisible;
00528 
00529 - (float) getDefaultRecordTime;
00530 - (void) setDefaultRecordTime: (float) seconds;
00531 
00538 - (void) selectionChanged;
00539 
00551 - (void) mouseDown: (NSEvent *) theEvent;
00552 
00561 - (void) pasteboard: (NSPasteboard *) thePasteboard provideDataForType: (NSString *) pboardType;
00562 
00567 - (void) pause: (id) sender;
00568 
00578 - (void) play: (id) sender;
00579 
00585 - (void) resume: (id) sender;
00586 
00597 - (void) record: (id) sender;
00598 
00603 - (void) stop: (id) sender;
00604 
00618 - (BOOL) readSelectionFromPasteboard: (NSPasteboard *) thePasteboard;
00619 
00629 - (void) setAmplitudeZoom: (float) newAmplitudeZoom;
00630 
00635 - (float) amplitudeZoom;
00636 
00643 - (float) reductionFactor;
00644 
00669 - (BOOL) setReductionFactor: (float) reductionFactor;
00670 
00677 - (void) scaleTo: (float) scaleRatio;
00678 
00689 - (void) scaleToFit;
00690 
00701 - (void) resizeToFit;
00702 
00714 - (void) resizeToFit: (BOOL) withAutoscaling;
00715 
00720 - (void) resizeToScale: (float) scaleRatio;
00721 
00734 - setAutoscale: (BOOL) aFlag;
00735 
00744 - (void) setBezeled: (BOOL) aFlag;
00745 
00753 - (void) setContinuousSelectionUpdates: (BOOL) aFlag;
00754 
00761 - (void) setDelegate: (id) anObject;
00762 
00769 - (void) setDisplayMode: (int) aMode;
00770 
00777 - (void) setEditable: (BOOL) aFlag;
00778 
00785 - (void) setEnabled: (BOOL) aFlag;
00786 
00797 - (void) setOptimizedForSpeed: (BOOL) flag;
00798 
00809 - (void) setSound: (Snd *) aSound;
00810 
00815 - (Snd *) sound;
00816 
00823 - (void) setFrameSize: (NSSize) newSize;
00824 
00836 - (Snd *) soundBeingProcessed;
00837 
00849 - (void) tellDelegate: (SEL) theMessage;
00850 
00862 - (void) tellDelegate: (SEL) theMessage duringPerformance: (SndPerformance *) performance;
00863 
00871 - validRequestorForSendType: (NSString *) sendType returnType: (NSString *) returnType;
00872 
00882 - (void) willPlay: sender duringPerformance: (SndPerformance *) performance;
00883 
00892 - (void) willRecord: (id) sender;
00893 
00899 - (BOOL) writeSelectionToPasteboard: (NSPasteboard *) thePasteboard types: (NSArray *) pboardTypes;
00900 - (BOOL) writeSelectionToPasteboardNoProvide: (NSPasteboard *) thePasteboard types: (NSArray *) pboardTypes;
00901 
00902 - (id) initWithCoder: (NSCoder *) aDecoder;
00903 - (void) encodeWithCoder: (NSCoder *) aCoder;
00904 
00905 
00906 /*************************
00907  * these methods are unique to SndKit.
00908  *************************/
00909 
00910 - (BOOL) invalidateCacheStartPixel: (int) start end: (int) end;
00911         /* if end == -1, invalidates to end of last cache*/
00912 - (BOOL) invalidateCacheStartSample: (int) start end: (int) end;
00913         /* start and end are samples. Must be exact. */
00914 
00922 - (void) invalidateCache;
00923 
00931 - (void) setDrawsCrosses: (BOOL) aFlag;
00932 
00937 - (BOOL) drawsCrosses;
00938 
00939 /* see class description for explanation of optimisation thresholds and skips, and peak fractions */
00940 - (void) setOptThreshold: (int) threshold;
00941 - (int) getOptThreshold;
00942 - (void) setOptSkip: (int) skip;
00943 - (int) getOptSkip;
00944 - (void) setPeakFraction: (float) fraction;
00945 - (float) getPeakFraction;
00946 
00951 - (BOOL) setStereoMode: (enum SndViewStereoMode) stereoMode;
00952 
00957 - (enum SndViewStereoMode) getStereoMode;
00958 
00963 - (void) setSelectionColor: (NSColor *) color;
00964 
00969 - (NSColor *) selectionColor;
00970 
00975 - (void) setBackgroundColor: (NSColor *) color;
00976 
00981 - (NSColor *) backgroundColor;
00982 
00987 - (void) setForegroundColor: (NSColor *) color;
00988 
00993 - (NSColor *) foregroundColor;
00994 
01003 - (void) setDragIcon: (NSImage *) newDragIcon;
01004 
01011 - (NSImage *) dragIcon;
01012 
01013 @end
01014 
01015 #endif