-
Notifications
You must be signed in to change notification settings - Fork 0
/
notebook.html
76 lines (62 loc) · 2.99 KB
/
notebook.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/codemirror.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.63.3/codemirror.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.63.3/mode/python/python.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="micropython.mjs" type="module"></script>
<script type="text/javascript" src="enable-threads.js"></script>
<script type="text/javascript" src="amy.js"></script>
<script type="text/javascript" src="amyrepl.js"></script>
</head>
<body>
<script type="module">
// For the notebook, we print python messages to JS console. use the REPL if you want more interaction
mp = await loadMicroPython({
stdout:(line) => { console.log(line); },
linebuffer: true,
});
</script>
<div class="container-fluid">
<h1>
<A HREF="https://github.com/shorepine/amy">AMY</A> Notebook demo for DAn
</h1>
<!-- Put your notebook content here -->
<div class="row py-3 my-5 px-3 mx-3 bg-light bg-gradient">
<p>Hi, i'm going to teach you how to use AMY in Python. You can type or edit the code in this
box below, or just run it.</p>
<div class="editor mb-4">
amy.send(osc=0,freq=220,vel=1)
amy.send(osc=1,freq=440,vel=1)
</div>
<p>When you hit play, you should hear two sine waves.
<p>Try changing the frequency and running again.
</div>
<div class="row py-3 my-5 px-3 mx-3 bg-light bg-gradient">
<p>OK, again!</p>
<div class="editor mb-4">
amy.send(voices=0, load_patch=0, vel=1, note=50)
</div>
<p>We reset AMY only from the red button, and Python state carries over cell to cell
like a normal notebook. So you can play multiple cells and AMY can play them both simultaneously.
We do reset the sample clock to 0 every time you hit play, so you can write code that uses time:
</div>
<div class="row py-3 my-5 px-3 mx-3 bg-light bg-gradient">
<p>Like this</p>
<div class="editor mb-4">
amy.send(osc=0, wave=amy.PCM, patch=0, time=500, vel=5)
amy.send(osc=0, wave=amy.PCM, patch=1, time=1000, vel=5)
</div>
<p><a href="repl.html">If you want to use a more normal Python REPL, do that here</a> but the idea of this
is to make a template for a future blog post / tutorial for AMY that is interactive like this.
</div>
</div>
<!-- End your notebook content -->
<script language="javascript">
document.querySelectorAll('.editor').forEach(create_editor);
</script>
</body>
</html>