1 QSoundFileView : QView {
7 *qtClass { ^"QcWaveform" }
9 load { arg filename, startframe, frames, block, doneAction;
10 if( filename.isString && filename != "" ) {
11 if( curDoneAction.notNil )
12 { this.disconnectFunction( 'loadingDone()', curDoneAction ) };
13 if( doneAction.notNil ) {
14 this.connectFunction( 'loadingDone()', doneAction );
17 curDoneAction = doneAction;
19 if( startframe.notNil && frames.notNil ) {
20 this.invokeMethod( \load, [filename, startframe.asInteger, frames.asInteger] );
22 this.invokeMethod( \load, filename );
27 readFile { arg aSoundFile, startframe, frames, block, closeFile, doneAction;
28 this.load( aSoundFile.path, startframe, frames, block, doneAction );
31 read { arg startframe, frames, block, closeFile, doneAction;
32 if( soundfile.notNil ) {
33 this.readFile( soundfile, startframe, frames, block, nil, doneAction );
37 readFileWithTask { arg aSoundFile, startframe, frames, block, doneAction, showProgress;
38 this.readFile( aSoundFile, startframe, frames, block, nil, doneAction );
41 readWithTask { arg startframe, frames, block, doneAction, showProgress;
42 this.read( startframe, frames, block, nil, doneAction );
45 drawsWaveForm { ^this.getProperty( \drawsWaveform ); }
47 drawsWaveForm_ { arg boolean; this.setProperty( \drawsWaveform, boolean ); }
49 waveColors { ^this.getProperty( \waveColors ) }
50 waveColors_ { arg colors; this.setProperty( \waveColors, colors ) }
54 startFrame { ^this.getProperty( \startFrame ); }
56 numFrames { ^this.getProperty( \frames ); }
58 scrollPos { ^this.getProperty( \scrollPos ); } // a fraction of the full scrolling range
60 viewFrames { ^this.getProperty( \viewFrames ); }
62 readProgress { ^this.getProperty( \readProgress ); }
66 zoom { arg factor; this.invokeMethod( \zoomBy, factor.asFloat ); }
68 zoomToFrac { arg fraction; this.invokeMethod( \zoomTo, fraction.asFloat ); }
70 zoomAllOut { this.invokeMethod( \zoomAllOut ); }
72 zoomSelection { arg selection;
73 if( selection.isNil ) { selection = this.currentSelection };
74 this.invokeMethod( \zoomSelection, selection );
77 scrollTo { arg fraction; // a fraction of the full scrolling range
78 this.setProperty( \scrollPos, fraction );
81 scroll { arg fraction; // a fraction of the visible range
82 var frames = this.viewFrames * fraction + this.getProperty(\viewStartFrame);
83 this.setProperty( \viewStartFrame, frames );
86 scrollToStart { this.invokeMethod( \scrollToStart ); }
88 scrollToEnd { this.invokeMethod( \scrollToEnd ); }
90 xZoom { ^this.getProperty( \xZoom ); }
92 xZoom_ { arg seconds; this.setProperty( \xZoom, seconds ); }
94 yZoom { ^this.getProperty( \yZoom ); }
96 yZoom_ { arg factor; this.setProperty( \yZoom, factor.asFloat ); }
100 selections { ^this.getProperty( \selections ); }
102 currentSelection { ^this.getProperty( \currentSelection ); }
104 currentSelection_ { arg index; this.setProperty( \currentSelection, index ); }
106 selection { arg index; ^this.invokeMethod( \selection, index, true ); }
108 setSelection { arg index, selection;
109 this.invokeMethod( \setSelection, [index, selection] );
112 selectionStart { arg index;
113 var sel = this.selection( index );
117 setSelectionStart { arg index, frame;
118 var sel = this.selection( index );
120 this.setSelection( index, sel );
123 selectionSize { arg index;
124 var sel = this.selection( index );
128 setSelectionSize { arg index, frames;
129 var sel = this.selection( index );
130 sel.put( 1, frames );
131 this.setSelection( index, sel );
134 selectAll { arg index; this.setSelection( this.currentSelection, [0, this.numFrames] ); }
136 selectNone { arg index; this.setSelection( this.currentSelection, [0, 0] ); }
139 setEditableSelectionStart { arg index, editable; ^this.nonimpl("setEditableSelectionStart"); }
141 setEditableSelectionSize { arg index, editable; ^this.nonimpl("setEditableSelectionSize"); }
143 setSelectionColor { arg index, color; this.invokeMethod( \setSelectionColor, [index,color] ); }
146 selectionStartTime { arg index; ^this.nonimpl("selectionStartTime"); }
148 selectionDuration { arg index; ^this.nonimpl("selectionDuration"); }
151 readSelection { arg block, closeFile; ^this.nonimpl("readSelection"); }
153 readSelectionWithTask { ^this.nonimpl("readSelectionWithTask"); }
157 timeCursorOn { ^this.getProperty( \cursorVisible ); }
158 timeCursorOn_ { arg flag; this.setProperty( \cursorVisible, flag ) }
160 timeCursorEditable { ^this.getProperty( \cursorEditable ); }
161 timeCursorEditable_ { arg flag; this.setProperty( \cursorEditable, flag ) }
163 timeCursorPosition { ^this.getProperty( \cursorPosition ); }
164 timeCursorPosition_ { arg frame; this.setProperty( \cursorPosition, frame ) }
166 timeCursorColor { ^this.getProperty( \cursorColor ); }
167 timeCursorColor_ { arg color; this.setProperty( \cursorColor, color ) }
171 gridOn { ^this.getProperty( \gridVisible ); }
172 gridOn_ { arg flag; this.setProperty( \gridVisible, flag ) }
174 gridResolution { ^this.getProperty( \gridResolution ) }
175 gridResolution_ { arg seconds; this.setProperty( \gridResolution, seconds ) }
177 gridOffset { ^this.getProperty( \gridOffset ) }
178 gridOffset_ { arg seconds; this.setProperty( \gridOffset, seconds ) }
180 gridColor { ^this.getProperty( \gridColor ) }
181 gridColor_ { arg color; this.setProperty( \gridColor, color ) }
185 metaAction_ { arg action;
186 this.manageFunctionConnection( metaAction, action, 'metaAction()' );