[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] Call for Code Contributions !!!



Your Thorness,

Here are some of my clearer pieces of code for the kids to chew on.  And by clear, I mean working.

Sam

{\rtf1\ansi\ansicpg1252\cocoartf949
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;\red191\green0\blue0;\red0\green0\blue0;\red0\green0\blue191;
\red96\green96\blue96;\red0\green115\blue0;}
\deftab720
\pard\pardeftab720\ql\qnatural

\f0\fs24 \cf2 //Sam Pluta - 2006\cf3 \
\cf2 //this Synth uses the AudioIn as a trigger to step through and granulate the loaded buffer\cf3 \
\
s.boot;\
b = \cf4 Buffer\cf3 .read(s, \cf5 "/Users/sam/Library/Application\\ Support/SuperCollider/sounds/eagleland2.aif"\cf3 );  \cf2 //use your own buffer here - mine is probably not on your computer\cf3 \
\
(\
\cf4 SynthDef\cf3 (\cf5 "TriggerBufferGranular"\cf3 ,\
\{\cf4 arg\cf3  out=0, bufnum=0, in=1, thresh = 0.004, ampScaler = 1, duration = \
0.2, pan=0,centerPosition=0.1, interp=1, incrementBy = 200;\
	\cf4 var\cf3  trig, amp, gatedAmp, triggerBool, outamp, bufferFrames, \
bufRateScale;\
	\cf4 var\cf3  bufPointer, trig1, trig2, trig3, trig4, env, envGen1, envGen2, envGen3, envGen4, out1, out2, out3, out4;\
\
	bufferFrames = \cf4 BufFrames\cf3 .kr(bufnum);\
	bufRateScale = \cf4 BufRateScale\cf3 .kr(bufnum);\
	amp = \cf4 Amplitude\cf3 .kr (\cf4 AudioIn\cf3 .ar(in));\
	triggerBool = (\cf4 AudioIn\cf3 .ar(in) >= thresh);\
	gatedAmp = \cf4 Latch\cf3 .kr(amp, triggerBool);\
	outamp = (gatedAmp * ampScaler);\
\
	trig = \cf4 Trig\cf3 .kr(triggerBool, duration/4);  \cf2 //makes a trigger if triggerBool goes over the threshold\cf3 \
\
	bufPointer = \cf4 PulseCount\cf3 .kr(trig);  \cf2 //a counter that counts the number of triggers triggered\cf3 \
\
	\cf2 //each trigger below triggers once for every four times trig (above) triggers (if a trig trig could trig trig)\cf3 \
	\
	trig1 = \cf4 PulseDivider\cf3 .kr(trig, 4, 0);\
	trig2 = \cf4 PulseDivider\cf3 .kr(trig, 4, 1);\
	trig3 = \cf4 PulseDivider\cf3 .kr(trig, 4, 2);\
	trig4 = \cf4 PulseDivider\cf3 .kr(trig, 4, 3);\
\
	env = \cf4 Env\cf3 ([0,1,0],[duration/2,duration/2],\cf6 'sine'\cf3 );\
\
	envGen1 = \cf4 EnvGen\cf3 .kr(env, trig1);\
	envGen2 = \cf4 EnvGen\cf3 .kr(env, trig2);\
	envGen3 = \cf4 EnvGen\cf3 .kr(env, trig3);\
	envGen4 = \cf4 EnvGen\cf3 .kr(env, trig4);\
\
	\cf2 //trig1-4 correspond to and trigger a PlayBuf below - the pointer slowly moves through the file\cf3 \
\
	out1 = \cf4 PlayBuf\cf3 .ar(1, bufnum, bufRateScale, trig1, (bufPointer*incrementBy)%bufferFrames)*envGen1;\
	out2 = \cf4 PlayBuf\cf3 .ar(1, bufnum, bufRateScale, trig2, (bufPointer*incrementBy)%bufferFrames)*envGen2;\
	out3 = \cf4 PlayBuf\cf3 .ar(1, bufnum, bufRateScale, trig3, (bufPointer*incrementBy)%bufferFrames)*envGen3;\
	out4 = \cf4 PlayBuf\cf3 .ar(1, bufnum, bufRateScale, trig4, (bufPointer*incrementBy)%bufferFrames)*envGen4;\
\
	\cf4 Out\cf3 .ar(out, \cf4 Pan2\cf3 .ar(out1+out2+out3+out4));\
\}).play(s,[\cf6 \\out\cf3 , 0, \cf6 \\bufnum\cf3 , b.bufnum]);\
)}
{\rtf1\ansi\ansicpg1252\cocoartf949
{\fonttbl\f0\fnil\fcharset0 Monaco;\f1\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;\red191\green0\blue0;\red0\green0\blue0;\red0\green0\blue191;
}
\deftab720
\pard\pardeftab720\ql\qnatural

\f0\fs18 \cf2 //Sam Pluta - 2007\cf3 \
\cf2 //A poor simulation of LaMonte's Dream House, found on Church St. in New York\cf3 \
\cf2 //No matter what you think of this patch, you should go check out the real thing!\cf3 \
\cf2 //If you want to understand the math, read the actual title of the piece\cf3 \
\cf2 //This will not be good in headphones - use speakers and walk around the room\cf3 \
\
(
\f1\fs24 \

\f0\fs18 c=0;
\f1\fs24 \

\f0\fs18 d=\cf4 IdentitySet\cf3 .new;
\f1\fs24 \

\f0\fs18 (224..288).do\{\cf4 arg\cf3  i;
\f1\fs24 \
	
\f0\fs18 if((((i*(9/8))/((i*(9/8)).floor))==1.0)&&((i*(9/8))<289),\{
\f1\fs24 \
		
\f0\fs18 d.add(i);
\f1\fs24 \
		
\f0\fs18 d.add((i*(9/8)).asInteger);
\f1\fs24 \
		
\f0\fs18 c=c+1;
\f1\fs24 \
	
\f0\fs18 \});
\f1\fs24 \
	
\f0\fs18 if((i.isPrime),\{
\f1\fs24 \
		
\f0\fs18 d.add(i);
\f1\fs24 \
		
\f0\fs18 c=c+1;
\f1\fs24 \
	
\f0\fs18 \});
\f1\fs24 \
	
\f0\fs18 if(i%2==1.0,\{
\f1\fs24 \
		
\f0\fs18 if(((i/2).asInteger.isPrime),\{
\f1\fs24 \
			
\f0\fs18 d.add(i);
\f1\fs24 \
			
\f0\fs18 c=c+1;
\f1\fs24 \
		
\f0\fs18 \})
\f1\fs24 \
	
\f0\fs18 \});
\f1\fs24 \
	
\f0\fs18 if(i%4==1.0,\{
\f1\fs24 \
		
\f0\fs18 if(((i/4).asInteger.isPrime),\{
\f1\fs24 \
			
\f0\fs18 d.add(i);
\f1\fs24 \
			
\f0\fs18 c=c+1;
\f1\fs24 \
		
\f0\fs18 \})
\f1\fs24 \
	
\f0\fs18 \});
\f1\fs24 \
	
\f0\fs18 if(i%8==1.0,\{
\f1\fs24 \
		
\f0\fs18 if(((i/8).asInteger.isPrime),\{
\f1\fs24 \
			
\f0\fs18 d.add(i);
\f1\fs24 \
			
\f0\fs18 c=c+1;
\f1\fs24 \
		
\f0\fs18 \})
\f1\fs24 \
	
\f0\fs18 \});
\f1\fs24 \

\f0\fs18 \};
\f1\fs24 \
\pard\pardeftab560\ql\qnatural

\f0\fs18 \cf3 d=d.asArray;\
d.sort;\
d=d*10;\
d.do\{\cf4 arg\cf3  item, i;\
	\{ \cf4 Out\cf3 .ar(2.rand, \cf4 SinOsc\cf3 .ar(item, 0, 0.006), ((2/d.size)*i-1).postln)  \}.play;  \cf2 //if you have more than 2 speakers, change the 2.rand to n.rand, where n is the number of speakers you have\cf3 \
\}
\f1\fs24 \
\pard\pardeftab720\ql\qnatural

\f0\fs18 \cf3 )}

On Nov 29, 2007, at 8:15 AM, 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

(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-devel mailing list
Sc-devel@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-devel



myspace.com/sampluta
myspace.com/exclusiveor
myspace.com/glissandobinladen