1 QSoundFileView : QView {
5 var <>elasticMode; // NOTE: no-op, only for compatibility
8 *qtClass { ^'QcWaveform' }
10 load { arg filename, startframe, frames, block, doneAction;
11 if( filename.isString && filename != "" ) {
12 if( curDoneAction.notNil )
13 { this.disconnectFunction( 'loadingDone()', curDoneAction ) };
14 if( doneAction.notNil ) {
15 this.connectFunction( 'loadingDone()', doneAction );
18 curDoneAction = doneAction;
20 if( startframe.notNil && frames.notNil ) {
21 this.invokeMethod( \load, [filename, startframe.asInteger, frames.asInteger] );
23 this.invokeMethod( \load, filename );
28 alloc { arg frames, channels=1, samplerate=44100;
29 this.invokeMethod( \allocate, [frames.asInteger, channels.asInteger, samplerate.asInteger] );
36 setData { arg data, block, startframe=0, channels=1, samplerate=44100;
37 if( data.isKindOf(DoubleArray).not and: {data.isKindOf(FloatArray).not} )
38 { data = data.as(DoubleArray) };
39 this.invokeMethod( \load, [data, startframe, channels, samplerate] );
42 set { arg offset=0, data;
43 if( data.isKindOf(DoubleArray).not and: {data.isKindOf(FloatArray).not} )
44 { data = data.as(DoubleArray) };
45 this.invokeMethod( \write, [data, offset.asInteger] );
48 readFile { arg aSoundFile, startframe, frames, block, closeFile, doneAction;
49 this.load( aSoundFile.path, startframe, frames, block, doneAction );
52 read { arg startframe, frames, block, closeFile, doneAction;
53 if( soundfile.notNil ) {
54 this.readFile( soundfile, startframe, frames, block, nil, doneAction );
58 readFileWithTask { arg aSoundFile, startframe, frames, block, doneAction, showProgress;
59 this.readFile( aSoundFile, startframe, frames, block, nil, doneAction );
62 readWithTask { arg startframe, frames, block, doneAction, showProgress;
63 this.read( startframe, frames, block, nil, doneAction );
66 drawsWaveForm { ^this.getProperty( \drawsWaveform ); }
68 drawsWaveForm_ { arg boolean; this.setProperty( \drawsWaveform, boolean ); }
70 waveColors { ^this.getProperty( \waveColors ) }
71 waveColors_ { arg colors; this.setProperty( \waveColors, colors ) }
75 startFrame { ^this.getProperty( \startFrame ); }
77 numFrames { ^this.getProperty( \frames ); }
79 scrollPos { ^this.getProperty( \scrollPos ); } // a fraction of the full scrolling range
81 viewFrames { ^this.getProperty( \viewFrames ); }
83 readProgress { ^this.getProperty( \readProgress ); }
87 zoom { arg factor; this.invokeMethod( \zoomBy, factor.asFloat ); }
89 zoomToFrac { arg fraction; this.invokeMethod( \zoomTo, fraction.asFloat ); }
91 zoomAllOut { this.invokeMethod( \zoomAllOut ); }
93 zoomSelection { arg selection;
94 if( selection.isNil ) { selection = this.currentSelection };
95 this.invokeMethod( \zoomSelection, selection );
98 scrollTo { arg fraction; // a fraction of the full scrolling range
99 this.setProperty( \scrollPos, fraction );
102 scroll { arg fraction; // a fraction of the visible range
103 var frames = this.viewFrames * fraction + this.getProperty(\viewStartFrame);
104 this.setProperty( \viewStartFrame, frames );
107 scrollToStart { this.invokeMethod( \scrollToStart ); }
109 scrollToEnd { this.invokeMethod( \scrollToEnd ); }
111 xZoom { ^this.getProperty( \xZoom ); }
113 xZoom_ { arg seconds; this.setProperty( \xZoom, seconds ); }
115 yZoom { ^this.getProperty( \yZoom ); }
117 yZoom_ { arg factor; this.setProperty( \yZoom, factor.asFloat ); }
121 selections { ^this.getProperty( \selections ); }
123 currentSelection { ^this.getProperty( \currentSelection ); }
125 currentSelection_ { arg index; this.setProperty( \currentSelection, index ); }
127 selection { arg index; ^this.invokeMethod( \selection, index, true ); }
129 setSelection { arg index, selection;
130 this.invokeMethod( \setSelection, [index, selection] );
133 selectionStart { arg index;
134 var sel = this.selection( index );
138 setSelectionStart { arg index, frame;
139 var sel = this.selection( index );
141 this.setSelection( index, sel );
144 selectionSize { arg index;
145 var sel = this.selection( index );
149 setSelectionSize { arg index, frames;
150 var sel = this.selection( index );
151 sel.put( 1, frames );
152 this.setSelection( index, sel );
155 selectAll { arg index; this.setSelection( this.currentSelection, [0, this.numFrames] ); }
157 selectNone { arg index; this.setSelection( this.currentSelection, [0, 0] ); }
160 setEditableSelectionStart { arg index, editable; ^this.nonimpl("setEditableSelectionStart"); }
162 setEditableSelectionSize { arg index, editable; ^this.nonimpl("setEditableSelectionSize"); }
164 setSelectionColor { arg index, color; this.invokeMethod( \setSelectionColor, [index,color] ); }
167 selectionStartTime { arg index; ^this.nonimpl("selectionStartTime"); }
169 selectionDuration { arg index; ^this.nonimpl("selectionDuration"); }
172 readSelection { arg block, closeFile; ^this.nonimpl("readSelection"); }
174 readSelectionWithTask { ^this.nonimpl("readSelectionWithTask"); }
178 timeCursorOn { ^this.getProperty( \cursorVisible ); }
179 timeCursorOn_ { arg flag; this.setProperty( \cursorVisible, flag ) }
181 timeCursorEditable { ^this.getProperty( \cursorEditable ); }
182 timeCursorEditable_ { arg flag; this.setProperty( \cursorEditable, flag ) }
184 timeCursorPosition { ^this.getProperty( \cursorPosition ); }
185 timeCursorPosition_ { arg frame; this.setProperty( \cursorPosition, frame ) }
189 gridOn { ^this.getProperty( \gridVisible ); }
190 gridOn_ { arg flag; this.setProperty( \gridVisible, flag ) }
192 gridResolution { ^this.getProperty( \gridResolution ) }
193 gridResolution_ { arg seconds; this.setProperty( \gridResolution, seconds ) }
195 gridOffset { ^this.getProperty( \gridOffset ) }
196 gridOffset_ { arg seconds; this.setProperty( \gridOffset, seconds ) }
200 peakColor { ^this.getProperty(\peakColor) }
201 peakColor_ { arg color; this.setProperty(\peakColor, color) }
203 rmsColor { ^this.getProperty(\rmsColor) }
204 rmsColor_ { arg color; this.setProperty(\rmsColor, color) }
206 timeCursorColor { ^this.getProperty( \cursorColor ); }
207 timeCursorColor_ { arg color; this.setProperty( \cursorColor, color ) }
209 gridColor { ^this.getProperty( \gridColor ) }
210 gridColor_ { arg color; this.setProperty( \gridColor, color ) }
214 metaAction_ { arg action;
215 this.manageFunctionConnection( metaAction, action, 'metaAction()' );