Codebase list supercollider / 2c8df6e
Imported Upstream version 3.5.4~repack Dan Stowell 11 years ago
24 changed file(s) with 309 addition(s) and 107 deletion(s). Raw diff Collapse all Expand all
121121 add_definitions(-DWIN32_LEAN_AND_MEAN)
122122
123123 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")
126126 endif()
127127
128128 # correctly link the static Boost Thread library:
129129 add_definitions(-DBOOST_THREAD_USE_LIB)
130 #avoid unnecesary autolink
131 add_definitions(-DBOOST_DATE_TIME_NO_LIB)
130132 endif()
131133
132134
44
55
66 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:
823 code::
924 GUI.schemes;
1025 ::
1328
1429 subsection:: Switching and Referring to GUI Kits
1530
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.
1732
1833 You can switch the GUI kit by calling one of the following class methods:
1934 code::
35 GUI.qt; // use Qt in subsequent GUI creation procedures
2036 GUI.cocoa; // use cocoa in subsequent GUI creation procedures
2137 GUI.swing; // use swing in subsequent GUI creation procedures
2238 // NOTE: If you do not have SwingOSC installed, you get
2339 // 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
2643 These methods return the new GUI kit implementation. The current implementation can be queried by calling
2744 code::
2845 GUI.current; // returns the current GUI kit implementation
5858
5959 (
6060 o = OSCFunc({ |msg|
61 "rms: %, peak: %".format(msg[3], msg[4]).postln
61 "peak: %, rms: %".format(msg[3], msg[4]).postln
6262 }, '/replyAddress');
6363 )
6464 o.free;
66
77 Strings can be written literally using double quotes:
88 code::
9 "my string".class.postln;
9 "my string".class
1010 ::
1111 A sequence of string literals will be concatenated together:
1212 code::
3838
3939 subsection:: Accessing characters
4040
41 method::@
42 method::at
41 method::@, at
4342 Strings respond to .at in a manner similar to other indexed collections. Each element is a link::Classes/Char::.
4443 code::
45 "ABCDEFG".at(2).postln;
44 "ABCDEFG".at(2)
4645 ::
4746
4847 method::ascii
4948 Returns an Array of asci numbers of the Strings's characters.
5049 code::
51 "wertvoll".ascii;
50 "wertvoll".ascii
5251 ::
5352
5453 subsection:: Comparing strings
5857
5958 method::<
6059 Returns a link::Classes/Boolean:: whether the receiver should be sorted before the argument.
60 code::
61 "same" < "samf"
62 ::
6163
6264 method::>
6365 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 ::
6482
6583 method::==
6684 Returns a link::Classes/Boolean:: whether the two Strings are equal.
6785 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
6991 ::
7092
7193 method::!=
7294 Returns a link::Classes/Boolean:: whether the two Strings are not equal.
95 code::
96 "same" != "same"; // false
97 "same" != "Same";
98 ::
7399
74100 subsection:: Posting strings
75101
76102 method::post
77103 Prints the string to the current post window.
104 code::
105 "One".post; "Two".post;"";
106 ::
78107
79108 method::postln
80109 Prints the string and a carriage return to the current post window.
110 code::
111 "One".postln; "Two".postln;"";
112 ::
81113
82114 method::postc, postcln
83115 As link::#-post:: and link::#-postln::, but formatted as a comment.
101133
102134 method::error
103135 Prepends an error banner and posts the string.
136 code::
137 "Do not press this button again".error;
138 ::
104139
105140 method::warn
106141 Prepends a warning banner and posts the string.
142 code::
143 "Do not press this button again".warn;
144 ::
107145
108146 method::inform
109147 Posts the string.
148 code::
149 "Do not press this button again".inform;
150 ::
110151
111152 subsection:: Interpreting strings as code
112153
186227
187228 method::++
188229 Return a concatenation of the two strings.
230 code::
231 "hello" ++ "word"
232 ::
189233
190234 method::+
191235 Return a concatenation of the two strings with a space between them.
236 code::
237 "hello" + "word"
238 ::
192239
193240 method::+/+
194241 Path concatenation operator - useful for avoiding doubling-up slashes unnecessarily.
248295 "aaaabaaa".findAllRegexp("a+");
249296 ::
250297
298 method::findAllRegexp
299 Like link::#-findAll::, but use regular expressions.
251300
252301 subsection:: Searching strings
253302
305354
306355 subsection:: Manipulating strings
307356
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
308384 method::escapeChar
309385 Add the escape character (\) before any character of your choice.
310386 code::
312388 "This will become a Unix friendly string".escapeChar($ ).postln;
313389 ::
314390
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
327391 method::quote
328392 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 ::
329409
330410 method::tr
331411 Transliteration. Replace all instances of strong::from:: with strong::to::.
332412 code::
333413 ":-(:-(:-(".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 ]
348414 ::
349415
350416
355421 Number of characters to fill
356422 argument:: string
357423 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 ::
358429
359430 method::toUpper
360431 Return this string with uppercase letters.
432 code::
433 "Please, don't be impolite".toUpper;
434 ::
361435
362436 method::toLower
363437 Return this string with lowercase letters.
438 code::
439 "SINOSC".toLower;
440 ::
364441
365442 method::stripRTF
366443 Returns a new String with all RTF formatting removed.
481558 "USER".getenv;
482559 ::
483560
561 method::unsetenv
562 Set the environment variable to nil.
563
564 method::mkdir
565 Make a directory from the given path location.
566
484567 method::pathMatch
485568 Returns an link::Classes/Array:: containing all paths matching this String. Wildcards apply, non-recursive.
486569 code::
532615 subsection::Pathname Support
533616
534617 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 ::
535631
536632 method::absolutePath
537633 method::asAbsolutePath
33
44
55
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.
1521
1622 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.
3052
3153 For a list of all the generic GUI classes and their kit-specific equivalents see link::Overviews/GUI-Classes::.
3254
3355 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
3556
3657
3758
225225 return;
226226 }
227227
228 double xStep;
228 qreal xStep;
229229
230230 QRect r( valueRect( c - startIndex, xStep ) );
231231
335335 }
336336
337337 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();
342342 yscale = bounds.height();
343343 if( !isFilled ) yscale -= thumbSize.height();
344344
108108 void setStartIndex( int i ) { startIndex = qBound(0, i, _values.count()-1); update(); }
109109
110110 QRect contentsRect();
111 QRect valueRect( int count, double & spacing );
111 QRect valueRect( int count, qreal & spacing );
112112 inline float valueFromPos( float pos, float range );
113113 inline void setValue( int index, double value );
114114 double rounded ( double value );
4646 { \control } { result }
4747 { \scalar } { DC.kr(result) }
4848 { 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 }
5058 }
5159
5260
6464
6565 prepareForProxySynthDef { arg proxy;
6666 proxy.initBus(\control, 1);
67 ^{ÊDC.multiNewList([proxy.rate] ++ this) };
67 ^{DC.multiNewList([proxy.rate] ++ this) };
6868 }
6969 }
7070
8181 +RawArray {
8282 prepareForProxySynthDef { arg proxy;
8383 proxy.initBus(\control, this.size);
84 ^{ÊDC.multiNewList([proxy.rate] ++ this) };
84 ^{DC.multiNewList([proxy.rate] ++ this) };
8585 }
8686 }
8787
2727 int scdoclex_destroy(void);
2828
2929 char * scdoc_current_file = NULL;
30
31 const char * NODE_TEXT = "TEXT";
32 const char * NODE_NL = "NL";
3033
3134 static int doc_node_dump_level_done[32] = {0,};
3235
118121
119122 void doc_node_fixup_tree(DocNode *n) {
120123 int i;
121 if(n->id != "TEXT" && n->text) {
124 if(n->id != NODE_TEXT && n->text) {
122125 n->text = striptrailingws(n->text);
123126 }
124127 if(n->n_childs) {
125128 DocNode *last = n->children[n->n_childs-1];
126 if(last->id=="NL") {
129 if(last->id==NODE_NL) {
127130 free(last); // NL has no text or children
128131 n->n_childs--;
129132 }
130133 last = NULL;
131134 for(i = 0; i < n->n_childs; i++) {
132135 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) {
135138 last->text = (char*)realloc(last->text,strlen(last->text)+2);
136139 strcat(last->text," ");
137140 } else {
33 #define SCDOC_PARSE_FULL 0
44 #define SCDOC_PARSE_PARTIAL 1
55 #define SCDOC_PARSE_METADATA 2
6
7 extern const char * NODE_TEXT;
8 extern const char * NODE_NL;
69
710 typedef struct DocNode {
811 const char *id;
26892689
26902690 /* Line 1455 of yacc.c */
26912691 #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); ;}
26932693 break;
26942694
26952695 case 81:
27172717
27182718 /* Line 1455 of yacc.c */
27192719 #line 296 "SCDoc.y"
2720 { (yyval.doc_node) = doc_node_create("NL"); ;}
2720 { (yyval.doc_node) = doc_node_create(NODE_NL); ;}
27212721 break;
27222722
27232723 case 85:
288288 | proseelem { $$ = doc_node_make("PROSE",NULL,$1); }
289289 ;
290290
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
292292 | URL { $$ = doc_node_make("LINK",$1,NULL); }
293293 | inlinetag words TAGSYM { $$ = doc_node_make($1,$2,NULL); }
294294 | FOOTNOTE body TAGSYM { $$ = doc_node_make_take_children("FOOTNOTE",NULL,$2); }
295 | NEWLINE { $$ = doc_node_create("NL"); }
295 | NEWLINE { $$ = doc_node_create(NODE_NL); }
296296 ;
297297
298298 inlinetag: LINK { $$ = "LINK"; }
22
33 set(PROJECT_VERSION_MAJOR 3)
44 set(PROJECT_VERSION_MINOR 5)
5 set(PROJECT_VERSION_PATCH .3)
5 set(PROJECT_VERSION_PATCH .4)
281281 # endif
282282 # endif
283283 # ifdef BOOST_BIG_ENDIAN
284 endian & operator=(T val) { m_value = val); return *this; }
284 endian & operator=(T val) { m_value = val; return *this; }
285285 operator T() const { return m_value; }
286286 # else
287287 endian & operator=(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); return *this; }
3131 // replacement for calloc.
3232 // calloc lazily zeroes memory on first touch. This is good for most purposes, but bad for realtime audio.
3333 void* zalloc(size_t n, size_t size);
34 void zfree(void* ptr);
3435
3536 ////////////////////////////////////////////////////////////////////////
3637
16451645 slotIntVal(slotRawObject(a)->slots + 5, &info.samplerate);
16461646
16471647 file = sf_open(filename, SFM_WRITE, &info);
1648 sf_command(file, SFC_SET_CLIPPING, NULL, SF_TRUE);
1649
16481650 if (file) {
16491651 SetPtr(slotRawObject(a)->slots+0, file);
16501652 SetTrue(a);
3838 fi
3939 returndir=`pwd`
4040 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
4243 cd "$returndir"
4344 # NB we only need one instance of boost, so we exclude one of its two appearances as a submodule in the following
4445 tar -x --exclude ".gitignore" --exclude ".gitmodules" \
240240 windowGuardFrame = windowFrames - 1; \
241241 } while (0);
242242
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 }
251264
252265 #define GRAIN_LOOP_BODY_4 \
253266 float amp = y1 * y1; \
533546
534547 float winType = grain_in_at<full_rate>(unit, 4, position);
535548 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)
538551 return;
539552
540553 GrainInG *grain = unit->mGrains + unit->mNumActive++;
682695
683696 float winType = grain_in_at<full_rate>(unit, 4, position);
684697 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)
687700 return;
688701
689702 GrainSinG *grain = unit->mGrains + unit->mNumActive++;
849862
850863 float winType = grain_in_at<full_rate>(unit, 6, position);
851864 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)
854867 return;
855868
856869 GrainFMG *grain = unit->mGrains + unit->mNumActive++;
10891102
10901103 GRAIN_BUF
10911104
1092 if (!bufData) {
1105 if (!bufData || (bufChannels != 1)) {
10931106 grain->counter -= inNumSamples;
10941107 if (!GrainBuf_grain_cleanup(unit, grain))
1095 ++i;
1108 ++i;
10961109 continue;
10971110 }
10981111
11021115
11031116 DECLARE_WINDOW
11041117 GET_GRAIN_AMP_PARAMS
1118
1119
11051120
11061121 // begin add //
11071122 float pan2 = 0.f;
11381153 GrainBufG *grain = unit->mGrains + unit->mNumActive++;
11391154 float winType = grain_in_at<full_rate>(unit, 7, position);
11401155 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);
11431159 return;
1160 }
11441161
11451162 int32 bufnum = grain_in_at<full_rate>(unit, 2, position);
11461163 grain->bufnum = bufnum;
318318
319319 void BufAllocCmd::Stage4()
320320 {
321 free(mFreeData);
321 zfree(mFreeData);
322322 SendDoneWithIntValue("/b_alloc", mBufIndex);
323323 }
324324
384384
385385 void BufGenCmd::Stage4()
386386 {
387 free(mFreeData);
387 zfree(mFreeData);
388388 SendDoneWithIntValue("/b_gen", mBufIndex);
389389 }
390390
439439
440440 void BufFreeCmd::Stage4()
441441 {
442 free(mFreeData);
442 zfree(mFreeData);
443443 SendDoneWithIntValue("/b_free", mBufIndex);
444444 }
445445
574574
575575 void BufAllocReadCmd::Stage4()
576576 {
577 free(mFreeData);
577 zfree(mFreeData);
578578 SendDoneWithIntValue("/b_allocRead", mBufIndex);
579579 }
580580
861861
862862 void BufAllocReadChannelCmd::Stage4()
863863 {
864 free(mFreeData);
864 zfree(mFreeData);
865865 SendDoneWithIntValue("/b_allocReadChannel", mBufIndex);
866866 }
867867
10951095
10961096 if (mNumFrames > framesToEnd) mNumFrames = framesToEnd;
10971097
1098 sf_command(sf, SFC_SET_CLIPPING, NULL, SF_TRUE); // choose clipping rather than wraparound for integer-format files
1099
10981100 if (mNumFrames > 0) {
10991101 sf_writef_float(sf, buf->data + (mBufOffset * buf->channels), mNumFrames);
11001102 }
153153 return zalloc_(n, size);
154154 }
155155
156 void zfree(void * ptr)
157 {
158 return free(ptr);
159 }
160
156161
157162 ////////////////////////////////////////////////////////////////////////////////
158163
541546 inOptions->mNonRealTimeOutputHeaderFormat, inOptions->mNonRealTimeOutputSampleFormat);
542547
543548 world->hw->mNRTOutputFile = sf_open(inOptions->mNonRealTimeOutputFilename, SFM_WRITE, &outputFileInfo);
549 sf_command(world->hw->mNRTOutputFile, SFC_SET_CLIPPING, NULL, SF_TRUE);
550
544551 if (!world->hw->mNRTOutputFile)
545552 throw std::runtime_error("Couldn't open non real time output file.\n");
546553
7272 output_channels = output_channel_count;
7373 samplerate_ = samplerate = std::floor(samplerate);
7474
75 if (!input_file_name.empty())
76 {
75 if (!input_file_name.empty()) {
7776 input_file = SndfileHandle(input_file_name.c_str(), SFM_READ);
7877 if (!input_file)
7978 throw std::runtime_error("cannot open input file");
9190 output_file = SndfileHandle(output_file_name.c_str(), SFM_WRITE, format, output_channel_count, samplerate);
9291 if (!output_file)
9392 throw std::runtime_error("cannot open output file");
93
94 output_file.command(SFC_SET_CLIPPING, NULL, SF_TRUE);
95
9496 super::output_samples.resize(output_channel_count);
9597
9698 temp_buffer.reset(calloc_aligned<float>(std::max(input_channels, output_channels) * 64));
153153 if (!sndfile)
154154 throw std::runtime_error(std::string("could not open file: ") + std::string(file));
155155
156 sndfile.command(SFC_SET_CLIPPING, NULL, SF_TRUE);
157
156158 size_t written = sndfile.writef(data, frames_);
157159 if (written != frames_)
158160 throw std::runtime_error(std::string("could not write file: ") + std::string(file));
2929 #include <tbb/cache_aligned_allocator.h>
3030 #endif /* HAVE_TBB */
3131
32 #ifdef _MSC_VER
33 #include <malloc.h>
34 #endif
35
3236 #include "function_attributes.h"
3337
3438 namespace nova {
8690 inline void free_aligned(void *ptr)
8791 {
8892 _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);
89107 }
90108
91109 #elif defined(HAVE_TBB)