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

RE: [sc-users] Main.sc and stand-alone application



Thanks, then please look at it below:

Server.default = s = Server.internal.waitForBoot({


var w;

var courier;

var dly;

var dlytime, dcytime;


var midiPitches = #[

62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84,

57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79,

52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74,

47, 49, 51, 53, 55, 57, 59, 61, 63, 65

];


// an Array of Strings representing the key layout,

// which is Japanese keyboard mapping

// if you want to use other language mapping,

// check the keycodes first and alter below


var keyboard = #["1234567890-^", "qwertyuiop@[", "asdfghjkl;:]", "zxcvbnm,./"];

var keycodes = [

18, 19, 20, 21, 23, 22, 26, 28, 25, 29, 27, 24,

12, 13, 14, 15, 17, 16, 32, 34, 31, 35, 33, 30,

0,? 1,? 2,? 3,? 5,? 4,? 38, 40, 37, 41, 39, 42,

6,? 7,? 8,? 9,? 11, 45, 46, 43, 47, 44

];


// horizontal offsets for keys.

var offsets = #[22, 30, 38, 0];


var positions, pitches;

var makeKey; // function to create a button for a key.


~source = Group.head(s);

~effect = Group.tail(s);

~eBus = Bus.audio(s, 2);


courier = GUI.font.new("Courier", 14).boldVariant;


positions = IdentityDictionary.new; // create positions dictionary

pitches = IdentityDictionary.new; // create pitches dictionary


// define a function that will create a button for a key.

makeKey = {|char, keyname, bounds|

var v;


keyname = keyname ? char.asString;

bounds = bounds ? (24 @ 24);


v = GUI.button.new(w, bounds);

v.font = courier;

v.states = [[keyname, Color.black], [keyname, Color.red]];

};


w = GUI.window.new("keyboard", Rect(128, 320, 371, 175));


w.view.decorator = FlowLayout(w.view.bounds);


// define a function to handle key downs.

w.view.keyDownAction = {|view, char, modifiers, unicode, keycode|

var pitch, bufnum, mod;

[char, modifiers, keycode].postln;

if (keycodes.indexOf(keycode)!=nil, {

w.view.children[keycodes.indexOf(keycode)].focus;

if (w.view.children[keycodes.indexOf(keycode)].value == 0, {

w.view.children[keycodes.indexOf(keycode)].value = 1;

mod = (modifiers/100000).floor.postln;

switch (mod.asInteger,

0, {

pitch = midiPitches[keycodes.indexOf(keycode)].midicps;

},

1, {

pitch = (midiPitches[keycodes.indexOf(keycode)]+1).midicps;

},

2, {

pitch = (midiPitches[keycodes.indexOf(keycode)]+0.5).midicps;

},

3, {

pitch = (midiPitches[keycodes.indexOf(keycode)]+1.5).midicps;

});

switch ( ~switch, ?

0, {?

~bufferc.free;?

~bufferc = Buffer.alloc(s, 1024, 1);

bufnum = ~bufferb.bufnum;

}, ?

1, {?

~buffera.free;?

~buffera = Buffer.alloc(s, 1024, 1);

bufnum = ~bufferc.bufnum;

}, ?

2, {?

~bufferb.free;?

~bufferb = Buffer.alloc(s, 1024, 1);

bufnum = ~buffera.bufnum;

});

s.sendMsg(

\s_new, \test,?

n=s.nextNodeID, 1, ~source.nodeID,?

\freq,?

pitch,?

\amp,?

0.07,

\bufnum,

bufnum,

\bus,

~eBus.index

);

switch (~switch,?

0, {?

~bufferc.sine1(?

Array.rand(32, 0, 1).cubed, ?

true, ?

true, ?

true?

);?

~switch = 1?

},?

1, { ?

~buffera.sine1(?

Array.rand(32, 0, 1).cubed, ?

true, ?

true, ?

true?

);?

~switch = 2?

},?

2, { ?

~bufferb.sine1(?

Array.rand(32, 0, 1).cubed, ?

true, ?

true, ?

true?

);?

~switch = 0?

});

})

}, {

if (char == $ , {

w.view.children[46].focus;

w.view.children[46].valueAction = w.view.children[46].value + 1;

});

})

};


// define a function to handle key ups.

w.view.keyUpAction = {|view, char, modifiers, unicode, keycode|

if (keycodes.indexOf(keycode)!=nil, {

w.view.children[keycodes.indexOf(keycode)].focus;

if (w.view.children[keycodes.indexOf(keycode)].value == 1, {

w.view.children[keycodes.indexOf(keycode)].value = 0

});

}/*, {

if (char == $ , {

w.view.children[46].focus

});

}*/)

};

// make the rows of the keyboard

keyboard.do {|row, i|?

var number;

switch (i,

0, {number = 0;},

1, {number = 12;},

2, {number = 24;},

3, {number = 36;} // for us key, 35, for japanese key, 36?

);

row.do {|key, j|?

makeKey.(key);

};

w.view.decorator.nextLine;

w.view.decorator.shift(offsets[i]);

};


// make button and sliders

dly = GUI.button.new(w, 72@24);

dly.states = [["delay on", Color.red], ["delay off", Color.black, Color.red]];

dly.action = "">arg butt; // "button" for win, linux

if (butt.value == 1, {

s.sendMsg(

\s_new, \delay,

m=s.nextNodeID, 1, ~effect.nodeID,

\dlytime, ~dlytime,

\dcytime, ~dcytime,

\bus, ~eBus.index

);

g = Group.basicNew(s, m);

NodeWatcher.register(g);

}, {

s.sendMsg(\n_free, m);

});

};

