|
@@ -542,38 +542,49 @@
|
|
|
if(t>=7&&t<9)return .69; // deliberately false positive
|
|
if(t>=7&&t<9)return .69; // deliberately false positive
|
|
|
return .12+((Math.sin(t*2.1)+1)*.025);
|
|
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){
|
|
function renderDemoSpec(t){
|
|
|
- const bytes=new Uint8Array(64*44); const fade=(t>=18&&t<34)?Math.max(0,Math.min(1,(t-18)/4,(34-t)/4)):0;
|
|
|
|
|
- const falseCue=(t>=7&&t<9)?0.24:0;
|
|
|
|
|
- for(let f=0;f<64;f++)for(let x=0;x<44;x++){
|
|
|
|
|
- const noise=18+((Math.sin(f*3.2+x*1.7+t*5)+Math.cos(f*.8-x*2.1+t*3))*8)+((f*11+x*7)%17);
|
|
|
|
|
- const band=(f>=5&&f<=13)?12*Math.max(0,Math.sin(x*.8+t*2)):0;
|
|
|
|
|
- const harmonic=fade*(f===9||f===18||f===27||f===36?220:((f%9===0)?115:((f%3===0)?42:0))) + falseCue*((f%9===0)?78:((f%3===0)?30:0));
|
|
|
|
|
- const gust=(t<18||t>34)?22*Math.max(0,Math.sin(t*1.4+f*.5)):8;
|
|
|
|
|
- bytes[f*44+x]=Math.max(0,Math.min(255,Math.round(noise+band+harmonic+gust)));
|
|
|
|
|
|
|
+ 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 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;
|
|
|
|
|
+ const vals=new Uint8Array(64);
|
|
|
|
|
+ for(let f=0;f<64;f++){
|
|
|
|
|
+ // irregular, asymmetric wind and ice background, no mirrored/repeating pattern
|
|
|
|
|
+ const wind=16+windLevel*(18*Math.exp(-f/17)+7*Math.sin(f*.31+t*.73)+5*Math.cos(f*.17+t*1.19));
|
|
|
|
|
+ const iceBands=(f===4||f===17||f===29||f===51)?(click*105):0;
|
|
|
|
|
+ const clickBroad=click*(22+Math.random()*65); // transient is broadband and irregular
|
|
|
|
|
+ const droneHarmonics=droneLevel*(f===8?180:f===15?150:f===22?122:f===29?96:f===36?70:f===43?42:0)
|
|
|
|
|
+ +falseCue*(f===8?65:f===15?54:f===22?40:f===29?29:f===36?18:0);
|
|
|
|
|
+ // additional uneven, non-periodic spectral texture
|
|
|
|
|
+ const ripple=(Math.sin(f*1.73+t*1.3)*4+Math.cos(f*.43-t*.9)*5);
|
|
|
|
|
+ vals[f]=Math.max(0,Math.min(255,Math.round(wind+ripple+iceBands+clickBroad+droneHarmonics)));
|
|
|
}
|
|
}
|
|
|
- return bytes;
|
|
|
|
|
|
|
+ return vals;
|
|
|
}
|
|
}
|
|
|
function drawRollingSpec(t){
|
|
function drawRollingSpec(t){
|
|
|
const canvas=$('spectrogram'),ctx=canvas.getContext('2d');const W=canvas.width,H=canvas.height;
|
|
const canvas=$('spectrogram'),ctx=canvas.getContext('2d');const W=canvas.width,H=canvas.height;
|
|
|
|
|
+ if(Math.floor(t)!==Math.floor(lastSpecSecond)) {specHistory.unshift(renderDemoSpec(t));if(specHistory.length>maxRows)specHistory.length=maxRows;lastSpecSecond=Math.floor(t);}
|
|
|
ctx.fillStyle='#101d24';ctx.fillRect(0,0,W,H);
|
|
ctx.fillStyle='#101d24';ctx.fillRect(0,0,W,H);
|
|
|
- const strip=renderDemoSpec(t),cw=W/44,ch=H/64;
|
|
|
|
|
- for(let f=0;f<64;f++)for(let x=0;x<44;x++){
|
|
|
|
|
- const v=strip[f*44+x],c=colorMap(v/255);
|
|
|
|
|
- ctx.fillStyle=`rgb(${c[0]},${c[1]},${c[2]})`;ctx.fillRect(x*cw,H-(f+1)*ch,Math.ceil(cw),Math.ceil(ch));
|
|
|
|
|
|
|
+ const cellW=W/64, rowH=H/maxRows;
|
|
|
|
|
+ for(let r=0;r<specHistory.length;r++)for(let f=0;f<64;f++){
|
|
|
|
|
+ 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));
|
|
|
}
|
|
}
|
|
|
- ctx.strokeStyle='rgba(230,215,185,.25)';ctx.lineWidth=1;
|
|
|
|
|
|
|
+ ctx.strokeStyle='rgba(230,215,185,.3)';ctx.lineWidth=1;
|
|
|
for(let i=1;i<4;i++){ctx.beginPath();ctx.moveTo(0,H*i/4);ctx.lineTo(W,H*i/4);ctx.stroke();}
|
|
for(let i=1;i<4;i++){ctx.beginPath();ctx.moveTo(0,H*i/4);ctx.lineTo(W,H*i/4);ctx.stroke();}
|
|
|
}
|
|
}
|
|
|
|
|
+ let lastSpecSecond=-1;
|
|
|
function drawMiniSpectrum(t){
|
|
function drawMiniSpectrum(t){
|
|
|
const canvas=$('miniSpectrum'); if(!canvas)return; const ctx=canvas.getContext('2d');
|
|
const canvas=$('miniSpectrum'); if(!canvas)return; const ctx=canvas.getContext('2d');
|
|
|
const W=canvas.width,H=canvas.height; ctx.clearRect(0,0,W,H);ctx.fillStyle='#293d41';ctx.fillRect(0,0,W,H);
|
|
const W=canvas.width,H=canvas.height; ctx.clearRect(0,0,W,H);ctx.fillStyle='#293d41';ctx.fillRect(0,0,W,H);
|
|
|
- const fade=(t>=18&&t<34)?Math.max(0,Math.min(1,(t-18)/4,(34-t)/4)):0;
|
|
|
|
|
- const weak=(t>=7&&t<9)?0.34:0; const n=64,barW=W/n;
|
|
|
|
|
|
|
+ const profile=specHistory[0]||renderDemoSpec(t),n=64,barW=W/n;
|
|
|
for(let i=0;i<n;i++){
|
|
for(let i=0;i<n;i++){
|
|
|
- const base=5+((Math.sin(i*.53+t*.4)+1)*4);
|
|
|
|
|
- const drone=fade*(i===9||i===18||i===27||i===36?42:(i%9===0?25:(i%3===0?12:0)))+weak*(i%9===0?18:0);
|
|
|
|
|
- const h=Math.min(H-5,base+drone);ctx.fillStyle=drone>12?'#b4422f':'#d0b78c';ctx.fillRect(i*barW+1,H-h,Math.max(1,barW-2),h);
|
|
|
|
|
|
|
+ const h=Math.max(2,Math.min(H-4,profile[i]*.42));
|
|
|
|
|
+ ctx.fillStyle=profile[i]>100?'#b4422f':'#d0b78c';ctx.fillRect(i*barW+1,H-h,Math.max(1,barW-2),h);
|
|
|
}
|
|
}
|
|
|
ctx.strokeStyle='#c7b99c';ctx.globalAlpha=.35;ctx.beginPath();ctx.moveTo(0,H-1);ctx.lineTo(W,H-1);ctx.stroke();ctx.globalAlpha=1;
|
|
ctx.strokeStyle='#c7b99c';ctx.globalAlpha=.35;ctx.beginPath();ctx.moveTo(0,H-1);ctx.lineTo(W,H-1);ctx.stroke();ctx.globalAlpha=1;
|
|
|
}
|
|
}
|
|
@@ -618,10 +629,10 @@
|
|
|
evaluateSecond(sec);
|
|
evaluateSecond(sec);
|
|
|
}
|
|
}
|
|
|
function stopDemo(){demoRunning=false;clearInterval(demoTimer);demoTimer=null;demoStart.textContent='▶ ЗАПУСК';demoAudio.pause();}
|
|
function stopDemo(){demoRunning=false;clearInterval(demoTimer);demoTimer=null;demoStart.textContent='▶ ЗАПУСК';demoAudio.pause();}
|
|
|
- function resetDemo(){stopDemo();demoAudio.currentTime=0;manualToggle.checked=false;demoScoring=[];demoSecond=-1;drone.style.opacity=0;updateScoreboard();drawRollingSpec(0);drawMiniSpectrum(0);updateDemo(0);$('demoClock').textContent='00:00';$('scenarioStatus').textContent='СЦЕНАРИЙ ГОТОВ · ОЖИДАНИЕ';}
|
|
|
|
|
|
|
+ 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='СЦЕНАРИЙ ГОТОВ · ОЖИДАНИЕ';}
|
|
|
demoStart?.addEventListener('click',async()=>{
|
|
demoStart?.addEventListener('click',async()=>{
|
|
|
if(demoRunning){stopDemo();$('scenarioStatus').textContent='СЦЕНАРИЙ ПРИОСТАНОВЛЕН';return;}
|
|
if(demoRunning){stopDemo();$('scenarioStatus').textContent='СЦЕНАРИЙ ПРИОСТАНОВЛЕН';return;}
|
|
|
- demoRunning=true;demoStart.textContent='Ⅱ ПАУЗА';demoSecond=-1;demoScoring=[];manualToggle.checked=false;demoAudio.currentTime=0;
|
|
|
|
|
|
|
+ demoRunning=true;demoStart.textContent='Ⅱ ПАУЗА';demoSecond=-1;demoScoring=[];specHistory.length=0;lastSpecSecond=-1;manualToggle.checked=false;demoAudio.currentTime=0;
|
|
|
updateScoreboard();
|
|
updateScoreboard();
|
|
|
try{await demoAudio.play();}catch(e){stopDemo();$('scenarioStatus').textContent='Не удалось воспроизвести звук';return;}
|
|
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);
|
|
updateDemo(0);demoTimer=setInterval(()=>{const t=demoAudio.currentTime;updateDemo(t);if(t>=39.95){stopDemo();$('scenarioStatus').textContent='ИСПЫТАНИЕ ЗАВЕРШЕНО · СБРОС ДЛЯ ПОВТОРА';}},250);
|