Upload index.html with huggingface_hub
Browse files- index.html +5 -3
index.html
CHANGED
|
@@ -17,7 +17,7 @@ html,body{background:#161719;overflow:hidden}
|
|
| 17 |
const MODELS=["mrt2_small","mrt2_base"], SR=48000, PIDX={0:"temperature",1:"topk",3:"cfg",4:"cfgnotes",8:"buffer",48:"cfgdrums"};
|
| 18 |
let currentModel="mrt2_base", params={temperature:1.1,topk:50,cfg:1.6,cfgnotes:2.4,cfgdrums:4.0,buffer:0}, lastData=null;
|
| 19 |
const activeNotes=new Set();
|
| 20 |
-
let playing=false, ctx=null, analyser=null, nextTime=0, client=null, freq=null;
|
| 21 |
let sessionLen=120, budget=120, lastBT=0, mtick=0, settingsOpen=false;
|
| 22 |
const US=s=>{ if(window.updateState) window.updateState(s); };
|
| 23 |
|
|
@@ -32,7 +32,9 @@ html,body{background:#161719;overflow:hidden}
|
|
| 32 |
case 'selectModel': if(m.name){ currentModel=m.name; US({modelName:m.name,localModels:MODELS}); setStyle(lastData); } break;
|
| 33 |
case 'downloadModel': case 'initResources': US({resourcesMissing:false,modelName:currentModel,localModels:MODELS}); break;
|
| 34 |
case 'textPrompts': lastData=m.value; setStyle(m.value); break;
|
| 35 |
-
case 'param': {
|
|
|
|
|
|
|
| 36 |
case 'openSettings': settingsOpen=!settingsOpen; US({openSettings:settingsOpen}); break;
|
| 37 |
case 'setSoloMode': US({solomode:!!m.value}); break;
|
| 38 |
case 'checkBanks': US({bankStatus:{}}); break;
|
|
@@ -74,7 +76,7 @@ html,body{background:#161719;overflow:hidden}
|
|
| 74 |
}
|
| 75 |
async function toggle(depleted){
|
| 76 |
if(playing||depleted){ playing=false; US({isPlaying:false}); if(ctx)ctx.suspend(); emitGpu(); return; }
|
| 77 |
-
if(!ctx){ ctx=new AudioContext({sampleRate:SR}); analyser=ctx.createAnalyser(); analyser.fftSize=64; analyser.connect(ctx.destination); freq=new Uint8Array(analyser.frequencyBinCount); meter(); }
|
| 78 |
await ctx.resume(); nextTime=ctx.currentTime+0.2; budget=sessionLen; lastBT=performance.now();
|
| 79 |
playing=true; US({isPlaying:true}); emitGpu(); await setStyle(lastData);
|
| 80 |
if(!client) client=await Client.connect(window.location.origin); loop();
|
|
|
|
| 17 |
const MODELS=["mrt2_small","mrt2_base"], SR=48000, PIDX={0:"temperature",1:"topk",3:"cfg",4:"cfgnotes",8:"buffer",48:"cfgdrums"};
|
| 18 |
let currentModel="mrt2_base", params={temperature:1.1,topk:50,cfg:1.6,cfgnotes:2.4,cfgdrums:4.0,buffer:0}, lastData=null;
|
| 19 |
const activeNotes=new Set();
|
| 20 |
+
let playing=false, ctx=null, analyser=null, gain=null, vol=1, muted=false, nextTime=0, client=null, freq=null;
|
| 21 |
let sessionLen=120, budget=120, lastBT=0, mtick=0, settingsOpen=false;
|
| 22 |
const US=s=>{ if(window.updateState) window.updateState(s); };
|
| 23 |
|
|
|
|
| 32 |
case 'selectModel': if(m.name){ currentModel=m.name; US({modelName:m.name,localModels:MODELS}); setStyle(lastData); } break;
|
| 33 |
case 'downloadModel': case 'initResources': US({resourcesMissing:false,modelName:currentModel,localModels:MODELS}); break;
|
| 34 |
case 'textPrompts': lastData=m.value; setStyle(m.value); break;
|
| 35 |
+
case 'param': { if(m.index===5){ vol=Math.max(0,Math.min(1,(m.value+60)/60)); if(gain)gain.gain.value=muted?0:vol; break; }
|
| 36 |
+
if(m.index===6){ muted=!!m.value; if(gain)gain.gain.value=muted?0:vol; break; }
|
| 37 |
+
const k=PIDX[m.index]; if(k){ params[k]=m.value; setStyle(lastData); } break; }
|
| 38 |
case 'openSettings': settingsOpen=!settingsOpen; US({openSettings:settingsOpen}); break;
|
| 39 |
case 'setSoloMode': US({solomode:!!m.value}); break;
|
| 40 |
case 'checkBanks': US({bankStatus:{}}); break;
|
|
|
|
| 76 |
}
|
| 77 |
async function toggle(depleted){
|
| 78 |
if(playing||depleted){ playing=false; US({isPlaying:false}); if(ctx)ctx.suspend(); emitGpu(); return; }
|
| 79 |
+
if(!ctx){ ctx=new AudioContext({sampleRate:SR}); analyser=ctx.createAnalyser(); analyser.fftSize=64; gain=ctx.createGain(); gain.gain.value=muted?0:vol; analyser.connect(gain); gain.connect(ctx.destination); freq=new Uint8Array(analyser.frequencyBinCount); meter(); }
|
| 80 |
await ctx.resume(); nextTime=ctx.currentTime+0.2; budget=sessionLen; lastBT=performance.now();
|
| 81 |
playing=true; US({isPlaying:true}); emitGpu(); await setStyle(lastData);
|
| 82 |
if(!client) client=await Client.connect(window.location.origin); loop();
|