Changeset 37673


Ignore:
Timestamp:
2023-04-18T10:36:19+12:00 (12 months ago)
Author:
davidb
Message:

Reverting back to renderWave=0 as default; added icon/legend for the two different AV charts

Location:
gs3-installations/mars/trunk/sites/mars/collect/amc-essentia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/etc/collectionConfig.xml

    r37541 r37673  
    976976                <div style="font-style: italic; min-height: 3.5rem;">
    977977                  <div style="float:right;">
    978                 <span style="display: inline-block; margin-bottomXXXX: 10px;;" class="display-view-modes" onclick="return showAVChartLabelled();">Labelled AV Chart</span>
     978                <span style="display: inline-block; margin-bottomXXXX: 5px;" class="display-view-modes" onclick="return loginToRecord()">
     979                  <img width="16" height="16" src="{$library_name}/sites/{$site_name}/collect/{$collName}/images/crosshair-cursor-red32.png"/>
     980                  Show your AV Feelings
     981                </span>
    979982                <br />
    980                 <span style="display: inline-block; margin-bottomXXXX: 5px;" class="display-view-modes" onclick="return loginToRecord()">Customise AV Experience </span>
     983                <span style="display: inline-block; margin-bottomXXXX: 10px;;" class="display-view-modes" onclick="return showAVChartLabelled();">
     984                  <canvas id="choose-within-av-chart-legend" width="16" height="16" style="width: 16px; height: 16px;">
     985                    Your browser does not support the canvas element
     986                  </canvas>
     987                  <gsf:script>
     988                    $(document).ready(function() {
     989                        var cwav_chart_legend = document.getElementById('choose-within-av-chart-legend');
     990   
     991                    var ctx = cwav_chart_legend.getContext("2d");
     992                    ctx.clearRect(0, 0, cwav_chart_legend.width, cwav_chart_legend.height);
     993                    ctx.beginPath();
     994                    ctx.arc(8, 8, 4.5, 0, 2*Math.PI, false);
     995                    ctx.fillStyle = 'rgba(50,50,128,0.5)';
     996                    ctx.fill();
     997                    ctx.lineWidth = 1;
     998                    ctx.strokeStyle = 'rgba(0,0,160,0.5)';
     999                    ctx.stroke();
     1000                     });
     1001                  </gsf:script>
     1002                  Choose within AV Chart
     1003                </span>
    9811004                  </div>
    9821005                 
     
    9841007                Based on the start of this musical/sound art work:
    9851008                  </span>
    986                   <input onclick="return preSubmit(this.form);" type="submit" value="Make Arousal-Valence Recommendation"/>
     1009                  <input onclick="return preSubmit(this.form);" type="submit" styleXXXX="font-size: 1.2rem;" value="Make Arousal-Valence Recommendation"/>
    9871010                  <div id="makeRecommendationFrom-AV" style="font-style: italics; font-size: 90%; display: none;"> <!-- **** -->
    9881011                <xsl:text> </xsl:text>
  • gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/js/av_document.js

    r37542 r37673  
    115115    //$('#makeRecommendationFrom-AV').html(`(@${current_time_1dp} secs: arousal=${arousal_val}, valence=${valence_val})`);
    116116
    117     return submitAVRecommendation(form, arousal_val,valence_val, clamped_current_time);
    118 }
     117    return submitAVRecommendation(form, arousal_val,valence_val, clamped_current_time, true);
     118}
     119
     120
     121function preSubmitDiff()
     122{
     123    var form = $('#av-query-form')[0];
     124
     125    // Note, the Arousal and Valence feature window values used is:
     126    //   6 secs + 50% overlap
     127    // So the Weka computed AV values are spaced out:
     128    //   6s, 9s, 12s, ...
     129   
     130    // clamp to ensure >= 6.0 secs
     131    //var current_time = Math.max(6.0,wavesurfer.getCurrentTime());
     132    //var current_time_1dp = current_time.toFixed(1);
     133
     134    var clamped_current_time = displayClampedCurrentTimeAndAV();
     135   
     136    AVEnsurePaused();
     137   
     138    weka_segment = Math.round(clamped_current_time/3) * 3;
     139    form.elements["s1.offset"].value = weka_segment;
     140   
     141    var arousal_val = parseFloat($('#arousal-val').text());
     142    var valence_val = parseFloat($('#valence-val').text());
     143
     144
     145    // Now to come up with something that's different
     146
     147    var num_choices = 3;
     148    var mix_up_choice = Math.floor(Math.random() * (num_choices))
     149
     150    if ((mix_up_choice == 0) || (mix_up_choice == 1)) {
     151    arousal_val = -1 * arousal_val;
     152    }
     153    if ((mix_up_choice == 0) || (mix_up_choice == 2)) {     
     154    valence_val = -1 * valence_val;
     155    }
     156   
     157    var av_magnitude = Math.sqrt(arousal_val*arousal_val + valence_val*valence_val);
     158
     159    if (av_magnitude < 0.1) {
     160    arousal_val *= 9.0;
     161    valence_val *= 9.0;
     162    }
     163    else if (av_magnitude < 0.25) {
     164    arousal_val *= 3.0;
     165    valence_val *= 3.0;
     166    }
     167    else if (av_magnitude < 0.5) {
     168    arousal_val *= 1.5;
     169    valence_val *= 1.5;
     170    }
     171
     172    var mix_up_boost = 1.0 + Math.random() * 0.1; // additive 10% boost
     173    arousal_val *= mix_up_boost;
     174    valence_val *= mix_up_boost;
     175   
     176    //$('#arousal-val').text(arousal_val.toFixed(3));
     177    //$('#valence-val').text(valence_val.toFixed(3));
     178
     179    //$('#makeRecommendationFrom-AV').html(`(@${current_time_1dp} secs: arousal=${arousal_val}, valence=${valence_val})`);
     180
     181    return submitAVRecommendation(form, arousal_val,valence_val, clamped_current_time, false);
     182}
     183
    119184
    120185function AVPlotRecommendations()
     
    283348}
    284349
    285 function submitAVRecommendation(form, arousal_val,valence_val, current_time)
     350function submitAVRecommendation(form, arousal_val,valence_val, current_time, update_av_vals)
    286351{
    287352    var adjusted_arousal_val = arousal_val;
     
    303368    adjusted_valence_val = Math.max(-1.0,Math.min(1.0,adjusted_valence_val));
    304369    }
    305    
    306     form.elements["s1.arousal"].value = adjusted_arousal_val;
    307     form.elements["s1.valence"].value = adjusted_valence_val;
     370
     371    if (update_av_vals) {
     372    form.elements["s1.arousal"].value = adjusted_arousal_val;
     373    form.elements["s1.valence"].value = adjusted_valence_val;
     374    }
    308375       
    309376    var args = {
     
    325392    };
    326393
    327    
     394    // ***** !!!! *****
    328395    var url = "https://mars.so-we-must-think.space/greenstone3/library";
    329396
     
    344411    })
    345412    .done(function(html_result) {
    346         $('#resultsAreaDiv').html("<div>Recommendations:</div>"+html_result);
     413
     414        var make_diff_recommend_html = '<div style="padding-top: 20px;">Or <input onclick="return preSubmitDiff();" styleXXXX="font-size: 1.2rem;" type="submit" value="Recommend Something Different" valueXX="Make Arousal-Valence Recommendation"/></div>';
     415       
     416        $('#resultsAreaDiv').html("<div>Recommendations:</div>"+html_result + make_diff_recommend_html);
    347417        $('#av-chart-div').show();
    348418
    349         AVPlotRecommendations();
     419        if (update_av_vals) {
     420        AVPlotRecommendations();
     421        }
    350422       
    351423        if (current_time) {
     
    389461{
    390462    console.log("postInitWavesurfer called with wavesufer = " + wavesurfer);
    391    
     463
     464    //$('#waveform').css('cusor','wait');
     465    //console.log("***** ##### !!!!! Away to load audio MP3 file => set cursor to 'wait'");
     466
     467//    wavesurfer.on('waveform-ready', function () {
     468//  console.log("**** #### !!!! wavesurfer Event 'waveform-ready': MP3 loaded and wavesurfer rendered => reverting cursor");
     469//  $('#waveform').css('cusor','revert');
     470//    });
     471         
     472   
    392473    wavesurfer.load(gs.variables.mp3url);
    393474   
     
    415496    av_chart_record_finish();
    416497    });
     498
    417499   
    418500    wavesurfer.on('ready', function () {
    419501
     502    //$('#waveform').css('cusor','revert');
     503   
    420504    console.log("**** wavesurfer ready()");
     505    //console.log("**** wavesurfer waveform-ready()");
    421506    //wavesurfer.drawer.setWidth(958);
    422507   
     
    440525    }
    441526   
    442     // The following draw blank visuals
    443     //wavesurfer.drawBuffer();
    444     //wavesurfer.zoom();
    445    
    446527    });
    447528
     
    563644    form.elements["s1.offset"].value = weka_segment;
    564645   
    565     submitAVRecommendation(form, capped_av_x, capped_av_y, null);
     646    submitAVRecommendation(form, capped_av_x, capped_av_y, null, true);
    566647   
    567648}
     
    916997    var renderWave = doc_url.searchParams.get('renderWave');
    917998
    918     if (renderWave && (renderWave == 1)) {
    919     // showing the waveform => offer link to spectrogram
    920     const sts_url = new URL(window.location);
    921     sts_url.searchParams.set('renderWave', 0);
    922     $('#switch-to-spectrogram').attr("href",sts_url);
    923     $('#switch-to-waveform').hide();
    924 
    925     $('#av-timelinebar-help').hide();
    926     }
    927     else {
     999    if (renderWave && (renderWave == 0)) {
    9281000    // show the spectrogram => offer link to waveform
    9291001   
     
    9331005    $('#switch-to-spectrogram').hide();
    9341006
    935     $('#av-timelinebar-help').show();   
     1007    $('#av-timelinebar-help').show();       
     1008    }
     1009    else {
     1010    // showing the waveform => offer link to spectrogram
     1011    const sts_url = new URL(window.location);
     1012    sts_url.searchParams.set('renderWave', 0);
     1013    sts_url.searchParams.set('showRecordAV', 0); // ****
     1014    $('#switch-to-spectrogram').attr("href",sts_url);
     1015    $('#switch-to-waveform').hide();
     1016
     1017    $('#av-timelinebar-help').hide();
    9361018    }
    9371019}
     
    10751157    $av_labels.css("display","none");
    10761158    */
     1159
     1160
     1161    var this_url = new URL(window.location)
     1162    var renderWave = this_url.searchParams.get('renderWave');
     1163    if (renderWave != 1) {
     1164        // Force to be waveForm Display
     1165        this_url.searchParams.set('renderWave', '1');
     1166        this_url.searchParams.set('showRecordAV', '1');
     1167        window.location.href = this_url.toString();
     1168    }
    10771169
    10781170    //console.log("Away to hide standard av-chart-img and show av-chart-img-unlabeled");
Note: See TracChangeset for help on using the changeset viewer.