Skip to content

Commit

Permalink
test param tables
Browse files Browse the repository at this point in the history
  • Loading branch information
gesellkammer committed Sep 17, 2023
1 parent ab274ed commit f18b269
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions notebooks/test-paramtable.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "c357dc88-e4f5-44fb-ade3-97846008f074",
"metadata": {},
"outputs": [],
"source": [
"from csoundengine import *"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a9e6384e-9305-437a-b4b6-5087c2fdbf58",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"\n",
"--Csound version 6.19 (double samples) May 26 2023\n",
"[commit: 593ac80dd986b58f24e3d59242243ba6266edda7]\n",
"\u001b[mlibsndfile-1.2.0\n",
"\u001b[msr = 48000.0,\u001b[m kr = 750.000,\u001b[m ksmps = 64\n",
"\u001b[m0dBFS level = 1.0,\u001b[m A4 tuning = 442.0\n",
"\u001b[maudio buffered in 1024 sample-frame blocks\n",
"\u001b[mreading 4096-byte blks of shorts from adc:PCM Source: (RAW)\n",
"writing 2048 sample blks of 64-bit floats to dac:Built-in Audio Analogue Stereo:\n",
"SECTION 1:\n"
]
}
],
"source": [
"s = Engine().session()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "11afefa8-a926-41bd-9187-a217690b9341",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"Instr <strong style=\"color:MediumSeaGreen\">foo</strong><br>\n",
"&nbsp&nbsp&nbsp&nbsptabargs = <code>{'kpitch': 60.0, 'kamp': 0.1}</code>\n",
"<hr style=\"width:38%;text-align:left;margin-left:0\">\n",
"<span style=\"font-size:90%\"><div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%;\"><span></span><code><span style=\"color: #bbbbbb\"> </span><span style=\"color: #3D7B7B; font-style: italic\">; --- start generated table code</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>params_<span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">=</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #19177C\">p4</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000; font-weight: bold\">if</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>params_<span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">==</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">0</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">||</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">ftexists</span>:<span style=\"color: #B00040\">i</span>(<span style=\"color: #B00040\">i</span>params_)<span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">==</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">0</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000; font-weight: bold\">then</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>niterror<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">sprintf</span>(<span style=\"color: #BA2121\">&quot;Params table (</span><span style=\"color: #A45A77; font-weight: bold\">%d</span><span style=\"color: #BA2121\">) does not exist (p1: </span><span style=\"color: #A45A77; font-weight: bold\">%f</span><span style=\"color: #BA2121\">)&quot;</span>,<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>params_,<span style=\"color: #bbbbbb\"> </span><span style=\"color: #19177C\">p1</span>)\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000; font-weight: bold\">goto</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #767600\">__exit</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000; font-weight: bold\">endif</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>paramslen_<span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">=</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">ftlen</span>(<span style=\"color: #B00040\">i</span>params_)\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000; font-weight: bold\">if</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>paramslen_<span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">&lt;</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">2</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000; font-weight: bold\">then</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>niterror<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">sprintf</span>(<span style=\"color: #BA2121\">&quot;params table too small (size: </span><span style=\"color: #A45A77; font-weight: bold\">%d</span><span style=\"color: #BA2121\">, needed: 2)&quot;</span>,<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>paramslen_)\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000; font-weight: bold\">endif</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">k</span>pitch<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">tab</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">0</span>,<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>params_\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">k</span>amp<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">tab</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">1</span>,<span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>params_\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">ftfree</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #B00040\">i</span>params_,<span style=\"color: #bbbbbb\"> </span><span style=\"color: #666666\">1</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #3D7B7B; font-style: italic\">; --- end generated table code</span>\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">outch</span><span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">oscili</span>:<span style=\"color: #B00040\">a</span>(<span style=\"color: #B00040\">k</span>amp,<span style=\"color: #bbbbbb\"> </span><span style=\"color: #008000\">mtof</span>(<span style=\"color: #B00040\">k</span>pitch)\n",
"<span style=\"color: #bbbbbb\"> </span><span style=\"color: #767600\">__exit</span>:\n",
"</code></pre></div>\n",
"</span>"
],
"text/plain": [
"Instr(foo, tabargs={'kpitch': 60.0, 'kamp': 0.1})"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"s.defInstr(\"foo\", r\"\"\"\n",
"{kpitch=60, kamp=0.1}\n",
"outch oscili:a(kamp, mtof(kpitch)\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d4e65796-6b76-4013-808b-041192f2cc76",
"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.9.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit f18b269

Please sign in to comment.