|
Re: NRT options Part II: msg#00158audio.supercollider.devel
This may work. I returned to having recordNRT using a duration argument. This takes care of what I originally was looking for: the ability to render to a certain point in NRT. Along with what Julian was suggesting, I also made a method called section, which creates a new Score object from a section of the original score (and keeps the original score intact). section has three arguments: start, end and configevents. configevents can contain a bundle array for any configuration events (as James mentioned). These changes wouldn't break any existing code (recordNRT works exactly the same way by default). section may be convenient for rendering just a part of a score (easier I think than going into a possibly long score and excising chunks). I tried to warn against a couple of possible errors. If configevents isn't an array, or use 0.0 as he time stamp, the function returns an error. How do these look? Thanks for any suggestions, Josh <x-tad-smaller> section {</x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> start = 0, end = </x-tad-smaller><x-tad-smaller>nil, configevents = nil</x-tad-smaller><x-tad-smaller>; </x-tad-smaller><x-tad-smaller>var</x-tad-smaller><x-tad-smaller> thisscore; thisscore = Array.new; end.isNil.if{end = </x-tad-smaller><x-tad-smaller>this</x-tad-smaller><x-tad-smaller>.score.size - 1][0]}; score.do{</x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> i; var me; if((i[0] >= start) && (i[0] <= end), {me = i.copy; me[0] = (me[0] - start); thisscore = thisscore.add(me)})}; thisscore.sort({</x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> a, b; a[0] < b[0]}); thisscore = thisscore.add([end - start, [</x-tad-smaller><x-tad-smaller>\c_set</x-tad-smaller><x-tad-smaller>, 0, 0]]); if(configevents.notNil, {if(configevents.isArray, {if(configevents[0] == 0.0, {thisscore = </x-tad-smaller><x-tad-smaller>thisscore.addFirst</x-tad-smaller><x-tad-smaller>(configevents)}, {</x-tad-smaller><x-tad-smaller>"Configuration events should have a timestamp of 0.0"</x-tad-smaller><x-tad-smaller>.warn; ^</x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>})}, {</x-tad-smaller><x-tad-smaller>"Configuration events need to be a bundle array: [time, [events]]"</x-tad-smaller><x-tad-smaller>.warn; ^</x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>})}); ^</x-tad-smaller><x-tad-smaller>this</x-tad-smaller><x-tad-smaller>.class.new(thisscore); } recordNRT { </x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> oscFilePath, outputFilePath, inputFilePath, sampleRate = 44100, headerFormat = </x-tad-smaller><x-tad-smaller>"AIFF"</x-tad-smaller><x-tad-smaller>, sampleFormat = </x-tad-smaller><x-tad-smaller>"int16"</x-tad-smaller><x-tad-smaller>, options, completionString=</x-tad-smaller><x-tad-smaller>""</x-tad-smaller><x-tad-smaller>, duration = </x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>; </x-tad-smaller><x-tad-smaller>this</x-tad-smaller><x-tad-smaller>.class.recordNRT( score, oscFilePath, outputFilePath, inputFilePath, sampleRate, headerFormat, sampleFormat, options, completionString, duration ); } *recordNRT { </x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> list, oscFilePath, outputFilePath, inputFilePath, sampleRate = 44100, headerFormat = </x-tad-smaller><x-tad-smaller>"AIFF"</x-tad-smaller><x-tad-smaller>, sampleFormat = </x-tad-smaller><x-tad-smaller>"int16"</x-tad-smaller><x-tad-smaller>, options, completionString=</x-tad-smaller><x-tad-smaller>""</x-tad-smaller><x-tad-smaller>, duration = </x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>; </x-tad-smaller><x-tad-smaller>var</x-tad-smaller><x-tad-smaller> finallist; if(duration.notNil, {finallist = </x-tad-smaller><x-tad-smaller>Array</x-tad-smaller><x-tad-smaller>.new; list.do{</x-tad-smaller><x-tad-smaller>|i|</x-tad-smaller><x-tad-smaller> if(i[0] <= duration, { finallist = finallist.add(i)})}; finallist.sort({</x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> a, b; a[0] < b[0]}); finallist = finallist.add([duration, [</x-tad-smaller><x-tad-smaller>\c_set</x-tad-smaller><x-tad-smaller>, 0, 0]])}, {finallist = list}); </x-tad-smaller><x-tad-smaller>this</x-tad-smaller><x-tad-smaller>.write(finallist, oscFilePath); unixCmd(program + </x-tad-smaller><x-tad-smaller>" -N"</x-tad-smaller><x-tad-smaller> + oscFilePath + (inputFilePath ? </x-tad-smaller><x-tad-smaller>"_"</x-tad-smaller><x-tad-smaller>) + outputFilePath + sampleRate + headerFormat + sampleFormat + (options ?? {</x-tad-smaller><x-tad-smaller>ServerOptions</x-tad-smaller><x-tad-smaller>.new}).asOptionsString + completionString); } and some examples: </x-tad-smaller> <x-tad-smaller>y = </x-tad-smaller><x-tad-smaller>Score</x-tad-smaller><x-tad-smaller>.new([ [0, [</x-tad-smaller><x-tad-smaller>\g_new</x-tad-smaller><x-tad-smaller>, 1, 1, 0]], [1, [</x-tad-smaller><x-tad-smaller>\s_new</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>\default</x-tad-smaller><x-tad-smaller>, -1, 0, 1]], [2, [</x-tad-smaller><x-tad-smaller>\s_new</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>\default</x-tad-smaller><x-tad-smaller>, -1, 0, 1]], [3, [</x-tad-smaller><x-tad-smaller>\s_new</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>\default</x-tad-smaller><x-tad-smaller>, -1, 0, 1]], [4, [</x-tad-smaller><x-tad-smaller>\s_new</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>\default</x-tad-smaller><x-tad-smaller>, -1, 0, 1]], [5, [</x-tad-smaller><x-tad-smaller>\s_new</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>\default</x-tad-smaller><x-tad-smaller>, -1, 0, 1]], [6, [</x-tad-smaller><x-tad-smaller>\c_set</x-tad-smaller><x-tad-smaller>, 0, 0]] ]) o = </x-tad-smaller><x-tad-smaller>ServerOptions</x-tad-smaller><x-tad-smaller>.new.numOutputBusChannels = 1; </x-tad-smaller><x-tad-smaller>// mono output</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>// will only write 2.5 sceconds worth </x-tad-smaller><x-tad-smaller> y.recordNRT(</x-tad-smaller><x-tad-smaller>"trashme.osc"</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>"test.aif"</x-tad-smaller><x-tad-smaller>, options: o, duration: 2.5) </x-tad-smaller><x-tad-smaller>// will create a new score object z from y, with events from 1 to 3.5 seconds, and specified</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>// config events</x-tad-smaller><x-tad-smaller> z = y.section(1, 3.5, [0.0, [</x-tad-smaller><x-tad-smaller>\g_new</x-tad-smaller><x-tad-smaller>, 1, 1, 0]]) z.score z.recordNRT(</x-tad-smaller><x-tad-smaller>"trashme.osc"</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>"test.aif"</x-tad-smaller><x-tad-smaller>, options: o); </x-tad-smaller><x-tad-smaller>// y is still intact</x-tad-smaller><x-tad-smaller> y.score </x-tad-smaller> Attached is the entire Score.sc. Thanks again, Josh
On Aug 18, 2004, at 2:50 PM, Joshua Parmenter wrote: ******************************************I may try to do something like what Julian suggests, along with keeping all events at time 0.0. (I don't know about anyone else, but this is usually where I set up groups and buffers for NRT). It does seem like, once the start time changes, all sorts of things can become a problem. For now I will put something together that simply truncates a score, and think more about altering start times.Keeping all events at time 0.0 is a bad idea also, since there may be something there that makes sound... Joshua D. Parmenter Graduate Student, Music Composition "...Some people think a composer's supposed to please them, but in a way a composer is a chronicler... He's supposed to report on what he's seen and lived." -Charles Mingus _______________________________________________ sc-dev mailing list sc-dev-Ayv8T2snMLBt9CRQqspbbg@xxxxxxxxxxxxxxxx http://www.create.ucsb.edu/mailman/listinfo/sc-dev |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: n_free crash: 00158, James McCartney |
|---|---|
| Next by Date: | Re: NRT options Part II: 00158, James McCartney |
| Previous by Thread: | Re: NRT options Part IIi: 00158, Joshua Parmenter |
| Next by Thread: | Re: NRT options Part II: 00158, James McCartney |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |