From f8dffe603a9573e80ff0efdc118b26d13fda5b3a Mon Sep 17 00:00:00 2001 From: gretchen Date: Mon, 18 Nov 2019 18:29:34 -0800 Subject: Play a random note in the example. --- example/example.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'example') diff --git a/example/example.lua b/example/example.lua index 3b989d2..73841c6 100644 --- a/example/example.lua +++ b/example/example.lua @@ -1,5 +1,7 @@ -- An example script for norns-etc -- Load this file in emacs and M-x compile to upload. +local MusicUtil = require "musicutil" +engine.name = "PolyPerc" function redraw() screen.clear() @@ -11,6 +13,19 @@ end function init() redraw() + -- random note output, just to emphasize the point + local note = math.random(60, 90) + engine.hz(MusicUtil.note_num_to_freq(note)) + local m = midi.connect(2) + local c = metro.init() + c.time = 0.5 + c.event = function () + c:stop() + metro.free(c.id) + m:note_off(note, 10) + end + m:note_on(note, 20) + c:start() end -- This needs to be at the end so that it doesn't conflict with the -- cgit v1.2.1