diff options
Diffstat (limited to 'examples/simple.ipynb')
-rw-r--r-- | examples/simple.ipynb | 115 |
1 files changed, 80 insertions, 35 deletions
diff --git a/examples/simple.ipynb b/examples/simple.ipynb index 1bfddff..a841d33 100644 --- a/examples/simple.ipynb +++ b/examples/simple.ipynb @@ -7,7 +7,9 @@ "source": [ "Applause supports Jupyter via [ILua](https://github.com/guysv/ilua)!\n", "\n", - "Unfortunately, there are currently some restrictions..." + "Unfortunately, there are currently some restrictions.\n", + "\n", + "**NOTE:** The following examples require some custom patches on top of ILua." ] }, { @@ -15,54 +17,28 @@ "id": "a0620a19-0b04-4b28-8169-fafe75002bbe", "metadata": {}, "source": [ - "Manually call `tostring()` when printing streams (**FIXME**):" + "ILua does not require a leading `=` for printing values:" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "id": "9179293d-9b2d-47b2-bb1c-4ee8cf576606", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "\"{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}\"" + "{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}" ] }, - "execution_count": 4, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "tostring(iota(10))" - ] - }, - { - "cell_type": "markdown", - "id": "88154e0d-baae-41ed-a973-92d2c1a233cc", - "metadata": {}, - "source": [ - "You cannot currently interrupt streams, so make sure not to play infinite streams:" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "04a654a8-f3e4-4168-966e-2d3e961e0bcf", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING: Buffer underrun detected\n" - ] - } - ], - "source": [ - "Stream.SinOsc(440):sub(1, sec(5)):play()" + "iota(10)" ] }, { @@ -75,7 +51,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 2, "id": "98b40a38-0ea1-4d5c-97a7-3de458812cb9", "metadata": {}, "outputs": [ @@ -395,9 +371,78 @@ ] }, { + "cell_type": "markdown", + "id": "3cadc448-1620-44b1-8821-7e54ef0ab1c7", + "metadata": {}, + "source": [ + "Play this sound for 5 seconds:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "d9b94d06-b5d8-42a7-93a8-25c4add1dd30", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING: Buffer underrun detected\n" + ] + } + ], + "source": [ + "w:sub(1, sec(5)):play()" + ] + }, + { + "cell_type": "markdown", + "id": "27665672-a97d-4b2e-a976-1e4ebb204ccb", + "metadata": {}, + "source": [ + "In fact, you can play infinite streams. To interrupt them, press the \"Interrupt the kernel\" button on the toolbar.\n", + "\n", + "**WARNING:** Just like on the Applause command line, while you can always interrupt playing streams, you cannot reliably interrupt all commands. Add `checkint()` to tight loops. If everything fails, you might have to restart the kernel!" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "78cd3b35-5e15-4c80-b7d2-dbe1be77856a", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING: Buffer underrun detected\n" + ] + }, + { + "ename": "n/a", + "evalue": "applause.lua:725: SIGINT received", + "execution_count": 5, + "output_type": "error", + "traceback": [ + "applause.lua:725: SIGINT received", + "stack traceback:", + "\t[C]: in function 'error'", + "\tapplause.lua:707: in function <applause.lua:663>", + "\t[C]: in function 'xpcall'", + "\t...ies/ilua/env/lib/python3.8/site-packages/ilua/interp.lua:65: in function 'handle_execute'", + "\t...ies/ilua/env/lib/python3.8/site-packages/ilua/interp.lua:176: in main chunk" + ] + } + ], + "source": [ + "w:play()" + ] + }, + { "cell_type": "code", "execution_count": null, - "id": "78a2478e-819c-42e0-a47d-5682e60886e1", + "id": "14bd4fad-e9ce-4b5f-8e46-47a140ad47e7", "metadata": {}, "outputs": [], "source": [] @@ -413,7 +458,7 @@ "file_extension": ".lua", "mimetype": "text/x-lua", "name": "lua", - "version": "5.1" + "version": "n/a" } }, "nbformat": 4, |