{
   "is_private" : null,
   "id" : "1-5fb",
   "code" : "(\r\n\r\nvar win = Window.new( \"\", Rect( 0, 800, 700, 400 ) ); // This will be our main window\r\n\r\nvar instrument_file = {};\r\n\r\nvar main_view = UserView();\r\nvar layout = UserView();\r\nvar background_color = Color( 0, 0, 0 );\r\n\r\nvar rythm = Point( 4, 4 );\r\nvar rythm_length = ( rythm.x * rythm.y );\r\nvar tempo = 1;\r\n\r\nvar parameters = Array.fill( 4,\r\n\t{ Array.fill( ( rythm_length + 1 ), { 0 } ) } );\r\n\r\nvar colors = [\r\n\tColor( 1, 0.8, 0 ),\r\n\tColor( 0, 1, 1 ),\r\n\tColor( 1, 0.2, 0.2 ),\r\n\tColor( 1, 0.6, 0.6 )\r\n];\r\n\r\nvar button_rack_view = UserView().maxWidth_( 100 );\r\nvar selected_view = 0;\r\n\r\nvar views = Array.fill( parameters.size,\r\n\t{ UserView() } );\r\n\r\nvar synth = SynthDef( \\synth, { | out, freq = 200, amp = 0.25 |\r\n\r\n\tvar snd, snd2, release;\r\n\r\n\tvar env, envctl;\r\n\tvar env2, envctl2;\r\n\tvar env3, envctl3;\r\n\tvar env4, envctl4;\r\n\r\n\tenv = Env.newClear(rythm_length);\r\n\tenvctl = \\env.kr(env.asArray);\r\n\tenv2 = Env.newClear(rythm_length);\r\n\tenvctl2 = \\env2.kr(env2.asArray);\r\n\tenv3 = Env.newClear(rythm_length);\r\n\tenvctl3 = \\env3.kr(env3.asArray);\r\n\tenv4 = Env.newClear(rythm_length);\r\n\tenvctl4 = \\env4.kr(env4.asArray);\r\n\r\n\trelease = EnvGen.kr( Env( [0,1,1,0], times: [ 0.1, rythm_length / 4, 0.1 ] ), doneAction: Done.freeSelf );\r\n\r\n\tsnd =\r\n\tSinOsc.ar( freq, 0, 0.5 ) +\r\n\tSinOsc.ar( freq * 2, 0, 0.4 ) +\r\n\tSinOsc.ar( freq * 4, 0, 0.3 ) +\r\n\tSinOsc.ar( freq * 8, 0, 0.35  * EnvGen.kr( envctl3 ) ) +\r\n\tSinOsc.ar( freq * 16, 0, 0.35  * EnvGen.kr( envctl3 ) );\r\n\r\n\tsnd = RLPF.ar(\r\n\t\tsnd,\r\n\t\tfreq / 2 + ( freq * EnvGen.kr( envctl2 ) * 2 ),\r\n\t\t0.5\r\n\t);\r\n\r\n\tsnd2 =\r\n\tSinOsc.ar( freq * 1.001, 0, 0.5 ) +\r\n\tSinOsc.ar( freq * 1.001 * 2, 0, 0.4 ) +\r\n\tSinOsc.ar( freq * 1.001 * (3/2), 0, 0.3 );\r\n\r\n\t\tsnd2 = RLPF.ar(\r\n\t\tsnd2,\r\n\t\tfreq / 2 + ( ( freq * 2 * ( 3/2 ) * EnvGen.kr( envctl4 ) * 4 ) ),\r\n\t\t0.5\r\n\t);\r\n\r\n\tsnd = snd * EnvGen.kr( envctl );\r\n\tsnd2 = snd2 * EnvGen.kr( envctl3 );\r\n\r\n\tsnd = Mix.ar( [ snd, snd2 ] );\r\n\r\n\tsnd = snd * amp * release;\r\n\r\n\tOut.ar( out, snd )\r\n\r\n} ).play;\r\n\r\nvar routine = Routine.new( {\r\n\tloop {\r\n\t\tSynth(\\synth, [\r\n\t\t\t\\env, Env( parameters[0], Array.fill( rythm_length -1, { 1 / rythm_length } )),\r\n\t\t\t\\env2, Env( parameters[1], Array.fill( rythm_length -1, { 1 / rythm_length } )),\r\n\t\t\t\\env3, Env( parameters[2], Array.fill( rythm_length -1, { 1 / rythm_length } )),\r\n\t\t\t\\env4, Env( parameters[3], Array.fill( rythm_length -1, { 1 / rythm_length } )),\r\n\t\t]);\r\n\t\t1.wait;\r\n\t};\r\n} ).play;\r\n\r\nwin.layout_(\r\n\tVLayout(\r\n\t\tmain_view\r\n\t).margins_(0)\r\n);\r\n\r\nmain_view.layout_(\r\n\tHLayout(\r\n\t\tbutton_rack_view,\r\n\t\tlayout\r\n\t).margins_(3)\r\n);\r\n\r\nlayout.layout_(\r\n\tStackLayout(\r\n\t\tviews[0],\r\n\t\tviews[1],\r\n\t\tviews[2],\r\n\t\tviews[3],\r\n\t).margins_(3).mode_(1)\r\n);\r\n\r\nmain_view.background_( background_color );\r\n\r\nbutton_rack_view.drawFunc = { | view |\r\n\r\n\tvar case_height = view.bounds.height / parameters.size;\r\n\r\n\tPen.fillColor_( colors[ selected_view ] );\r\n\tPen.fillRect(\r\n\t\tRect(\r\n\t\t\tcase_height * 0.2,\r\n\t\t\tcase_height * selected_view + ( case_height * 0.2 ),\r\n\t\t\tview.bounds.width - ( case_height * 0.4 ),\r\n\t\t\tcase_height - ( case_height * 0.4 )\r\n\t\t)\r\n\t);\r\n};\r\n\r\nbutton_rack_view.refresh;\r\n\r\nbutton_rack_view.mouseDownAction_( { | view, x, y |\r\n\r\n\tvar selection_y = y.linlin(\r\n\t\t0,\r\n\t\tview.bounds.height,\r\n\t\t0,\r\n\t\t4,\r\n\t\tclip: 'minmax'\r\n\t).asInt;\r\n\r\n\tselected_view = selection_y;\r\n\r\n\tviews.do( { | view, index |\r\n\t\tif( index == selected_view, {\r\n\t\t\tview.visible_( true )\r\n\t\t}, {\r\n\t\t\tview.visible_( false )\r\n\t\t} );\r\n\t} );\r\n\r\n\tbutton_rack_view.refresh;\r\n} );\r\n\r\nviews.do( { | view, view_index |\r\n\r\n\tview.background_( Color( 0.25, 0.25, 0.25 ) );\r\n\r\n\tview.drawFunc_( { | view |\r\n\r\n\t\tvar case_size = view.bounds.width / rythm_length;\r\n\r\n\t\t// Back Shadow Vertical Sections\r\n\t\tPen.strokeColor_( Color( 0, 0, 0, 0.5 ) );\r\n\t\tPen.width = case_size * 0.15;\r\n\t\trythm_length.do( { | index |\r\n\t\t\tPen.moveTo(\r\n\t\t\t\tPoint(\r\n\t\t\t\t\tcase_size * index,\r\n\t\t\t\t\t0 )\r\n\t\t\t);\r\n\t\t\tPen.lineTo(\r\n\t\t\t\tPoint(\r\n\t\t\t\t\tcase_size * index,\r\n\t\t\t\t\tview.bounds.height )\r\n\t\t\t);\r\n\t\t} );\r\n\t\tPen.stroke;\r\n\r\n\t\t// Draw Mountain\r\n\t\tPen.strokeColor_( Color.black );\r\n\t\tPen.fillColor_( colors[ view_index ] );\r\n\t\tPen.width = case_size * 0.2;\r\n\t\tPen.moveTo(\r\n\t\t\tPoint(\r\n\t\t\t\t0,\r\n\t\t\t\tview.bounds.height * ( 1 - parameters[ view_index ][ 0 ] ) -\r\n\t\t\t\t( view.bounds.height * 0.05 )\r\n\t\t\t)\r\n\t\t);\r\n\t\trythm_length.do( { | index |\r\n\t\t\tPen.lineTo(\r\n\t\t\t\tPoint(\r\n\t\t\t\t\tcase_size * index + ( case_size * 0.5 ),\r\n\t\t\t\t\tview.bounds.height * ( 1 - parameters[ view_index ][ index ] ) -\r\n\t\t\t\t\t( view.bounds.height * 0.05 )\r\n\t\t\t\t)\r\n\t\t\t);\r\n\t\t} );\r\n\t\tPen.lineTo(\r\n\t\t\tPoint(\r\n\t\t\t\tview.bounds.width,\r\n\t\t\t\tview.bounds.height ));\r\n\t\tPen.lineTo(\r\n\t\t\tPoint(\r\n\t\t\t\t0,\r\n\t\t\t\tview.bounds.height ));\r\n\t\tPen.lineTo(\r\n\t\t\tPoint(\r\n\t\t\t\t0,\r\n\t\t\t\tview.bounds.height * ( 1 - parameters[ view_index ][ 0 ] )));\r\n\t\tPen.fillStroke;\r\n\r\n\t\t// Draw Vertical Sections\r\n\t\tPen.strokeColor_( Color( 0, 0, 0, 0.25 ) );\r\n\t\tPen.width = case_size * 0.1;\r\n\t\trythm_length.do( { | index |\r\n\t\t\tPen.moveTo(\r\n\t\t\t\tPoint(\r\n\t\t\t\t\tcase_size * index + ( case_size * 0 ),\r\n\t\t\t\t\t0 )\r\n\t\t\t);\r\n\t\t\tPen.lineTo(\r\n\t\t\t\tPoint(\r\n\t\t\t\t\tcase_size * index + ( case_size * 0.25 ),\r\n\t\t\t\t\tview.bounds.height )\r\n\t\t\t);\r\n\t\t} );\r\n\t\tPen.stroke;\r\n\r\n\t\t// Draw Mountain 2\r\n\t\tPen.strokeColor_( Color( 0.2, 0.2, 0.2, 0.75 ) );\r\n\t\tPen.fillColor_( Color( 0, 0, 0, 0.25 ) );\r\n\t\tPen.width = case_size * 0.1;\r\n\t\tPen.moveTo(\r\n\t\t\tPoint(\r\n\t\t\t\t0,\r\n\t\t\t\tview.bounds.height * ( 1 - parameters[ view_index ][ 0 ] ) +\r\n\t\t\t\t( view.bounds.height - ( view.bounds.height * ( 1 - parameters[ view_index ][ 0 ] ) ) * 0.05 )\r\n\t\t\t)\r\n\t\t);\r\n\t\trythm_length.do( { | index |\r\n\t\t\tPen.lineTo(\r\n\t\t\t\tPoint(\r\n\t\t\t\t\tcase_size * index + ( case_size * 0.5 ),\r\n\t\t\t\t\tview.bounds.height * ( 1 - parameters[ view_index ][ index ] ) +\r\n\t\t\t\t\t( view.bounds.height - ( view.bounds.height * ( 1 - parameters[ view_index ][ index ] ) ) * 0.05 )\r\n\t\t\t\t)\r\n\t\t\t);\r\n\t\t} );\r\n\t\tPen.lineTo(\r\n\t\t\tPoint(\r\n\t\t\t\tview.bounds.width,\r\n\t\t\t\tview.bounds.height\r\n\t\t\t)\r\n\t\t);\r\n\t\tPen.lineTo(\r\n\t\t\tPoint(\r\n\t\t\t\t0,\r\n\t\t\t\tview.bounds.height\r\n\t\t\t)\r\n\t\t);\r\n\t\tPen.lineTo(\r\n\t\t\tPoint(\r\n\t\t\t\t0,\r\n\t\t\t\tview.bounds.height * ( 1 - parameters[ view_index ][ 0 ] )\r\n\t\t\t)\r\n\t\t);\r\n\t\tPen.fillStroke;\r\n\r\n\t\t// Front Vertical Sections\r\n\t\tPen.strokeColor_( Color( 0, 0, 0, 0.15 ) );\r\n\t\tPen.width = case_size * 0.05;\r\n\t\trythm_length.do( { | index |\r\n\t\t\tPen.moveTo(\r\n\t\t\t\tPoint(\r\n\t\t\t\t\tcase_size * index,\r\n\t\t\t\t\t0 )\r\n\t\t\t);\r\n\t\t\tPen.lineTo(\r\n\t\t\t\tPoint(\r\n\t\t\t\t\tcase_size * index,\r\n\t\t\t\t\tview.bounds.height )\r\n\t\t\t);\r\n\t\t} );\r\n\t\tPen.stroke;\r\n\r\n\t} );\r\n\r\n\tview.mouseDownAction_( { | view, x, y |\r\n\r\n\t\tvar selection_x = x.linlin(\r\n\t\t\t0,\r\n\t\t\tview.bounds.width,\r\n\t\t\t0,\r\n\t\t\trythm_length,\r\n\t\t\tclip: 'minmax'\r\n\t\t).asInt();\r\n\r\n\t\tvar selection_y = y.linlin(\r\n\t\t\t0,\r\n\t\t\tview.bounds.height,\r\n\t\t\t1,\r\n\t\t\t0,\r\n\t\t\tclip: 'minmax'\r\n\t\t);\r\n\r\n\t\tif( selection_x == rythm_length, { selection_x = rythm_length- 1 } );\r\n\r\n\t\tparameters[ view_index ][ selection_x ] = selection_y;\r\n\t\tview.refresh;\r\n\r\n\t} );\r\n\r\n\tview.mouseMoveAction_( view.mouseDownAction );\r\n} );\r\n\r\n\r\n\r\nwin.front;\r\nwin.onClose = {\r\n\tWindow.closeAll;\r\n};\r\n\r\n)",
   "labels" : [
      "gui",
      "enveloppe"
   ],
   "description" : "A personnal interpretation of enveloppe pictural representation.",
   "ancestor_list" : [],
   "author" : "Dindoléon",
   "name" : "Mountains"
}
