summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/fun.rhai16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/fun.rhai b/examples/fun.rhai
new file mode 100644
index 0000000..05b915c
--- /dev/null
+++ b/examples/fun.rhai
@@ -0,0 +1,16 @@
+// plays ode to joy, no matter which keys you press
+
+const data = [64, 64, 65, 67, 67, 65, 64, 62, 60, 60, 62, 64, 64, 62, 62,
+ 64, 64, 65, 67, 67, 65, 64, 62, 60, 60, 62, 64, 62, 60, 60];
+
+fn pm_note_played(channel, note, vel) {
+ pm_play_note(0, data[this.i], vel);
+ this.i += 1;
+ this.i %= data.len;
+}
+
+fn pm_start() {
+ this.i = 0;
+ pm_load_soundfont("soundfont.sf3");
+ pm_load_preset(-1, "grand piano");
+}