|
|
@@ -531,23 +531,25 @@
|
|
|
const demoStart = $('demoStart'), demoReset = $('demoReset'), demoAlert = $('demoAlert');
|
|
|
const demoAudio = $('demoAudio'), manualToggle = $('manualToggle');
|
|
|
let demoRunning=false, demoTimer=null, demoSecond=-1, demoScoring=[];
|
|
|
+ let demoSchedule={};
|
|
|
+ function makeSchedule(){const falseStart=6+Math.random()*3,falseEnd=falseStart+.8+Math.random()*1.5;const onset=17+Math.random()*3,autoStart=onset+1.0+Math.random()*2,visibleStart=autoStart+2+Math.random()*3,fadeStart=29+Math.random()*3,off=33+Math.random()*2;return {falseStart,falseEnd,onset,autoStart,visibleStart,fadeStart,off};}
|
|
|
const scenarioDuration=40;
|
|
|
const drone=$('droneSilhouette'), snow=$('snowLayer'), visual=$('demoVisual');
|
|
|
// seconds 18..34: sound is present; the silhouette becomes visible only after 24 seconds.
|
|
|
// a weak drone-like sound at 7..9 is a deliberately ambiguous background cue (false-alarm trap).
|
|
|
- function truthAt(t){return t>=18 && t<34;}
|
|
|
- function autoAt(t){return (t>=18 && t<34) || (t>=7 && t<9);}
|
|
|
+ function truthAt(t){return t>=demoSchedule.onset && t<demoSchedule.off;}
|
|
|
+ function autoAt(t){return (t>=demoSchedule.autoStart && t<demoSchedule.off) || (t>=demoSchedule.falseStart && t<demoSchedule.falseEnd);}
|
|
|
function autoConfidence(t){
|
|
|
- if(t>=18&&t<34){return t<20?.58:t<24?.76:t<30?.93:t<32?.78:.61;}
|
|
|
- if(t>=7&&t<9)return .69; // deliberately false positive
|
|
|
+ if(t>=demoSchedule.autoStart&&t<demoSchedule.off){const peak=demoSchedule.visibleStart;return t<peak?.57+Math.random()*.12:t<demoSchedule.fadeStart?.78+Math.random()*.16:.55+Math.random()*.12;}
|
|
|
+ if(t>=demoSchedule.falseStart&&t<demoSchedule.falseEnd)return .65+Math.random()*.1;
|
|
|
return .12+((Math.sin(t*2.1)+1)*.025);
|
|
|
}
|
|
|
// Rolling spectrogram: newest one-second spectral snapshot is at the top;
|
|
|
// each subsequent snapshot pushes previous rows downward.
|
|
|
const specHistory=[]; const maxRows=40;
|
|
|
function renderDemoSpec(t){
|
|
|
- const droneLevel=(t>=18&&t<34)?Math.max(0,Math.min(1,(t-18)/4,(34-t)/4)):0;
|
|
|
- const falseCue=(t>=7&&t<9)?0.30:0;
|
|
|
+ const droneLevel=truthAt(t)?Math.max(0,Math.min(1,(t-demoSchedule.onset)/4,(demoSchedule.off-t)/4)):0;
|
|
|
+ const falseCue=(t>=demoSchedule.falseStart&&t<demoSchedule.falseEnd)?0.30:0;
|
|
|
const clickTimes=[4,11,15,36]; // ice cracks / impacts / equipment clicks
|
|
|
const click=clickTimes.some(x=>Math.abs(t-x)<.55)?1:0;
|
|
|
const windLevel=(t<18||t>=34)?1:0.65;
|
|
|
@@ -574,22 +576,7 @@
|
|
|
const c=colorMap(specHistory[r][f]/255);ctx.fillStyle=`rgb(${c[0]},${c[1]},${c[2]})`;
|
|
|
ctx.fillRect(f*cellW,r*rowH,Math.ceil(cellW),Math.ceil(rowH));
|
|
|
}
|
|
|
- // Instrument-like calibrated overlays: logarithmic frequency ticks on mel axis,
|
|
|
- // temporal marks down the right edge, and a relative dB color scale.
|
|
|
- const hzToMel = hz => 2595*Math.log10(1+hz/700);
|
|
|
- const lo=hzToMel(30), hi=hzToMel(8000);
|
|
|
- const ticks=[30,100,250,500,1000,2000,4000,8000];
|
|
|
- ctx.save(); ctx.font='10px Consolas, monospace'; ctx.lineWidth=1;
|
|
|
- ticks.forEach(hz=>{
|
|
|
- const x=(hzToMel(hz)-lo)/(hi-lo)*W;
|
|
|
- ctx.strokeStyle='rgba(235,225,205,.42)';ctx.beginPath();ctx.moveTo(x,0);ctx.lineTo(x,H);ctx.stroke();
|
|
|
- ctx.fillStyle='#f0dfbd';ctx.textAlign=(x<30?'left':x>W-30?'right':'center');ctx.fillText(hz>=1000?(hz/1000)+'k':String(hz),x,12);
|
|
|
- });
|
|
|
- for(let r=0;r<maxRows;r+=5){
|
|
|
- const y=r*rowH;ctx.strokeStyle='rgba(235,225,205,.25)';ctx.beginPath();ctx.moveTo(0,y);ctx.lineTo(W,y);ctx.stroke();
|
|
|
- ctx.fillStyle='#f0dfbd';ctx.textAlign='right';ctx.fillText(`${r}s`,W-5,y+11);
|
|
|
- }
|
|
|
- ctx.restore();
|
|
|
+
|
|
|
}
|
|
|
let lastSpecSecond=-1;
|
|
|
function drawMiniSpectrum(t){
|
|
|
@@ -628,10 +615,11 @@
|
|
|
$('demoClock').textContent=`00:${String(sec).padStart(2,'0')}`;
|
|
|
$('demoCaption').textContent= t<14?'ФОНОВАЯ ОБСТАНОВКА · ВЕТЕР И ЛЁД':t<18?'СЛАБЫЙ АКУСТИЧЕСКИЙ СИГНАЛ · ОБЪЕКТ НЕ ВИДЕН':t<24?'СИГНАЛ ВИНТОВ · ОЖИДАНИЕ ВИЗУАЛЬНОГО ПОДТВЕРЖДЕНИЯ':t<30?'БПЛА В СЕКТОРЕ · СИГНАЛ ОТЧЁТЛИВ':t<34?'БПЛА УДАЛЯЕТСЯ · СИГНАЛ ЗАТУХАЕТ':'ФОН · СИГНАЛ ИСЧЕЗ';
|
|
|
// Reveal the aircraft silhouette gradually after the alarm window begins.
|
|
|
- const vis=sec<24?0:sec<26?(sec-24)/2:sec<30?1:sec<32?(32-sec)/2:0;
|
|
|
+ const vis=sec<demoSchedule.visibleStart?0:sec<demoSchedule.visibleStart+2?(sec-demoSchedule.visibleStart)/2:sec<demoSchedule.fadeStart?1:sec<demoSchedule.fadeStart+3?(demoSchedule.fadeStart+3-sec)/3:0;
|
|
|
drone.style.opacity=Math.max(0,vis);drone.style.transform=`translate(${Math.max(0,sec-24)*4}px,${Math.max(0,sec-24)*1.8}px) scale(${.75+vis*.25})`;
|
|
|
snow.style.opacity=(sec<14||sec>=34)?1:sec<18?.75:.35;
|
|
|
const alarm=manualToggle.checked;
|
|
|
+ $('autoAlert').classList.toggle('detected',auto);$('autoAlertText').textContent=auto?'АВТОМАТ · ТРЕВОГА':'АВТОМАТ · ФОН';$('autoAlertSub').textContent=auto?'Сигнал выше порога':'Контроль акустического фона';
|
|
|
demoAlert.classList.toggle('detected',alarm);$('demoAlertText').textContent=alarm?'РУЧНАЯ ТРЕВОГА':'НАБЛЮДЕНИЕ';
|
|
|
$('demoAlertSub').textContent=alarm?'Оператор включил сигнал тревоги':'Фоновый шум / акустический контроль';
|
|
|
$('manualState').textContent=alarm?'ТРЕВОГА ВКЛЮЧЕНА':'ТРЕВОГА ОТКЛЮЧЕНА';
|
|
|
@@ -646,10 +634,10 @@
|
|
|
evaluateSecond(sec);
|
|
|
}
|
|
|
function stopDemo(){demoRunning=false;clearInterval(demoTimer);demoTimer=null;demoStart.textContent='▶ ЗАПУСК';demoAudio.pause();}
|
|
|
- function resetDemo(){stopDemo();demoAudio.currentTime=0;manualToggle.checked=false;demoScoring=[];demoSecond=-1;specHistory.length=0;lastSpecSecond=-1;drone.style.opacity=0;updateScoreboard();drawRollingSpec(0);drawMiniSpectrum(0);updateDemo(0);$('demoClock').textContent='00:00';$('scenarioStatus').textContent='СЦЕНАРИЙ ГОТОВ · ОЖИДАНИЕ';}
|
|
|
+ function resetDemo(){stopDemo();demoSchedule=makeSchedule();demoAudio.currentTime=0;manualToggle.checked=false;demoScoring=[];demoSecond=-1;specHistory.length=0;lastSpecSecond=-1;drone.style.opacity=0;updateScoreboard();drawRollingSpec(0);drawMiniSpectrum(0);updateDemo(0);$('demoClock').textContent='00:00';$('scenarioStatus').textContent='СЦЕНАРИЙ ГОТОВ · ОЖИДАНИЕ';}
|
|
|
demoStart?.addEventListener('click',async()=>{
|
|
|
if(demoRunning){stopDemo();$('scenarioStatus').textContent='СЦЕНАРИЙ ПРИОСТАНОВЛЕН';return;}
|
|
|
- demoRunning=true;demoStart.textContent='Ⅱ ПАУЗА';demoSecond=-1;demoScoring=[];specHistory.length=0;lastSpecSecond=-1;manualToggle.checked=false;demoAudio.currentTime=0;
|
|
|
+ demoRunning=true;demoStart.textContent='Ⅱ ПАУЗА';demoSecond=-1;demoScoring=[];specHistory.length=0;lastSpecSecond=-1;manualToggle.checked=false;demoSchedule=makeSchedule();demoAudio.currentTime=0;
|
|
|
updateScoreboard();
|
|
|
try{await demoAudio.play();}catch(e){stopDemo();$('scenarioStatus').textContent='Не удалось воспроизвести звук';return;}
|
|
|
updateDemo(0);demoTimer=setInterval(()=>{const t=demoAudio.currentTime;updateDemo(t);if(t>=39.95){stopDemo();$('scenarioStatus').textContent='ИСПЫТАНИЕ ЗАВЕРШЕНО · СБРОС ДЛЯ ПОВТОРА';}},250);
|