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

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



A bit bizarre...

Two auditory scene analysis experience as discussed by Bregman.

Code should be cleaned and gui should be made GUI compliant (sorry, no time now)

Do as you think

Best
-a-
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf440
{\fonttbl\f0\fnil\fcharset77 Monaco;}
{\colortbl;\red255\green255\blue255;\red191\green0\blue0;\red0\green0\blue191;\red96\green96\blue96;
\red0\green115\blue0;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f0\fs18 \cf2 /*\
Two Auditory Scene Analysis experiences \
as proposed by Bregman, Auditory Scene Analysis, MIT Press, 1990\
\
1. Streaming: varying rate of presentation and \
frequency gap between the two series of sinusoidal one or two stream(s) appear(s).\
\
2. Miniature ASA Problem: varying frequency distance of A and C with respect to B, and attack time of C, two grouping are possible: \
(A+B)/C: a two note melody with a low tone (parallel)\
A(B+C): a simple tone and a complex tone (sequence)\
\
(andrea valle)\
*/\cf0 \
\
\
(\
\cf2 // start server\cf0 \
s = \cf3 Server\cf0 .local.boot;\
)\
\
\
(\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs20 \cf2 /*\
Streaming\
*/\cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 \
\
\cf3 var\cf0  r1, r2;\
\cf3 var\cf0  rateSlide, deltaSlide, volumeSlide;\
\cf3 var\cf0  pauseButton1, pauseButton2, recButton; \
\cf3 var\cf0  volume1 = 1.0, volume2 = 1.0;\
\cf3 var\cf0  base = 500;\
\cf3 var\cf0  synth1, synth2;\
\cf3 var\cf0  fileName, index = 1;\
\
\
\
\
\
\cf2 // Two analogous synthDefs\cf0 \
\
\
\cf3 SynthDef\cf0 (\cf4 "sine1"\cf0 ,\{ \cf3 arg\cf0  out=0, freq=440, dur=1.0, mul=0.5;\
	\cf3 var\cf0  env;\
	env = \cf3 Env\cf0 .new([0, 1,1,0,0],[dur*0.05, dur*0.3,dur*0.15,dur*0.5], \cf5 'welch'\cf0 );\
	\cf3 Out\cf0 .ar(out,\
		\cf3 SinOsc\cf0 .ar(\
			freq, \
			0, mul\
		) * \cf3 EnvGen\cf0 .kr(env)\
	)\
\}).load(s);\
\
\
\
\
\cf3 SynthDef\cf0 (\cf4 "sine2"\cf0 ,\{ \cf3 arg\cf0  out=0, freq=440, dur=1.0, mul=0.5;\
	\cf3 var\cf0  env;\
	env = \cf3 Env\cf0 .new([0,0,1,1,0],[dur*0.5, dur*0.05, dur*0.3,dur*0.15], \cf5 'welch'\cf0 );\
	\cf3 Out\cf0 .ar(out,\
		\cf3 SinOsc\cf0 .ar(\
			freq, \
			0, mul\
		) * \cf3 EnvGen\cf0 .kr(env)\
	)\
\}).load(s);\
\
\
\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs24 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf2 // Two analogous routines\cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs22 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 r1 = \cf3 Routine\cf0 .new(\{\
	\cf3 inf\cf0 .do(\{ \cf3 arg\cf0  i; \cf3 var\cf0  k;\
	\cf3 var\cf0  arr=[0,0, 1, 0, 2];\
	synth1 = \cf3 Synth\cf0 .new(\cf4 "sine1"\cf0 );\
	\cf2 //i.mod(5).postln;\cf0 \
	k = arr[i.mod(5)]*100+base;\
	\cf2 //k.postln;\cf0 \
	synth1.set(\cf4 "freq"\cf0 , k);\
	synth1.set(\cf4 "dur"\cf0 , rateSlide.value);\
	synth1.set(\cf4 "mul"\cf0 , volumeSlide.value*volume1);\
	rateSlide.value.wait;\
	synth1.free;\
	\});\
	0.5.wait;\
	\cf4 "finished"\cf0 .postln;\
\
\
\});\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs10 \cf0 \
\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 \
r2 = \cf3 Routine\cf0 .new(\{\
	\cf3 inf\cf0 .do(\{ \cf3 arg\cf0  i; \cf3 var\cf0  k;\
	\cf3 var\cf0  arr=[1, 0, 3, 1, 2];\
	synth2 = \cf3 Synth\cf0 .new(\cf4 "sine2"\cf0 );\
	\cf2 //i.mod(5).postln;\cf0 \
	k = arr[i.mod(5)]*100+base+deltaSlide.value;\
	\cf2 //k.postln;		\cf0 \
	synth2.set(\cf4 "freq"\cf0 , k);\
	synth2.set(\cf4 "dur"\cf0 , rateSlide.value);\
	synth2.set(\cf4 "mul"\cf0 , volumeSlide.value*volume2);\
	rateSlide.value.wait;\
	synth2.free;\
	\});\
	0.5.wait;\
	\cf4 "finished"\cf0 .postln;\
	\
\
\});\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs10 \cf0 \
\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 \
\cf2 // GUI stuff
\fs10 \cf0 \
\

\fs18 w = \cf3 SCWindow\cf0 (\cf4 "ASA: Streaming"\cf0 , \cf3 Rect\cf0 (20, 400, 440, 150));\
w.front; \cf2 // make window visible and front window.
\fs20 \cf0 \
w.view.decorator = \cf3 FlowLayout\cf0 (w.view.bounds);
\fs26 \

\fs18 rateSlide = \cf3 EZSlider\cf0 (w, 400 @ 20, \cf4 "DurEach"\cf0 , \cf3 ControlSpec\cf0 (0.05, 2.0, \cf5 \\exp\cf0 , 0.001, 0.01), \
	\{\cf3 arg\cf0  ez; ez.value;\}, 0.1);\
deltaSlide = \cf3 EZSlider\cf0 (w, 400 @ 20, \cf4 "Delta"\cf0 , \cf3 ControlSpec\cf0 (0, 1000, \cf5 \\lin\cf0 , 1, 1), \
	\{\cf3 arg\cf0  ez; ez.value;\}, 500);\
	\
volumeSlide = \cf3 EZSlider\cf0 (w, 400 @ 20, \cf4 "Volume"\cf0 , \cf3 ControlSpec\cf0 (0.0, 1.0, \cf5 \\lin\cf0 , 0.1, 0.1), \
	\{\cf3 arg\cf0  ez; ez.value;\}, 0.5);\
\
\
\
w.view.decorator.nextLine.shift(50, 20);\
\
	pauseButton1 = \cf3 SCButton\cf0 (w, 110 @ 30);\
	pauseButton1.states = [\
			[\cf4 "1 now is active"\cf0 ,\cf3 Color\cf0 .black,\cf3 Color\cf0 .red],\
			[\cf4 "1 now is muted"\cf0 ,\cf3 Color\cf0 .white,\cf3 Color\cf0 .black],\
		];\
		\
	pauseButton1.action = \{ \cf3 arg\cf0  state; \
			if(state.value == 1, \{volume1 = 0; \cf4 "muted 1"\cf0 .postln\});\
			if(state.value == 0, \{volume1 = 1.0; \cf4 "activated 1"\cf0 .postln\}); \
		\};\
		\
w.view.decorator.shift(10, 0);\
		\
\
	pauseButton2 = \cf3 SCButton\cf0 (w, 110 @ 30);\
	pauseButton2.states = [\
			[\cf4 "2 now is active"\cf0 ,\cf3 Color\cf0 .black,\cf3 Color\cf0 .red],\
			[\cf4 "2 now is muted"\cf0 ,\cf3 Color\cf0 .white,\cf3 Color\cf0 .black],\
		];\
		\
	pauseButton2.action = \{ \cf3 arg\cf0  state; \
			if(state.value == 1, \{volume2 = 0; \cf4 "muted 2"\cf0 .postln\});\
			if(state.value == 0, \{volume2 = 1.0; \cf4 "activated 2"\cf0 .postln\}); \
		\};\
\
\
\
\
w.onClose_(\{r1.stop; synth1.free; r2.stop; synth2.free;\});\
\
\cf3 SystemClock\cf0 .play(r1);\
\cf3 SystemClock\cf0 .play(r2);\
\
\
)\
\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs14 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs20 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 (\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs20 \cf2 /*\
The miniature ASA problem\
*/\cf0 \
\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf3 var\cf0  r1, r2, r3;\
\cf3 var\cf0  text;\
\cf3 var\cf0  rateSlide, volumeSlide, freqASlide, freqBSlide, freqCSlide, shiftCSlide;\
\cf3 var\cf0  pauseButton1, pauseButton2, recButton; \
\cf3 var\cf0  volume1 = 1.0, volume2 = 1.0, volume3 = 1.0;\
\cf3 var\cf0  base = 500;\
\cf3 var\cf0  synth1, synth2, synth3;\
\cf3 var\cf0  fileName, index = 1;\
\
\
\
\
\cf2 // Three analogous synthDefs\cf0 \
\
\
\cf3 SynthDef\cf0 (\cf4 "sineA"\cf0 ,\{ \cf3 arg\cf0  out=0, freq=1000, dur=1.0, mul=0.35;\
	\cf3 var\cf0  env;\
	env = \cf3 Env\cf0 .new([0, 0,1,1, 0,0],dur*[0.1, 0.0, 0.3, 0, 0.6], \cf5 'welch'\cf0 );\
	\cf3 Out\cf0 .ar(out,\
		\cf3 SinOsc\cf0 .ar(\
			freq, \
			0, mul\
		) * \cf3 EnvGen\cf0 .kr(env)\
	)\
\}).load(s);\
\
\
\
\
\cf3 SynthDef\cf0 (\cf4 "sineB"\cf0 ,\{ \cf3 arg\cf0  out=0, freq=500, dur=1.0, mul=0.35;\
	\cf3 var\cf0  env;\
	env = \cf3 Env\cf0 .new([0, 0,1,1, 0,0],dur*[0.6, 0.0, 0.3, 0, 0.1], \cf5 'welch'\cf0 );\
	\cf3 Out\cf0 .ar(out,\
		\cf3 SinOsc\cf0 .ar(\
			freq, \
			0, mul\
		) * \cf3 EnvGen\cf0 .kr(env)\
	)\
\}).load(s);\
\
\
\
\
\cf3 SynthDef\cf0 (\cf4 "sineC"\cf0 ,\{ \cf3 arg\cf0  out=0, freq=250, dur=1.0, mul=0.35, shift=0;\
	\cf3 var\cf0  env;\
	env = \cf3 Env\cf0 .new([0, 0,1,1, 0,0], dur*[0.6+shift, 0.0, 0.3, 0, 0.1+shift], \cf5 'welch'\cf0 );\
	\cf3 Out\cf0 .ar(out,\
		\cf3 SinOsc\cf0 .ar(\
			freq, \
			0, mul\
		) * \cf3 EnvGen\cf0 .kr(env)\
	)\
\}).load(s);\
\
\cf2 // Two analogous routines\cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs22 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 r1 = \cf3 Routine\cf0 .new(\{\
	\cf3 inf\cf0 .do(\{ \cf3 arg\cf0  i;\
	synth1 = \cf3 Synth\cf0 .new(\cf4 "sineA"\cf0 );\
	synth1.set(\cf4 "freq"\cf0 , freqASlide.value);\
	synth1.set(\cf4 "dur"\cf0 , rateSlide.value);\
	synth1.set(\cf4 "mul"\cf0 , volumeSlide.value*volume1);\
	rateSlide.value.wait;\
	synth1.free;\
	\});\
	0.5.wait;\
	\cf4 "finished"\cf0 .postln;\
\
\
\});\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs10 \cf0 \
\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 \
r2 = \cf3 Routine\cf0 .new(\{\
	\cf3 inf\cf0 .do(\{ \cf3 arg\cf0  i; \
	synth2 = \cf3 Synth\cf0 .new(\cf4 "sineB"\cf0 );\
	synth2.set(\cf4 "dur"\cf0 , rateSlide.value);\
	synth2.set(\cf4 "mul"\cf0 , volumeSlide.value*volume2);\
	rateSlide.value.wait;\
	synth2.free;\
	\});\
	0.5.wait;\
	\cf4 "finished"\cf0 .postln;\
	\
\
\});\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs10 \cf0 \
\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 r3 = \cf3 Routine\cf0 .new(\{\
	\cf3 inf\cf0 .do(\{ \cf3 arg\cf0  i;\
	synth3 = \cf3 Synth\cf0 .new(\cf4 "sineC"\cf0 );\
	synth3.set(\cf4 "freq"\cf0 , freqCSlide.value);\
	synth3.set(\cf4 "dur"\cf0 , rateSlide.value);\
	synth3.set(\cf4 "mul"\cf0 , volumeSlide.value*volume3);\
	synth3.set(\cf4 "shift"\cf0 , shiftCSlide.value);\
	rateSlide.value.wait;\
	synth3.free;\
	\});\
	0.5.wait;\
	\cf4 "finished"\cf0 .postln;\
\
\
\});\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs10 \cf0 \
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\fs18 \cf0 \
\cf2 // GUI stuff
\fs10 \cf0 \
\

\fs18 w = \cf3 SCWindow\cf0 (\cf4 "ASA: Miniature problem"\cf0 , \cf3 Rect\cf0 (20, 400, 440, 220));\
w.front; \cf2 // make window visible and front window.
\fs20 \cf0 \

\fs18 w.view.decorator = \cf3 FlowLayout\cf0 (w.view.bounds);\
rateSlide = \cf3 EZSlider\cf0 (w, 400 @ 20, \cf4 "DurEach"\cf0 , \cf3 ControlSpec\cf0 (0.2, 2.0, \cf5 \\exp\cf0 , 0.001, 0.01), \
	\{\cf3 arg\cf0  ez; ez.value;\}, 1.0);\
freqASlide = \cf3 EZSlider\cf0 (w, 400 @ 20, \cf4 "Freq A"\cf0 , \cf3 ControlSpec\cf0 (50, 2000, \cf5 \\exp\cf0 , 1, 1), \
	\{\cf3 arg\cf0  ez; ez.value;\}, 1000);\
w.view.decorator.nextLine.shift(30);\
text = 	\cf3 SCTextField\cf0 (w,\cf3 Rect\cf0 (0,0,150,30));\
text.string = \cf4 "Freq B = fixed at 500 Hz"\cf0 ;\
text.boxColor_(\cf3 Color\cf0 .grey);\
text.stringColor_(\cf3 Color\cf0 .white);\
w.view.decorator.nextLine;\
freqCSlide = \cf3 EZSlider\cf0 (w, 400 @ 20, \cf4 "Freq C"\cf0 , \cf3 ControlSpec\cf0 (50, 500, \cf5 \\exp\cf0 , 1, 1), \
	\{\cf3 arg\cf0  ez; ez.value;\}, 250);	\
shiftCSlide = \cf3 EZSlider\cf0 (w, 400 @ 20, \cf4 "Shift C"\cf0 , \cf3 ControlSpec\cf0 (-0.5, 0.0, \cf5 \\lin\cf0 , 0.01, 0.01), \
	\{\cf3 arg\cf0  ez; ez.value;\}, 0.0);		\
volumeSlide = \cf3 EZSlider\cf0 (w, 400 @ 20, \cf4 "Volume"\cf0 , \cf3 ControlSpec\cf0 (0.0, 1.0, \cf5 \\lin\cf0 , 0.1, 0.1), \
	\{\cf3 arg\cf0  ez; ez.value;\}, 0.5);\
\
\
\
w.view.decorator.nextLine.shift(50, 20);\
\
	pauseButton1 = \cf3 SCButton\cf0 (w, 110 @ 30);\
	pauseButton1.states = [\
			[\cf4 "A now is active"\cf0 ,\cf3 Color\cf0 .black,\cf3 Color\cf0 .red],\
			[\cf4 "A now is muted"\cf0 ,\cf3 Color\cf0 .white,\cf3 Color\cf0 .black],\
		];\
		\
	pauseButton1.action = \{ \cf3 arg\cf0  state; \
			if(state.value == 1, \{volume1 = 0; \cf4 "muted A"\cf0 .postln\});\
			if(state.value == 0, \{volume1 = 1.0; \cf4 "activated A"\cf0 .postln\}); \
		\};\
		\
w.view.decorator.shift(10, 0);\
		\
\
	pauseButton2 = \cf3 SCButton\cf0 (w, 110 @ 30);\
	pauseButton2.states = [\
			[\cf4 "C now is active"\cf0 ,\cf3 Color\cf0 .black,\cf3 Color\cf0 .red],\
			[\cf4 "C now is muted"\cf0 ,\cf3 Color\cf0 .white,\cf3 Color\cf0 .black],\
		];\
		\
	pauseButton2.action = \{ \cf3 arg\cf0  state; \
			if(state.value == 1, \{volume3 = 0; \cf4 "muted C"\cf0 .postln\});\
			if(state.value == 0, \{volume3 = 1.0; \cf4 "activated C"\cf0 .postln\}); \
		\};\
\
\
w.view.decorator.shift(20, 0);\
\
\
w.onClose_(\{r1.stop; synth1.free; r2.stop; synth2.free;  r3.stop; synth3.free;\});\
\
\cf3 SystemClock\cf0 .play(r1);\
\cf3 SystemClock\cf0 .play(r2);\
\cf3 SystemClock\cf0 .play(r3);\
\
\
)
\fs14 \
}

On 29 Nov 2007, at 20:23, Julian Rohrhuber wrote:

some fishy sounds.
-- 





.<deap_sea.rtf>_______________________________________________
Sc-devel mailing list

--------------------------------------------------
Andrea Valle
--------------------------------------------------
CIRMA - DAMS
Università degli Studi di Torino
--------------------------------------------------


I did this interview where I just mentioned that I read Foucault. Who doesn't in university, right? I was in this strip club giving this guy a lap dance and all he wanted to do was to discuss Foucault with me. Well, I can stand naked and do my little dance, or I can discuss Foucault, but not at the same time; too much information.
(Annabel Chong)