Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Mountains
name
code content
( var win = Window.new( "", Rect( 0, 800, 700, 400 ) ); // This will be our main window var instrument_file = {}; var main_view = UserView(); var layout = UserView(); var background_color = Color( 0, 0, 0 ); var rythm = Point( 4, 4 ); var rythm_length = ( rythm.x * rythm.y ); var tempo = 1; var parameters = Array.fill( 4, { Array.fill( ( rythm_length + 1 ), { 0 } ) } ); var colors = [ Color( 1, 0.8, 0 ), Color( 0, 1, 1 ), Color( 1, 0.2, 0.2 ), Color( 1, 0.6, 0.6 ) ]; var button_rack_view = UserView().maxWidth_( 100 ); var selected_view = 0; var views = Array.fill( parameters.size, { UserView() } ); var synth = SynthDef( \synth, { | out, freq = 200, amp = 0.25 | var snd, snd2, release; var env, envctl; var env2, envctl2; var env3, envctl3; var env4, envctl4; env = Env.newClear(rythm_length); envctl = \env.kr(env.asArray); env2 = Env.newClear(rythm_length); envctl2 = \env2.kr(env2.asArray); env3 = Env.newClear(rythm_length); envctl3 = \env3.kr(env3.asArray); env4 = Env.newClear(rythm_length); envctl4 = \env4.kr(env4.asArray); release = EnvGen.kr( Env( [0,1,1,0], times: [ 0.1, rythm_length / 4, 0.1 ] ), doneAction: Done.freeSelf ); snd = SinOsc.ar( freq, 0, 0.5 ) + SinOsc.ar( freq * 2, 0, 0.4 ) + SinOsc.ar( freq * 4, 0, 0.3 ) + SinOsc.ar( freq * 8, 0, 0.35 * EnvGen.kr( envctl3 ) ) + SinOsc.ar( freq * 16, 0, 0.35 * EnvGen.kr( envctl3 ) ); snd = RLPF.ar( snd, freq / 2 + ( freq * EnvGen.kr( envctl2 ) * 2 ), 0.5 ); snd2 = SinOsc.ar( freq * 1.001, 0, 0.5 ) + SinOsc.ar( freq * 1.001 * 2, 0, 0.4 ) + SinOsc.ar( freq * 1.001 * (3/2), 0, 0.3 ); snd2 = RLPF.ar( snd2, freq / 2 + ( ( freq * 2 * ( 3/2 ) * EnvGen.kr( envctl4 ) * 4 ) ), 0.5 ); snd = snd * EnvGen.kr( envctl ); snd2 = snd2 * EnvGen.kr( envctl3 ); snd = Mix.ar( [ snd, snd2 ] ); snd = snd * amp * release; Out.ar( out, snd ) } ).play; var routine = Routine.new( { loop { Synth(\synth, [ \env, Env( parameters[0], Array.fill( rythm_length -1, { 1 / rythm_length } )), \env2, Env( parameters[1], Array.fill( rythm_length -1, { 1 / rythm_length } )), \env3, Env( parameters[2], Array.fill( rythm_length -1, { 1 / rythm_length } )), \env4, Env( parameters[3], Array.fill( rythm_length -1, { 1 / rythm_length } )), ]); 1.wait; }; } ).play; win.layout_( VLayout( main_view ).margins_(0) ); main_view.layout_( HLayout( button_rack_view, layout ).margins_(3) ); layout.layout_( StackLayout( views[0], views[1], views[2], views[3], ).margins_(3).mode_(1) ); main_view.background_( background_color ); button_rack_view.drawFunc = { | view | var case_height = view.bounds.height / parameters.size; Pen.fillColor_( colors[ selected_view ] ); Pen.fillRect( Rect( case_height * 0.2, case_height * selected_view + ( case_height * 0.2 ), view.bounds.width - ( case_height * 0.4 ), case_height - ( case_height * 0.4 ) ) ); }; button_rack_view.refresh; button_rack_view.mouseDownAction_( { | view, x, y | var selection_y = y.linlin( 0, view.bounds.height, 0, 4, clip: 'minmax' ).asInt; selected_view = selection_y; views.do( { | view, index | if( index == selected_view, { view.visible_( true ) }, { view.visible_( false ) } ); } ); button_rack_view.refresh; } ); views.do( { | view, view_index | view.background_( Color( 0.25, 0.25, 0.25 ) ); view.drawFunc_( { | view | var case_size = view.bounds.width / rythm_length; // Back Shadow Vertical Sections Pen.strokeColor_( Color( 0, 0, 0, 0.5 ) ); Pen.width = case_size * 0.15; rythm_length.do( { | index | Pen.moveTo( Point( case_size * index, 0 ) ); Pen.lineTo( Point( case_size * index, view.bounds.height ) ); } ); Pen.stroke; // Draw Mountain Pen.strokeColor_( Color.black ); Pen.fillColor_( colors[ view_index ] ); Pen.width = case_size * 0.2; Pen.moveTo( Point( 0, view.bounds.height * ( 1 - parameters[ view_index ][ 0 ] ) - ( view.bounds.height * 0.05 ) ) ); rythm_length.do( { | index | Pen.lineTo( Point( case_size * index + ( case_size * 0.5 ), view.bounds.height * ( 1 - parameters[ view_index ][ index ] ) - ( view.bounds.height * 0.05 ) ) ); } ); Pen.lineTo( Point( view.bounds.width, view.bounds.height )); Pen.lineTo( Point( 0, view.bounds.height )); Pen.lineTo( Point( 0, view.bounds.height * ( 1 - parameters[ view_index ][ 0 ] ))); Pen.fillStroke; // Draw Vertical Sections Pen.strokeColor_( Color( 0, 0, 0, 0.25 ) ); Pen.width = case_size * 0.1; rythm_length.do( { | index | Pen.moveTo( Point( case_size * index + ( case_size * 0 ), 0 ) ); Pen.lineTo( Point( case_size * index + ( case_size * 0.25 ), view.bounds.height ) ); } ); Pen.stroke; // Draw Mountain 2 Pen.strokeColor_( Color( 0.2, 0.2, 0.2, 0.75 ) ); Pen.fillColor_( Color( 0, 0, 0, 0.25 ) ); Pen.width = case_size * 0.1; Pen.moveTo( Point( 0, view.bounds.height * ( 1 - parameters[ view_index ][ 0 ] ) + ( view.bounds.height - ( view.bounds.height * ( 1 - parameters[ view_index ][ 0 ] ) ) * 0.05 ) ) ); rythm_length.do( { | index | Pen.lineTo( Point( case_size * index + ( case_size * 0.5 ), view.bounds.height * ( 1 - parameters[ view_index ][ index ] ) + ( view.bounds.height - ( view.bounds.height * ( 1 - parameters[ view_index ][ index ] ) ) * 0.05 ) ) ); } ); Pen.lineTo( Point( view.bounds.width, view.bounds.height ) ); Pen.lineTo( Point( 0, view.bounds.height ) ); Pen.lineTo( Point( 0, view.bounds.height * ( 1 - parameters[ view_index ][ 0 ] ) ) ); Pen.fillStroke; // Front Vertical Sections Pen.strokeColor_( Color( 0, 0, 0, 0.15 ) ); Pen.width = case_size * 0.05; rythm_length.do( { | index | Pen.moveTo( Point( case_size * index, 0 ) ); Pen.lineTo( Point( case_size * index, view.bounds.height ) ); } ); Pen.stroke; } ); view.mouseDownAction_( { | view, x, y | var selection_x = x.linlin( 0, view.bounds.width, 0, rythm_length, clip: 'minmax' ).asInt(); var selection_y = y.linlin( 0, view.bounds.height, 1, 0, clip: 'minmax' ); if( selection_x == rythm_length, { selection_x = rythm_length- 1 } ); parameters[ view_index ][ selection_x ] = selection_y; view.refresh; } ); view.mouseMoveAction_( view.mouseDownAction ); } ); win.front; win.onClose = { Window.closeAll; }; )
code description
A personnal interpretation of enveloppe pictural representation.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change