-
Notifications
You must be signed in to change notification settings - Fork 5
/
02-getting-started.html
235 lines (206 loc) · 11.6 KB
/
02-getting-started.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 2020-04-22 Wed 15:39 -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Getting Started</title>
<meta name="generator" content="Org mode">
</head>
<body>
<div id="content">
<header>
<h1 class="title">Getting Started</h1>
</header><nav id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orga72c5b4">1. Requirements</a>
<ul>
<li><a href="#orge783023">1.1. SuperCollider</a></li>
<li><a href="#org9ea6e91">1.2. Emacs</a></li>
<li><a href="#orga915d91">1.3. SBCL</a></li>
<li><a href="#orgd93e513">1.4. Slime</a></li>
<li><a href="#orgcc137ac">1.5. Quicklisp</a></li>
<li><a href="#org4dba891">1.6. cl-collider</a></li>
</ul>
</li>
<li><a href="#org8c627ff">2. Setting Up</a>
<ul>
<li><a href="#org66ed14b">2.1. Portacle</a></li>
<li><a href="#org1b64b2a">2.2. Vanilla Emacs</a></li>
</ul>
</li>
<li><a href="#org14dad14">3. Starting Up</a></li>
</ul>
</div>
</nav>
<p>
This chapter gives an explanation of the requirements for this guide, as well as some information on how to set them up.
</p>
<div id="outline-container-orga72c5b4" class="outline-2">
<h2 id="orga72c5b4"><span class="section-number-2">1</span> Requirements</h2>
<div class="outline-text-2" id="text-1">
<p>
To interact with SuperCollider, you will need the following software:
</p>
</div>
<div id="outline-container-orge783023" class="outline-3">
<h3 id="orge783023"><span class="section-number-3">1.1</span> SuperCollider</h3>
<div class="outline-text-3" id="text-1-1">
<p>
The <a href="https://supercollider.github.io/">SuperCollider</a> package provides scsynth, which is the SuperCollider sound server that we will be using. This is the program that actually produces sound.
</p>
</div>
</div>
<div id="outline-container-org9ea6e91" class="outline-3">
<h3 id="org9ea6e91"><span class="section-number-3">1.2</span> Emacs</h3>
<div class="outline-text-3" id="text-1-2">
<p>
<a href="https://www.gnu.org/software/emacs/">Emacs</a> is a well-known text editor. It is specialized for writing Lisp code, and can even be extended using its own dialect of Lisp called Emacs Lisp or Elisp. Emacs is recommended because it has facilities to enhance writing and interacting with Lisp programs. It is possible to use another editor instead, but for the purposes of this guide we are assuming that Emacs is being used.
</p>
</div>
</div>
<div id="outline-container-orga915d91" class="outline-3">
<h3 id="orga915d91"><span class="section-number-3">1.3</span> SBCL</h3>
<div class="outline-text-3" id="text-1-3">
<p>
<a href="https://www.sbcl.org/">SBCL</a> is Steel Bank Common Lisp, a compiler of Common Lisp code. It is the program that reads and evaluates your Lisp code. Many other Lisp compilers exist, but SBCL is a good choice to start off with because it is fast and well-supported.
</p>
</div>
</div>
<div id="outline-container-orgd93e513" class="outline-3">
<h3 id="orgd93e513"><span class="section-number-3">1.4</span> Slime</h3>
<div class="outline-text-3" id="text-1-4">
<p>
<a href="https://common-lisp.net/project/slime/">Slime</a> is the "Superior Lisp Interaction Mode for Emacs". It is effectively the link between Emacs and the Lisp processs, however it also provides many more advanced features for interacting with a Lisp program.
</p>
</div>
</div>
<div id="outline-container-orgcc137ac" class="outline-3">
<h3 id="orgcc137ac"><span class="section-number-3">1.5</span> Quicklisp</h3>
<div class="outline-text-3" id="text-1-5">
<p>
<a href="https://www.quicklisp.org/beta/">Quicklisp</a> is the de facto Common Lisp library manager. It can be used to install Common Lisp libraries, and will take care of the required dependencies for those libraries for you.
</p>
</div>
</div>
<div id="outline-container-org4dba891" class="outline-3">
<h3 id="org4dba891"><span class="section-number-3">1.6</span> cl-collider</h3>
<div class="outline-text-3" id="text-1-6">
<p>
<a href="https://github.com/byulparan/cl-collider">cl-collider</a> is the Lisp library that provides an interface to SuperCollider.
</p>
</div>
</div>
</div>
<div id="outline-container-org8c627ff" class="outline-2">
<h2 id="org8c627ff"><span class="section-number-2">2</span> Setting Up</h2>
<div class="outline-text-2" id="text-2">
<p>
To set up a basic environment for writing Lisp, there are two options you should consider. First, if you're already familiar with Emacs or want to start from scratch, you may prefer simply adapting your current configuration to work with Lisp; see "Vanilla Emacs", below, for more information on that. It should be noted, however, that setting up Emacs and Lisp from scratch is already considered to be a somewhat involved process, and is thus not recommended for people unfamiliar with Emacs.
</p>
<p>
Instead, if that's the case for you, it's strongly suggested to simply use Portacle. Portacle is effectively a software bundle containing SBCL, Slime, Quicklisp, and Emacs already preconfigured to work together. Using Portacle will generally get you up and running fairly quickly with little additional configuration needed on your end. In our case, the only additional configuration should be installing SuperCollider.
</p>
</div>
<div id="outline-container-org66ed14b" class="outline-3">
<h3 id="org66ed14b"><span class="section-number-3">2.1</span> Portacle</h3>
<div class="outline-text-3" id="text-2-1">
<p>
Portacle's <a href="https://portacle.github.io/">official site</a> describes it like so:
</p>
<blockquote>
<p>
Portacle is a complete IDE for Common Lisp that you can take with you on a USB stick. It is multi-platform and can be run on Windows, OS X, and Linux. Since it does not require any complicated installation process, it is set up and running in no time.
</p>
<p>
It lends itself very well both to absolute beginners of Lisp that just need a good starting point, as well as advanced users that want to minimise the time spent getting everything ready.
</p>
</blockquote>
<p>
If you're using Linux, your distribution's standard package manager may already have a package for Portacle available, and it's recommended you start off by trying that one first. Alternatively, if it doesn't, or if you're on another OS, you can download and install the package from Portacle's official site.
</p>
<p>
Once you've installed it, you'll want to continue by installing SuperCollider. Again, install it from your OS's official package manager if possible. Otherwise, SuperCollider's <a href="https://supercollider.github.io/download">official site</a> may have a package that works.
</p>
</div>
</div>
<div id="outline-container-org1b64b2a" class="outline-3">
<h3 id="org1b64b2a"><span class="section-number-3">2.2</span> Vanilla Emacs</h3>
<div class="outline-text-3" id="text-2-2">
<p>
It's outside the scope of this guide to give detailed information on how to set all of these programs up, but if you're using a Linux-based operating system, your package manager most likely provides packages for SuperCollider, Emacs, and SBCL for you. Simply installing those packages should suffice.
</p>
<p>
Your package manager may provide Slime, but if not, it's possible to install it using Emacs' standard package manager. You can run the package manager in Emacs by typing <code>M-x list-packages RET</code>. Then use <code>C-s</code> to search for <code>slime</code>. With your cursor over <code>slime</code>, press <code>i</code> to mark it for installation, and then <code>x</code> to install it.
</p>
<p>
<a href="https://www.quicklisp.org/beta/">The Quicklisp site</a> provides a guide on how to install it on Mac OS or Linux. It's a fairly simple process and most of the work is done for you just by running a few commands in the shell.
</p>
<p>
Since <a href="https://github.com/byulparan/cl-collider">cl-collider</a> is now available in Quicklisp, all you have to do to install it is type the following once Quicklisp is loaded in your Lisp image: <code>(ql:quickload :cl-collider)</code> . This will download and install the library and all of its dependencies, and then make it available for use in your Lisp session.
</p>
</div>
</div>
</div>
<div id="outline-container-org14dad14" class="outline-2">
<h2 id="org14dad14"><span class="section-number-2">3</span> Starting Up</h2>
<div class="outline-text-2" id="text-3">
<p>
Once you've successfully installed all of the above software, start Emacs, open a new lisp file using <code>C-x C-f FILENAME.lisp RET</code> where FILENAME is the name you want to give to your file. Then, you can start slime using <code>M-x slime RET</code>. If all goes well, you should see a Lisp REPL that looks something like this:
</p>
<pre class="example">
CL-USER>
</pre>
<p>
So far, so good. Position your cursor after the <code>></code> and then type the following Lisp expressions, one at a time. After each expression, you may see some output before getting a prompt back again.
</p>
<div class="org-src-container">
<pre class="src src-lisp"><span style="color: #268bd2;">(</span>ql:quickload <span style="color: #268bd2;">:cl-collider</span><span style="color: #268bd2;">)</span>
<span style="color: #268bd2;">(</span><span style="color: #859900; font-weight: bold;">in-package</span> <span style="color: #268bd2;">:sc-user</span><span style="color: #268bd2;">)</span>
<span style="color: #268bd2;">(</span>setf *s* <span style="color: #d33682;">(</span>make-external-server <span style="color: #2aa198;">"localhost"</span> <span style="color: #268bd2;">:port</span> 4444<span style="color: #d33682;">)</span><span style="color: #268bd2;">)</span>
<span style="color: #268bd2;">(</span>server-boot *s*<span style="color: #268bd2;">)</span>
</pre>
</div>
<p>
Once you run that last line, you're ready to make sound!
</p>
<p>
For reference, here's an example of what it might look like when you run these expressions:
</p>
<div class="org-src-container">
<pre class="src src-lisp">CL-USER> <span style="color: #268bd2;">(</span>ql:quickload <span style="color: #268bd2;">:cl-collider</span><span style="color: #268bd2;">)</span>
To load <span style="color: #2aa198;">"sc"</span>:
Load 1 ASDF system:
sc
<span style="color: #405A61;">; </span><span style="color: #405A61;">Loading "cl-collider"</span>
..
<span style="color: #268bd2;">(</span><span style="color: #268bd2;">:CL-COLLIDER</span><span style="color: #268bd2;">)</span>
CL-USER> <span style="color: #268bd2;">(</span><span style="color: #859900; font-weight: bold;">in-package</span> <span style="color: #268bd2;">:sc-user</span><span style="color: #268bd2;">)</span>
#<PACKAGE <span style="color: #2aa198;">"SC-USER"</span>>
SC-USER> <span style="color: #268bd2;">(</span>setf *s* <span style="color: #d33682;">(</span>make-external-server <span style="color: #2aa198;">"localhost"</span> <span style="color: #268bd2;">:port</span> 4444<span style="color: #d33682;">)</span><span style="color: #268bd2;">)</span>
#<SC-SYNTH localhost-127.0.0.1:4444>
SC-USER> <span style="color: #268bd2;">(</span>server-boot *s*<span style="color: #268bd2;">)</span>
VST_PATH not set, defaulting to /home/user/vst:/usr/local/lib/vst:/usr/lib/vst
Found 278 LADSPA plugins
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 44100.000000, driver's block size = 256
SuperCollider 3 server ready.
Zeroconf: failed to create client: Daemon not running
#<SC-SYNTH localhost-127.0.0.1:4444>
JackDriver: max output latency 11.6 ms
SC-USER>
</pre>
</div>
<p>
…Of course, it may be slightly different for you. As long as you don't get any errors, you should be good to go. In the next chapter, we'll take it for a spin, and make our first sound.
</p>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="date">Last updated: 2020-04-22 Wed 15:39</p>
</div>
</body>
</html>