From c60bffafc9857fb77684074f04d0410900afa472 Mon Sep 17 00:00:00 2001 From: equilet <2237372+equilet@users.noreply.github.com> Date: Tue, 8 Apr 2025 12:36:28 -0700 Subject: [PATCH] added a test for region propagation with lanes and waveform --- app.js | 82 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/app.js b/app.js index 0e7ddb3..8991623 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,6 @@ const num_storage_slots = 16; const skip_factor = 0.5; -let num_regions = 1; +let wf_nregions = 1; let global_dict = new Object(); let active_region, was_clicked = null; let global_dur = 3.0; @@ -94,7 +94,7 @@ function linear_map(phase, imn, imx, omn, omx) { function region_add_specified(tstart, tend, ttext, id, tcolor) { - num_regions++; + wf_nregions++; wsr.addRegion({ channelIdx: id, @@ -109,6 +109,7 @@ function region_add_specified(tstart, tend, ttext, id, tcolor) { } +//this was updated to the new system function region_add_1(lane_id) { if(lane_id > 2 | lane_id < 0){ @@ -117,21 +118,40 @@ function region_add_1(lane_id) { } const gen = gen_region_startend(); - //let nreg = wsr_lanes[2][lane_id]; - console.log("lane id: ", lane_id); - console.log("wsr value: ", wsr_lanes[2][lane_id]); - wsr_lanes[1][lane_id].addRegion({ - channelIdx: wsr_lanes[2][lane_id], - content: "lane: " + lane_id + "inc: " + wsr_lanes[2][lane_id], - id: 'region', - start: gen[0], - end: gen[1], - loop: false, - color: 'hsla(184, 32%, 72%, 0.1)' + if (lane_id == 0) { + + console.log("wsr value: ", wf_nregions); + wsr.addRegion({ + channelIdx: wf_nregions, + content: "wsr inc: " + (wf_nregions - 1), + id: 'region', + start: gen[0], + end: gen[1], + loop: false, + color: 'hsla(184, 32%, 72%, 0.1)' }); - //increment the lane region counter - wsr_lanes[2][lane_id]++; + wf_nregions++; + + } else { + + const nregions = wsr_lanes[2][lane_id]; + console.log("lane id: ", lane_id); + console.log("wsr value: ", nregions); + + wsr_lanes[1][lane_id].addRegion({ + channelIdx: nregions, + content: "lane: " + lane_id + "inc: " + (nregions - 1), + id: 'region', + start: gen[0], + end: gen[1], + loop: false, + color: 'hsla(184, 32%, 72%, 0.1)' + }); + //increment the lane region counter + wsr_lanes[2][lane_id]++; + + } } function gen_color() { @@ -143,12 +163,12 @@ function region_add_3() { for(let i = 1; i < 4; i++) { const gen = gen_region_startend(); - num_regions++; + wf_nregions++; //percent_hue = Math.floor(Math.random() * 100.0); - //console.log("adding a region with id", num_regions); + //console.log("adding a region with id", wf_nregions); wsr.addRegion({ - channelIdx: num_regions, - content: "region" + (num_regions - 1) + "text", + channelIdx: wf_nregions, + content: "region" + (wf_nregions - 1) + "text", id: 'region', start: gen[0], end: gen[1], @@ -160,16 +180,16 @@ function region_add_3() { } function region_add_at_time(time){ - num_regions++; + wf_nregions++; //const percent_lum = Math.random() * 100.0; let percent_hue = Math.floor(Math.random() * 100.0); const color_str = 'hsla(' + percent_hue + ', 100%, 50%, 0.1)'; - //console.log("adding a region with id", num_regions); + //console.log("adding a region with id", wf_nregions); wsr.addRegion({ - channelIdx: num_regions, - content: "region " + (num_regions - 1) + " text", + channelIdx: wf_nregions, + content: "region " + (wf_nregions - 1) + " text", //id: "cue " + i, id: 'region', start: time, @@ -182,14 +202,14 @@ function region_add_at_time(time){ //add a region via a lane function region_add_in_lane(id, time){ - num_regions++; + wf_nregions++; let percent_hue = Math.floor(Math.random() * 100.0); const color_str = 'hsla(' + percent_hue + ', 100%, 50%, 0.1)'; //2nd index is region instance wsr_lanes[1][id].addRegion({ - channelIdx: num_regions, - content: "region" + (num_regions - 1) + "text", + channelIdx: wf_nregions, + content: "region" + (wf_nregions - 1) + "text", id: 'region', start: time, end: time + global_dur, @@ -210,7 +230,7 @@ function gen_region_startend(){ function clear_regions() { wsr.clearRegions(); - num_regions = 1; + wf_nregions = 1; for(let i = 0; i < wsr_lanes[0].length; i++){ wsr_lanes[1][i].clearRegions(); @@ -368,7 +388,7 @@ function localstorage_restore() { console.log("ls restore: reading localStorage..."); let inc = 0; - clear_regions(); //sets num_regions to 1 + clear_regions(); //sets wf_nregions to 1 for(var key in localStorage) { let data = localStorage.getItem(key); @@ -378,7 +398,7 @@ function localstorage_restore() { inc++; } - num_regions = inc; + wf_nregions = inc; } //------------------------------------------------------------- @@ -771,8 +791,8 @@ function initialize() { call_action: function () { active_region.remove(); active_region = null; - num_regions--; - console.log('num_regions is now:', num_regions); + wf_nregions--; + console.log('wf_nregions is now:', wf_nregions); }, }, -- 2.34.1