Commit 700b9b25 authored by Joseph Larralde's avatar Joseph Larralde
Browse files

cosmetics

parent 19100e71
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>COMO mouse gestures</title> <title>COMO mouse gestures</title>
<meta charset="utf-8"> <meta charset="utf-8">
<script type="text/javascript" src="https://como.ircam.fr/motion-features.min.js"></script> <script type="text/javascript" src="https://como.ircam.fr/motion-features.min.js"></script>
<script type="text/javascript" src="https://como.ircam.fr/waves-loaders.min.js"></script> <script type="text/javascript" src="https://como.ircam.fr/waves-loaders.min.js"></script>
<style> <style>
div { div {
margin: 0 auto; margin: 0 auto;
} }
button { button {
display: inline-block; display: inline-block;
width: 100%; width: 100%;
height: 50px; height: 50px;
padding: 20px; padding: 20px;
margin-bottom: 10px; margin-bottom: 10px;
} }
</style> </style>
</head> </head>
<body> <body>
<button id="unlock"> unlock audio </button> <button id="unlock"> unlock audio </button>
<script type="text/javascript"> <script type="text/javascript">
/* globals motionFeatures */ /* globals motionFeatures */
/* globals wavesLoaders */ /* globals wavesLoaders */
var audioContext; var audioContext;
try { try {
audioContext = new webkitAudioContext(); audioContext = new webkitAudioContext();
} catch (e) { } catch (e) {
audioContext = new AudioContext(); audioContext = new AudioContext();
} }
var audioFiles = [ var audioFiles = [
'./assets/1_808-kick_long.wav', './assets/1_808-kick_long.wav',
'./assets/2_808-hh_closed.wav', './assets/2_808-hh_closed.wav',
'./assets/3_808-SD1.wav', './assets/3_808-SD1.wav',
'./assets/4_808-hh_open.wav' './assets/4_808-hh_open.wav',
]; ];
// this is for iOS !!!! (need user action to enable audio playback) // this is for iOS !!!! (need user action to enable audio playback)
var locked = true; var locked = true;
var b = document.querySelector('#unlock'); var b = document.querySelector('#unlock');
b.addEventListener('click', function(e) { b.addEventListener('click', function(e) {
// console.log('click'); // console.log('click');
if(locked) { if(locked) {
var buffer = audioContext.createBuffer(1, 1, 22050); var buffer = audioContext.createBuffer(1, 1, 22050);
var source = audioContext.createBufferSource(); var source = audioContext.createBufferSource();
source.buffer = buffer; source.buffer = buffer;
source.connect(audioContext.destination); source.connect(audioContext.destination);
source.start(); source.start();
locked = false; locked = false;
console.log('audio unlocked !'); console.log('audio unlocked !');
b.style.backgroundColor = '#0f0'; b.style.backgroundColor = '#0f0';
} }
}); });
var loader = new wavesLoaders.AudioBufferLoader(); var loader = new wavesLoaders.AudioBufferLoader();
loader.load(audioFiles).then(function(loaded) { loader.load(audioFiles).then(function(loaded) {
var counter = 0; var counter = 0;
var mf = new motionFeatures.MotionFeatures({ var mf = new motionFeatures.MotionFeatures({
descriptors: [ 'accIntensity', 'kick' ], descriptors: [ 'accIntensity', 'kick' ],
kickThresh: 20, kickThresh: 20,
kickCallback: kick, kickCallback: kick,
}); });
window.addEventListener('devicemotion', function(e) { window.addEventListener('devicemotion', function(e) {
var x = e.accelerationIncludingGravity.x; var x = e.accelerationIncludingGravity.x;
var y = e.accelerationIncludingGravity.y; var y = e.accelerationIncludingGravity.y;
var z = e.accelerationIncludingGravity.z; var z = e.accelerationIncludingGravity.z;
mf.setAccelerometer(x, y, z); mf.setAccelerometer(x, y, z);
mf.update(); mf.update();
});
function kick(res) {
var indexArray = [0, 1, 2, 1];
var index = indexArray[counter];
var buf = audioContext.createBufferSource();
buf.buffer = loaded[index];
buf.connect(audioContext.destination);
buf.start();
counter = (counter + 1) % 4;
}
}); });
</script>
function kick(res) {
var indexArray = [0, 1, 2, 1];
var index = indexArray[counter];
var buf = audioContext.createBufferSource();
buf.buffer = loaded[index];
buf.connect(audioContext.destination);
buf.start();
counter = (counter + 1) % 4;
}
});
</script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -62,10 +62,18 @@ ...@@ -62,10 +62,18 @@
<h2> links to docs </h2> <h2> links to docs </h2>
<ul> <ul>
<li><a href="http://wavesjs.github.io/">wavesjs documentation</a></li> <li><a href="http://wavesjs.github.io/" target="_blank">
<li><a href="https://github.com/Ircam-RnD/xmm-node">xmm-node documentation</a></li> wavesjs documentation
<li><a href="https://ircam-rnd.github.io/xmm-client/">xmm-client documentation</a></li> </a></li>
<li><a href="https://github.com/Ircam-RnD/motion-features">motion-features documentation</a></li> <li><a href="https://github.com/Ircam-RnD/xmm-node" target="_blank">
xmm-node documentation
</a></li>
<li><a href="https://ircam-rnd.github.io/xmm-client/" target="_blank">
xmm-client documentation
</a></li>
<li><a href="https://github.com/Ircam-RnD/motion-features" target="_blank">
motion-features documentation
</a></li>
</ul> </ul>
</div> </div>
</body> </body>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment