deprecate SCViewHolder-layRight
[supercollider.git] / SCClassLibrary / deprecated / deprecated-3.5.sc
bloba0ca014c9b84f7568c73662f6846290984736a3f
1 UI {
2         classvar resetActions, shutdownActions;
4         initClass {
5                 resetActions = Array.new;
6                 shutdownActions = Array.new; // braindead extensions may rely on these
7         }
9         *registerForReset {|aFunction|
10                 this.deprecated(thisMethod, OnError.class.findMethod(\add));
11                 OnError.add(aFunction)
12         }
13         *registerForShutdown {|aFunction|
14                 this.deprecated(thisMethod, ShutDown.class.findMethod(\add));
15                 ShutDown.add(aFunction)
16         }
19 Pflow : FilterPattern {
20         *new {
21                 Error("Pflow was replaced. please use Pstep instead").throw;
22         }
25 Model {
26         var <>dependants;
28         *new {
29                 this.deprecated(thisMethod, Object.class.findMethod(\new));
30                 "NB Model's functionality is duplicated by Object".postln;
31                 ^super.new;
32         }
33         changed { arg what ... moreArgs;
34                 dependants.do({ arg item;
35                         item.update(this, what, *moreArgs);
36                 });
37         }
38         addDependant { arg dependant;
39                 if (dependants.isNil, {
40                         dependants = IdentitySet.new(4);
41                 });
42                 dependants.add(dependant);
43         }
44         removeDependant { arg dependant;
45                 if (dependants.notNil, {
46                         dependants.remove(dependant);
47                 });
48         }
49         release {
50                 dependants = nil;
51         }
54 Panner : MultiOutUGen {
55         *new {|...x|
56                 this.deprecated(thisMethod);
57                 ^super.new(*x);
58         }
59         *new1 {|...x|
60                 this.deprecated(thisMethod);
61                 ^super.new(*x);
62         }
65 XFade : UGen {
66         *new {|...x|
67                 this.deprecated(thisMethod);
68                 ^super.new(*x);
69         }
70         *new1 {|...x|
71                 this.deprecated(thisMethod);
72                 ^super.new(*x);
73         }
76 GetFileDialog {
78         *new { arg function;
79                 // platform neutral (eventually)
80                 this.deprecated(thisMethod, File.class.findMethod(\openDialog));
81                 File.openDialog(nil,
82                         { arg path; function.value(true,path) },
83                         {  function.value(false) } );
84                 //CocoaDialog.getPaths({arg paths; function.value(paths.first) },nil)
85         }
86         // warning:  doesn't handle doAction (no instance)
91 GetStringDialog  {
93         *new { arg prompt,defaultString="",func;
94                 var b;
95                 this.deprecated(thisMethod);
96                 Sheet({ arg l;
97                         b =     TextField(l,Rect(0,0,150,30));
98                         b.string = String.new ++ defaultString;
99                         b.action = {arg field; func.value(true,field.value); l.close; };
100                 },prompt);
101                 { b.focus }.defer;
102         }
105 + Mix {
107         *ar { arg array;
108                 this.deprecated(thisMethod, Mix.class.findMethod(\new));
109                 ^this.new(array);
110         }
111         *arFill { arg n,func;
112                 this.deprecated(thisMethod, Mix.class.findMethod(\fill));
113                 ^this.fill(n,func);
114         }
117 + SimpleNumber {
118         // rgb() still will not work in variable declarations in classes
119         // because rgb is no longer a literal
121         // move them to init methods
122         rgb { arg green,blue;
123                 this.deprecated(thisMethod, Color.class.findMethod(\new255));
124                 ^Color(this / 255.0,green / 255.0, blue / 255.0)
125         }
129 + Synth {
131         *stop {
132                 this.deprecated(thisMethod, Server.findMethod(\free));
133                 RootNode.new.freeAll;
134         }
135         *play { arg func;
136                 this.deprecated(thisMethod, Synth.class.findMethod(\new));
137                 Server.default.doWhenBooted({
138                         func.play;
139                 })
140         }
141         play {
142                 this.deprecated(thisMethod, Synth.class.findMethod(\new));
143                 //if not already playing, play
144         }
145         *sampleRate {
146                 this.deprecated(thisMethod, Server.findMethod(\sampleRate));
147                 ^Server.default.sampleRate ? Server.default.options.sampleRate ? 44100.0
148         }
152 + RawArray {
154         write { arg path;
155                 var file;
156                 this.deprecated(thisMethod, File.findMethod(\write));
157                 file = File.new(path, "wb");
158                 if (file.notNil, {
159                         file.write(this);
160                         if(file.length < this.size,{
161                                 Error("Write file failed !!!! " ++ path).throw;
162                         });
163                         file.close;
164                 });
165         }
169 + ServerOptions {
170         blockAllocClass {
171                 this.deprecated(thisMethod)
172         }
173         blockAllocClass_ {
174                 this.deprecated(thisMethod)
175         }
177         rendezvous_ {|bool|
178                 zeroConf = bool;
179                 this.deprecated(thisMethod, ServerOptions.findMethod(\zeroConf_))
180         }
182         rendezvous {|bool|
183                 this.deprecated(thisMethod, ServerOptions.findMethod(\zeroConf));
184                 ^zeroConf;
185         }
187         numAudioBusChannels_{|num|
188                 this.numPrivateAudioBusChannels = num - (numInputBusChannels + numOutputBusChannels);
189                 this.deprecated(thisMethod);
190         }
193 + Server {
194         // Buffer objects are cached in an Array for easy
195         // auto buffer info updating
196         addBuf { |buffer|
197                 this.deprecated(thisMethod, Buffer.findRespondingMethodFor(\cache));
198                 buffer.cache;
199         }
201         freeBuf { |i|
202                 var     buf;
203                 this.deprecated(thisMethod, Buffer.findRespondingMethodFor(\uncache));
204                 if((buf = Buffer.cachedBufferAt(this, i)).notNil) { buf.free };
205         }
207         // /b_info on the way
208         // keeps a reference count of waiting Buffers so that only one responder is needed
209         waitForBufInfo {
210                 this.deprecated(thisMethod, Buffer.findRespondingMethodFor(\cache));
211         }
213         resetBufferAutoInfo {
214                 this.deprecated(thisMethod, Meta_Buffer.findRespondingMethodFor(\clearServerCaches));
215                 Buffer.clearServerCaches(this);
216         }
219 + Node {
220         // map to Bus objects
221         busMap { arg firstControl, aBus ... args;
222                 var values;
223                 this.deprecated(thisMethod, Node.findMethod(\map));
224                 values = List.new;
225                 args.pairsDo({ arg control, bus; values.addAll([control, bus.index, bus.numChannels])});
226                 server.sendMsg(48, nodeID, firstControl, aBus.index, aBus.numChannels, *values);
227                 //"/n_mapn"
228         }
229         busMapMsg { arg firstControl, aBus ... args;
230                 var values;
231                 this.deprecated(thisMethod, Node.findMethod(\mapMsg));
232                 values = List.new;
233                 args.pairsDo({ arg control, bus; values.addAll([control, bus.index, bus.numChannels])});
234                 ^[48, nodeID, firstControl, aBus.index, aBus.numChannels] ++ values;
235                 //"/n_mapn"
236         }
239 + SynthDef {
240         memStore { arg libname = \global, completionMsg, keepDef = true;
241                 this.deprecated(thisMethod, this.class.findRespondingMethodFor(\add));
242                 this.add(libname, completionMsg, keepDef);
243         }
246 + Env {
247         shapeNumber { arg shapeName;
248                 this.deprecated(thisMethod, this.class.class.findMethod(\shapeNumber));
249                 ^this.class.shapeNumber(shapeName)
250         }
253 + Help {
254         searchGUI {
255                 this.deprecated(thisMethod, Meta_Help.findRespondingMethodFor(\gui));
256                 ^this.gui
257         }
260 + Collection{
261         occurencesOf { | obj |
262                 this.deprecated(thisMethod, Collection.findRespondingMethodFor(\occurrencesOf));
263                 ^this.occurrencesOf(obj);
264         }
267 + Buffer {
268         copy { arg buf, dstStartAt = 0, srcStartAt = 0, numSamples = -1;
269                 if(buf.notNil) {
270                         this.deprecated(thisMethod, this.class.findRespondingMethodFor(\copyData));
271                         this.copyData(buf, dstStartAt, srcStartAt, numSamples);
272                 } {
273                         ^super.copy
274                 }
275         }
278 + ArrayedCollection {
279         plotOld { arg name, bounds, discrete=false, numChannels, minval, maxval, parent, labels=true;
280                 var plotter, txt, chanArray, unlaced, val, window, thumbsize, zoom, width,
281                         layout, write=false, msresize, gui;
282                 var flattened;
283                 this.deprecated(thisMethod, ArrayedCollection.findRespondingMethodFor(\plot));
285                 gui = GUI.current;
287                 bounds = bounds ?? {
288                                 if(parent.notNil) {
289                                         if(parent.respondsTo(\view)) {
290                                                 parent.view.bounds
291                                         } {
292                                                 parent.bounds
293                                         }
294                         } {
295                                 Rect(200 ,140, 705, 410);
296                         }
297                 };
299                 width = bounds.width - 8;
301                 name = name ? "plot";
303                 numChannels = numChannels ? this.first.size.max(1);
304                 flattened = if(numChannels > 1) { this.flat } { this };
305                 unlaced = flattened.unlace(numChannels);
307                 minval = if(minval.isArray) {
308                         numChannels.collect {|index| minval.wrapAt(index) ?? { unlaced[index].minItem } }
309                 } {
310                         { minval ?? { flattened.minItem } }.dup(numChannels);
311                 };
312                 maxval = if(maxval.isArray) {
313                         numChannels.collect{|index| maxval.wrapAt(index) ?? { unlaced[index].maxItem } }
314                 } {
315                         {maxval ?? { flattened.maxItem }}.dup(numChannels);
316                 };
318                 chanArray = Array.newClear(numChannels);
319                 if(discrete) {
320                         zoom = 1;
321                         thumbsize = max(1.0, width / (flattened.size / numChannels));
322                         unlaced.do { |chan, j|
323                                 chanArray[j] = chan.linlin( minval[j], maxval[j], 0.0, 1.0 );
324                         };
325                 } {
326                         zoom = (width / (flattened.size / numChannels));
327                         thumbsize = 1;
328                         unlaced.do { |chan, j|
329                                 val = Array.newClear(width);
330                                 width.do { arg i;
331                                         var x;
332                                         x = chan.blendAt(i / zoom);
333                                         val[i] = x.linlin(minval[j], maxval[j], 0.0, 1.0);
334                                 };
335                                 chanArray[j] = val;
336                         }
337                 };
338                 window = parent ?? { gui.window.new( name, bounds ) };
340                 layout = gui.vLayoutView.new(window,
341                         if(parent.notNil) {
342                                 Rect(bounds.left + 4, bounds.top + 4, bounds.width - 10, bounds.height - 10)
343                         } {
344                                 Rect(4, 4, bounds.width - 10, bounds.height - 10)
345                         }
346                 ).resize_(5);
348                 if(labels) {
349                         txt = gui.staticText.new(layout, Rect( 8, 0, width, 18))
350                                         .string_("index: 0, value: " ++ flattened[0].asString);
351                 };
353                 numChannels.do { |i|
354                         plotter = gui.multiSliderView.new(layout,
355                                 Rect(0, 0,
356                                         // compensate for the text
357                                         layout.bounds.width, layout.bounds.height - if(labels, {26}, {0})
358                                 ))
359                                 .readOnly_(true)
360                                 .drawLines_(discrete.not)
361                                 .drawRects_(discrete)
362                                 .indexThumbSize_(thumbsize)
363                                 .valueThumbSize_(1)
364                                 .background_(Color.white)
365                                 .colors_(Color.black, Color.blue(1.0,1.0))
366                                 .action_({|v|
367                                         var curval;
368                                         curval = v.currentvalue.linlin(0.0, 1.0, minval[i], maxval[i]);
370                                         if(labels){
371                                                 txt.string_("index: " ++ (v.index / zoom).roundUp(0.01).asString ++
372                                                 ", value: " ++ curval);
373                                         };
374                                         if(write) { flattened[(v.index / zoom).asInteger * numChannels + i ]  = curval };
375                                 })
376                                 .keyDownAction_({ |v, char|
377                                         if(char === $l) { write = write.not; v.readOnly = write.not;  };
378                                 })
379                                 .value_(chanArray[i])
380                                 .elasticMode_(1);
381                         if(numChannels > 1) { plotter.resize_(5) };
382                 };
384                 ^window.tryPerform(\front) ?? { window }
385         }
387         plot2 {|name, bounds, discrete=false, numChannels, minval, maxval|
388                 this.deprecated(thisMethod, ArrayedCollection.findRespondingMethodFor(\plot));
389                 ^this.plot(name, bounds, discrete, numChannels, minval, maxval)
390         }
393 + Function {
394         plotOld { arg duration  = 0.01, server, bounds, minval = -1.0, maxval = 1.0, parent, labels=true;
395                 var gui;
396                 this.deprecated(thisMethod, Function.findRespondingMethodFor(\plot));
397                 gui = GUI.current;
398                 this.loadToFloatArray(duration, server, { |array, buf|
399                         var numChan;
400                         numChan = buf.numChannels;
401                         {
402                                 GUI.use( gui, {
403                                         array.plotOld(bounds: bounds, numChannels: numChan, minval: minval, maxval: maxval,
404                                                 parent: parent, labels: labels)
405                                 });
406                         }.defer;
407                 })
408         }
409         plot2 {|duration = 0.01, server, bounds, minval, maxval|
410                 this.deprecated(thisMethod, Function.findRespondingMethodFor(\plot));
411                 ^this.plot(duration, server, bounds, minval, maxval)
412         }
415 + Wavetable {
416         plotOld { arg name, bounds, minval, maxval, parent, labels=true;
417                 this.deprecated(thisMethod, Wavetable.findRespondingMethodFor(\plot));
418                 ^this.asSignal.plotOld(name, bounds, minval: minval, maxval: maxval, parent: parent, labels: labels);
419         }
421         plot2 { |name, bounds, minval, maxval|
422                 this.deprecated(thisMethod, Wavetable.findRespondingMethodFor(\plot));
423                 ^this.plot(name, bounds, minval, maxval)
424         }
427 + Buffer {
428         plotOld { arg name, bounds, minval = -1.0, maxval = 1.0, parent, labels=true;
429                 var gui;
430                 gui = GUI.current;
431                 this.deprecated(thisMethod, Buffer.findRespondingMethodFor(\plot));
432                 this.loadToFloatArray(action: { |array, buf|
433                         {
434                                 GUI.use( gui, {
435                                         array.plotOld(name, bounds, numChannels: buf.numChannels, minval: minval, maxval: maxval, parent: parent, labels: labels);
436                                 });
437                         }.defer;
438                 });
439         }
440         plot2 { |name, bounds, minval, maxval|
441                 this.deprecated(thisMethod, Buffer.findRespondingMethodFor(\plot));
442                 ^this.plot(name, bounds, minval, maxval)
443         }
446 + Env {
447         plot2 { |size = 400, bounds, minval, maxval|
448                 this.deprecated(thisMethod, Env.findRespondingMethodFor(\plot));
449                 ^this.plot(size, bounds, minval, maxval)
450         }
452         plotOld { arg size = 400, bounds, minval, maxval, parent;
453                 this.deprecated(thisMethod, Env.findRespondingMethodFor(\plot));
454                 this.asSignal(size).plotOld(bounds: bounds, minval: minval, maxval: maxval, parent: parent);
455         }
458 + AbstractFunction{
459         plotGraphOld { arg n=500, from = 0.0, to = 1.0, name, bounds, discrete = false,
460                                 numChannels, minval, maxval, parent, labels = true;
461                 var array, res;
462                 this.deprecated(thisMethod, AbstractFunction.findRespondingMethodFor(\plotGraph));
463                 array = Array.interpolation(n, from, to);
464                 res = array.collect { |x| this.value(x) };
465                 res.plotOld(name, bounds, discrete, numChannels, minval, maxval, parent, labels)
466         }
468         plotGraph2 { arg n=500, from = 0.0, to = 1.0, name, bounds, discrete = false,
469                 numChannels, minval, maxval, parent, labels = true;
470                 this.deprecated(thisMethod, AbstractFunction.findRespondingMethodFor(\plotGraph));
471                 this.plotGraph(n, from, to, name, bounds, discrete, numChannels, minval, maxval, parent, labels)
472         }
475 + Main {
476         
477         recvOSCfunc { this.deprecated(thisMethod); ^recvOSCfunc; }
478         
479         recvOSCfunc_ { |newFunc|
480                 this.deprecated(thisMethod, Main.findMethod(\addOSCFunc));
481                 recvOSCfunc = newFunc;  
482         }
483         
486 + SCViewHolder {
488         layRight { arg x,y;
489                 this.deprecated(thisMethod);
490                 ^Rect(0,0,x,y)
491         }