@grame/faust-web-component 0.2.35 → 0.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1860,7 +1860,7 @@ const dependencies = {
|
|
1860
1860
|
|
1861
1861
|
${Fo}
|
1862
1862
|
</style>
|
1863
|
-
`;class Bh extends HTMLElement{constructor(){super()}connectedCallback(){const A=this.innerHTML.replace("<!--","").replace("-->","").trim();this.attachShadow({mode:"open"}).appendChild(Oc.content.cloneNode(!0));const g=this.shadowRoot.querySelector("#ide");g.onfocus=()=>{const T=new URLSearchParams;T.set("inline",btoa(C.state.doc.toString()).replace("+","-").replace("/","_")),g.href=`https://faustide.grame.fr/?${T.toString()}`};const B=this.shadowRoot.querySelector("#editor"),C=Ah(B,A),Q=this.shadowRoot.querySelector("#run"),E=this.shadowRoot.querySelector("#stop"),N=this.shadowRoot.querySelector("#faust-ui"),D=this.shadowRoot.querySelector("#faust-diagram"),o=this.shadowRoot.querySelector("#sidebar"),M=this.shadowRoot.querySelector("#sidebar-content"),i=[...this.shadowRoot.querySelectorAll(".tab")],G=[...M.querySelectorAll("div")],c=Zy([B,o],{sizes:[100,0],minSize:[0,20],gutterSize:7,snapOffset:150,onDragEnd:()=>{t==null||t.onResize(),L==null||L.onResize()}});TC.then(()=>Q.disabled=!1);const S=[70,30];let w=!1;const Y=()=>{w||c.setSizes(S),w=!0};let k,a,h,t,L,y=!1,K=-1,e;Q.onclick=async()=>{HA.state==="suspended"&&await HA.resume(),await TC;const T=C.state.doc.toString();let z=null;try{await FC.compile(hI,"main",T,"");const m=FC.getMeta();let{midi:x,nvoices:r}=_o(m);y=x,K=r,z=r>0?vo():Xo(),await z.compile(hI,"main",T,"")}catch(m){gh(C,m);return}Ih(C),k!==void 0&&k.disconnect(),K>0?k=await z.createNode(HA,K):k=await z.createNode(HA),k.numberOfInputs>0?(b.disabled=!1,H(await fo()),await F()):(b.disabled=!0,b.innerHTML="<option>Audio input</option>"),k.connect(HA.destination),E.disabled=!1;for(const m of i)m.disabled=!1;y&&Po(qo(k)).then(()=>{console.log("Successfully connected to the MIDI device.")}).catch(m=>{console.error("Error accessing MIDI device:",m.message)}),Y();for(const m of G)for(;m.lastChild;)m.lastChild.remove();h=new AnalyserNode(HA,{fftSize:Math.pow(2,11),minDecibels:-96,maxDecibels:0,smoothingTimeConstant:.85}),k.connect(h),t=new jc(G[2]),L=new jc(G[3]);const p=k.getUI();Z(p.length>1||p[0].items.length>0?0:3);const U=new eo.FaustUI({ui:p,root:N});U.paramChangeByUI=(m,x)=>k==null?void 0:k.setParamValue(m,x),k.setOutputParamHandler((m,x)=>U.paramChangeByDSP(m,x)),d(Vo.from("main",T,"")["process.svg"]),B.style.height=`${Math.max(125,U.minHeight)}px`,N.style.width=U.minWidth*1.25+"px",N.style.height=U.minHeight*1.25+"px"};const d=T=>{D.innerHTML=T;for(const z of D.querySelectorAll("a"))z.onclick=p=>{p.preventDefault();const U=z.href.baseVal,m=hI.fs().readFile("main-svg/"+U,{encoding:"utf8"});d(m)}};let R;const s=()=>{t.renderScope([{analyser:h,style:"rgb(212, 100, 100)",edgeThreshold:.09}]),R=requestAnimationFrame(s)},l=()=>{L.renderSpectrum(h),R=requestAnimationFrame(l)},Z=T=>{for(const[z,p]of i.entries())T===z?(p.classList.add("active"),G[z].classList.add("active")):(p.classList.remove("active"),G[z].classList.remove("active"));T===2?(t.onResize(),R!==void 0&&cancelAnimationFrame(R),R=requestAnimationFrame(s)):T===3?(L.onResize(),R!==void 0&&cancelAnimationFrame(R),R=requestAnimationFrame(l)):R!==void 0&&(cancelAnimationFrame(R),R=void 0)};for(const[T,z]of i.entries())z.onclick=()=>Z(T);E.onclick=()=>{k!==void 0&&(k.disconnect(),k.destroy(),k=void 0,E.disabled=!0)};const b=this.shadowRoot.querySelector("#audio-input"),H=T=>{if(!b.disabled){for(;b.lastChild;)b.lastChild.remove();for(const z of T)z.kind==="audioinput"&&b.appendChild(new Option(z.label||z.deviceId,z.deviceId));b.appendChild(new Option("Audio File","Audio File"))}};bE.push(H);const F=async()=>{const T=b.value,z=await navigator.mediaDevices.getUserMedia({audio:{deviceId:T,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});if(a&&(a.disconnect(),a=void 0),k&&k.numberOfInputs>0)if(T=="Audio File")try{const U=document.querySelector('script[src$="faust-web-component.js"]').src,m=U.substring(0,U.lastIndexOf("/")+1),r=await(await fetch(m+"02-XYLO1.mp3")).arrayBuffer();let J=await HA.decodeAudioData(r);e=HA.createBufferSource(),e.buffer=J,e.connect(k),e.start()}catch(p){console.error("Error loading file: ",p)}else e!==void 0&&(e.stop(),e.disconnect(),e=void 0),a=HA.createMediaStreamSource(z),a.connect(k)};b.onchange=F}}const pc=document.createElement("template");pc.innerHTML=`
|
1863
|
+
`;class Bh extends HTMLElement{constructor(){super()}connectedCallback(){const A=this.innerHTML.replace("<!--","").replace("-->","").trim();this.attachShadow({mode:"open"}).appendChild(Oc.content.cloneNode(!0));const g=this.shadowRoot.querySelector("#ide");g.onfocus=()=>{const T=new URLSearchParams;T.set("inline",btoa(C.state.doc.toString()).replace("+","-").replace("/","_")),g.href=`https://faustide.grame.fr/?${T.toString()}`};const B=this.shadowRoot.querySelector("#editor"),C=Ah(B,A),Q=this.shadowRoot.querySelector("#run"),E=this.shadowRoot.querySelector("#stop"),N=this.shadowRoot.querySelector("#faust-ui"),D=this.shadowRoot.querySelector("#faust-diagram"),o=this.shadowRoot.querySelector("#sidebar"),M=this.shadowRoot.querySelector("#sidebar-content"),i=[...this.shadowRoot.querySelectorAll(".tab")],G=[...M.querySelectorAll("div")],c=Zy([B,o],{sizes:[100,0],minSize:[0,20],gutterSize:7,snapOffset:150,onDragEnd:()=>{t==null||t.onResize(),L==null||L.onResize()}});TC.then(()=>Q.disabled=!1);const S=[70,30];let w=!1;const Y=()=>{w||c.setSizes(S),w=!0};let k,a,h,t,L,y=!1,K=-1,e;Q.onclick=async()=>{HA.state==="suspended"&&await HA.resume(),await TC;const T=C.state.doc.toString();let z=null;try{await FC.compile(hI,"main",T,"");const m=FC.getMeta();let{midi:x,nvoices:r}=_o(m);y=x,K=r,z=r>0?vo():Xo(),await z.compile(hI,"main",T,"-ftz 2")}catch(m){gh(C,m);return}Ih(C),k!==void 0&&k.disconnect(),K>0?k=await z.createNode(HA,K):k=await z.createNode(HA),k.numberOfInputs>0?(b.disabled=!1,H(await fo()),await F()):(b.disabled=!0,b.innerHTML="<option>Audio input</option>"),k.connect(HA.destination),E.disabled=!1;for(const m of i)m.disabled=!1;y&&Po(qo(k)).then(()=>{console.log("Successfully connected to the MIDI device.")}).catch(m=>{console.error("Error accessing MIDI device:",m.message)}),Y();for(const m of G)for(;m.lastChild;)m.lastChild.remove();h=new AnalyserNode(HA,{fftSize:Math.pow(2,11),minDecibels:-96,maxDecibels:0,smoothingTimeConstant:.85}),k.connect(h),t=new jc(G[2]),L=new jc(G[3]);const p=k.getUI();Z(p.length>1||p[0].items.length>0?0:3);const U=new eo.FaustUI({ui:p,root:N});U.paramChangeByUI=(m,x)=>k==null?void 0:k.setParamValue(m,x),k.setOutputParamHandler((m,x)=>U.paramChangeByDSP(m,x)),d(Vo.from("main",T,"")["process.svg"]),B.style.height=`${Math.max(125,U.minHeight)}px`,N.style.width=U.minWidth*1.25+"px",N.style.height=U.minHeight*1.25+"px"};const d=T=>{D.innerHTML=T;for(const z of D.querySelectorAll("a"))z.onclick=p=>{p.preventDefault();const U=z.href.baseVal,m=hI.fs().readFile("main-svg/"+U,{encoding:"utf8"});d(m)}};let R;const s=()=>{t.renderScope([{analyser:h,style:"rgb(212, 100, 100)",edgeThreshold:.09}]),R=requestAnimationFrame(s)},l=()=>{L.renderSpectrum(h),R=requestAnimationFrame(l)},Z=T=>{for(const[z,p]of i.entries())T===z?(p.classList.add("active"),G[z].classList.add("active")):(p.classList.remove("active"),G[z].classList.remove("active"));T===2?(t.onResize(),R!==void 0&&cancelAnimationFrame(R),R=requestAnimationFrame(s)):T===3?(L.onResize(),R!==void 0&&cancelAnimationFrame(R),R=requestAnimationFrame(l)):R!==void 0&&(cancelAnimationFrame(R),R=void 0)};for(const[T,z]of i.entries())z.onclick=()=>Z(T);E.onclick=()=>{k!==void 0&&(k.disconnect(),k.destroy(),k=void 0,E.disabled=!0)};const b=this.shadowRoot.querySelector("#audio-input"),H=T=>{if(!b.disabled){for(;b.lastChild;)b.lastChild.remove();for(const z of T)z.kind==="audioinput"&&b.appendChild(new Option(z.label||z.deviceId,z.deviceId));b.appendChild(new Option("Audio File","Audio File"))}};bE.push(H);const F=async()=>{const T=b.value,z=await navigator.mediaDevices.getUserMedia({audio:{deviceId:T,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});if(a&&(a.disconnect(),a=void 0),k&&k.numberOfInputs>0)if(T=="Audio File")try{const U=document.querySelector('script[src$="faust-web-component.js"]').src,m=U.substring(0,U.lastIndexOf("/")+1),r=await(await fetch(m+"02-XYLO1.mp3")).arrayBuffer();let J=await HA.decodeAudioData(r);e=HA.createBufferSource(),e.buffer=J,e.connect(k),e.start()}catch(p){console.error("Error loading file: ",p)}else e!==void 0&&(e.stop(),e.disconnect(),e=void 0),a=HA.createMediaStreamSource(z),a.connect(k)};b.onchange=F}}const pc=document.createElement("template");pc.innerHTML=`
|
1864
1864
|
<div id="root">
|
1865
1865
|
<div id="controls">
|
1866
1866
|
<button title="On/off" class="button" id="power" disabled>${AI({prefix:"fas",iconName:"power-off"}).html[0]}</button>
|
@@ -1947,5 +1947,5 @@ const dependencies = {
|
|
1947
1947
|
|
1948
1948
|
${Fo}
|
1949
1949
|
</style>
|
1950
|
-
`;class Ch extends HTMLElement{constructor(){super()}connectedCallback(){const A=this.innerHTML.replace("<!--","").replace("-->","").trim();this.attachShadow({mode:"open"}).appendChild(pc.content.cloneNode(!0));const g=this.shadowRoot.querySelector("#power"),B=this.shadowRoot.querySelector("#faust-ui");TC.then(()=>g.disabled=!1);let C=!1,Q=!1,E=-1,N,D,o,M,i;const G=async()=>{await TC,await FC.compile(hI,"main",A,"");const a=FC.getMeta();let{midi:h,nvoices:t}=_o(a);Q=h,E=t,M=t>0?vo():Xo(),await M.compile(hI,"main",A,"");const L=M.getUI();o=new eo.FaustUI({ui:L,root:B}),B.style.width=o.minWidth*1.25+"px",B.style.height=o.minHeight*1.25+"px",o.resize()},c=async()=>{HA.state==="suspended"&&await HA.resume(),N===void 0&&(E>0?N=await M.createNode(HA,E):N=await M.createNode(HA)),Q&&Po(qo(N)).then(()=>{console.log("Successfully connected to the MIDI device.")}).catch(a=>{console.error("Error accessing MIDI device:",a.message)}),o.paramChangeByUI=(a,h)=>N==null?void 0:N.setParamValue(a,h),N.setOutputParamHandler((a,h)=>o.paramChangeByDSP(a,h)),N.numberOfInputs>0?(w.disabled=!1,Y(await fo()),await k()):(w.disabled=!0,w.innerHTML="<option>Audio input</option>"),N.connect(HA.destination),g.style.color="#ffa500"},S=()=>{N==null||N.disconnect(),g.style.color="#fff"};g.onclick=()=>{C?S():c(),C=!C};const w=this.shadowRoot.querySelector("#audio-input"),Y=a=>{if(!w.disabled){for(;w.lastChild;)w.lastChild.remove();for(const h of a)h.kind==="audioinput"&&w.appendChild(new Option(h.label||h.deviceId,h.deviceId));w.appendChild(new Option("Audio File","Audio File"))}};bE.push(Y);const k=async()=>{const a=w.value,h=await navigator.mediaDevices.getUserMedia({audio:{deviceId:a,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});if(D&&(D.disconnect(),D=void 0),N&&N.numberOfInputs>0)if(a=="Audio File")try{const L=document.querySelector('script[src$="faust-web-component.js"]').src,y=L.substring(0,L.lastIndexOf("/")+1),e=await(await fetch(y+"02-XYLO1.mp3")).arrayBuffer();let d=await HA.decodeAudioData(e);i=HA.createBufferSource(),i.buffer=d,i.connect(N),i.start()}catch(t){console.error("Error loading file: ",t)}else i!==void 0&&(i.stop(),i.disconnect(),i=void 0),D=HA.createMediaStreamSource(h),D.connect(N)};w.onchange=k,G()}}customElements.define("faust-editor",Bh),customElements.define("faust-widget",Ch);const nc=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}))})();
|
1950
|
+
`;class Ch extends HTMLElement{constructor(){super()}connectedCallback(){const A=this.innerHTML.replace("<!--","").replace("-->","").trim();this.attachShadow({mode:"open"}).appendChild(pc.content.cloneNode(!0));const g=this.shadowRoot.querySelector("#power"),B=this.shadowRoot.querySelector("#faust-ui");TC.then(()=>g.disabled=!1);let C=!1,Q=!1,E=-1,N,D,o,M,i;const G=async()=>{await TC,await FC.compile(hI,"main",A,"");const a=FC.getMeta();let{midi:h,nvoices:t}=_o(a);Q=h,E=t,M=t>0?vo():Xo(),await M.compile(hI,"main",A,"-ftz 2");const L=M.getUI();o=new eo.FaustUI({ui:L,root:B}),B.style.width=o.minWidth*1.25+"px",B.style.height=o.minHeight*1.25+"px",o.resize()},c=async()=>{HA.state==="suspended"&&await HA.resume(),N===void 0&&(E>0?N=await M.createNode(HA,E):N=await M.createNode(HA)),Q&&Po(qo(N)).then(()=>{console.log("Successfully connected to the MIDI device.")}).catch(a=>{console.error("Error accessing MIDI device:",a.message)}),o.paramChangeByUI=(a,h)=>N==null?void 0:N.setParamValue(a,h),N.setOutputParamHandler((a,h)=>o.paramChangeByDSP(a,h)),N.numberOfInputs>0?(w.disabled=!1,Y(await fo()),await k()):(w.disabled=!0,w.innerHTML="<option>Audio input</option>"),N.connect(HA.destination),g.style.color="#ffa500"},S=()=>{N==null||N.disconnect(),g.style.color="#fff"};g.onclick=()=>{C?S():c(),C=!C};const w=this.shadowRoot.querySelector("#audio-input"),Y=a=>{if(!w.disabled){for(;w.lastChild;)w.lastChild.remove();for(const h of a)h.kind==="audioinput"&&w.appendChild(new Option(h.label||h.deviceId,h.deviceId));w.appendChild(new Option("Audio File","Audio File"))}};bE.push(Y);const k=async()=>{const a=w.value,h=await navigator.mediaDevices.getUserMedia({audio:{deviceId:a,echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}});if(D&&(D.disconnect(),D=void 0),N&&N.numberOfInputs>0)if(a=="Audio File")try{const L=document.querySelector('script[src$="faust-web-component.js"]').src,y=L.substring(0,L.lastIndexOf("/")+1),e=await(await fetch(y+"02-XYLO1.mp3")).arrayBuffer();let d=await HA.decodeAudioData(e);i=HA.createBufferSource(),i.buffer=d,i.connect(N),i.start()}catch(t){console.error("Error loading file: ",t)}else i!==void 0&&(i.stop(),i.disconnect(),i=void 0),D=HA.createMediaStreamSource(h),D.connect(N)};w.onchange=k,G()}}customElements.define("faust-editor",Bh),customElements.define("faust-widget",Ch);const nc=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}))})();
|
1951
1951
|
//# sourceMappingURL=faust-web-component.js.map
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@grame/faust-web-component",
|
3
3
|
"description": "Web component embedding the Faust Compiler",
|
4
|
-
"version": "0.2.
|
4
|
+
"version": "0.2.36",
|
5
5
|
"module": "dist/faust-web-component.js",
|
6
6
|
"files": [
|
7
7
|
"src/",
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"@codemirror/legacy-modes": "^6.3.3",
|
43
43
|
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
44
44
|
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
45
|
-
"@grame/faustwasm": "^0.0.
|
45
|
+
"@grame/faustwasm": "^0.0.59",
|
46
46
|
"@shren/faust-ui": "^1.1.5",
|
47
47
|
"codemirror": "^6.0.1",
|
48
48
|
"split.js": "^1.6.5"
|
package/src/faust-editor.ts
CHANGED
@@ -287,7 +287,7 @@ export default class FaustEditor extends HTMLElement {
|
|
287
287
|
|
288
288
|
// Build the generator
|
289
289
|
generator = nvoices > 0 ? get_poly_generator() : get_mono_generator();
|
290
|
-
await generator.compile(compiler, "main", code, "");
|
290
|
+
await generator.compile(compiler, "main", code, "-ftz 2");
|
291
291
|
|
292
292
|
} catch (e: any) {
|
293
293
|
setError(editor, e)
|
package/src/faust-widget.ts
CHANGED
@@ -130,7 +130,7 @@ export default class FaustWidget extends HTMLElement {
|
|
130
130
|
|
131
131
|
// Build the generator and generate UI
|
132
132
|
generator = nvoices > 0 ? get_poly_generator() : get_mono_generator();
|
133
|
-
await generator.compile(compiler, "main", code, "");
|
133
|
+
await generator.compile(compiler, "main", code, "-ftz 2");
|
134
134
|
const ui = generator.getUI();
|
135
135
|
|
136
136
|
faustUI = new FaustUI({ ui, root: faustUIRoot });
|