Changeset 29897


Ignore:
Timestamp:
2015-05-19T00:02:41+12:00 (7 years ago)
Author:
davidb
Message:

Boxing now drawn around blocks of recorded track

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/respooled/collect/popup-video-respooled/js/game-on.js

    r29895 r29897  
    3030
    3131    if (gs.xsltParams.interface_name == "respooled") {
    32     go_top_level_group.translate(group_x_scale*go_paper_y_dim, go_paper_y_dim+(gameOnCurrentTimeYPos * group_x_scale * Math.abs(group_y_scale)));
     32    //go_top_level_group.translate(group_x_scale*go_paper_y_dim, go_paper_y_dim+(gameOnCurrentTimeYPos * group_x_scale * Math.abs(group_y_scale)));
     33    go_top_level_group.translate(group_x_trans, go_paper_y_dim+(gameOnCurrentTimeYPos * group_x_scale * Math.abs(group_y_scale)));
    3334    }
    3435
     
    112113    }
    113114
     115   
    114116    // Process each block within the track
    115117    for (var b=0; b<track.length; b++) {
     
    188190        if (track != null) {
    189191
    190 
    191192        var midi_stats = computeMidiStats(track);
    192193        console.log("*** midi stats = " + JSON.stringify(midi_stats));
     
    199200        }
    200201
    201 
    202         // calculate range of midi pitches present
    203 /*
    204         for (var b=0; b<track.length; b++) {
    205             var track_block = track[b];
    206             var base_ctime = track_block.baseCTime;
    207             var block_events = track_block.events;
    208 
    209             for (var ne=0; ne<block_events.length; ne++) {
    210             var midi_pitch = block_events[ne].midiPitch;
    211             if (midi_pitch < min_midi_pitch) {
    212                 min_midi_pitch = midi_pitch;
    213             }
    214             if (midi_pitch > max_midi_pitch) {
    215                 max_midi_pitch = midi_pitch;
    216             }
    217             }
    218         }
    219 */
    220 
    221202        }
    222203    }
     
    226207    var midi_range = Math.max(4,raw_midi_range);
    227208   
    228     console.log("*** midi_range = " + midi_range);
     209    //console.log("*** midi_range = " + midi_range);
    229210
    230211    var midi_y_dim_spacing = go_paper_y_dim / midi_range;
     
    244225            var block_events = track_block.events;
    245226           
    246             for (var ne=0; ne<block_events.length; ne++) {
     227            var block_min_midi_pitch = num_midi_pitches-1;
     228            var block_max_midi_pitch = 0;
     229
     230            var block_events_len = block_events.length;
     231            for (var ne=0; ne<block_events_len; ne++) {
    247232           
    248233            var note_event = block_events[ne];
    249            
     234            var midi_pitch = note_event.midiPitch;
     235
    250236            var startPercTime = (base_ctime + note_event.startCurrentTime)/total_duration;
    251237            var rx_org = startPercTime * go_paper_x_dim;
     
    260246            rect.attr({"stroke":"black","stroke-width":0.25, "fill":"#2E52A4"});
    261247            go_top_level_group.push(rect);
     248
     249            if (midi_pitch < block_min_midi_pitch) {
     250                block_min_midi_pitch = midi_pitch;
     251            }
     252            if (midi_pitch > block_max_midi_pitch) {
     253                block_max_midi_pitch = midi_pitch;
     254            }
    262255            }
     256
     257            var block_midi_range = block_max_midi_pitch - block_min_midi_pitch + 1;
     258
     259            var last_event = block_events[block_events_len-1];
     260            var last_note_off = last_event.midiNoteOff;
     261            var block_duration = (base_ctime + last_note_off)/1000.0;
     262
     263            var block_x_org = (base_ctime/total_duration) * go_paper_x_dim;
     264            var block_x_dim = (block_duration/total_duration) * go_paper_x_dim;
     265
     266            var block_y_org = go_paper_y_dim - ((block_max_midi_pitch - min_midi_pitch) * midi_y_dim_spacing) - midi_y_dim_spacing;
     267            var block_y_dim = midi_y_dim_spacing * (block_midi_range);
     268
     269            var block_rect = goPaper.rect(block_x_org-1,block_y_org-1,block_x_dim+2,block_y_dim+2); // fudge factor!
     270            block_rect.attr({"stroke":"none", "stroke-width":0, "fill":"rgba(46, 82, 164, 0.5)"});
     271            go_top_level_group.push(block_rect);
     272
    263273        }
    264274        }
     
    285295    group_rotate  = 90.0;
    286296
    287     group_x_trans = group_x_scale * go_paper_y_dim;
     297    group_x_trans = 15 + group_x_scale * go_paper_y_dim;
    288298    group_y_trans = go_paper_y_dim;
    289299    }
Note: See TracChangeset for help on using the changeset viewer.