Skip to content

Commit

Permalink
Add example notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Nov 10, 2023
1 parent f154889 commit 727d8e4
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ dist
.cmake-*
.coverage
.ipynb_checkpoints
notebooks/
wheelhouse/
85 changes: 85 additions & 0 deletions examples/notebooks/01. Hello World.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from signalflow import *"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#--------------------------------------------------------------------------------\n",
"# Create and start the global processing graph\n",
"#--------------------------------------------------------------------------------\n",
"graph = AudioGraph()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#--------------------------------------------------------------------------------\n",
"# Create a stereo sine wave\n",
"#--------------------------------------------------------------------------------\n",
"sine = SineOscillator(440)\n",
"stereo = StereoPanner(sine, 0.0)\n",
"output = sine * 0.1\n",
"output.play()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#--------------------------------------------------------------------------------\n",
"# Change the frequency\n",
"#--------------------------------------------------------------------------------\n",
"sine.frequency = 880"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#--------------------------------------------------------------------------------\n",
"# Stop playback\n",
"#--------------------------------------------------------------------------------\n",
"output.stop()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
73 changes: 73 additions & 0 deletions examples/notebooks/02. Patch Example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from signalflow import *"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"graph = AudioGraph()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class Ping (Patch):\n",
" def __init__(self, frequency=440):\n",
" #--------------------------------------------------------------------------------\n",
" # It's vital to call the super().__init__ function to properly create the patch.\n",
" #--------------------------------------------------------------------------------\n",
" super().__init__()\n",
" frequency = self.add_input(\"frequency\", frequency)\n",
" square = SquareOscillator([frequency, frequency * 1.01])\n",
" lowpass = SVFilter(square, \"low_pass\", Line(frequency, frequency / 4, 0.1))\n",
" envelope = ASREnvelope(0.0, 0.0, 0.5)\n",
" output = lowpass * envelope * 0.1\n",
" self.set_output(output)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ping = Ping(frequency=440)\n",
"ping.play()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 727d8e4

Please sign in to comment.