class library: Spawner - don't access PriorityQueue-array
[supercollider.git] / editors / scapp / include / SCSoundFileView.h
blobe63080eb795c372ba071fef8084cb7ccc14991fd
1 /*
2 * SCSoundFileView.h
3 * xSC3lang
5 * Created by falkenst on Thu Nov 18 2004.
6 * Copyright (c) 2004 jan truetzschler. All rights reserved.
8 SuperCollider real time audio synthesis system
9 Copyright (c) 2002 James McCartney. All rights reserved.
10 http://www.audiosynth.com
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 //#import "DrawBackground.h"
29 //#include "PyrObject.h"
30 #include "SCView.h"
31 #import "SCTextView.h"
32 #import "SCVirtualMachine.h"
34 #ifndef NO_LIBSNDFILE
35 #include <sndfile.h>
36 #else
37 #include "SC_sndfile_stub.h"
38 #endif
40 //jan t
41 struct SCSoundFileSelection {
42 bool startIsEditable;
43 bool sizeIsEditable;
44 int start;
45 int size;
46 SCColor color;
48 typedef struct SCSoundFileSelection SCSoundFileSelection;
49 //struct SndMinMax {
50 // float min;
51 // float max;
52 //};
53 //typedef struct SndMinMax SndMinMax;
54 struct SndMinMaxBuf {
55 float *min;
56 float *max;
57 int samples;
58 bool isUsable;
60 typedef struct SndMinMaxBuf SndMinMaxBuf;
61 const int kMaxSndSelections = 64;
62 const int kMaxSndChannels = 128;
63 class SCSoundFileView : public SCView
65 public:
66 SCSoundFileView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);
67 virtual ~SCSoundFileView();
69 virtual void draw(SCRect inDamage);
70 virtual void draw0(SCRect inDamage, CGContextRef cgc);
71 virtual void draw1(SCRect inDamage, CGContextRef cgc);
72 virtual void draw2(SCRect inDamage, CGContextRef cgc);
73 virtual void draw0Buf(SCRect inDamage, CGContextRef cgc);
74 virtual void mouseTrack(SCPoint where, int modifiers,NSEvent *theEvent);
75 //virtual int readSndFile(const char * filename, int startFrame, int frames, int resampleFactor, bool closeFile);
76 virtual int readSndFile(SNDFILE *file, int startFrame, int frames, int resampleFactor, SF_INFO info);
77 virtual int setProperty(PyrSymbol *symbol, PyrSlot *slot);
78 virtual int getProperty(PyrSymbol *symbol, PyrSlot *slot);
79 virtual void mouseBeginTrack(SCPoint where, int modifiers, NSEvent *theEvent);
80 virtual void mouseEndTrack(SCPoint where, int modifiers, NSEvent *theEvent);
81 // virtual void mouseOver(SCPoint where);
82 virtual int findSelection(int frame);
83 virtual void setBounds(SCRect inbounds);
85 SCPoint pixelToUnits(SCPoint p, SCRect r)
87 return SCMakePoint(
88 (p.x - r.x) * mZoom.x + mScroll.x,
89 (p.y - r.y) * mZoom.y + mScroll.y);
91 SCPoint unitsToPixel(SCPoint u, SCRect r)
93 return SCMakePoint(
94 (u.x - mScroll.x) * mInvZoom.x + r.x,
95 (u.y - mScroll.y) * mInvZoom.y + r.y);
98 protected:
100 int mBufNum;
101 SNDFILE *mSndFile;
102 SndMinMaxBuf mSndMinMax;
103 SndBuf mSndBuf;
104 SCPoint mZoom, mInvZoom, mScroll;
105 int mStyle; // 0 = separate, 1 = overlay, 2 = x,y.
106 SCColor mWaveColors[kMaxSndChannels];
107 SCColor mGridColor;
108 bool mGridOn;
109 float mGridResolution;
110 int mGridOffset;
111 SCPoint mAbsolutePosition;
112 bool mIsReadingSoundFile;
113 int mCurrentSelection;
114 bool mMoveSelection;
115 int mLastFrame;
116 SCSoundFileSelection mSelections[kMaxSndSelections];
117 bool mDrawsWaveForm;
118 float mResampleFactor;
119 int mElasticMode;
120 bool mShowTimeCursor;
121 int mTimeCursorPosition;
122 SCColor mTimeCursorColor;
123 int mFramesInBounds;
127 SCView* NewSCSoundFileView(SCContainerView *inParent, PyrObject* inObj, SCRect inBounds);