1 /*	Copyright � 2007 Apple Inc. All Rights Reserved.
2 
3 	Disclaimer: IMPORTANT:  This Apple software is supplied to you by
4 			Apple Inc. ("Apple") in consideration of your agreement to the
5 			following terms, and your use, installation, modification or
6 			redistribution of this Apple software constitutes acceptance of these
7 			terms.  If you do not agree with these terms, please do not use,
8 			install, modify or redistribute this Apple software.
9 
10 			In consideration of your agreement to abide by the following terms, and
11 			subject to these terms, Apple grants you a personal, non-exclusive
12 			license, under Apple's copyrights in this original Apple software (the
13 			"Apple Software"), to use, reproduce, modify and redistribute the Apple
14 			Software, with or without modifications, in source and/or binary forms;
15 			provided that if you redistribute the Apple Software in its entirety and
16 			without modifications, you must retain this notice and the following
17 			text and disclaimers in all such redistributions of the Apple Software.
18 			Neither the name, trademarks, service marks or logos of Apple Inc.
19 			may be used to endorse or promote products derived from the Apple
20 			Software without specific prior written permission from Apple.  Except
21 			as expressly stated in this notice, no other rights or licenses, express
22 			or implied, are granted by Apple herein, including but not limited to
23 			any patent rights that may be infringed by your derivative works or by
24 			other works in which the Apple Software may be incorporated.
25 
26 			The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
27 			MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
28 			THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
29 			FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
30 			OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
31 
32 			IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
33 			OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 			SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 			INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
36 			MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
37 			AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
38 			STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
39 			POSSIBILITY OF SUCH DAMAGE.
40 */
41 #import <Cocoa/Cocoa.h>
42 
43 // One data point for the filter frequency response
44 // for the filter frequency response.
45 
46 typedef struct FrequencyResponse {
47   Float32 mFrequency;
48   Float32 mMagnitude;
49 } FrequencyResponse;
50 
51 // number of data points in the filter frequency response
52 
53 #define kNumberOfResponseFrequencies 512
54 
55 
56 /************************************************************************************************************/
57 /* NOTE: It is important to rename ALL ui classes when using the XCode Audio Unit with Cocoa View template	*/
58 /*		 Cocoa has a flat namespace, and if you use the default filenames, it is possible that you will		*/
59 /*		 get a namespace collision with classes from the cocoa view of a previously loaded audio unit.		*/
60 /*		 We recommend that you use a unique prefix that includes the manufacturer name and unit name on		*/
61 /*		 all objective-C source files. You may use an underscore in your name, but please refrain from		*/
62 /*		 starting your class name with an undescore as these names are reserved for Apple.					*/
63 /************************************************************************************************************/
64 
65 @interface UCBLopassFilter_GraphView : NSView
66 {
67 	NSRect	mGraphFrame;		// This is the frame of the drawing area of the view
68 	float	mActiveWidth;		// The usable portion of the graph
69 	NSPoint mEditPoint;			// This is the current location in the drawing area that is active
70 	BOOL	mMouseDown;			// True if the mouse is currently down
71 
72 	NSColor *curveColor;		// the current color of the graph curve
73 
74 	NSImage *mBackgroundCache;	// An image cache of the background so that we don't have to re-draw the grid lines and labels all the time
75 
76 	float mRes;					// internal copy of the resonance value
77 	float mFreq;				// internal copy of the frequency value
78 
79 	NSBezierPath *mCurvePath;	// The bezier path that is used to draw the curve.
80 
81 	NSDictionary *mDBAxisStringAttributes;		// Text attributes used to draw the strings on the db axis
82 	NSDictionary *mFreqAxisStringAttributes;	// Text attributes used to draw the strings on the frequency axis
83 }
84 
85 -(void) setRes: (float) res;	// sets the graph's internal resonance value (to match the au)
86 -(void) setFreq: (float) freq;	// sets the graphs' internal frequency value (to match the au
87 
88 -(float)getRes;					// gets the graph's internal resonance value (so the au can match the graph)
89 -(float)getFreq;				// gets the graph's internal frequency value (so the au can match the graph)
90 
91 -(double) locationForFrequencyValue: (double) value;	// converts a frequency value to the pixel coordinate in the graph
92 -(double) locationForDBValue: (double) value;			// converts a db value to the pixel coordinate in the graph
93 
94 -(FrequencyResponse *) prepareDataForDrawing: (FrequencyResponse *) data;	// prepares the data for drawing by initializing frequency fields based on values on pixel boundaries
95 -(void) plotData: (FrequencyResponse *) data;								// draws the curve data
96 -(void) disableGraphCurve;													// update the view, but don't draw the curve (used when the AU is not initialized and the curve can not be retrieved)
97 
98 -(void) handleBeginGesture;		// called when parameter automation started
99 -(void) handleEndGesture;		// called when parameter automation finished
100 
101 @end
102