|
|
Re: NRT options Part II: msg#00161
audio.supercollider.devel
|
Subject: |
Re: NRT options Part II |
Sorry to bug you all about this again, but if the following is fine, could someone please commit the changes ?
Attached is a copy of Score.sc with the changes.
Thanks again,
Josh
Score.sc
Description: Binary data
On Aug 18, 2004, at 8:31 PM, Joshua Parmenter wrote:
Thanks James... I think I understand.
Is this closer?
<x-tad-smaller> section {</x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> start = 0.0, end = </x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>, configevents = </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.section(score, start, end, configevents);
}
*section {</x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> list, start = 0, end = </x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>, configevents = </x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>;
</x-tad-smaller><x-tad-smaller> var sectionlist;</x-tad-smaller><x-tad-smaller>
end.isNil.if{end = </x-tad-smaller><x-tad-smaller>list</x-tad-smaller><x-tad-smaller>.size - 1][0]};
sectionlist = list.copy;
list.copy.do{</x-tad-smaller><x-tad-smaller>arg</x-tad-smaller><x-tad-smaller> me;
if((me[0] >= start) && (me[0] <= end), {me[0] = me[0] - start}, {sectionlist.remove(me)})};
sectionlist = sectionlist.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,
{sectionlist = sectionlist.addFirst(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>.new(sectionlist);
}
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>;
if(duration.notNil, {list = </x-tad-smaller><x-tad-smaller>this</x-tad-smaller><x-tad-smaller>.section(list, 0, duration, </x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>).score});
</x-tad-smaller><x-tad-smaller>this</x-tad-smaller><x-tad-smaller>.write(list, 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);
}
</x-tad-smaller>
Thanks again for your help!
Josh
On Aug 18, 2004, at 7:43 PM, James McCartney wrote:
On Aug 18, 2004, at 7:31 PM, Joshua Parmenter wrote:
<x-tad-smaller> 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>
It is not very modular to do this here.
The principle of "once and only once" says only implement functionality in one place: http://c2.com/cgi/wiki?OnceAndOnlyOnce
So you should call out to the section method to do this work, and not replicate the functionality here.
--
--- james mccartney james-M9HdPQXNfxq9Zq0HfjR8jw@xxxxxxxxxxxxxxxx <http://www.audiosynth.com>
SuperCollider - a real time audio synthesis programming language_______________________________________________
sc-dev mailing list
sc-dev-Ayv8T2snMLBt9CRQqspbbg@xxxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev
******************************************
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
******************************************
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
|
|