From 429991e37fc9ca4aeb49cf05db6819f735efe5b3 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 15 Nov 2023 00:08:08 +0300 Subject: Added Jupyter notebook example --- examples/simple.ipynb | 421 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 421 insertions(+) create mode 100644 examples/simple.ipynb (limited to 'examples/simple.ipynb') diff --git a/examples/simple.ipynb b/examples/simple.ipynb new file mode 100644 index 0000000..1bfddff --- /dev/null +++ b/examples/simple.ipynb @@ -0,0 +1,421 @@ +{ + "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..." + ] + }, + { + "cell_type": "markdown", + "id": "a0620a19-0b04-4b28-8169-fafe75002bbe", + "metadata": {}, + "source": [ + "Manually call `tostring()` when printing streams (**FIXME**):" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "9179293d-9b2d-47b2-bb1c-4ee8cf576606", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}\"" + ] + }, + "execution_count": 4, + "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()" + ] + }, + { + "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": 6, + "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": "code", + "execution_count": null, + "id": "78a2478e-819c-42e0-a47d-5682e60886e1", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Lua", + "language": "lua", + "name": "lua" + }, + "language_info": { + "file_extension": ".lua", + "mimetype": "text/x-lua", + "name": "lua", + "version": "5.1" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} -- cgit v1.2.3