lasprs 0.14.1

Library for Acoustic Signal Processing (Rust edition, with optional Python bindings via pyo3)
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "afa2bdda-0748-4a76-ad5c-d19859f833f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lasprs import DaqConfig, StreamMgr, StreamType, DaqConfig, StreamDirection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "2b47552e-823e-48ba-8853-7f58fc1f90de",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "thread '<unnamed>' panicked at src/daq/streammgr.rs:180:13:\n",
      "BUG: Stream manager is supposed to be a singleton\n"
     ]
    },
    {
     "ename": "PanicException",
     "evalue": "BUG: Stream manager is supposed to be a singleton",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mPanicException\u001b[39m                            Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[39]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m s = \u001b[43mStreamMgr\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[31mPanicException\u001b[39m: BUG: Stream manager is supposed to be a singleton"
     ]
    }
   ],
   "source": [
    "s = StreamMgr()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "39d4c156-8304-4ed6-b9da-1d8a14d3bbe8",
   "metadata": {},
   "outputs": [],
   "source": [
    "ds = s.getDeviceInfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "a6f28472-a52c-4ccf-b65f-2a44b2eb59e1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DeviceInfo { api: Loopback, device_name: \"Loopback\", avDataTypes: [F32], prefDataType: F32, avFramesPerBlock: [512], prefFramesPerBlock: 512, avSampleRates: [48000.0], prefSampleRate: 48000.0, iChannelCount: 2, oChannelCount: 2, hasInputIEPE: false, hasInputACCouplingSwitch: false, hasInputTrigger: false, hasInternalOutputMonitor: false, hasDuplexMode: false, duplexModeForced: false, physicalIOQty: Number, avInputRanges: [(-1.0, 1.0)], avOutputRanges: [(-1.0, 1.0)] }"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ds[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "f572836b-e346-40c4-a7e5-d145ecd174ba",
   "metadata": {},
   "outputs": [],
   "source": [
    "config = DaqConfig.newFromDeviceInfo(ds[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "fc6ace58-e77b-4e61-9f1e-5f953bb8a541",
   "metadata": {},
   "outputs": [],
   "source": [
    "ich = config.inchannel_config\n",
    "ich[0].enabled = True\n",
    "och = config.outchannel_config\n",
    "och[0].enabled=True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "d2615472-ed00-4a97-9306-2c9aa21a9a56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ich[0].enabled"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "77c6a3bd-3a72-472c-ad56-0b447a5c683a",
   "metadata": {},
   "outputs": [],
   "source": [
    "config.inchannel_config = ich\n",
    "config.outchannel_config = och"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "00635264-6cbc-4391-b207-308e859fd109",
   "metadata": {},
   "outputs": [
    {
     "ename": "RuntimeError",
     "evalue": "Output stream already running",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mRuntimeError\u001b[39m                              Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[46]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43ms\u001b[49m\u001b[43m.\u001b[49m\u001b[43mstartStream\u001b[49m\u001b[43m(\u001b[49m\u001b[43mStreamType\u001b[49m\u001b[43m.\u001b[49m\u001b[43mOutput\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[31mRuntimeError\u001b[39m: Output stream already running"
     ]
    }
   ],
   "source": [
    "s.startStream(StreamType.Output, config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "332c16c0-ac70-426f-9301-dc4b8470c44d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "StreamMetaData {\n",
       "    channelInfo: [\n",
       "        DaqChannel {\n",
       "            enabled: true,\n",
       "            name: \"\",\n",
       "            sensitivity: 1.0,\n",
       "            IEPEEnabled: false,\n",
       "            ACCouplingMode: false,\n",
       "            range: (\n",
       "                -1.0,\n",
       "                1.0,\n",
       "            ),\n",
       "            qty: Number,\n",
       "            digitalHighpassCutOn: -1.0,\n",
       "        },\n",
       "    ],\n",
       "    rawDatatype: F32,\n",
       "    samplerate: 48000.0,\n",
       "    framesPerBlock: 512,\n",
       "    physicalIOQty: Number,\n",
       "}"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.getStreamMetaData(StreamDirection.Output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "3f91dc33-b072-4100-80bc-f552285dcc32",
   "metadata": {},
   "outputs": [],
   "source": [
    "s.stopStream(StreamType.Output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1a50ebd4-fe23-4546-a3f3-61b112a77f58",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}