Upload index.html with huggingface_hub
Browse files16 unmodified lines171819202122238 unmodified lines3233343536373835 unmodified lines7475767778798016 unmodified linesconst MODELS=["mrt2_small","mrt2_base"], SR=48000, PIDX={0:"temperature",1:"topk",3:"cfg",4:"cfgnotes",8:"buffer",48:"cfgdrums"};let currentModel="mrt2_base", params={temperature:1.1,topk:50,cfg:1.6,cfgnotes:2.4,cfgdrums:4.0,buffer:0}, lastData=null;const activeNotes=new Set();let playing=false, ctx=null, analyser=null, nextTime=0, client=null, freq=null;let sessionLen=120, budget=120, lastBT=0, mtick=0, settingsOpen=false;const US=s=>{ if(window.updateState) window.updateState(s); };8 unmodified linescase 'selectModel': if(m.name){ currentModel=m.name; US({modelName:m.name,localModels:MODELS}); setStyle(lastData); } break;case 'downloadModel': case 'initResources': US({resourcesMissing:false,modelName:currentModel,localModels:MODELS}); break;case 'textPrompts': lastData=m.value; setStyle(m.value); break;case 'param': { const k=PIDX[m.index]; if(k){ params[k]=m.value; setStyle(lastData); } break; }case 'openSettings': settingsOpen=!settingsOpen; US({openSettings:settingsOpen}); break;case 'setSoloMode': US({solomode:!!m.value}); break;case 'checkBanks': US({bankStatus:{}}); break;35 unmodified lines}async function toggle(depleted){if(playing||depleted){ playing=false; US({isPlaying:false}); if(ctx)ctx.suspend(); emitGpu(); return; }if(!ctx){ ctx=new AudioContext({sampleRate:SR}); analyser=ctx.createAnalyser(); analyser.fftSize=64; analyser.connect(ctx.destination); freq=new Uint8Array(analyser.frequencyBinCount); meter(); }await ctx.resume(); nextTime=ctx.currentTime+0.2; budget=sessionLen; lastBT=performance.now();playing=true; US({isPlaying:true}); emitGpu(); await setStyle(lastData);if(!client) client=await Client.connect(window.location.origin); loop();16 unmodified lines171819202122238 unmodified lines32333435363738394035 unmodified lines7677787980818216 unmodified linesconst MODELS=["mrt2_small","mrt2_base"], SR=48000, PIDX={0:"temperature",1:"topk",3:"cfg",4:"cfgnotes",8:"buffer",48:"cfgdrums"};let currentModel="mrt2_base", params={temperature:1.1,topk:50,cfg:1.6,cfgnotes:2.4,cfgdrums:4.0,buffer:0}, lastData=null;const activeNotes=new Set();let playing=false, ctx=null, analyser=null, gain=null, vol=1, muted=false, nextTime=0, client=null, freq=null;let sessionLen=120, budget=120, lastBT=0, mtick=0, settingsOpen=false;const US=s=>{ if(window.updateState) window.updateState(s); };8 unmodified linescase 'selectModel': if(m.name){ currentModel=m.name; US({modelName:m.name,localModels:MODELS}); setStyle(lastData); } break;case 'downloadModel': case 'initResources': US({resourcesMissing:false,modelName:currentModel,localModels:MODELS}); break;case 'textPrompts': lastData=m.value; setStyle(m.value); break;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; }if(m.index===6){ muted=!!m.value; if(gain)gain.gain.value=muted?0:vol; break; }const k=PIDX[m.index]; if(k){ params[k]=m.value; setStyle(lastData); } break; }case 'openSettings': settingsOpen=!settingsOpen; US({openSettings:settingsOpen}); break;case 'setSoloMode': US({solomode:!!m.value}); break;case 'checkBanks': US({bankStatus:{}}); break;35 unmodified lines}async function toggle(depleted){if(playing||depleted){ playing=false; US({isPlaying:false}); if(ctx)ctx.suspend(); emitGpu(); return; }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(); }await ctx.resume(); nextTime=ctx.currentTime+0.2; budget=sessionLen; lastBT=performance.now();playing=true; US({isPlaying:true}); emitGpu(); await setStyle(lastData);if(!client) client=await Client.connect(window.location.origin); loop();
index.html+5-3