sc-kernel 0.3.2__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ Copyright 2020 Dennis Scheiba
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,218 @@
1
+ Metadata-Version: 2.4
2
+ Name: sc_kernel
3
+ Version: 0.5.0
4
+ Summary: SuperCollider kernel for Jupyter
5
+ Author: Dennis Scheiba
6
+ License: BSD
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Framework :: IPython
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Topic :: System :: Shells
12
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Sound Synthesis
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: metakernel<0.31,>=0.23.0
17
+ Requires-Dist: ipython<10.0,>=4.0
18
+ Requires-Dist: pygments<3.0
19
+ Requires-Dist: jupyterlab<5.0,>=3.0
20
+ Requires-Dist: jupyter_server<3.0,>2.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: coverage==5.2.1; extra == "dev"
23
+ Requires-Dist: flake8<=6.0.0; extra == "dev"
24
+ Requires-Dist: unittest-xml-reporting==3.0.4; extra == "dev"
25
+ Requires-Dist: mypy<=1.0.0; extra == "dev"
26
+ Requires-Dist: pre-commit==2.17.0; extra == "dev"
27
+ Requires-Dist: black<=23.1.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # Supercollider Jupyter Kernel
31
+
32
+ This kernel allows running [SuperCollider](https://supercollider.github.io/) Code in a [Jupyter](https://jupyter.org/) environment.
33
+
34
+ ![Demo Notebook](demo.jpg)
35
+
36
+ ## Installation
37
+
38
+ Please make sure one has installed [SuperCollider](https://supercollider.github.io/) and
39
+ [Python 3 with pip](https://realpython.com/installing-python).
40
+
41
+ * To install the kernel for Jupyter execute
42
+
43
+ ```shell
44
+ pip3 install --upgrade sc-kernel
45
+ ```
46
+
47
+ This will also install [Jupyter Lab](https://jupyter.org/) if it is not already installed on the system.
48
+
49
+ * Start a new Jupyter Lab instance by executing `jupyter lab` in a console.
50
+
51
+ * Click on the SuperCollider icon
52
+
53
+ If one has not installed SuperCollider in the default location, one has to set a environment variable
54
+ called `SCLANG_PATH` which points to the sclang executable.
55
+
56
+ To uninstall the kernel execute
57
+
58
+ ```shell
59
+ jupyter kernelspec uninstall sc_kernel
60
+ ```
61
+
62
+ ### As a Docker container
63
+
64
+ It is also possible to run sc-kernel in a Docker container, although a sound output is not possible in this case.
65
+ Assuming you have cloned the repository and opened a terminal in its directory.
66
+
67
+ ```shell
68
+ # build container - takes some time b/c we build supercollider
69
+ docker build -t sc_kernel .
70
+ # run container
71
+ # -v mounts the current directory to the container
72
+ # -p passes the container port to our host
73
+ docker run -v ${PWD}:/home/sc_kernel -p 8888:8888 sc_kernel
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ Contrary to ScIDE each document will run in its own interpreter and not in a shared one.
79
+ This is the default behavior of Jupyter but maybe this will be changed at a later point.
80
+
81
+ Currently it is only possible to use the default config - if you encounter missing classes
82
+ it is probably caused that they are not available in the default config.
83
+
84
+ ### Stop sound
85
+
86
+ Currently the `Cmd + .` command is not binded. Instead create a new cell with a single dot
87
+
88
+ ```supercollider
89
+ .
90
+ ```
91
+
92
+ and execute this cell. This will transform the command to `CommandPeriod.run;` which is what is actually called on the `Cmd + .` press in the IDE.
93
+
94
+ ### Recording
95
+
96
+ `sc_kernel` provides an easy way to record audio to the local directory and store it embedded in the notebook
97
+ so one can transfer the notebook into a website which has the audio files included.
98
+
99
+ The audio is stored in FLAC with 16 bit resolution.
100
+
101
+ The provided function `record` takes 2 arguments:
102
+
103
+ * Duration in seconds
104
+ * Filename which will be used for the recording, using the path of the notebook as base path.
105
+
106
+ Assuming one has started the server, simply execute
107
+
108
+ ```supercollider
109
+ Ndef(\sine, {
110
+ var sig = SinOsc.ar(LFDNoise0.kr(1.0!2).exprange(100, 400));
111
+ sig = sig * \amp.kr(0.2);
112
+ sig;
113
+ }).play;
114
+
115
+ record.(4.0);
116
+ ```
117
+
118
+ ![Recording](recording.png)
119
+
120
+ ### Plotting
121
+
122
+ `sc_kernel` also provides a way to embed images of SuperCollider windows into the Jupyter document.
123
+ First create a window that you want to embed into the document
124
+
125
+ ```supercollider
126
+ w = {SinOsc.ar(2.0)}.plot(1.0);
127
+ ```
128
+
129
+ After the plotting is finished by the server we can now simply save an image of the window
130
+ to a file and also embed the image into the document via a SuperCollider helper method which is available.
131
+
132
+ ```supercollider
133
+ plot.(w);
134
+ ```
135
+
136
+ ![Plotting magic](plotting.png)
137
+
138
+ The image will be saved relative the directory where `jupyter lab` was executed.
139
+ The optional second argument can be the filename.
140
+
141
+ > Note that `{}.plot` does not return a `Window` but a `Plotter`, but `sc_kernel`
142
+ > accesses the window of a `Plotter` automatically.
143
+ >
144
+ > For plotting e.g. the server meter you need to pass the proper window, so
145
+ >
146
+ > ```supercollider
147
+ > a = s.meter;
148
+ > // a is a ServerMeter
149
+ >
150
+ > // new cell
151
+ > plot.(a.window, "meter.png");
152
+ > ```
153
+
154
+ ### Autocomplete
155
+
156
+ Simply push `Tab` to see available autocompletions.
157
+ This is currently limited to scan for available classes.
158
+
159
+ ### Documentation
160
+
161
+ To display the documentation of a Class, simply prepend a `?` to it and execute it, e.g.
162
+
163
+ ```supercollider
164
+ ?SinOsc
165
+ ```
166
+
167
+ You can also hit `shift <tab>` iff the cursor is behind a class to trigger the inline documentation.
168
+
169
+ ![Inline documentation](inline_docs.png)
170
+
171
+ ### Real Time Collaboration
172
+
173
+ Jupyter Lab allows for real time collaboration in which multiple users can write in the same document from different computers by visiting the Jupyter server via their browser.
174
+ Each user can write and execute sclang statements on your local sclang interpreter and the cursors of each user is shown to everyone.
175
+
176
+ This allows for interactive, shared sessions which can be an interesting live coding sessions.
177
+
178
+ > Be aware that this can be a security threat as it allows for other people from within the network to execute arbitrary sclang commands on your computer
179
+
180
+ To start such a session you can spin Jupyter Lab via
181
+
182
+ ```shell
183
+ jupyter lab --ip 0.0.0.0 --collaborative --NotebookApp.token='sclang'
184
+ ```
185
+
186
+ where the `NotebookApp.token` is the necessary password to login - set it to `''` if no password is wanted.
187
+
188
+ Check out the [documentation on Jupyter Lab](https://jupyterlab.readthedocs.io/en/stable/user/rtc.html) about *Real Time Collaboration*.
189
+
190
+ ## Development
191
+
192
+ Any PR is welcome! Please state the changes in an Issue.
193
+ To contribute, please
194
+
195
+ * Fork the repository and clone it to a local directory
196
+
197
+ * Create a virtual environment and install the dev dependencies
198
+ in it with
199
+
200
+ ```shell
201
+ pip3 install -e ".[dev]"
202
+ ```
203
+
204
+ * If one wants to add the kernel to an existing Jupyter installation one can execute
205
+
206
+ ```shell
207
+ jupyter kernelspec install sc_kernel
208
+ ```
209
+
210
+ and run `jupyter lab` from within the cloned directory as
211
+ we need to have access to `sc_kernel`.
212
+
213
+ * Run `./run_tests.sh` and make a PR :)
214
+ Use `black sc_kernel test` to format the source code.
215
+
216
+ ## Maintainers
217
+
218
+ * [Dennis Scheiba](https://dennis-scheiba.com)
@@ -0,0 +1,189 @@
1
+ # Supercollider Jupyter Kernel
2
+
3
+ This kernel allows running [SuperCollider](https://supercollider.github.io/) Code in a [Jupyter](https://jupyter.org/) environment.
4
+
5
+ ![Demo Notebook](demo.jpg)
6
+
7
+ ## Installation
8
+
9
+ Please make sure one has installed [SuperCollider](https://supercollider.github.io/) and
10
+ [Python 3 with pip](https://realpython.com/installing-python).
11
+
12
+ * To install the kernel for Jupyter execute
13
+
14
+ ```shell
15
+ pip3 install --upgrade sc-kernel
16
+ ```
17
+
18
+ This will also install [Jupyter Lab](https://jupyter.org/) if it is not already installed on the system.
19
+
20
+ * Start a new Jupyter Lab instance by executing `jupyter lab` in a console.
21
+
22
+ * Click on the SuperCollider icon
23
+
24
+ If one has not installed SuperCollider in the default location, one has to set a environment variable
25
+ called `SCLANG_PATH` which points to the sclang executable.
26
+
27
+ To uninstall the kernel execute
28
+
29
+ ```shell
30
+ jupyter kernelspec uninstall sc_kernel
31
+ ```
32
+
33
+ ### As a Docker container
34
+
35
+ It is also possible to run sc-kernel in a Docker container, although a sound output is not possible in this case.
36
+ Assuming you have cloned the repository and opened a terminal in its directory.
37
+
38
+ ```shell
39
+ # build container - takes some time b/c we build supercollider
40
+ docker build -t sc_kernel .
41
+ # run container
42
+ # -v mounts the current directory to the container
43
+ # -p passes the container port to our host
44
+ docker run -v ${PWD}:/home/sc_kernel -p 8888:8888 sc_kernel
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ Contrary to ScIDE each document will run in its own interpreter and not in a shared one.
50
+ This is the default behavior of Jupyter but maybe this will be changed at a later point.
51
+
52
+ Currently it is only possible to use the default config - if you encounter missing classes
53
+ it is probably caused that they are not available in the default config.
54
+
55
+ ### Stop sound
56
+
57
+ Currently the `Cmd + .` command is not binded. Instead create a new cell with a single dot
58
+
59
+ ```supercollider
60
+ .
61
+ ```
62
+
63
+ and execute this cell. This will transform the command to `CommandPeriod.run;` which is what is actually called on the `Cmd + .` press in the IDE.
64
+
65
+ ### Recording
66
+
67
+ `sc_kernel` provides an easy way to record audio to the local directory and store it embedded in the notebook
68
+ so one can transfer the notebook into a website which has the audio files included.
69
+
70
+ The audio is stored in FLAC with 16 bit resolution.
71
+
72
+ The provided function `record` takes 2 arguments:
73
+
74
+ * Duration in seconds
75
+ * Filename which will be used for the recording, using the path of the notebook as base path.
76
+
77
+ Assuming one has started the server, simply execute
78
+
79
+ ```supercollider
80
+ Ndef(\sine, {
81
+ var sig = SinOsc.ar(LFDNoise0.kr(1.0!2).exprange(100, 400));
82
+ sig = sig * \amp.kr(0.2);
83
+ sig;
84
+ }).play;
85
+
86
+ record.(4.0);
87
+ ```
88
+
89
+ ![Recording](recording.png)
90
+
91
+ ### Plotting
92
+
93
+ `sc_kernel` also provides a way to embed images of SuperCollider windows into the Jupyter document.
94
+ First create a window that you want to embed into the document
95
+
96
+ ```supercollider
97
+ w = {SinOsc.ar(2.0)}.plot(1.0);
98
+ ```
99
+
100
+ After the plotting is finished by the server we can now simply save an image of the window
101
+ to a file and also embed the image into the document via a SuperCollider helper method which is available.
102
+
103
+ ```supercollider
104
+ plot.(w);
105
+ ```
106
+
107
+ ![Plotting magic](plotting.png)
108
+
109
+ The image will be saved relative the directory where `jupyter lab` was executed.
110
+ The optional second argument can be the filename.
111
+
112
+ > Note that `{}.plot` does not return a `Window` but a `Plotter`, but `sc_kernel`
113
+ > accesses the window of a `Plotter` automatically.
114
+ >
115
+ > For plotting e.g. the server meter you need to pass the proper window, so
116
+ >
117
+ > ```supercollider
118
+ > a = s.meter;
119
+ > // a is a ServerMeter
120
+ >
121
+ > // new cell
122
+ > plot.(a.window, "meter.png");
123
+ > ```
124
+
125
+ ### Autocomplete
126
+
127
+ Simply push `Tab` to see available autocompletions.
128
+ This is currently limited to scan for available classes.
129
+
130
+ ### Documentation
131
+
132
+ To display the documentation of a Class, simply prepend a `?` to it and execute it, e.g.
133
+
134
+ ```supercollider
135
+ ?SinOsc
136
+ ```
137
+
138
+ You can also hit `shift <tab>` iff the cursor is behind a class to trigger the inline documentation.
139
+
140
+ ![Inline documentation](inline_docs.png)
141
+
142
+ ### Real Time Collaboration
143
+
144
+ Jupyter Lab allows for real time collaboration in which multiple users can write in the same document from different computers by visiting the Jupyter server via their browser.
145
+ Each user can write and execute sclang statements on your local sclang interpreter and the cursors of each user is shown to everyone.
146
+
147
+ This allows for interactive, shared sessions which can be an interesting live coding sessions.
148
+
149
+ > Be aware that this can be a security threat as it allows for other people from within the network to execute arbitrary sclang commands on your computer
150
+
151
+ To start such a session you can spin Jupyter Lab via
152
+
153
+ ```shell
154
+ jupyter lab --ip 0.0.0.0 --collaborative --NotebookApp.token='sclang'
155
+ ```
156
+
157
+ where the `NotebookApp.token` is the necessary password to login - set it to `''` if no password is wanted.
158
+
159
+ Check out the [documentation on Jupyter Lab](https://jupyterlab.readthedocs.io/en/stable/user/rtc.html) about *Real Time Collaboration*.
160
+
161
+ ## Development
162
+
163
+ Any PR is welcome! Please state the changes in an Issue.
164
+ To contribute, please
165
+
166
+ * Fork the repository and clone it to a local directory
167
+
168
+ * Create a virtual environment and install the dev dependencies
169
+ in it with
170
+
171
+ ```shell
172
+ pip3 install -e ".[dev]"
173
+ ```
174
+
175
+ * If one wants to add the kernel to an existing Jupyter installation one can execute
176
+
177
+ ```shell
178
+ jupyter kernelspec install sc_kernel
179
+ ```
180
+
181
+ and run `jupyter lab` from within the cloned directory as
182
+ we need to have access to `sc_kernel`.
183
+
184
+ * Run `./run_tests.sh` and make a PR :)
185
+ Use `black sc_kernel test` to format the source code.
186
+
187
+ ## Maintainers
188
+
189
+ * [Dennis Scheiba](https://dennis-scheiba.com)
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sc_kernel"
7
+ version = "0.5.0"
8
+ description = "SuperCollider kernel for Jupyter"
9
+ readme = "README.md"
10
+ license = { text = "BSD" }
11
+ authors = [
12
+ { name = "Dennis Scheiba" }
13
+ ]
14
+ requires-python = ">=3.10"
15
+ dependencies = [
16
+ "metakernel>=0.23.0, <0.31",
17
+ "ipython>=4.0, <10.0",
18
+ "pygments<3.0",
19
+ "jupyterlab>=3.0, <5.0",
20
+ "jupyter_server<3.0, >2.0",
21
+ ]
22
+ classifiers = [
23
+ "Programming Language :: Python :: 3",
24
+ "Operating System :: OS Independent",
25
+ "Framework :: IPython",
26
+ "License :: OSI Approved :: BSD License",
27
+ "Topic :: System :: Shells",
28
+ "Topic :: Multimedia :: Sound/Audio :: Sound Synthesis",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ dev = [
33
+ "coverage==5.2.1",
34
+ "flake8<=6.0.0",
35
+ "unittest-xml-reporting==3.0.4",
36
+ "mypy<=1.0.0",
37
+ "pre-commit==2.17.0",
38
+ "black<=23.1.0"
39
+ ]
40
+
41
+ [tool.setuptools]
42
+ packages = ["sc_kernel"]
43
+
44
+ [tool.setuptools.package-data]
45
+ "sc_kernel" = ["images/*.png", "kernel.json"]
46
+
47
+ [tool.setuptools.data-files]
48
+ "share/jupyter/kernels/sc_kernel" = [
49
+ "sc_kernel/kernel.json",
50
+ "sc_kernel/images/logo-32x32.png",
51
+ "sc_kernel/images/logo-64x64.png",
52
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.4.0"