|
@@ -286,6 +286,7 @@
|
|
|
" time.sleep(0.005)\n",
|
|
|
" \n",
|
|
|
" stream.stop()\n",
|
|
|
+ " stream.close()\n",
|
|
|
" print('Sound stopped')\n",
|
|
|
"\n",
|
|
|
" \n",
|
|
@@ -328,6 +329,7 @@
|
|
|
" self.stream.write(self.data[start_idx:end_idx])\n",
|
|
|
" \n",
|
|
|
" self.stream.stop()\n",
|
|
|
+ " self.stream.close()\n",
|
|
|
" \n",
|
|
|
" \n",
|
|
|
"class SoundControllerPR:\n",
|
|
@@ -426,7 +428,8 @@
|
|
|
" def stop(self):\n",
|
|
|
" for t in self.timers:\n",
|
|
|
" t.cancel()\n",
|
|
|
- " self.stream.stop()"
|
|
|
+ " self.stream.stop()\n",
|
|
|
+ " self.stream.close()"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
@@ -476,25 +479,45 @@
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": null,
|
|
|
+ "execution_count": 89,
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "sc = SoundControllerPR(1, SoundControllerPR.default_cfg)"
|
|
|
+ "sound_cfg = {\n",
|
|
|
+ " \"device\": [1, 24],\n",
|
|
|
+ " \"n_channels\": 14,\n",
|
|
|
+ " \"sounds\": {\n",
|
|
|
+ " \"noise\": {\"amp\": 0.01, \"duration\": 10.0, \"channels\": [6]}, # 69 DBA (amp 0.01, volume 0.1)\n",
|
|
|
+ " \"target\": {\"freq\": 660, \"amp\": 0.3, \"duration\": 0.015, \"window\": 0.005, \"iti\": 0.1, \"number\": 10, \"channels\": [5]}\n",
|
|
|
+ " },\n",
|
|
|
+ " \"sample_rate\": 44100,\n",
|
|
|
+ " \"volume\": 0.1,\n",
|
|
|
+ " \"file_path\": \"sounds.csv\"\n",
|
|
|
+ "}"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": null,
|
|
|
+ "execution_count": 87,
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|
|
|
- "sc.play_non_blocking('target', 0)"
|
|
|
+ "sc = SoundControllerPR(1, sound_cfg)"
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
- "execution_count": null,
|
|
|
+ "execution_count": 88,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "sc.noise() # 5 is 3\n",
|
|
|
+ "#sc.play_non_blocking('noise', 0)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 85,
|
|
|
"metadata": {},
|
|
|
"outputs": [],
|
|
|
"source": [
|