Created
November 25, 2017 23:56
-
-
Save drart/96f6fc037e276c880939b97cf02eac60 to your computer and use it in GitHub Desktop.
A quick demo with Flocking and Nexus to demo providing Flocking's audio context to Nexus for metering.
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
<!DOCTYPE html> | |
<head> | |
<title>Nexus + Flocking</title> | |
<script src="../node_modules/nexusui/dist/NexusUI.js"></script> | |
<script src="../node_modules/flocking/dist/flocking-all.min.js"></script> | |
</head> | |
<body> | |
<div id="meter"></div> | |
<div id="power"></div> | |
<script> | |
flock.init(); | |
var as = flock.environment.audioSystem; | |
var synth = flock.synth({ | |
synthDef: [ | |
{ | |
ugen: "flock.ugen.filter.biquad.hp", | |
freq: { | |
ugen: "flock.ugen.sin", | |
rate: "control", | |
freq: { | |
ugen: "flock.ugen.xLine", | |
rate: "control", | |
start: 0.7, | |
end: 100, | |
duration: 20 | |
}, | |
phase: 0, | |
mul: 3600, | |
add: 4000 | |
}, | |
source: { | |
ugen: "flock.ugen.lfSaw", | |
freq: 200, | |
mul: 0.1 | |
} | |
}, | |
{ | |
ugen: "flock.ugen.filter.biquad.hp", | |
freq: { | |
ugen: "flock.ugen.sin", | |
rate: "control", | |
freq: { | |
ugen: "flock.ugen.xLine", | |
rate: "control", | |
start: 40, | |
end: 1, | |
duration: 20 | |
}, | |
phase: 0, | |
mul: 3600, | |
add: 4000 | |
}, | |
source: { | |
ugen: "flock.ugen.lfSaw", | |
freq: 204, | |
mul: 0.1 | |
} | |
} | |
] | |
}); | |
Nexus.context = as.context; | |
var meter = new Nexus.Meter("#meter"); | |
meter.connect(as.nativeNodeManager.outputNode, 2); | |
var power = new Nexus.Toggle("#power"); | |
power.on('change', function(val){ | |
if(val){ | |
synth.play(); | |
}else{ | |
synth.pause(); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment