Browse Source

phone and wad

Bachir Soussi Chiadmi 6 months ago
parent
commit
4dffd3ce64

+ 36 - 0
Phone/assets/css/styles.css

@@ -0,0 +1,36 @@
+
+html,body{
+  position: relative;
+  width: 100%; height:100%;
+  margin:0;
+  font-family: sans-serif;
+  font-size: 16px;
+}
+
+#container{
+  /*min-height:100%;*/
+  padding:1em;
+}
+
+h1{
+    margin: 0;
+    padding: 0.5em 0;
+}
+
+#footer{
+  position: fixed;
+  bottom:0; left:0; width:100%;
+  text-align: center;
+}
+
+#footer div{
+  display: inline-block;
+}
+
+#footer span.label{
+  font-size:0.7em;
+}
+#footer span.data{
+  font-size:0.9em;
+  font-weight: bold;
+}

File diff suppressed because it is too large
+ 5 - 0
Phone/assets/js/gyronorm.complete.min.js


+ 67 - 0
Phone/assets/js/main.js

@@ -0,0 +1,67 @@
+console.log('Hello Gyro !');
+
+var saw = new Wad({
+  source  : 'sine',
+  volume  : 1.2,
+  pitch   : "G4",
+
+  env     : {
+    attack  : 0.1,
+    sustain : 0.8,
+    decay   : 0.2,
+    hold    : 5*60,
+    release : 1
+  }
+});
+saw.play();
+
+var leftright_log = document.getElementById("leftright");
+var frontback_log = document.getElementById("frontback");
+var direction_log = document.getElementById("direction");
+
+
+var gn = new GyroNorm();
+
+var params = {
+    frequency:50, // ( La frequence avec la quelle les données se rafraichissent - milliseconds )
+    gravityNormalized:true, // ( If the garvity related values to be normalized )
+    orientationBase:GyroNorm.WORLD,// ( Can be GyroNorm.GAME or GyroNorm.WORLD. gn.GAME returns orientation values with respect to the head direction of the device. gn.WORLD returns the orientation values with respect to the actual north direction of the world. )
+    decimalCount:2, // ( How many digits after the decimal point will there be in the return values )
+    logger:null, // ( Function to be called to log messages from gyronorm.js )
+    screenAdjusted:false // ( If set to true it will return screen adjusted values. )
+};
+
+gn.init(params).then(function(){
+  // alert(gyro);
+  gn.start(function(data){
+    // data.do.alpha    ( deviceorientation event alpha value (direction) )
+    direction_log.innerHTML = data.do.alpha;
+    // data.do.beta     ( deviceorientation event beta value (front/back) )
+    frontback_log.innerHTML = data.do.beta;
+    saw.setPitch(data.do.beta*2);
+    // mm_gain_node.gain.value = (data.do.gamma+90) * (2/180);
+    // data.do.gamma    ( deviceorientation event gamma value (left/right) )
+    leftright_log.innerHTML = data.do.gamma;
+    saw.setPanning(data.do.gamma/40);
+
+    // mm_osci.frequency.value = 720+(data.do.gamma+90)*4;
+    // data.do.absolute ( deviceorientation event absolute value )
+
+
+    // data.dm.x        ( devicemotion event acceleration x value )
+    // data.dm.y        ( devicemotion event acceleration y value )
+    // data.dm.z        ( devicemotion event acceleration z value )
+
+    // data.dm.gx       ( devicemotion event accelerationIncludingGravity x value )
+    // data.dm.gy       ( devicemotion event accelerationIncludingGravity y value )
+    // data.dm.gz       ( devicemotion event accelerationIncludingGravity z value )
+
+    // data.dm.alpha    ( devicemotion event rotationRate alpha value )
+    // data.dm.beta     ( devicemotion event rotationRate beta value )
+    // data.dm.gamma    ( devicemotion event rotationRate gamma value )
+    // alert(data.dm.gamma);
+  });
+}).catch(function(e){
+  // Catch if the DeviceOrientation or DeviceMotion is not supported by the browser or device
+  // alert("gyronorm is not available");
+});

File diff suppressed because it is too large
+ 1 - 0
Phone/assets/js/wad.min.js


+ 40 - 0
Phone/index.html

@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr">
+  <head>
+    <meta charset="utf-8">
+    <title>Phone</title>
+
+    <link rel="stylesheet" href="assets/css/styles.css">
+  </head>
+  <body>
+
+    <div id="container">
+      <h1>JsPhone Starter Kit</h1>
+    </div>
+
+    <div id="footer">
+      <div>
+        <span class="label">Left / right</span><br>
+        <span class="data" id="leftright">0</span>
+      </div>
+      <div>
+        <span class="label">Front / Back</span><br>
+        <span class="data" id="frontback">0</span>
+      </div>
+      <div>
+        <span class="label">Direction</span><br>
+        <span class="data" id="direction">0</span>
+      </div>
+      <div>
+        <span class="label">GPS</span><br>
+        <span class="data" id="lat">0</span>
+        <span class="data" id="lon">0</span>
+      </div>
+    </div>
+
+
+    <script src="assets/js/wad.min.js" charset="utf-8"></script>
+    <script src="assets/js/gyronorm.complete.min.js" charset="utf-8"></script>
+    <script src="assets/js/main.js" charset="utf-8"></script>
+  </body>
+</html>

+ 3 - 0
Wad/assets/css/styles.css

@@ -0,0 +1,3 @@
+html {
+  background-color: red;
+}

+ 42 - 0
Wad/assets/js/main.js

@@ -0,0 +1,42 @@
+console.log('Salut WAD!');
+
+// var basse = new Wad({
+//   source : 'assets/sons/donovan - basse.wav',
+//   rate  : 2,
+// });
+// basse.play();
+
+
+
+var saw = new Wad({
+  source  : 'sine',
+  volume  : 1.2,
+  pitch   : "G4",
+
+  env     : {
+    attack  : 0.1,
+    sustain : 0.8,
+    decay   : 0.2,
+    hold    : 60,
+    release : 1
+  }
+});
+// saw.play();
+
+
+var paner = (1/60)*2;
+var pan = 0;
+
+
+function music(){
+
+  pan += paner;
+  if(pan < -1 || pan > 1){
+    paner = paner * -1;
+  }
+
+  saw.setPanning(pan);
+  window.requestAnimationFrame(music);
+}
+saw.play();
+music()

File diff suppressed because it is too large
+ 1 - 0
Wad/assets/js/wad.min.js


BIN
Wad/assets/sons/donovan - basse.wav


+ 17 - 0
Wad/index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr">
+  <head>
+    <meta charset="utf-8">
+    <title>WAD</title>
+    <link rel="stylesheet" href="assets/css/styles.css">
+  </head>
+  <body>
+
+    <!-- <audio src="assets/sons/donovan - basse.wav" controls> -->
+
+    </audio>
+
+    <script src="assets/js/wad.min.js" charset="utf-8"></script>
+    <script src="assets/js/main.js" charset="utf-8"></script>
+  </body>
+</html>