//w.view.decorator.nextLine;

dlytime = EZSlider(w, 285@24, "time", ControlSpec(0.1, 1.5, \lin),

{|ez| ~dlytime = ez.value;

s.sendMsg(\n_set, m, \dlytime, ~dlytime);

}, 0.3, labelWidth: 40

);

w.view.decorator.nextLine.shift(76);

dcytime = EZSlider(w, 285@24, "decay", ControlSpec(1, 6, \lin),

{|ez| ~dcytime = ez.value;

s.sendMsg(\n_set, m, \dcytime, ~dcytime);

}, 2, labelWidth: 40

);


~dlytime = 0.3;

~dcytime = 2;


//keycodes.postln;

//positions.postln;

w.>

if (g.isPlaying, {s.sendMsg(\n_free, m)});

s.quit;

};

w.front;



/******* buffer settings *******/?

?

~buffera = Buffer.alloc(s, 1024, 1);?

~bufferb = Buffer.alloc(s, 1024, 1);?

~bufferb.sine1(Array.rand(32, 0, 1).cubed, true, true, true);?

~bufferc = Buffer.alloc(s, 1024, 1);?

?

~switch = 0;?

?


SynthDef(\test, {arg freq, amp, bufnum, bus;

Out.ar(

[0, bus],

Osc.ar(

bufnum,?

{Rand(0.99, 1.02)*freq}.dup,

SinOsc.ar( ?

0.15, ?

SinOsc.ar(0.15, 0, pi, pi), ?

pi,?

pi

) ?

)

*EnvGen.kr(Env.perc, doneAction: 2, levelScale: amp)

*AmpComp.kr(freq, 47.midicps)

)

}).send(s);


SynthDef(\delay, {arg dlytime, dcytime, bus;

var in;

in = In.ar(bus, 2);?

Out.ar(?

0,?

CombN.ar(

in,?

dlytime*1.1,?

dlytime,?

0.5+(dcytime*dcytime)

)?

)

}).send(s);


});


sorry for letting you to read ugly one...

Tadashi

> Date: Thu, 25 Dec 2008 22:03:39 -0800
> From: suckspit@xxxxxxxxx
> To: sc-users@xxxxxxxxxxxxxxxx
> Subject: RE: [sc-users] Main.sc and stand-alone application
>
>
> hi Tadashi,
>
> why don't you just post the entire code? or provide a download url.
> its kind of tricky to help you when there isn't a whole lot of
> information provided.
>
>
> regards,
> suckspit
>
>
>
>
> --
> View this message in context: http://www.nabble.com/SuperCollider-3.3.-alpha-release-tp21166826p21172085.html
> Sent from the Supercollider - User mailing list archive at Nabble.com.
>
>
> _______________________________________________
> sc-users mailing list
>
> info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
> archive: https://listarc.bham.ac.uk/marchives/sc-users/
> search: https://listarc.bham.ac.uk/lists/sc-users/search/


豪華プレゼントが抽選で当たる。『六本木ラグジュアリーナイト』 この冬限定のプレゼント。今すぐ応募を!