Last active
April 25, 2022 10:53
-
-
Save catfact/c08ec86bd7def0a1b072925e1287a4af to your computer and use it in GitHub Desktop.
norns passthru example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Engine_SimplePassThru : CroneEngine { | |
var amp=0; | |
var <synth; | |
// this is your constructor. the 'context' arg is a CroneAudioContext. | |
// it provides input and output busses and groups. | |
// see its implementation for details. | |
*new { arg context, doneCallback; | |
^super.new(context, doneCallback); | |
} | |
// this is called when the engine is actually loaded by a script. | |
// you can assume it will be called in a Routine, | |
// and you can use .sync and .wait methods. | |
alloc { | |
//Add SynthDefs | |
SynthDef(\passThru, {|inL, inR, out, amp=0 | | |
// read stereo | |
var sound = [In.ar(inL), In.ar(inR)]; | |
Out.ar(out, sound*amp); | |
}).add; | |
context.server.sync; | |
synth = Synth.new(\passThru, [ | |
\inL, context.in_b[0].index, | |
\inR, context.in_b[1].index, | |
\out, context.out_b.index, | |
\amp, 0], | |
context.xg); | |
// this is how you add "commands", | |
// which is how the lua interpreter controls the engine. | |
// the format string is analogous to an OSC message format string, | |
// and the 'msg' argument contains data. | |
this.addCommand("test", "ifs", {|msg| | |
msg.postln; | |
}); | |
this.addCommand("amp", "f", {|msg| | |
synth.set(\amp, msg[1]); | |
}); | |
} | |
free { | |
// here you should free resources (e.g. Synths, Buffers &c) | |
// and stop processes (e.g. Routines, Tasks &c) | |
synth.free; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- PassThru Test | |
engine.name = 'SimplePassThru' | |
local audio = require 'audio' | |
function init() | |
print("Simple Pass Thru Test") | |
audio.level_monitor(0) | |
end | |
function key(n,z) | |
if n == 2 then | |
if z == 1 then | |
screen.move(10, 10) | |
screen.text("Listen") | |
screen.update() | |
engine.amp(1.0) | |
elseif z == 0 then | |
screen.clear() | |
screen.update() | |
engine.amp(0.0) | |
end | |
end | |
end | |
apologies; that's right, the method was removed in 2.0 and this gist is pretty old. updated
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
audio.monitor_off()
is not a valid method ofaudio
.