[sc-users] Call for Code Contributions !!!
olaf hochherz
hochherz_olaf at gmx.de
Tue Dec 4 12:13:59 PST 2007
yes but you than you have to fill a list with messages which has not
such a good performance and i would need another global variable.
but whats the commen sc style to do this?
"scsynth -N test.osc _ test.wav 44100 WAV int24 -o 1".unixCmd
Till Bovermann wrote:
> Hey,
>
> Are you aware of the Score class?
> It makes offline rendering of osc commands really easy... see its help
> page for help :-)
>
> regards
> TIll
>
> On 04.12.2007, at 11:34, olaf hochherz wrote:
>
>> ok
>> another try
>> sorry
>>
>> on linux i can do
>>
>> "scsynth -N test.osc _ test.wav 44100 WAV int24 -o 1".unixCmd
>
> this should work if you have scsynth in your PATH (which is not the case
> on osx), apart from that it does not produce any sound (i think...)
>
>
>>
>> how to do this on mac or in common-sc?
>>
>> thor wrote:
>>> On 3 Dec 2007, at 01:03, olaf hochherz wrote:
>>>> i like this type of code maybe someone like this to:
>>> Hi Olaf
>>> Could you explain (with comments) what this code does?
>>> I get the test.wav.osc file, but then what?
>>> I think examples like this have to have good documentation and
>>> preferably some sounding result.
>>> Thanks.
>>> thor
>>> PS. There are now lots of new examples in the latest commit of SC.
>>>>
>>>> (
>>>> ~createVars={var
>>>> sampleRate=44100,oscfile=File("test.wav.osc","w"),wavfilename="test.wav",pos=0;
>>>>
>>>>
>>>> SynthDef("sineperiod",{arg freq,amp;
>>>> var env=EnvGen.ar(Env.new([0,1,1,0], [0,1/freq,0]), doneAction: 2);
>>>> var sig=SinOsc.ar(freq,0,amp);
>>>> OffsetOut.ar(0,sig*env);
>>>> }).writeDefFile;
>>>>
>>>> ~addFreq={arg freq,amp;
>>>> var msg=[pos,
>>>> [\s_new, \sineperiod,-1,1,0,
>>>> \freq,freq,
>>>> \amp,amp*0.999]
>>>> ].asRawOSC;
>>>> oscfile.write(msg.size);
>>>> oscfile.write(msg);
>>>> pos=pos+(1/freq);
>>>> };
>>>>
>>>> ~addSamples={arg samples,amp;
>>>> ~addFreq.(sampleRate/samples,amp);
>>>> };
>>>>
>>>> ~render={
>>>> var msg = [ pos, [0]].asRawOSC;
>>>> oscfile.write(msg.size);
>>>> oscfile.write(msg);
>>>> oscfile.close;
>>>> ("scsynth -N"+wavfilename++".osc _ "+wavfilename+sampleRate+"
>>>> WAV int24 -o 1 >/dev/null ").systemCmd.postln;
>>>> };
>>>>
>>>>
>>>> f={arg maxdeep,samples=[2,2],amps=
>>>> [1,1],smod={|akt,deep,at|akt.flat},amod={|akt,deep,at|akt.flat},sakt=1,aakt=1,howdeep=0,at=0;
>>>>
>>>> var self=thisFunction;
>>>> if(howdeep<maxdeep,{
>>>> samples=smod.(samples,howdeep,at);
>>>> amps=amod.(amps,howdeep,at);
>>>> [(samples*sakt).flat,(amps*aakt).flat].postln
>>>> .flop
>>>> .do{|i,j|
>>>> [i,j].postln;
>>>> self.(maxdeep,samples,amps,smod,amod,i[0],i[1],howdeep+1,j)
>>>> }
>>>> },{
>>>> [maxdeep,samples,amps,smod,amod,sakt,aakt,howdeep,at].postln;
>>>> ~addSamples.(sakt,aakt);
>>>> });
>>>> };
>>>> };
>>>> )
>>>>
>>>> (
>>>> ~createVars.value;
>>>> //default
>>>> f.(7);
>>>> ~render.value;
>>>> )
>>>>
>>>> (
>>>> ~createVars.value;
>>>> f.(5,
>>>> [1,2,3,4,5].linexp(1,5,1,10),
>>>> (1/[1,5,3,4,2]),
>>>> {|akt,deep,at|akt.flat},
>>>> {|akt,deep,at|akt.reverse.flat}
>>>> );
>>>> ~render.value;
>>>> )
>>>>
>>>>
>>>> (
>>>> ~createVars.value;
>>>> f.(3,
>>>> [1,2,3,4,5].linexp(1,5,1,10),
>>>> (1/[1,5,3,4,2]),
>>>> {|akt,deep,at|(akt.reverse+++akt).flat},
>>>> {|akt,deep,at|(akt.reverse++akt).reverse.flat}
>>>> );
>>>> ~render.value;
>>>> )
>>>>
>>>>
>>>> thor wrote:
>>>>> Hello everyone
>>>>> SuperCollider is stable, rock-solid and super efficient. There is a
>>>>> book coming out and version 3.2 is in the making. However, the
>>>>> state of the "contributions" in the "examples" folder in the
>>>>> distribution is not very good. There are only 5 examples there. I'm
>>>>> volunteering to fix this if you just send examples here to the list
>>>>> or to myself and I'll commit them into the SVN and the official
>>>>> distribution. I might also try to sort them into some intelligent
>>>>> categories.
>>>>> These do not have to be finished pieces or grand projects. Just an
>>>>> exploration of some UGen, synthesis, algorithmic composition, audio
>>>>> analysis, effects, instruments, graphics.... whatever.
>>>>> The code can be seen as addition to the examples we find in the
>>>>> helpfiles, but it can be much more general as it does not have to
>>>>> focus on one UGen or functionality as the helpfiles do. I have
>>>>> already ported some of the examples from SC2 over but there might
>>>>> be much more out there as well, so if you know of some good
>>>>> examples, please let me know.
>>>>> With hope to see some wicked code !
>>>>> Thor
>>>>> PS. It would be nice (although optional) if you put your name and
>>>>> year at the top + if there are 3rd party code needed. Here is a
>>>>> good example (Tim even has a small description of what the code does):
>>>>> // Termite College
>>>>> // (Tim Walters) (CC 2006)
>>>>> // Features recursively generated phase modulation trees
>>>>> //
>>>>> // Requires the GVerb and BEQsuite UGens, downloadable at
>>>>> // http://realizedsound.net/downloads
>>>>> (Although we should remove the CC as the code has to be GPL.
>>>>> I suggest we change it to C (for copyright) as it's always your
>>>>> copyright)
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>> _______________________________________________
>>>>> sc-users mailing list
>>>>> sc-users at create.ucsb.edu
>>>>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
>>>> _______________________________________________
>>>> sc-users mailing list
>>>> sc-users at create.ucsb.edu
>>>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
>>> _______________________________________________
>>> sc-users mailing list
>>> sc-users at create.ucsb.edu
>>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
>> // (Olaf HOchherz) (CC 2007)
>> // Features recursively generated
>> // Sine Period Concatination
>> // with NonRealtimeSynthesis
>>
>> // a set of functions:
>>
>>
>> (
>> //function to setup global variables;
>> ~setup={arg oscfilename,wavfilename,sampleRate;
>> ~oscfile=File(oscfilename,"w");
>> ~oscfilename=oscfilename;
>> ~wavfilename=wavfilename;
>> ~sampleRate=sampleRate;
>> ~pos=0;
>> };
>>
>> //a Synth which creates one period of a sinewave
>> SynthDef("sineperiod",{arg freq,amp;
>> var env=EnvGen.ar(Env.new([0,1,1,0], [0,1/freq,0]), doneAction: 2);
>> var sig=SinOsc.ar(freq,0,amp);
>> OffsetOut.ar(0,sig*env);
>> }).writeDefFile;
>>
>> //writes a Period into an oscfile
>> ~addFreq={arg freq,amp;
>> var msg=[~pos,
>> [\s_new, \sineperiod,-1,1,0,
>> \freq,freq,
>> \amp,amp*0.999]
>> ].asRawOSC;
>> ~oscfile.write(msg.size);
>> ~oscfile.write(msg);
>> ~pos=~pos+(1/freq);
>> };
>>
>> //writes a Period into an oscfile
>> ~addSamples={arg samples,amp;
>> ~addFreq.(~sampleRate/samples,amp);
>> };
>>
>> //render a oscfile to a wav file
>> ~render={
>> var msg = [ ~pos, [0]].asRawOSC;
>> ~oscfile.write(msg.size);
>> ~oscfile.write(msg);
>> ~oscfile.close;
>> ("scsynth -N"+~oscfilename++" _ "+~wavfilename+~sampleRate+" WAV
>> int24 -o 1").postln.systemCmd.postln;
>> };
>>
>>
>> //function to recursive generate sine periodes
>> f={
>> arg
>> maxdeep,
>> samples=[2,2],amps=[1,1],//proportion-array in each recusion step
>> the actual value of length and amp of a period gets multiplicated with
>> this arrays
>> smod={|samples,deep,at|samples},//this are functions to transform
>> the previews arrays
>> amod={|amps,deep,at|amps},
>> sakt=1,aakt=1,//these are the start-values
>> howdeep=0,at=0;//the is for orientation in the recursion
>> var self=thisFunction;
>> if(howdeep<maxdeep,{//stop recursion after a feew steps
>> samples=smod.(samples,howdeep,at);//modulate the poportion arrays
>> amps=amod.(amps,howdeep,at);
>> [(samples*sakt).flat,(amps*aakt).flat]
>> .flop//for easy itteration
>> .do{|i,j|
>>
>> self.(maxdeep,samples,amps,smod,amod,i[0],i[1],howdeep+1,j)//do it
>> again with new poportion-arrays and start-values
>> }
>> },{
>> ~addSamples.(sakt,aakt);//at a some point the recursion stops
>> and a period gets written
>> });
>> };
>> )
>>
>> //usage:
>>
>> (
>> //setup global variables
>> ~setup.value("test.osc","test.wav",44100);
>> //the default test case
>> f.(7);
>> //is the same as:
>> f.(7,samples=[2,2],amps=[1,1],smod={|samples,deep,at|samples},amod={|amps,deep,at|amps},1,1)
>>
>> //write the file
>> ~render.value;
>> //on linux use:
>> "aplay test.wav".unixCmd
>> )
>>
>> (
>> ~setup.value("test.osc","test.wav",44100);
>> f.(8,//for mac users: this can freeze your sc don't use big numbers
>> //for linux users: don't use big numbers this can freeze your
>> sclang so you have to recompile the library (C-c C-l in emacs)
>> [1,3],//a more interesting set of proportions
>> ([1,1])
>> );
>> ~render.value;
>> )
>>
>> (
>> ~setup.value("test.osc","test.wav",44100);
>> f.(5,
>> [1,2,3,4,5],//a more interesting set of proportions
>> (1/[1,2,3,4,5]),// also for the volume
>> {|akt,deep,at|akt.flat},
>> {|akt,deep,at|akt.reverse.flat}//reverse the volume
>> );
>> ~render.value;
>> )
>>
>>
>> (
>> ~setup.value("test.osc","test.wav",44100);
>> f.(3,
>> [1,2,3,4,5,6,7],
>> (1/[1,2,3,4,5,6,7]),
>> {|akt,deep,at|(akt.reverse+++akt).flat},
>> {|akt,deep,at|(akt.reverse++akt).reverse.flat}
>> );
>> ~render.value;
>> )
>> _______________________________________________
>> sc-users mailing list
>> sc-users at create.ucsb.edu
>> http://www.create.ucsb.edu/mailman/listinfo/sc-users
>
> _______________________________________________
> sc-users mailing list
> sc-users at create.ucsb.edu
> http://www.create.ucsb.edu/mailman/listinfo/sc-users
>
More information about the sc-users
mailing list