2 summary:: score of timed OSC commands
3 related:: Guides/Non-Realtime-Synthesis
4 categories:: Control, OpenSoundControl
7 Score encapsulates a list of timed OSC commands and provides some methods for using it, as well as support for the creation of binary OSC files for non-realtime synthesis. See link::Guides/Non-Realtime-Synthesis:: for more details.
9 The list should be in the following format, with times in ascending order. Bundles are okay.
14 [beat2, [OSCcmd2], [OSCcmd3]],
17 [beatToEndNRT, [\c_set, 0, 0]] // finish
21 For NRT synthesis the final event should a dummy event, after which synthesis will cease. It is thus important that this event be timed to allow previous events to complete.
23 Score scheduling defaults to link::Classes/TempoClock::. A setting of code::TempoClock.default.tempo = 1 :: (60 beats per minute), may be used to express score events in seconds if desired.
30 returns a new Score object with the supplied list.
33 can be an link::Classes/Array::, a link::Classes/List::, or similar object.
36 as link::#*new::, but reads the list in from a text file.
39 a link::Classes/String:: indicating the path of the file. The file must contain a valid SC expression.
42 as link::#*new:: but immediately plays it. (See also the instance method below.)
45 If no value is supplied it will play on the default link::Classes/Server::.
48 as link::#*play::, but reads the list from a file.
51 a convenience method to create a binary OSC file for NRT synthesis. Does not create an instance.
54 a link::Classes/String:: containing the desired path of the OSC file.
57 Use clock as a tempo base. code::TempoClock.default:: is used if clock is nil.
60 as link::#*write:: but reads the list from a file.
63 Use clock as a tempo base. code::TempoClock.default:: is used if clock is nil.
66 a convenience method to synthesize strong::list:: in non-realtime. This method writes an OSC file to strong::oscFilePath:: (you have to do your own cleanup if desired) and then starts a server app to synthesize it. For details on valid headerFormats and sampleFormats see link::Classes/SoundFile::. Use code::TempoClock.default:: as a tempo base. Does not return an instance.
69 the path to which the binary OSC file will be written.
71 argument::outputFilePath
72 the path of the resultant soundfile.
74 argument::inputFilePath
75 an optional path for an input soundfile.
78 the sample rate at which synthesis will occur.
80 argument::headerFormat
81 the header format of the output file. The default is 'AIFF'.
83 argument::sampleFormat
84 the sample format of the output file. The default is 'int16'.
87 an instance of link::Classes/ServerOptions::. If not supplied the options of the default link::Classes/Server:: will be used.
90 A function to be evaluated once the NRT server has finished rendering its score.
95 play the list on strong::server::, use strong::clock:: as a tempo base and quantize start time to strong::quant::. If strong::server:: is nil, then on the default server. code::TempoClock.default:: if strong::clock:: is nil. now if strong::quant:: is 0.
101 create a binary OSC file for NRT synthesis from the list. Use strong::clock:: as a tempo base. code::TempoClock.default:: if strong::clock:: is nil.
107 adds bundle to the list.
110 sort the score time order. This is recommended to do strong::before recordNRT or write:: when you are not sure about the packet order.
113 synthesize the score in non-realtime. For details of the arguments see link::#*recordNRT:: above.
116 save the score list as a text file to strong::path::.
120 subsection::NRT Examples
125 SynthDef("helpscore",{ arg freq = 440;
127 SinOsc.ar(freq, 0, 0.2) * Line.kr(1, 0, 0.5, doneAction: 2)
132 // write a sample file for testing
135 TempoClock.default.tempo = 1;
137 [0.1, [\s_new, \helpscore, 1000, 0, 0, \freq, 440]],
138 [0.2, [\s_new, \helpscore, 1001, 0, 0, \freq, 660]],
139 [0.3, [\s_new, \helpscore, 1002, 0, 0, \freq, 220]],
140 [1, [\c_set, 0, 0]] // finish
142 f = File("score-test","w");
143 f.write(g.asCompileString);
147 //convert it to a binary OSC file for use with NRT
148 Score.writeFromFile("score-test", "test.osc");
151 From the command line, the file can then be rendered from within the build directory:
154 ./scsynth -N test.osc _ test.aif 44100 AIFF int16 -o 1
157 Score also provides methods to do all this more directly:
163 [0.1, [\s_new, \helpscore, 1000, 0, 0, \freq, 440]],
164 [0.2, [\s_new, \helpscore, 1001, 0, 0, \freq, 660],
165 [\s_new, \helpscore, 1002, 0, 0, \freq, 880]],
166 [0.3, [\s_new, \helpscore, 1003, 0, 0, \freq, 220]],
167 [1, [\c_set, 0, 0]] // finish
169 o = ServerOptions.new.numOutputBusChannels = 1; // mono output
170 Score.recordNRT(g, "help-oscFile", "helpNRT.aiff", options: o); // synthesize
174 subsection::Real-time Examples
177 s.boot; // boot the default server
181 SynthDef("helpscore",{ arg freq = 440;
183 SinOsc.ar(freq, 0, 0.2) * Line.kr(1, 0, 0.5, doneAction: 2)
188 // write a sample file for testing
191 TempoClock.default.tempo = 1;
193 [0.1, [\s_new, \helpscore, 1000, 0, 0, \freq, 440]],
194 [0.2, [\s_new, \helpscore, 1001, 0, 0, \freq, 660],
195 [\s_new, \helpscore, 1002, 0, 0, \freq, 880]],
196 [0.3, [\s_new, \helpscore, 1003, 0, 0, \freq, 220]],
197 [1, [\c_set, 0, 0]] // finish
199 f = File("score-test","w");
200 f.write(g.asCompileString);
204 z = Score.newFromFile("score-test");
206 // play it on the default server
212 [0.0, [ \s_new, \helpscore, 1000, 0, 0, \freq, 1413 ]],
213 [0.1, [ \s_new, \helpscore, 1001, 0, 0, \freq, 712 ]],
214 [0.2, [ \s_new, \helpscore, 1002, 0, 0, \freq, 417 ]],
215 [0.3, [ \s_new, \helpscore, 1003, 0, 0, \freq, 1238 ]],
216 [0.4, [ \s_new, \helpscore, 1004, 0, 0, \freq, 996 ]],
217 [0.5, [ \s_new, \helpscore, 1005, 0, 0, \freq, 1320 ]],
218 [0.6, [ \s_new, \helpscore, 1006, 0, 0, \freq, 864 ]],
219 [0.7, [ \s_new, \helpscore, 1007, 0, 0, \freq, 1033 ]],
220 [0.8, [ \s_new, \helpscore, 1008, 0, 0, \freq, 1693 ]],
221 [0.9, [ \s_new, \helpscore, 1009, 0, 0, \freq, 410 ]],
222 [1.0, [ \s_new, \helpscore, 1010, 0, 0, \freq, 1349 ]],
223 [1.1, [ \s_new, \helpscore, 1011, 0, 0, \freq, 1449 ]],
224 [1.2, [ \s_new, \helpscore, 1012, 0, 0, \freq, 1603 ]],
225 [1.3, [ \s_new, \helpscore, 1013, 0, 0, \freq, 333 ]],
226 [1.4, [ \s_new, \helpscore, 1014, 0, 0, \freq, 678 ]],
227 [1.5, [ \s_new, \helpscore, 1015, 0, 0, \freq, 503 ]],
228 [1.6, [ \s_new, \helpscore, 1016, 0, 0, \freq, 820 ]],
229 [1.7, [ \s_new, \helpscore, 1017, 0, 0, \freq, 1599 ]],
230 [1.8, [ \s_new, \helpscore, 1018, 0, 0, \freq, 968 ]],
231 [1.9, [ \s_new, \helpscore, 1019, 0, 0, \freq, 1347 ]],
232 [2.0, [\c_set, 0, 0]] // finish
241 // play and stop after one second
244 SystemClock.sched(1.0, {z.stop;});
248 subsection::creating Score from a pattern
256 \dur, Prand([0.3, 0.5], inf),
257 \freq, Prand([200, 300, 500],inf)
261 // make a score from the pattern, 4 beats long
267 // rendering a pattern to sound file directly:
269 // render the pattern to aiff (4 beats)
271 p.render("asScore-Help.aif", 4.0);