Imported Upstream version 3.5.4~repack
Dan Stowell
11 years ago
121 | 121 | add_definitions(-DWIN32_LEAN_AND_MEAN) |
122 | 122 | |
123 | 123 | if(MSVC) |
124 | SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} /MTd") | |
125 | SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT") | |
124 | SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") | |
125 | SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") | |
126 | 126 | endif() |
127 | 127 | |
128 | 128 | # correctly link the static Boost Thread library: |
129 | 129 | add_definitions(-DBOOST_THREAD_USE_LIB) |
130 | #avoid unnecesary autolink | |
131 | add_definitions(-DBOOST_DATE_TIME_NO_LIB) | |
130 | 132 | endif() |
131 | 133 | |
132 | 134 |
4 | 4 | |
5 | 5 | |
6 | 6 | description:: |
7 | The GUI class provides a means of writing cross platform gui code. GUI provides Factory abstraction for all gui related core classes. Each gui kit is described by a gui scheme which maps class names to actual classes. These schemes are in turn used by link::Classes/ViewRedirect:: to provide a simple cross-platform gui syntax. It also provide utilities for switching kits and other cross platform tasks. You can get your available schemes (depending on what you installed) with: | |
7 | SuperCollider currently supports three operating system platforms: Macintosh OSX, UNIX (Linux and FreeBSD) and Windows (with some limitations). | |
8 | ||
9 | Graphical User Interface (GUI) code, for the most part, does not need to worry about which platform is executing the code because of the strong::view redirect:: system. At any time, one and only one strong::GUI kit:: is active. This determines which GUI classes will be used for rendering. These classes, the active views, have prefixes for the GUI kit that created the view object: SCWindow vs. JSCWindow vs. QWindow. | |
10 | ||
11 | table:: | |
12 | ## strong::GUI kit:: || strong::Code to activate:: || strong::Supported platform(s):: || strong::Framework:: || strong::Prefix:: | |
13 | ## Cocoa || code::GUI.cocoa:: || Mac OSX only || Cocoa || SC- | |
14 | ## SwingOSC || code::GUI.swing:: || All || Java + Swing || JSC- | |
15 | ## Qt || code::GUI.qt:: || All || Qt || Q- | |
16 | :: | |
17 | ||
18 | In general, users should not concern themselves with the prefixes. Instead, work with the emphasis::redirect:: classes, which have no prefix: Window, Button, Slider, etc. The redirect class will ask the currently-selected kit which emphasis::implementation class:: should be used. | |
19 | ||
20 | The GUI kit (CocoaGUI, QtGUI, SwingGUI) maps the generic view names to the implementing classes: code::Window --> SCWindow, QWindow or JSCWindow::. These schemes are in turn used by link::Classes/ViewRedirect:: to provide a simple cross-platform gui syntax. The GUI class provides utilities for switching kits and other cross platform tasks. | |
21 | ||
22 | You can get your available schemes (depending on what you installed) with: | |
8 | 23 | code:: |
9 | 24 | GUI.schemes; |
10 | 25 | :: |
13 | 28 | |
14 | 29 | subsection:: Switching and Referring to GUI Kits |
15 | 30 | |
16 | As of this writing, two GUI kits are available through the GUI class: link::Classes/CocoaGUI:: (Mac OS X native) and link::Classes/SwingGUI:: (Java). Note that link::Classes/SwingOSC:: is not part of every SuperCollider distribution, so you may have to install it separately. | |
31 | As of this writing, three GUI kits are available through the GUI class: link::Classes/QtGUI:: (Qt framework), link::Classes/CocoaGUI:: (Mac OS X native) and link::Classes/SwingGUI:: (Java). Note that link::Classes/SwingOSC:: is not part of every SuperCollider distribution, so you may have to install it separately. | |
17 | 32 | |
18 | 33 | You can switch the GUI kit by calling one of the following class methods: |
19 | 34 | code:: |
35 | GUI.qt; // use Qt in subsequent GUI creation procedures | |
20 | 36 | GUI.cocoa; // use cocoa in subsequent GUI creation procedures |
21 | 37 | GUI.swing; // use swing in subsequent GUI creation procedures |
22 | 38 | // NOTE: If you do not have SwingOSC installed, you get |
23 | 39 | // a warning only, and do not switch; so you cannot |
24 | // accidentally disable your (mac) gui system. | |
25 | :: | |
40 | // accidentally disable your gui system. | |
41 | :: | |
42 | ||
26 | 43 | These methods return the new GUI kit implementation. The current implementation can be queried by calling |
27 | 44 | code:: |
28 | 45 | GUI.current; // returns the current GUI kit implementation |
58 | 58 | |
59 | 59 | ( |
60 | 60 | o = OSCFunc({ |msg| |
61 | "rms: %, peak: %".format(msg[3], msg[4]).postln | |
61 | "peak: %, rms: %".format(msg[3], msg[4]).postln | |
62 | 62 | }, '/replyAddress'); |
63 | 63 | ) |
64 | 64 | o.free; |
6 | 6 | |
7 | 7 | Strings can be written literally using double quotes: |
8 | 8 | code:: |
9 | "my string".class.postln; | |
9 | "my string".class | |
10 | 10 | :: |
11 | 11 | A sequence of string literals will be concatenated together: |
12 | 12 | code:: |
38 | 38 | |
39 | 39 | subsection:: Accessing characters |
40 | 40 | |
41 | method::@ | |
42 | method::at | |
41 | method::@, at | |
43 | 42 | Strings respond to .at in a manner similar to other indexed collections. Each element is a link::Classes/Char::. |
44 | 43 | code:: |
45 | "ABCDEFG".at(2).postln; | |
44 | "ABCDEFG".at(2) | |
46 | 45 | :: |
47 | 46 | |
48 | 47 | method::ascii |
49 | 48 | Returns an Array of asci numbers of the Strings's characters. |
50 | 49 | code:: |
51 | "wertvoll".ascii; | |
50 | "wertvoll".ascii | |
52 | 51 | :: |
53 | 52 | |
54 | 53 | subsection:: Comparing strings |
58 | 57 | |
59 | 58 | method::< |
60 | 59 | Returns a link::Classes/Boolean:: whether the receiver should be sorted before the argument. |
60 | code:: | |
61 | "same" < "samf" | |
62 | :: | |
61 | 63 | |
62 | 64 | method::> |
63 | 65 | Returns a link::Classes/Boolean:: whether the receiver should be sorted after the argument. |
66 | code:: | |
67 | "same" > "samf" | |
68 | :: | |
69 | method::<= | |
70 | Returns a link::Classes/Boolean:: whether the receiver should be sorted before the argument, including the same string. | |
71 | code:: | |
72 | "same" <= "same" | |
73 | "same" <= "samf" | |
74 | :: | |
75 | ||
76 | method::>= | |
77 | Returns a link::Classes/Boolean:: whether the receiver should be sorted after the argument, including the same string. | |
78 | code:: | |
79 | "same" >= "same" | |
80 | "same" >= "samf" | |
81 | :: | |
64 | 82 | |
65 | 83 | method::== |
66 | 84 | Returns a link::Classes/Boolean:: whether the two Strings are equal. |
67 | 85 | note:: |
68 | This method is case insensitive! Use code::a.compare(b)==0:: if you need case sensitivity. | |
86 | This method is (now) case sensitive! | |
87 | :: | |
88 | code:: | |
89 | "same" == "same" | |
90 | "same" == "Same"; // false | |
69 | 91 | :: |
70 | 92 | |
71 | 93 | method::!= |
72 | 94 | Returns a link::Classes/Boolean:: whether the two Strings are not equal. |
95 | code:: | |
96 | "same" != "same"; // false | |
97 | "same" != "Same"; | |
98 | :: | |
73 | 99 | |
74 | 100 | subsection:: Posting strings |
75 | 101 | |
76 | 102 | method::post |
77 | 103 | Prints the string to the current post window. |
104 | code:: | |
105 | "One".post; "Two".post;""; | |
106 | :: | |
78 | 107 | |
79 | 108 | method::postln |
80 | 109 | Prints the string and a carriage return to the current post window. |
110 | code:: | |
111 | "One".postln; "Two".postln;""; | |
112 | :: | |
81 | 113 | |
82 | 114 | method::postc, postcln |
83 | 115 | As link::#-post:: and link::#-postln::, but formatted as a comment. |
101 | 133 | |
102 | 134 | method::error |
103 | 135 | Prepends an error banner and posts the string. |
136 | code:: | |
137 | "Do not press this button again".error; | |
138 | :: | |
104 | 139 | |
105 | 140 | method::warn |
106 | 141 | Prepends a warning banner and posts the string. |
142 | code:: | |
143 | "Do not press this button again".warn; | |
144 | :: | |
107 | 145 | |
108 | 146 | method::inform |
109 | 147 | Posts the string. |
148 | code:: | |
149 | "Do not press this button again".inform; | |
150 | :: | |
110 | 151 | |
111 | 152 | subsection:: Interpreting strings as code |
112 | 153 | |
186 | 227 | |
187 | 228 | method::++ |
188 | 229 | Return a concatenation of the two strings. |
230 | code:: | |
231 | "hello" ++ "word" | |
232 | :: | |
189 | 233 | |
190 | 234 | method::+ |
191 | 235 | Return a concatenation of the two strings with a space between them. |
236 | code:: | |
237 | "hello" + "word" | |
238 | :: | |
192 | 239 | |
193 | 240 | method::+/+ |
194 | 241 | Path concatenation operator - useful for avoiding doubling-up slashes unnecessarily. |
248 | 295 | "aaaabaaa".findAllRegexp("a+"); |
249 | 296 | :: |
250 | 297 | |
298 | method::findAllRegexp | |
299 | Like link::#-findAll::, but use regular expressions. | |
251 | 300 | |
252 | 301 | subsection:: Searching strings |
253 | 302 | |
305 | 354 | |
306 | 355 | subsection:: Manipulating strings |
307 | 356 | |
357 | method::rotate | |
358 | Rotate the string by n steps. | |
359 | code:: | |
360 | "hello word".rotate(1) | |
361 | :: | |
362 | ||
363 | method::scramble | |
364 | Randomize the order of characters in the string. | |
365 | code:: | |
366 | "hello word".scramble | |
367 | :: | |
368 | ||
369 | ||
370 | method::replace | |
371 | Like link::#-tr::, but with strings as arguments. | |
372 | code:: | |
373 | "Here are several words which are fish".replace("are", "were"); | |
374 | :: | |
375 | ||
376 | method::format | |
377 | Returns a formatted string with arguments. The % character in the format string is replaced by a string representation of an argument. To print a % character use \\% . | |
378 | code:: | |
379 | format("this % a %. pi = %, list = %\n", "is", "test", pi.round(1e-4), (1..4)) | |
380 | ||
381 | this is a test. pi = 3.1416, list = [ 1, 2, 3, 4 ] | |
382 | :: | |
383 | ||
308 | 384 | method::escapeChar |
309 | 385 | Add the escape character (\) before any character of your choice. |
310 | 386 | code:: |
312 | 388 | "This will become a Unix friendly string".escapeChar($ ).postln; |
313 | 389 | :: |
314 | 390 | |
315 | method::shellQuote | |
316 | Return a new string suitable for use as a filename in a shell command, by enclosing it in single quotes ( teletype::':: ). | |
317 | If the string contains any single quotes they will be escaped. | |
318 | discussion:: | |
319 | You should use this method on a path before embedding it in a string executed by link::#-unixCmd:: or link::#-systemCmd::. | |
320 | code:: | |
321 | unixCmd("ls"+Platform.userExtensionDir.shellQuote) | |
322 | :: | |
323 | note:: | |
324 | This works well with shells such as strong::bash::, other shells might need different quotation/escaping. | |
325 | :: | |
326 | ||
327 | 391 | method::quote |
328 | 392 | Return this string enclosed in double-quote ( teletype::":: ) characters. |
393 | code:: | |
394 | "tell your" + "friends".quote + "not to tread onto the lawn" | |
395 | :: | |
396 | ||
397 | method::zeroPad | |
398 | Return this string enclosed in space characters. | |
399 | code:: | |
400 | "spaces".zeroPad.postcs; | |
401 | :: | |
402 | ||
403 | method::underlined | |
404 | Return this string followed by dashes in the next line ( teletype::-:: ). | |
405 | code:: | |
406 | "underlined".underlined; | |
407 | "underlined".underlined($~); | |
408 | :: | |
329 | 409 | |
330 | 410 | method::tr |
331 | 411 | Transliteration. Replace all instances of strong::from:: with strong::to::. |
332 | 412 | code:: |
333 | 413 | ":-(:-(:-(".tr($(, $)); //turn the frowns upside down |
334 | :: | |
335 | ||
336 | method::replace | |
337 | Like link::#-tr::, but with strings as arguments. | |
338 | code:: | |
339 | "Here are several words which are fish".replace("are", "were"); | |
340 | :: | |
341 | ||
342 | method::format | |
343 | Returns a formatted string with arguments. The % character in the format string is replaced by a string representation of an argument. To print a % character use \\% . | |
344 | code:: | |
345 | format("this % a %. pi = %, list = %\n", "is", "test", pi.round(1e-4), (1..4)) | |
346 | ||
347 | this is a test. pi = 3.1416, list = [ 1, 2, 3, 4 ] | |
348 | 414 | :: |
349 | 415 | |
350 | 416 | |
355 | 421 | Number of characters to fill |
356 | 422 | argument:: string |
357 | 423 | Padding string |
424 | code:: | |
425 | "this sentence has thirty-nine letters".padRight(39, "-+"); | |
426 | "this sentence has thirty-nine letters".padLeft(30, "-+"); | |
427 | "this sentence has thirty-nine letters".padRight(13, "-+"); // nothing to pad. | |
428 | :: | |
358 | 429 | |
359 | 430 | method::toUpper |
360 | 431 | Return this string with uppercase letters. |
432 | code:: | |
433 | "Please, don't be impolite".toUpper; | |
434 | :: | |
361 | 435 | |
362 | 436 | method::toLower |
363 | 437 | Return this string with lowercase letters. |
438 | code:: | |
439 | "SINOSC".toLower; | |
440 | :: | |
364 | 441 | |
365 | 442 | method::stripRTF |
366 | 443 | Returns a new String with all RTF formatting removed. |
481 | 558 | "USER".getenv; |
482 | 559 | :: |
483 | 560 | |
561 | method::unsetenv | |
562 | Set the environment variable to nil. | |
563 | ||
564 | method::mkdir | |
565 | Make a directory from the given path location. | |
566 | ||
484 | 567 | method::pathMatch |
485 | 568 | Returns an link::Classes/Array:: containing all paths matching this String. Wildcards apply, non-recursive. |
486 | 569 | code:: |
532 | 615 | subsection::Pathname Support |
533 | 616 | |
534 | 617 | Also see link::#-+/+:: for path concatenation. |
618 | ||
619 | method::shellQuote | |
620 | Return a new string suitable for use as a filename in a shell command, by enclosing it in single quotes ( teletype::':: ). | |
621 | If the string contains any single quotes they will be escaped. | |
622 | discussion:: | |
623 | You should use this method on a path before embedding it in a string executed by link::#-unixCmd:: or link::#-systemCmd::. | |
624 | code:: | |
625 | unixCmd("ls " + Platform.userExtensionDir.shellQuote) | |
626 | :: | |
627 | note:: | |
628 | This works well with shells such as strong::bash::, other shells might need different quotation/escaping. | |
629 | Apart from usage in the construction of shell commands, strong::escaping is not needed:: for paths passed to methods like pathMatch(path) or File.open(path). | |
630 | :: | |
535 | 631 | |
536 | 632 | method::absolutePath |
537 | 633 | method::asAbsolutePath |
3 | 3 | |
4 | 4 | |
5 | 5 | |
6 | SECTION:: Platform indepedent GUI code | |
7 | ||
8 | SuperCollider provides for writing graphical user interface code that may be executed by different GUI kits implementing the same functionality. A user may not worry about the different implementations and under most circumstances generic GUI code will have the same effect in any of them. Nontheless, there may appear slight differences between them, therefore it's worth mentioning them here. | |
9 | ||
10 | subsection:: Different GUI kits | |
11 | ||
12 | Various GUI kits are managed by the link::Classes/GUI:: class. See it's documentation for details of how to switch the active GUI kit. | |
13 | ||
14 | At the moment of this writing, there exist three GUI kits: | |
6 | SECTION:: First problem: Platform independence | |
7 | ||
8 | strong::Why do you need to know about this?:: | |
9 | ||
10 | numberedlist:: | |
11 | ## You'll create a Window.new and wonder why you got back a SCWindow or QWindow. | |
12 | ## You might use Mac-only GUI objects and wonder why your friend on Windows can't run your code. | |
13 | ## On Mac, you might run some examples that are specific to Q- objects and wonder why they don't work right away. | |
14 | :: | |
15 | ||
16 | strong::Short answer:: | |
17 | ||
18 | Make sure you select the right strong::GUI kit::. | |
19 | ||
20 | When SuperCollider starts, one of the available kits becomes the default. | |
15 | 21 | |
16 | 22 | table:: |
17 | ||
18 | ## strong::Name:: || strong::Implementation:: || strong::Availability:: | |
19 | ## strong::Cocoa:: || Mac OS Cocoa toolkit || Only on Mac OS, within the SuperCollider application | |
20 | ## strong::SwingOSC:: || Java || Cross-platform, running as a separate program and commuincating with SuperCollider via OSC. | |
21 | ## strong::Qt:: || Qt framework || Cross-platform. | |
22 | ||
23 | :: | |
24 | ||
25 | subsection:: Generic GUI code | |
26 | ||
27 | There is a set of classes available for writing generic GUI code. When they are instantiated an instance of the kit-specific equivalent class is returned instead. The equivalent classes of all the GUI kits implement a large set of common methods which can therefore be used in generic code, and are documented as belonging to the generic class. | |
28 | ||
29 | The kit-specific classes typically have the same name as their generic equivalents, but prefixed with an identifier of the implementation: "SC" for Cocoa, "JSC" for SwingOSC and "Q" for Qt. | |
23 | ## strong::Platform:: || strong::Default kit:: | |
24 | ## Mac OSX || Cocoa -- code::GUI.cocoa:: | |
25 | ## Linux/FreeBSD || Qt -- code::GUI.qt:: | |
26 | ## Windows || Qt -- code::GUI.qt:: | |
27 | :: | |
28 | ||
29 | For most cases, the Qt GUI kit is sufficient. Cocoa is retained as the default in Mac OSX for historical reasons. (This may change in a future release.) | |
30 | ||
31 | warning:: Some GUI examples are Qt-specific. They are labeled as such in the documentation. Strong::These examples will not work in OSX unless you manually switch to the Qt kit:: by running the following code: | |
32 | ||
33 | code::GUI.qt;:: | |
34 | :: | |
35 | ||
36 | See the link::Classes/GUI:: help file for more background on the GUI kits. | |
37 | ||
38 | ||
39 | subsection:: Use "GUI redirect" classes whenever possible | |
40 | ||
41 | It is strongly recommended to use generic view class names: Window, Button, Slider, etc. Code written using the generic names can run in other GUI kits. | |
42 | ||
43 | code:: | |
44 | // DO write | |
45 | w = Window.new.front; | |
46 | ||
47 | // DO NOT write | |
48 | w = SCWindow.new.front; | |
49 | :: | |
50 | ||
51 | In the second example, the use of the Cocoa-specific window class ensures that the code will not run in Linux or Windows without modification. This is usually not a good idea. | |
30 | 52 | |
31 | 53 | For a list of all the generic GUI classes and their kit-specific equivalents see link::Overviews/GUI-Classes::. |
32 | 54 | |
33 | 55 | In the rest of this document we will refer to GUI classes by their generic name, adding notes where important differences between GUI kits are of concern. |
34 | ||
35 | 56 | |
36 | 57 | |
37 | 58 |
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | double xStep; | |
228 | qreal xStep; | |
229 | 229 | |
230 | 230 | QRect r( valueRect( c - startIndex, xStep ) ); |
231 | 231 | |
335 | 335 | } |
336 | 336 | |
337 | 337 | int count = _values.count() - startIndex; |
338 | double spacing, width, yscale; | |
339 | ||
340 | spacing = elastic ? (double) bounds.width() / count : thumbSize.width() + gap; | |
341 | width = elastic ? qMin( spacing, (double) thumbSize.width() ) : thumbSize.width(); | |
338 | qreal spacing, width, yscale; | |
339 | ||
340 | spacing = elastic ? (qreal) bounds.width() / count : thumbSize.width() + gap; | |
341 | width = elastic ? qMin( spacing, (qreal) thumbSize.width() ) : thumbSize.width(); | |
342 | 342 | yscale = bounds.height(); |
343 | 343 | if( !isFilled ) yscale -= thumbSize.height(); |
344 | 344 |
108 | 108 | void setStartIndex( int i ) { startIndex = qBound(0, i, _values.count()-1); update(); } |
109 | 109 | |
110 | 110 | QRect contentsRect(); |
111 | QRect valueRect( int count, double & spacing ); | |
111 | QRect valueRect( int count, qreal & spacing ); | |
112 | 112 | inline float valueFromPos( float pos, float range ); |
113 | 113 | inline void setValue( int index, double value ); |
114 | 114 | double rounded ( double value ); |
46 | 46 | { \control } { result } |
47 | 47 | { \scalar } { DC.kr(result) } |
48 | 48 | { Error("Unsupported rate % for Mix.kr".format(result.rate)).throw }; |
49 | } | |
49 | } | |
50 | ||
51 | *arFill { |n, function| | |
52 | ^this.ar(Array.fill(n, function)) | |
53 | } | |
54 | ||
55 | *krFill { |n, function| | |
56 | ^this.kr(Array.fill(n, function)) | |
57 | } | |
50 | 58 | } |
51 | 59 | |
52 | 60 |
64 | 64 | |
65 | 65 | prepareForProxySynthDef { arg proxy; |
66 | 66 | proxy.initBus(\control, 1); |
67 | ^{ÊDC.multiNewList([proxy.rate] ++ this) }; | |
67 | ^{DC.multiNewList([proxy.rate] ++ this) }; | |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
81 | 81 | +RawArray { |
82 | 82 | prepareForProxySynthDef { arg proxy; |
83 | 83 | proxy.initBus(\control, this.size); |
84 | ^{ÊDC.multiNewList([proxy.rate] ++ this) }; | |
84 | ^{DC.multiNewList([proxy.rate] ++ this) }; | |
85 | 85 | } |
86 | 86 | } |
87 | 87 |
27 | 27 | int scdoclex_destroy(void); |
28 | 28 | |
29 | 29 | char * scdoc_current_file = NULL; |
30 | ||
31 | const char * NODE_TEXT = "TEXT"; | |
32 | const char * NODE_NL = "NL"; | |
30 | 33 | |
31 | 34 | static int doc_node_dump_level_done[32] = {0,}; |
32 | 35 | |
118 | 121 | |
119 | 122 | void doc_node_fixup_tree(DocNode *n) { |
120 | 123 | int i; |
121 | if(n->id != "TEXT" && n->text) { | |
124 | if(n->id != NODE_TEXT && n->text) { | |
122 | 125 | n->text = striptrailingws(n->text); |
123 | 126 | } |
124 | 127 | if(n->n_childs) { |
125 | 128 | DocNode *last = n->children[n->n_childs-1]; |
126 | if(last->id=="NL") { | |
129 | if(last->id==NODE_NL) { | |
127 | 130 | free(last); // NL has no text or children |
128 | 131 | n->n_childs--; |
129 | 132 | } |
130 | 133 | last = NULL; |
131 | 134 | for(i = 0; i < n->n_childs; i++) { |
132 | 135 | DocNode *child = n->children[i]; |
133 | if((child->id=="TEXT" || child->id=="NL") && last && last->id=="TEXT") { | |
134 | if(child->id=="NL") { | |
136 | if((child->id==NODE_TEXT || child->id==NODE_NL) && last && last->id==NODE_TEXT) { | |
137 | if(child->id==NODE_NL) { | |
135 | 138 | last->text = (char*)realloc(last->text,strlen(last->text)+2); |
136 | 139 | strcat(last->text," "); |
137 | 140 | } else { |
3 | 3 | #define SCDOC_PARSE_FULL 0 |
4 | 4 | #define SCDOC_PARSE_PARTIAL 1 |
5 | 5 | #define SCDOC_PARSE_METADATA 2 |
6 | ||
7 | extern const char * NODE_TEXT; | |
8 | extern const char * NODE_NL; | |
6 | 9 | |
7 | 10 | typedef struct DocNode { |
8 | 11 | const char *id; |
2689 | 2689 | |
2690 | 2690 | /* Line 1455 of yacc.c */ |
2691 | 2691 | #line 292 "SCDoc.y" |
2692 | { (yyval.doc_node) = doc_node_make("TEXT",(yyvsp[(1) - (1)].str),NULL); ;} | |
2692 | { (yyval.doc_node) = doc_node_make(NODE_TEXT,(yyvsp[(1) - (1)].str),NULL); ;} | |
2693 | 2693 | break; |
2694 | 2694 | |
2695 | 2695 | case 81: |
2717 | 2717 | |
2718 | 2718 | /* Line 1455 of yacc.c */ |
2719 | 2719 | #line 296 "SCDoc.y" |
2720 | { (yyval.doc_node) = doc_node_create("NL"); ;} | |
2720 | { (yyval.doc_node) = doc_node_create(NODE_NL); ;} | |
2721 | 2721 | break; |
2722 | 2722 | |
2723 | 2723 | case 85: |
288 | 288 | | proseelem { $$ = doc_node_make("PROSE",NULL,$1); } |
289 | 289 | ; |
290 | 290 | |
291 | proseelem: anyword { $$ = doc_node_make("TEXT",$1,NULL); } // one TEXT for each word | |
291 | proseelem: anyword { $$ = doc_node_make(NODE_TEXT,$1,NULL); } // one TEXT for each word | |
292 | 292 | | URL { $$ = doc_node_make("LINK",$1,NULL); } |
293 | 293 | | inlinetag words TAGSYM { $$ = doc_node_make($1,$2,NULL); } |
294 | 294 | | FOOTNOTE body TAGSYM { $$ = doc_node_make_take_children("FOOTNOTE",NULL,$2); } |
295 | | NEWLINE { $$ = doc_node_create("NL"); } | |
295 | | NEWLINE { $$ = doc_node_create(NODE_NL); } | |
296 | 296 | ; |
297 | 297 | |
298 | 298 | inlinetag: LINK { $$ = "LINK"; } |
2 | 2 | |
3 | 3 | set(PROJECT_VERSION_MAJOR 3) |
4 | 4 | set(PROJECT_VERSION_MINOR 5) |
5 | set(PROJECT_VERSION_PATCH .3) | |
5 | set(PROJECT_VERSION_PATCH .4) |
281 | 281 | # endif |
282 | 282 | # endif |
283 | 283 | # ifdef BOOST_BIG_ENDIAN |
284 | endian & operator=(T val) { m_value = val); return *this; } | |
284 | endian & operator=(T val) { m_value = val; return *this; } | |
285 | 285 | operator T() const { return m_value; } |
286 | 286 | # else |
287 | 287 | endian & operator=(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); return *this; } |
31 | 31 | // replacement for calloc. |
32 | 32 | // calloc lazily zeroes memory on first touch. This is good for most purposes, but bad for realtime audio. |
33 | 33 | void* zalloc(size_t n, size_t size); |
34 | void zfree(void* ptr); | |
34 | 35 | |
35 | 36 | //////////////////////////////////////////////////////////////////////// |
36 | 37 |
1645 | 1645 | slotIntVal(slotRawObject(a)->slots + 5, &info.samplerate); |
1646 | 1646 | |
1647 | 1647 | file = sf_open(filename, SFM_WRITE, &info); |
1648 | sf_command(file, SFC_SET_CLIPPING, NULL, SF_TRUE); | |
1649 | ||
1648 | 1650 | if (file) { |
1649 | 1651 | SetPtr(slotRawObject(a)->slots+0, file); |
1650 | 1652 | SetTrue(a); |
38 | 38 | fi |
39 | 39 | returndir=`pwd` |
40 | 40 | cd ../ |
41 | bash package/git-archive-all.sh --prefix SuperCollider-Source/ "$returndir/SuperCollider-Source.tmp.tar" | |
41 | python package/git-archive-all.py --prefix SuperCollider-Source/ "$returndir/SuperCollider-Source.tmp.tar" | |
42 | ||
42 | 43 | cd "$returndir" |
43 | 44 | # NB we only need one instance of boost, so we exclude one of its two appearances as a submodule in the following |
44 | 45 | tar -x --exclude ".gitignore" --exclude ".gitmodules" \ |
240 | 240 | windowGuardFrame = windowFrames - 1; \ |
241 | 241 | } while (0); |
242 | 242 | |
243 | #define GET_GRAIN_WIN(WINTYPE) \ | |
244 | do { \ | |
245 | if (WINTYPE >= unit->mWorld->mNumSndBufs) { \ | |
246 | Print("Envelope buffer out of range!\n"); \ | |
247 | return; \ | |
248 | } \ | |
249 | GET_GRAIN_WIN_RELAXED(WINTYPE) \ | |
250 | } while (0); | |
243 | ||
244 | static inline bool getGrainWin(Unit * unit, float wintype, SndBuf *& window, const float * & windowData, | |
245 | uint32 & windowSamples, uint32 & windowFrames, int & windowGuardFrame) | |
246 | { | |
247 | if (wintype >= unit->mWorld->mNumSndBufs) { | |
248 | Print("Envelope buffer out of range!\n"); | |
249 | return false; | |
250 | } | |
251 | ||
252 | assert(wintype < unit->mWorld->mNumSndBufs); | |
253 | window = unit->mWorld->mSndBufs + (int)wintype; | |
254 | windowData = window->data; | |
255 | if (!windowData) | |
256 | return false; | |
257 | ||
258 | windowSamples = window->samples; | |
259 | windowFrames = window->frames; | |
260 | windowGuardFrame = windowFrames - 1; | |
261 | ||
262 | return true; | |
263 | } | |
251 | 264 | |
252 | 265 | #define GRAIN_LOOP_BODY_4 \ |
253 | 266 | float amp = y1 * y1; \ |
533 | 546 | |
534 | 547 | float winType = grain_in_at<full_rate>(unit, 4, position); |
535 | 548 | DECLARE_WINDOW |
536 | GET_GRAIN_WIN(winType) | |
537 | if (winType >= 0 && (windowData == NULL)) | |
549 | bool success = getGrainWin(unit, winType, window, windowData, windowSamples, windowFrames, windowGuardFrame); | |
550 | if (!success) | |
538 | 551 | return; |
539 | 552 | |
540 | 553 | GrainInG *grain = unit->mGrains + unit->mNumActive++; |
682 | 695 | |
683 | 696 | float winType = grain_in_at<full_rate>(unit, 4, position); |
684 | 697 | DECLARE_WINDOW |
685 | GET_GRAIN_WIN(winType) | |
686 | if (winType >= 0 && (windowData == NULL)) | |
698 | bool success = getGrainWin(unit, winType, window, windowData, windowSamples, windowFrames, windowGuardFrame); | |
699 | if (!success) | |
687 | 700 | return; |
688 | 701 | |
689 | 702 | GrainSinG *grain = unit->mGrains + unit->mNumActive++; |
849 | 862 | |
850 | 863 | float winType = grain_in_at<full_rate>(unit, 6, position); |
851 | 864 | DECLARE_WINDOW |
852 | GET_GRAIN_WIN(winType) | |
853 | if (winType >= 0 && (windowData == NULL)) | |
865 | bool success = getGrainWin(unit, winType, window, windowData, windowSamples, windowFrames, windowGuardFrame); | |
866 | if (!success) | |
854 | 867 | return; |
855 | 868 | |
856 | 869 | GrainFMG *grain = unit->mGrains + unit->mNumActive++; |
1089 | 1102 | |
1090 | 1103 | GRAIN_BUF |
1091 | 1104 | |
1092 | if (!bufData) { | |
1105 | if (!bufData || (bufChannels != 1)) { | |
1093 | 1106 | grain->counter -= inNumSamples; |
1094 | 1107 | if (!GrainBuf_grain_cleanup(unit, grain)) |
1095 | ++i; | |
1108 | ++i; | |
1096 | 1109 | continue; |
1097 | 1110 | } |
1098 | 1111 | |
1102 | 1115 | |
1103 | 1116 | DECLARE_WINDOW |
1104 | 1117 | GET_GRAIN_AMP_PARAMS |
1118 | ||
1119 | ||
1105 | 1120 | |
1106 | 1121 | // begin add // |
1107 | 1122 | float pan2 = 0.f; |
1138 | 1153 | GrainBufG *grain = unit->mGrains + unit->mNumActive++; |
1139 | 1154 | float winType = grain_in_at<full_rate>(unit, 7, position); |
1140 | 1155 | DECLARE_WINDOW |
1141 | GET_GRAIN_WIN(winType) | |
1142 | if (winType >= 0 && (windowData == NULL)) | |
1156 | bool success = getGrainWin(unit, winType, window, windowData, windowSamples, windowFrames, windowGuardFrame); | |
1157 | if (!success) { | |
1158 | GrainBuf_grain_cleanup(unit, grain); | |
1143 | 1159 | return; |
1160 | } | |
1144 | 1161 | |
1145 | 1162 | int32 bufnum = grain_in_at<full_rate>(unit, 2, position); |
1146 | 1163 | grain->bufnum = bufnum; |
318 | 318 | |
319 | 319 | void BufAllocCmd::Stage4() |
320 | 320 | { |
321 | free(mFreeData); | |
321 | zfree(mFreeData); | |
322 | 322 | SendDoneWithIntValue("/b_alloc", mBufIndex); |
323 | 323 | } |
324 | 324 | |
384 | 384 | |
385 | 385 | void BufGenCmd::Stage4() |
386 | 386 | { |
387 | free(mFreeData); | |
387 | zfree(mFreeData); | |
388 | 388 | SendDoneWithIntValue("/b_gen", mBufIndex); |
389 | 389 | } |
390 | 390 | |
439 | 439 | |
440 | 440 | void BufFreeCmd::Stage4() |
441 | 441 | { |
442 | free(mFreeData); | |
442 | zfree(mFreeData); | |
443 | 443 | SendDoneWithIntValue("/b_free", mBufIndex); |
444 | 444 | } |
445 | 445 | |
574 | 574 | |
575 | 575 | void BufAllocReadCmd::Stage4() |
576 | 576 | { |
577 | free(mFreeData); | |
577 | zfree(mFreeData); | |
578 | 578 | SendDoneWithIntValue("/b_allocRead", mBufIndex); |
579 | 579 | } |
580 | 580 | |
861 | 861 | |
862 | 862 | void BufAllocReadChannelCmd::Stage4() |
863 | 863 | { |
864 | free(mFreeData); | |
864 | zfree(mFreeData); | |
865 | 865 | SendDoneWithIntValue("/b_allocReadChannel", mBufIndex); |
866 | 866 | } |
867 | 867 | |
1095 | 1095 | |
1096 | 1096 | if (mNumFrames > framesToEnd) mNumFrames = framesToEnd; |
1097 | 1097 | |
1098 | sf_command(sf, SFC_SET_CLIPPING, NULL, SF_TRUE); // choose clipping rather than wraparound for integer-format files | |
1099 | ||
1098 | 1100 | if (mNumFrames > 0) { |
1099 | 1101 | sf_writef_float(sf, buf->data + (mBufOffset * buf->channels), mNumFrames); |
1100 | 1102 | } |
153 | 153 | return zalloc_(n, size); |
154 | 154 | } |
155 | 155 | |
156 | void zfree(void * ptr) | |
157 | { | |
158 | return free(ptr); | |
159 | } | |
160 | ||
156 | 161 | |
157 | 162 | //////////////////////////////////////////////////////////////////////////////// |
158 | 163 | |
541 | 546 | inOptions->mNonRealTimeOutputHeaderFormat, inOptions->mNonRealTimeOutputSampleFormat); |
542 | 547 | |
543 | 548 | world->hw->mNRTOutputFile = sf_open(inOptions->mNonRealTimeOutputFilename, SFM_WRITE, &outputFileInfo); |
549 | sf_command(world->hw->mNRTOutputFile, SFC_SET_CLIPPING, NULL, SF_TRUE); | |
550 | ||
544 | 551 | if (!world->hw->mNRTOutputFile) |
545 | 552 | throw std::runtime_error("Couldn't open non real time output file.\n"); |
546 | 553 |
72 | 72 | output_channels = output_channel_count; |
73 | 73 | samplerate_ = samplerate = std::floor(samplerate); |
74 | 74 | |
75 | if (!input_file_name.empty()) | |
76 | { | |
75 | if (!input_file_name.empty()) { | |
77 | 76 | input_file = SndfileHandle(input_file_name.c_str(), SFM_READ); |
78 | 77 | if (!input_file) |
79 | 78 | throw std::runtime_error("cannot open input file"); |
91 | 90 | output_file = SndfileHandle(output_file_name.c_str(), SFM_WRITE, format, output_channel_count, samplerate); |
92 | 91 | if (!output_file) |
93 | 92 | throw std::runtime_error("cannot open output file"); |
93 | ||
94 | output_file.command(SFC_SET_CLIPPING, NULL, SF_TRUE); | |
95 | ||
94 | 96 | super::output_samples.resize(output_channel_count); |
95 | 97 | |
96 | 98 | temp_buffer.reset(calloc_aligned<float>(std::max(input_channels, output_channels) * 64)); |
153 | 153 | if (!sndfile) |
154 | 154 | throw std::runtime_error(std::string("could not open file: ") + std::string(file)); |
155 | 155 | |
156 | sndfile.command(SFC_SET_CLIPPING, NULL, SF_TRUE); | |
157 | ||
156 | 158 | size_t written = sndfile.writef(data, frames_); |
157 | 159 | if (written != frames_) |
158 | 160 | throw std::runtime_error(std::string("could not write file: ") + std::string(file)); |
29 | 29 | #include <tbb/cache_aligned_allocator.h> |
30 | 30 | #endif /* HAVE_TBB */ |
31 | 31 | |
32 | #ifdef _MSC_VER | |
33 | #include <malloc.h> | |
34 | #endif | |
35 | ||
32 | 36 | #include "function_attributes.h" |
33 | 37 | |
34 | 38 | namespace nova { |
86 | 90 | inline void free_aligned(void *ptr) |
87 | 91 | { |
88 | 92 | _mm_free(ptr); |
93 | } | |
94 | ||
95 | #elif defined(_MSC_VER) | |
96 | ||
97 | const int malloc_memory_alignment = 64; | |
98 | ||
99 | inline void* MALLOC malloc_aligned(std::size_t nbytes) | |
100 | { | |
101 | return _aligned_malloc(nbytes, malloc_memory_alignment); | |
102 | } | |
103 | ||
104 | inline void free_aligned(void *ptr) | |
105 | { | |
106 | _aligned_free(ptr); | |
89 | 107 | } |
90 | 108 | |
91 | 109 | #elif defined(HAVE_TBB) |