Browse Source

fix transport

Nikolay Suslov 6 years ago
parent
commit
707c19d121

+ 4 - 0
public/defaults/proxy/vwf.example.com/aframe/aentity.js

@@ -141,6 +141,10 @@ this.callMethod = function(methodName, params){
     vwf_view.kernel.callMethod(this.id, methodName, params)
 }
 
+this.do = function() {
+    //do in step
+}
+
 this.step = function(){
 
     if (this.stepping){

+ 2 - 0
public/defaults/proxy/vwf.example.com/aframe/aentity.vwf.yaml

@@ -47,6 +47,7 @@ properties:
   ownedBy:
   class:
   stepping:
+  stepTime:
   globalBeat:
 events:
   positionChanged:
@@ -100,5 +101,6 @@ methods:
   changeVisual:
   resetVisual:  
   step:
+  do:
 scripts:
   - source: "http://vwf.example.com/aframe/aentity.js"

+ 18 - 29
public/defaults/proxy/vwf.example.com/aframe/transport.js

@@ -48,44 +48,33 @@ this.setupTransport = function () {
     this.animationLoop = true;
     this.animationDuration = 1;
     this.animationRate = 1;
+    this.animationTPS = 30;
     //this.animationPlay(0,1);
 }
 
 this.animationUpdate = function (time, duration) {
-    //let sceneID = this.find("/")[0].id
-    let rate = this.animationTPS / this.animationRate; // 60/1 by default
-
-    var b = this.beat;
-
-    //console.log('time: ' + time + ' b: ' + this.beat + ' simTime: ' + this.time);
-
-    if (b == rate + 1) { //time == 1 && 
-        this.beat = 0;
-    }
-    else {
-
-        this.doGlobalBeat(time, duration, b);
-        //vwf_view.kernel.fireEvent(this.id, "transportTick", [time, duration, this.beat]);
-
-        if (b / rate == 0) {
-            this.vis.material.color = "white";
-        } else if (b / rate == 1 / 2) {
-            this.vis.material.color = "red";
-        }
-
-        this.beat = this.beat + 1;
-
-    }
-
-
-
+           //let sceneID = this.find("/")[0].id
+           let rate = this.animationTPS / this.animationRate; // 60/1 by default
+
+           var b = this.beat;
+           //console.log('b: ' + this.beat + ' t: ' + time + ' ta: ' + this.time);
+        
+           if (time == this.animationDuration) { //time == 1 && 
+               this.beat = 0;
+               //this.doGlobalBeat(time, duration, b);
+           } else {
+           
+            this.doGlobalBeat(time, duration, b);
+            this.beat = this.beat + 1;
+           }
+    
 
 }
 
 this.doGlobalBeat = function (time, duration, beat) {
 
-    let allChilds = this.find("//element(*,'http://vwf.example.com/aframe/aentity.vwf')");
-    allChilds.forEach(el => {
+   let allChilds = this.find("//element(*,'http://vwf.example.com/aframe/aentity.vwf')"); //this.children
+   allChilds.forEach(el => {
         if (el.globalBeat) {
             let obj = {
                 name: this.name,

+ 16 - 11
public/defaults/worlds/orchestra/index.vwf.yaml

@@ -75,12 +75,15 @@ children:
         body: |
                 let transportNode = this.find('//' + obj.name)[0];
                 let rate = transportNode.animationRate; // 1 by default
-                let drumSeq = [{beat:0, msg: 0}];
+                let drumSeq = [
+                  {beat:0, msg: 0},
+                  {beat:15, msg: 0}
+                ];
                 drumSeq.forEach(el=>{
                   if(el.beat/rate == obj.beat){
                     let msg = {
                         address: "/trigger/sample01",
-                        args: [this.time, 'bd_808', 3]
+                        args: [this.time, 'bd_haus', 2]
                     };
                     this.sendOSC(msg); 
                     this.changeVisual();
@@ -132,15 +135,14 @@ children:
                 let transportNode = this.find('//' + obj.name)[0];
                 let rate = transportNode.animationRate; // 1 by default
                 let drumSeq = [
-                  {beat:0, msg: 0},
-                  {beat:15, msg: 0},
-                  {beat:30, msg: 0},
-                  {beat:45, msg: 0}];
+                  {beat:10, msg: 0},
+                  {beat:20, msg: 0}
+                  ];
                 drumSeq.forEach(el=>{
                   if(el.beat/rate == obj.beat){
                     let msg = {
                         address: "/trigger/sample02",
-                        args: [this.time, 'drum_cymbal_closed', 0.5]
+                        args: [this.time, 'bass_hit_c', 1]
                     };
                     this.sendOSC(msg); 
                     this.changeVisual();
@@ -192,14 +194,17 @@ children:
               let rate = transportNode.animationRate; // 1 by default
               let drumSeq = [
                 {beat:0, msg: "C3"},
-                {beat:15, msg: "E3"},
-                {beat:30, msg: "G3"},
-                {beat:45, msg: "A3"}];
+                {beat:5, msg: "D3"},
+                {beat:10, msg: "E3"},
+                {beat:15, msg: "G3"},
+                {beat:20, msg: "A3"},
+                {beat:25, msg: "B3"}
+                ];
               drumSeq.forEach(el=>{
                 if(el.beat/rate == obj.beat){
                   let msg = {
                     address: "/trigger/synth01",
-                          args: [this.time, 'pluck', el.msg, 0.1, 0.01]
+                          args: [this.time, 'pluck', el.msg, 0.1, 0.01, 0.6]
                   };
                   this.sendOSC(msg); 
                   this.changeVisual();