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"
31 #import "SCTextView.h"
32 #import "SCVirtualMachine.h"
37 #include "SC_sndfile_stub.h"
41 struct SCSoundFileSelection
{
48 typedef struct SCSoundFileSelection SCSoundFileSelection
;
53 //typedef struct SndMinMax SndMinMax;
60 typedef struct SndMinMaxBuf SndMinMaxBuf
;
61 const int kMaxSndSelections
= 64;
62 const int kMaxSndChannels
= 128;
63 class SCSoundFileView
: public SCView
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
)
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
)
94 (u
.x
- mScroll
.x
) * mInvZoom
.x
+ r
.x
,
95 (u
.y
- mScroll
.y
) * mInvZoom
.y
+ r
.y
);
102 SndMinMaxBuf mSndMinMax
;
104 SCPoint mZoom
, mInvZoom
, mScroll
;
105 int mStyle
; // 0 = separate, 1 = overlay, 2 = x,y.
106 SCColor mWaveColors
[kMaxSndChannels
];
109 float mGridResolution
;
111 SCPoint mAbsolutePosition
;
112 bool mIsReadingSoundFile
;
113 int mCurrentSelection
;
116 SCSoundFileSelection mSelections
[kMaxSndSelections
];
118 float mResampleFactor
;
120 bool mShowTimeCursor
;
121 int mTimeCursorPosition
;
122 SCColor mTimeCursorColor
;
127 SCView
* NewSCSoundFileView(SCContainerView
*inParent
, PyrObject
* inObj
, SCRect inBounds
);