{ "cells": [ { "cell_type": "markdown", "id": "192e31a8-1d7c-4804-8d2c-65e365b13921", "metadata": {}, "source": [ "Applause supports Jupyter via [ILua](https://github.com/guysv/ilua)!\n", "\n", "Unfortunately, there are currently some restrictions.\n", "\n", "**NOTE:** The following examples require some custom patches on top of ILua." ] }, { "cell_type": "markdown", "id": "a0620a19-0b04-4b28-8169-fafe75002bbe", "metadata": {}, "source": [ "ILua does not require a leading `=` for printing values:" ] }, { "cell_type": "code", "execution_count": 1, "id": "9179293d-9b2d-47b2-bb1c-4ee8cf576606", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "iota(10)" ] }, { "cell_type": "markdown", "id": "fd156b09-fb7d-4e0e-a055-0f0f129b1fb5", "metadata": {}, "source": [ "There is some basic plotting support via `Stream:gnuplot()`, which will automatically render into a cell instead of displaying a separate window:" ] }, { "cell_type": "code", "execution_count": 2, "id": "98b40a38-0ea1-4d5c-97a7-3de458812cb9", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "Gnuplot\n", "Produced by GNUPLOT 5.2 patchlevel 8 \n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t \n", "\t \n", "\t\n", "\t\n", "\t \n", "\t \n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t-1\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t-0.5\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.5\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 1\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.0005\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.001\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.0015\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.002\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.0025\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.003\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.0035\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.004\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.0045\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\t\t\n", "\t\t 0.005\n", "\t\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\tgnuplot_plot_1\n", "\n", "\t\n", "\t\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\t\n", "\n", "\n", "\n", "\n", "\n" ] }, "metadata": { "": "" }, "output_type": "display_data" } ], "source": [ "w = Stream.SinOsc(440) * Stream.SinOsc(880)\n", "w:sub(1, 200):gnuplot()" ] }, { "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 ", "\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": "14bd4fad-e9ce-4b5f-8e46-47a140ad47e7", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Lua", "language": "lua", "name": "lua" }, "language_info": { "file_extension": ".lua", "mimetype": "text/x-lua", "name": "lua", "version": "n/a" } }, "nbformat": 4, "nbformat_minor": 5 }