From 2a0eb137545bed4b9a142a3a9c498563a8eb7bab Mon Sep 17 00:00:00 2001 From: Kajetan Enge Date: Wed, 20 Sep 2023 15:12:28 +0200 Subject: [PATCH] stethoscope-like sonification with loop in constant order --- examples/SoniScope.ipynb | 64 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/examples/SoniScope.ipynb b/examples/SoniScope.ipynb index 573c8d9..d6ac6c9 100644 --- a/examples/SoniScope.ipynb +++ b/examples/SoniScope.ipynb @@ -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" ] }, { @@ -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", + " " ] }, {