Skip to content

Commit

Permalink
fix multi-touch problem, restart SC button, translate to German
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rind committed Sep 29, 2023
1 parent 1c9fde5 commit d7c6365
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 28 deletions.
86 changes: 63 additions & 23 deletions examples/SoniScope-Graz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "0d3fcf36-2fce-49b5-8d9b-5ec584162c10",
"metadata": {},
"source": [
"# SoniScope Prototype\n"
"# SoniScope Prototype (Luftgüte Graz)\n"
]
},
{
Expand Down Expand Up @@ -38,7 +38,7 @@
"\n",
"import ipywidgets as widgets\n",
"from ipywidgets import interactive, interact\n",
"from ipywidgets import HBox, Label\n",
"from ipywidgets import HBox, Label, Layout\n",
"from ipywidgets import IntSlider\n",
"\n",
"from soniscope_jupyter import LensWidget\n",
Expand Down Expand Up @@ -130,7 +130,7 @@
"outputs": [],
"source": [
"numeric_cols = daily.select_dtypes(include='number').columns.values.tolist() # get possible colums for axes\n",
"numeric_cols"
"# numeric_cols"
]
},
{
Expand Down Expand Up @@ -292,6 +292,9 @@
" scanduration = duration.value / 13\n",
" decay = 1\n",
" \n",
" # stop the previous loop - TODO remove next line to explore multi-touch multi-lens sonification\n",
" %sc k.stop;\n",
" \n",
" # convert list to pattern\n",
" sc.lang.cmd(r\"\"\"\n",
" // old version with random sorting of auditory marks: \n",
Expand Down Expand Up @@ -415,7 +418,7 @@
"# Silders for sound parameters:\n",
"dB_range = widgets.IntRangeSlider(description='Volume Range [dB]',min=-100,max=-60,step=1,value=[-80,-60],style = style)\n",
"midi_range = widgets.IntRangeSlider(description='Pitch Range [Midi]',min=48,max=90,step=1,value=[60,90],style = style)\n",
"duration = widgets.FloatSlider(description='Scan Duration [*s]',min = 0.5, max=10, step=0.1, value = 3,style = style)\n",
"duration = widgets.FloatSlider(description='Tempo',min = 0.5, max=10, step=0.1, value = 3,style = style)\n",
"\n",
"def f(dB_range,midi_range,duration):\n",
" return [dB_range,midi_range,duration]\n",
Expand All @@ -425,7 +428,7 @@
"#---------------------------------------------------\n",
"soni_dim = widgets.Dropdown(options=numeric_cols,\n",
" value=numeric_cols[1],\n",
" description='Pitch:',\n",
" description='Tonhöhe:',\n",
" disabled=False)\n",
"\n",
"def soni_dim_handler(change1):\n",
Expand All @@ -437,7 +440,7 @@
"#----------------------------------------------------\n",
"soni_sort_dim = widgets.Dropdown(options=numeric_cols,\n",
" value=numeric_cols[0],\n",
" description='Sort:',\n",
" description='Sortierung:',\n",
" disabled=False)\n",
"\n",
"def soni_sort_dim_handler(change2):\n",
Expand Down Expand Up @@ -472,7 +475,8 @@
"#----------------------------------------------------\n",
"# interface text in widget\n",
"interface_text = widgets.HTML(value=\"\"\"\n",
"<b>SoniScope Interface:</b> <br>\n",
"<b>SoniScope:<br> \n",
"Luftgüte in Graz Mitte-Gries</b>\n",
"<br>\n",
"<br>\n",
"\"\"\")\n",
Expand Down Expand Up @@ -515,27 +519,27 @@
"execution_count": null,
"id": "fa2be301-99ee-4dab-b606-6fa0078fec74",
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [],
"source": [
"plot = LensWidget(daily, numeric_cols[0], numeric_cols[1])\n",
"plot.substrate_width = 700\n",
"plot.substrate_height = 500\n",
"plot.size = 0.18\n",
"\n",
"#----------------------------------------------------\n",
"sliderSize = widgets.FloatSlider(description='Lens Size', min=0.01, max=1.5, step=0.01, readout_format='.0%')\n",
"sliderSize = widgets.FloatSlider(description='Linsengröße', min=0.01, max=0.5, step=0.01, readout_format='.0%')\n",
"\n",
"#----------------------------------------------------\n",
"radioShape = widgets.RadioButtons(options=ALLOWED_SHAPES,\n",
" layout={'width': 'max-content'}, # If the items' names are long\n",
" description='Lens Shape:')\n",
"\n",
"#----------------------------------------------------\n",
"drpX = widgets.Dropdown(options=numeric_cols, value=numeric_cols[0], description='X-Axis:',)\n",
"drpY = widgets.Dropdown(options=numeric_cols, value=numeric_cols[1], description='Y-Axis:',)\n",
"drpC = widgets.Dropdown(options=['', 'Jahreszeit', 'Wochentag', 'Jahr', 'Monat'], value='', description='Color:',)\n",
"drpX = widgets.Dropdown(options=numeric_cols, value=numeric_cols[0], description='X-Achse:',)\n",
"drpY = widgets.Dropdown(options=numeric_cols, value=numeric_cols[1], description='Y-Achse:',)\n",
"drpC = widgets.Dropdown(options=['', 'Jahreszeit', 'Wochentag', 'Jahr', 'Monat'], value='', description='Farbe:',)\n",
"\n",
"#----------------------------------------------------\n",
"# connection between frontend and python\n",
Expand All @@ -561,14 +565,15 @@
" duration,\n",
" #midi_range, # uncomment if you want to change pitch range interactively (run all cells above again)\n",
" #dB_range, # uncomment if you want to change volume range for the circular lens interactively (!! also uncomment a line in the \"sonifyer\"-def cell above)(run all cells above again)\n",
" radioShape,\n",
" # radioShape,\n",
" #decay_switch, # uncomment for the decay option (run also the cell above again)\n",
" #euclidean_switch, # uncomment for the eclidean distance sorting option (run also the cell above again)\n",
" ]),\n",
" plot\n",
" ]),\n",
" explanation_text,\n",
" outputBike)\n",
" ], layout=Layout(justify_content='center', margin='20px 20px 10px 20px')),\n",
" # explanation_text,\n",
" # outputBike\n",
" )\n",
"\n",
"#----------------------------------------------------\n",
"# optional for bigger datasets\n",
Expand All @@ -593,15 +598,50 @@
"The SoniScope will always sonify the items thats lie within the visible lens."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db3c9e72-4720-4136-9342-018a6f4dd432",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"buttonSuperCollider = widgets.Button(description=\"Audio neu starten\")\n",
"\n",
"def on_button_clicked(b):\n",
" global sc\n",
" sc.exit()\n",
" \n",
" sc = scn.startup()\n",
" \n",
" Lens_Synth_def = SynthDef('Lens_Synth',\n",
" \"\"\"{ | freq = 1 , amp = 0.5, decayscale = 1, panning = 0|\n",
" var sig, exciter;\n",
" //exciter = WhiteNoise.ar() * EnvGen.ar(Env.perc(0.0001, 0.0001), 1);\n",
" exciter = Impulse.ar(0);\n",
" sig = DynKlank.ar(`[\n",
" [1, 4, 10, 11, 12, 15], \n",
" [1, 0.66, 0.7, 0.36, 0.28, 0.3], \n",
" [1, 0.3, 0.1, 0.023, 0.021, 0.018]], exciter, freq, 0, decayscale);\n",
"\n",
" DetectSilence.ar(sig, 0.0001, 0.05, doneAction:2);\n",
" Out.ar(0, Pan2.ar(sig*amp, panning));\n",
" }\"\"\").add()\n",
"\n",
"buttonSuperCollider.on_click(on_button_clicked)\n",
"display(buttonSuperCollider)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d0e80cf1-7b28-4dfa-a3fc-094488328f53",
"metadata": {},
"outputs": [],
"source": [
"plot.substrate_width = 600\n",
"plot.substrate_height = 600"
"# plot.substrate_width = 600\n",
"# plot.substrate_height = 600"
]
},
{
Expand Down Expand Up @@ -639,7 +679,7 @@
"outputs": [],
"source": [
"# end the connection to SuperCollider\n",
"sc.exit()"
"# sc.exit()"
]
},
{
Expand All @@ -649,7 +689,7 @@
"metadata": {},
"outputs": [],
"source": [
"%sc k.stop;"
"# %sc k.stop;"
]
},
{
Expand All @@ -659,7 +699,7 @@
"metadata": {},
"outputs": [],
"source": [
"daily.loc[(daily['PM10 (Feinstaub) [µg/m³]'] > 40) & (daily['Jahreszeit'] == 'Sommer')]"
"# daily.loc[(daily['PM10 (Feinstaub) [µg/m³]'] > 40) & (daily['Jahreszeit'] == 'Sommer')]"
]
},
{
Expand Down
48 changes: 43 additions & 5 deletions examples/SoniScope-Rad-Deutsch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
" if filtered.shape[0] == 1: # otherwise linlin division by zero whenever only one point in lens\n",
" x_min = 0\n",
" y_min = 0\n",
" soni_dim_min = 0\n",
" # soni_dim_min = 0\n",
" soni_sort_dim_min = 0\n",
" \n",
" #---------------------------------------------------------------------------------------------- \n",
Expand Down Expand Up @@ -346,6 +346,9 @@
" scanduration = duration.value / 13\n",
" decay = 1\n",
" \n",
" # stop the previous loop - TODO remove next line to explore multi-touch multi-lens sonification\n",
" %sc k.stop;\n",
" \n",
" # convert list to pattern\n",
" sc.lang.cmd(r\"\"\"\n",
" // old version with random sorting of auditory marks: \n",
Expand Down Expand Up @@ -649,15 +652,50 @@
"The SoniScope will always sonify the items thats lie within the visible lens."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db3c9e72-4720-4136-9342-018a6f4dd432",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"buttonSuperCollider = widgets.Button(description=\"Audio neu starten\")\n",
"\n",
"def on_button_clicked(b):\n",
" global sc\n",
" sc.exit()\n",
" \n",
" sc = scn.startup()\n",
" \n",
" Lens_Synth_def = SynthDef('Lens_Synth',\n",
" \"\"\"{ | freq = 1 , amp = 0.5, decayscale = 1, panning = 0|\n",
" var sig, exciter;\n",
" //exciter = WhiteNoise.ar() * EnvGen.ar(Env.perc(0.0001, 0.0001), 1);\n",
" exciter = Impulse.ar(0);\n",
" sig = DynKlank.ar(`[\n",
" [1, 4, 10, 11, 12, 15], \n",
" [1, 0.66, 0.7, 0.36, 0.28, 0.3], \n",
" [1, 0.3, 0.1, 0.023, 0.021, 0.018]], exciter, freq, 0, decayscale);\n",
"\n",
" DetectSilence.ar(sig, 0.0001, 0.05, doneAction:2);\n",
" Out.ar(0, Pan2.ar(sig*amp, panning));\n",
" }\"\"\").add()\n",
"\n",
"buttonSuperCollider.on_click(on_button_clicked)\n",
"display(buttonSuperCollider)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d0e80cf1-7b28-4dfa-a3fc-094488328f53",
"metadata": {},
"outputs": [],
"source": [
"plotBike.substrate_width = 600\n",
"plotBike.substrate_height = 600"
"# plotBike.substrate_width = 600\n",
"# plotBike.substrate_height = 600"
]
},
{
Expand Down Expand Up @@ -695,7 +733,7 @@
"outputs": [],
"source": [
"# end the connection to SuperCollider\n",
"sc.exit()"
"# sc.exit()"
]
},
{
Expand All @@ -705,7 +743,7 @@
"metadata": {},
"outputs": [],
"source": [
"%sc k.stop;"
"# %sc k.stop;"
]
},
{
Expand Down

0 comments on commit d7c6365

Please sign in to comment.