Skip to content

Commit

Permalink
sonification loop handle 1 item and 0 items
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rind committed Sep 21, 2023
1 parent 67a0651 commit aacc788
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# soniscope-jupyter

[![PyPI-Server](https://img.shields.io/pypi/v/soniscope-jupyter.svg)](https://pypi.org/project/soniscope-jupyter/)

jupyter notebook widget with a scatter plot and an interactive lens to enable interactive sonification

## Installation
Expand Down
88 changes: 42 additions & 46 deletions examples/SoniScope.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "7ca415b7-f2b8-4e8e-ac4e-e3fa49191f42",
"metadata": {},
"outputs": [],
"source": [
"# pip install sc3nb"
"# pip install sc3nb soniscope_jupyter"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "ed04a35d-22bc-407a-913e-6206c19c660e",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "09e9a5d6-9043-496b-9fde-1e89dfc0a088",
"metadata": {
"tags": []
Expand Down Expand Up @@ -218,7 +218,7 @@
"outputs": [],
"source": [
"%%scs # Listen to the marimba with 200 Hz fundamental frequency\n",
"Synth.new(\\Lens_Synth ,[\"freq\", 200, \"amp\", 0.005, \"decayscale\", 1.5, \"panning\", 0]);"
"Synth.new(\\Lens_Synth ,[\"freq\", 200, \"amp\", 0.05, \"decayscale\", 1.5, \"panning\", 0]);"
]
},
{
Expand Down Expand Up @@ -307,38 +307,39 @@
" # ---------------------------------------------------------------------------------------------- \n",
" # SONIFICATION \n",
"\n",
" loop = 0 #set loop to 1 to use the physical stetoskope on the touch display\n",
" loop = 1 #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",
" dlist = filtered[soni_dim.value].to_numpy()\n",
" # dlist = filtered.cnt.to_numpy()\n",
" if dlist.size > 0:\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",
Expand All @@ -362,21 +363,6 @@
" \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",
" "
]
},
{
"cell_type": "markdown",
"id": "90fe8f87-04d6-4108-b1ab-0a58f0ce9423",
Expand Down Expand Up @@ -679,6 +665,16 @@
"id": "f1981939-ba95-4276-9a49-a0489e80204c",
"metadata": {},
"outputs": [],
"source": [
"%sc k.stop;"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3105710f-a640-438b-8ea2-7f690b7d92f0",
"metadata": {},
"outputs": [],
"source": []
}
],
Expand Down

0 comments on commit aacc788

Please sign in to comment.