Skip to content

Commit

Permalink
stethoscope-like sonification with loop in constant order
Browse files Browse the repository at this point in the history
  • Loading branch information
engek committed Sep 20, 2023
1 parent 21871d9 commit 2a0eb13
Showing 1 changed file with 58 additions and 6 deletions.
64 changes: 58 additions & 6 deletions examples/SoniScope.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,43 @@
" \n",
" # ---------------------------------------------------------------------------------------------- \n",
" # SONIFICATION \n",
" # the \"sonifyer\" will be applied to all the datapoints in the \"filtered\" dataframe.\n",
" filtered.apply(sonifyer, axis=1, args = [shape, size, t0, T_max, decay, soni_dim.value, soni_dim_min, soni_dim_max, soni_sort_dim.value, soni_sort_dim_min, soni_sort_dim_max, x_field, y_field, x_min, x_max, y_min, y_max, midi_min, midi_max, dB_min, dB_max])\n",
"\n",
" loop = 0 #set loop to 1 to use the physical stetoskope on the touch display\n",
" \n",
" if loop == 1:\n",
" #todo: bring the functionality to a function called \"sonifyer_loop\"\n",
" #filtered.apply(sonifyer_loop, axis=1, args = [shape, size, t0, T_max, decay, soni_dim.value, soni_dim_min, soni_dim_max, soni_sort_dim.value, soni_sort_dim_min, soni_sort_dim_max, x_field, y_field, x_min, x_max, y_min, y_max, midi_min, midi_max, dB_min, dB_max])\n",
"\n",
" #convert data to python list\n",
" #dlist = filtered[soni_dim.value].to_list()\n",
" dlist = filtered.cnt.to_list()\n",
" dlist = scn.midicps(scn.linlin(dlist, soni_dim_min, soni_dim_max, midi_min, midi_max))\n",
" #dlist = [dlist np.zeros(20)]\n",
" np.append(dlist , [0,0,0,0,0,0,0,0,0,0])\n",
" \n",
" \n",
" # convert list to pattern\n",
" sc.lang.cmd(r\"\"\"\n",
" p = Pseq(^dlist, inf); //p = Pn(Pshuf(^dlist, 1), inf);\n",
" \"\"\")\n",
" \n",
" # use the existing slidersand parameters of the interface nd synth\n",
" scanduration = duration.value / 10\n",
" decay = 2\n",
" \n",
" "
" ## setting up the pbind (basically a pattern player - the pattern is set as \"p\" above)\n",
" sc.lang.cmd(r\"\"\"\n",
" k = Pbind(\n",
" \\instrument, \\Lens_Synth,\n",
" \\freq, p,\n",
" \\dur, Pseq([^scanduration], inf), // Pwhite(0.02, 0.1, inf), // alternatively use regular onsets: Pseq([^scanduration], inf)\n",
" \\decayscale, ^decay,\n",
" ).play;\n",
" \"\"\")\n",
" \n",
" elif loop == 0:\n",
" # the \"sonifyer\" will be applied to all the datapoints in the \"filtered\" dataframe.\n",
" filtered.apply(sonifyer, axis=1, args = [shape, size, t0, T_max, decay, soni_dim.value, soni_dim_min, soni_dim_max, soni_sort_dim.value, soni_sort_dim_min, soni_sort_dim_max, x_field, y_field, x_min, x_max, y_min, y_max, midi_min, midi_max, dB_min, dB_max])\n"
]
},
{
Expand All @@ -320,9 +353,28 @@
"outputs": [],
"source": [
"def on_lens_released(widget): \n",
" # what should be done when the touch has ended or the mouse button is released \n",
" # (e.g., stop the sonification)\n",
" print(\"lens released\")"
" \n",
" # stop the pbind pattern player\n",
" %sc k.stop;\n",
" \n",
" # free all synths (i.e. also stop sound in conventional SoniScope)\n",
" #sc.server.free_all()\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c389afd-475f-47d6-a928-c367c1fe37b2",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"dlist = daily[soni_dim.value].to_list()\n",
"#dlist = daily.cnt.to_list()\n",
"len(dlist)\n",
" "
]
},
{
Expand Down

0 comments on commit 2a0eb13

Please sign in to comment.