Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

4 Commits 6400ec29e7 ... 33602747d4

Author SHA1 Message Date
  Andrey Sobolev 33602747d4 merged conflicts 1 year ago
  Andrey Sobolev b51004d27f some fixes 1 year ago
  Andrey Sobolev cf95d7771d values for new amplifier 1 year ago
  Andrey Sobolev 562e801e81 fixes to sound controllers 1 year ago
2 changed files with 32 additions and 6 deletions
  1. 29 6
      controllers/sound.ipynb
  2. 3 0
      controllers/sound.py

+ 29 - 6
controllers/sound.ipynb

@@ -165,6 +165,7 @@
     "                time.sleep(0.005)\n",
     "                \n",
     "        stream.stop()\n",
+    "        stream.close()\n",
     "        print('Sound stopped')\n",
     "\n",
     "        \n",
@@ -207,6 +208,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",
@@ -305,7 +307,8 @@
     "    def stop(self):\n",
     "        for t in self.timers:\n",
     "            t.cancel()\n",
-    "        self.stream.stop()"
+    "        self.stream.stop()\n",
+    "        self.stream.close()"
    ]
   },
   {
@@ -376,25 +379,45 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "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": 6,
+   "execution_count": 87,
    "metadata": {},
    "outputs": [],
    "source": [
-    "sc.play_non_blocking('target', 0)"
+    "sc = SoundControllerPR(1, sound_cfg)"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "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": [

+ 3 - 0
controllers/sound.py

@@ -148,6 +148,7 @@ class SoundController:
                 time.sleep(0.005)
                 
         stream.stop()
+        stream.close()
         print('Sound stopped')
 
         
@@ -190,6 +191,7 @@ class ContinuousSoundStream:
             self.stream.write(self.data[start_idx:end_idx])
             
         self.stream.stop()
+        self.stream.close()
         
         
 class SoundControllerPR:
@@ -289,3 +291,4 @@ class SoundControllerPR:
         for t in self.timers:
             t.cancel()
         self.stream.stop()
+        self.stream.close()