|
Mostra de codi amb Web Audio i Web Midi (orgue de Cadaquers) Tots els elements necessaris són en aquest script: https://www.casacota.net/mostres/cadaquers/index.atm Per a fer instruments nous és un bon punt de partida atès que totes les funcions necessàries hi són presents. |
|
screenshot_2026-04-19_09_19_43_0001.png![]() |
|
El codi Javascript del nucli (naturalment sense les imatges ni mostres de so que són a http://www.casacota.net/mostres/cadaquers/index.atm)
Code: <!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=1024"><META NAME="Keywords" CONTENT="midi, historic,organ,virtual,online,sampler"><meta name="description" content="sampled virtual historic organ online">
<META HTTP-EQUIV="Cache-Control" CONTENT="max-age=31536000">
<title>Orgue de Santa Maria de Cadaquers, 1689-1691 Josep Boscà i Serinyena</title>
<style>
#keys .activekey{
background: #ff7f50;
}
#keys1 .activekey{
background: #ff7f50;
}
#keys0 .activekey{
background: #ff7f50;
}
body{
font-family: Verdana;
}
#kb{
margin: 0 auto;
width: 1200px;
}
.logo{
font-family: Verdana;
font-style: normal;
text-align: center;
}
.fullscreen .logo,
.fullscreen #options{
display: none;
}
body.fullscreen{
background: black;
}
#options{
text-align: center;
}
ul{
list-style: none;
overflow: auto;
padding-bottom: 10px;
padding-left: 1px;
position: relative;
width: 1200px;
}
li{
align-items: flex-end;
display: flex;
float: left;
justify-content: center;
padding-bottom: 24px;
position: relative;
font-size: 18px;
text-align: center;
-moz-user-select: none;
user-select: none;
}
li:first-child{
margin-left: 0;
}
.white + .white{
margin-left: 1px;
}
#keys0.labels{
display: flex;
align-items: center;
gap: 90px; /* separació horitzontal neta */
list-style: none; /* treu punts de llista */
padding: 0;
margin: 0;
line-height: normal;
transform: none; /* per si alguna regla el deformava */
}
/* 2) Cada tecla com a cercle perfecte */
#keys0.labels .whitep{
width: 50px;
height: 50px; /* mateix valor que width */
aspect-ratio: 1 / 1; /* reforç 1:1 (si el navegador ho suporta) */
border-radius: 50%;
display: inline-flex; /* mida pròpia, no s’estira */
align-items: center;
justify-content: center;
background: brown;
opacity: 0.5;
border: 1px solid #ccc;
box-shadow: 0 1px 5px rgba(0,0,0,0.7);
margin: 0; /* la separació la fa el gap del contenidor */
padding: 0; /* evita oval per padding */
box-sizing: content-box;
}
/* (Opcional) Ajust del text dins la tecla */
#keys0.labels .whitep .notename,
#keys0.labels .whitep .keyname{
pointer-events: none;
font-size: 10px;
line-height: 1;
}
.white{
background: ivory;
opacity: 0.5;
border-radius: 0 0 5px 5px;
border: 1px solid #ccc;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
height: 90px;
margin-left: -15px;
width: 40px;
color: #222;
}
.black{
# background: linear-gradient(3deg, rgb(0, 0, 0), rgb(100, 100, 100) 90%);
opacity: 0.5;
background: sienna;
border-color: #666 #222 #111 #555;
border-radius: 0 0 2px 2px;
border-style: solid;
border-width: 1px 2px 7px;
height: 40px;
margin-left: -14px;
position: relative;
width: 26px;
z-index: 1;
color: #ddd;
left: 0;
}
.whitep{
background: ivory;
opacity: 0.5;
border-radius: 50%;
border: 1px solid #ccc;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.7);
height: 20px;
width: 20px;
margin: 0 36px;
color: #222;
}
.blackp{
# background: linear-gradient(3deg, rgb(0, 0, 0), rgb(100, 100, 100) 90%);
opacity: 0.5;
background: sienna;
border-color: #666 #222 #111 #555;
border-radius: 0 0 2px 2px;
border-style: solid;
border-width: 1px 2px 7px;
height: 40px;
margin-left: 5px;
position: relative;
width: 10px;
z-index: 1;
color: #ddd;
left: 0;
}
.notename,
.keyname{
display: none !important;
}
.labels .notename,
.keylabels .keyname{
display: initial;
}
#keys .activekey{
border-bottom-width: 1px;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}
#keys1 .activekey{
border-bottom-width: 1px;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}
#keys0 .activekey{
border-bottom-width: 1px;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}
#opts{
display: none;
text-align: left;
}
#toolbar{
cursor: pointer;
font-size: 24px;
}
#toolbar:-webkit-full-screen{
display: none;
}
#labels,
#keylabels{
font-size: 20px;
}
#color{
width: 20px;
height: 20px;
border: none;
padding: 2px;
}
label,
input{
cursor: pointer;
}
.soundon #soundisyes,
#soundisnot{
display: inline;
}
#soundisyes,
.soundon #soundisnot{
display: none;
}
#loading-info{
font-family: Verdana;
color: red;
font-size: 14px;
font-weight: bold;
margin-top: 20px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px;
background-color: white;
border: 2px solid black;
z-index: 1000;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
font-size: 16px;
text-align: center;
}
#keys0.labels .whitep .notenamep{
display: block !important;
font-size: 24px;
font-weight: bold;
pointer-events: none;
}
#keys0.labels .whitep .keyname{
display: none !important;
}
#effects-overlay{
position: fixed;
inset: 0;
pointer-events: none;
z-index: 999;
overflow: hidden;
}
/* Element genèric: bombolla o caramel */
.fx-item{
position: absolute;
top: -60px;
opacity: 0;
will-change: transform, opacity;
animation: fx-fall var(--dur, 8s) linear forwards;
}
/* Caiguda amb oscil·lació */
@keyframes fx-fall{
0%{transform: translate(0, -10vh) scale(1); opacity: 0;}
10%{opacity: .8;}
25%{transform: translate(-20px, 20vh) scale(1.05);}
50%{transform: translate( 12px, 55vh) scale(1.08);}
75%{transform: translate( -8px, 85vh) scale(1.12);}
100%{transform: translate( 0px, 105vh) scale(1.15); opacity: 0;}
}
/* Bombolles */
.fx-bubble{
border-radius: 50%;
background: rgba(180,220,255,0.75); /* abans 0.45 */
box-shadow: 0 0 8px rgba(160,200,255,0.8) inset; /* més intens */
}
/* llaminadures */
.fx-candy{
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
/* Mode teclat únic */
.single-manual #keys1,
.single-manual #keys0 {
display: none !important;
}
</style>
</head>
<!--<body background="../imatges/fonsfust.jpg" onload="myFunction()">-->
<body background="../imatges/fonsfust.jpg">
<div id="kb">
<h4 class="logo"><button onclick="unloadSampleBuffers();history.back();">tornar a la sala</button> Orgue de Santa Maria de Cadaquers, 1689-1691 Josep Boscà i Serinyena <button onclick="unloadSampleBuffers();location.reload()";>buidar memòria i recarregar</button> <img SRC="../documents/infob.png" data-doc="../documents/cadaquers.atm"></h4>
<center><table style="background-color:ivory;"><tr><td><font size="-2"><input type="radio" id="MeanTone 1/4" name="temperament" value="MeanTone 1/4" checked /><label for="MeanTone 1/4">MeanTone 1/4</label> <input type="radio" id="proportional" name="temperament" value="proportional" /><label for="proportional">proportional</label> <input type="radio" id="Zwolle MeanTone" name="temperament" value="Zwolle MeanTone" /><label for="Zwolle MeanTone">Zwolle MeanTone</label> <input type="radio" id="1/3 comma MeanTone" name="temperament" value="1/3 comma MeanTone" /><label for="1/3 comma MeanTone">1/3 comma MeanTone</label> <input type="radio" id="1/6 comma MeanTone" name="temperament" value="1/6 comma MeanTone" /><label for="1/6 comma MeanTone">1/6 comma MeanTone</label> <input type="radio" id="1/9 comma MeanTone" name="temperament" value="1/9 comma MeanTone" /><label for="1/9 comma MeanTone">1/9 comma MeanTone</label> <input type="radio" id="Werckmeister III" name="temperament" value="Werckmeister III" /><label for="Werckmeister III">Werckmeister III</label> <input type="radio" id="Kirnberger" name="temperament" value="Kirnberger" /><label for="Kirnberger">Kirnberger</label></font></td><td><font size="-2">A=<select name="afina" size="1"><option id="392" value="392">392<option id="415" value="415">415<option selected id="440" value="440">440<option id="442" value="442">442<option id="466" value="466">466<option id="493" value="493">493</select> Hz</font></td></tr></table></center>
<div id="kb">
<ul id="keys" class="labels">
<li class="white" id="midi-36"><span class="notename">C</span><span class="keyname"></span></li>
<li class="white" id="midi-41"><span class="notename">F</span><span class="keyname"></span></li>
<li class="black" id="midi-38"><span class="notename">D<br></span><span class="keyname"></span></li>
<li class="white" id="midi-43"><span class="notename">G</span><span class="keyname"></span></li>
<li class="black" id="midi-40"><span class="notename">E<br></span><span class="keyname"></span></li>
<li class="white" id="midi-45"><span class="notename">A2</span><span class="keyname"></span></li>
<li class="black" id="midi-46"><span class="notename">A?<br>B?</span><span class="keyname"></span></li>
<li class="white" id="midi-47"><span class="notename">B</span><span class="keyname"></span></li>
<li class="white" id="midi-48"><span class="notename">C</span><span class="keyname">z</span></li>
<li class="black" id="midi-49"><span class="notename">C?<br>D?</span><span class="keyname">s</span></li>
<li class="white" id="midi-50"><span class="notename">D</span><span class="keyname">x</span></li>
<li class="black" id="midi-51"><span class="notename">D?<br>E?</span><span class="keyname">d</span></li>
<li class="white" id="midi-52"><span class="notename">E</span><span class="keyname">c</span></li>
<li class="white" id="midi-53"><span class="notename">F</span><span class="keyname">v</span></li>
<li class="black" id="midi-54"><span class="notename">F?<br>G?</span><span class="keyname">g</span></li>
<li class="white" id="midi-55"><span class="notename">G</span><span class="keyname">b</span></li>
<li class="black" id="midi-56"><span class="notename">G?<br>A?</span><span class="keyname">h</span></li>
<li class="white" id="midi-57"><span class="notename">A3</span><span class="keyname">n</span></li>
<li class="black" id="midi-58"><span class="notename">A?<br>B?</span><span class="keyname">j</span></li>
<li class="white" id="midi-59"><span class="notename">B</span><span class="keyname">m</span></li>
<li class="white" id="midi-60"><span class="notename">C</span><span class="keyname">q</span></li>
<li class="black" id="midi-61"><span class="notename">C?<br>D?</span><span class="keyname">2</span></li>
<li class="white" id="midi-62"><span class="notename">D</span><span class="keyname">w</span></li>
<li class="black" id="midi-63"><span class="notename">D?<br>E?</span><span class="keyname">3</span></li>
<li class="white" id="midi-64"><span class="notename">E</span><span class="keyname">e</span></li>
<li class="white" id="midi-65"><span class="notename">F</span><span class="keyname">r</span></li>
<li class="black" id="midi-66"><span class="notename">F?<br>G?</span><span class="keyname">5</span></li>
<li class="white" id="midi-67"><span class="notename">G</span><span class="keyname">t</span></li>
<li class="black" id="midi-68"><span class="notename">G?<br>A?</span><span class="keyname">6</span></li>
<li class="white" id="midi-69"><span class="notename">A4</span><span class="keyname">y</span></li>
<li class="black" id="midi-70"><span class="notename">A?<br>B?</span><span class="keyname">7</span></li>
<li class="white" id="midi-71"><span class="notename">B</span><span class="keyname">u</span></li>
<li class="white" id="midi-72"><span class="notename">C</span><span class="keyname">i</span></li>
<li class="black" id="midi-73"><span class="notename">C?<br>D?</span><span class="keyname">9</span></li>
<li class="white" id="midi-74"><span class="notename">D</span><span class="keyname">o</span></li>
<li class="black" id="midi-75"><span class="notename">D?<br>E?</span><span class="keyname">0</span></li>
<li class="white" id="midi-76"><span class="notename">E</span><span class="keyname">p</span></li>
<li class="white" id="midi-77"><span class="notename">F</span><span class="keyname"></span></li>
<li class="black" id="midi-78"><span class="notename">F?<br>G?</span><span class="keyname"></span></li>
<li class="white" id="midi-79"><span class="notename">G</span><span class="keyname"></span></li>
<li class="black" id="midi-80"><span class="notename">G?<br>A?</span><span class="keyname"></span></li>
<li class="white" id="midi-81"><span class="notename">A5</span><span class="keyname"></span></li>
<li class="black" id="midi-82"><span class="notename">A?<br>B?</span><span class="keyname"></span></li>
<li class="white" id="midi-83"><span class="notename">B</span><span class="keyname"></span></li>
<li class="white" id="midi-84"><span class="notename">C</span><span class="keyname"></span></li>
</ul>
</div>
<div id="kb">
<ul id="keys1" class="labels">
<li class="white" id="midi1-36"><span class="notename">C</span><span class="keyname"></span></li>
<li class="white" id="midi1-41"><span class="notename">F</span><span class="keyname"></span></li>
<li class="black" id="midi1-38"><span class="notename">D<br></span><span class="keyname"></span></li>
<li class="white" id="midi1-43"><span class="notename">G</span><span class="keyname"></span></li>
<li class="black" id="midi1-40"><span class="notename">E<br></span><span class="keyname"></span></li>
<li class="white" id="midi1-45"><span class="notename">A2</span><span class="keyname"></span></li>
<li class="black" id="midi1-46"><span class="notename">A?<br>B?</span><span class="keyname"></span></li>
<li class="white" id="midi1-47"><span class="notename">B</span><span class="keyname"></span></li>
<li class="white" id="midi1-48"><span class="notename">C</span><span class="keyname">z</span></li>
<li class="black" id="midi1-49"><span class="notename">C?<br>D?</span><span class="keyname">s</span></li>
<li class="white" id="midi1-50"><span class="notename">D</span><span class="keyname">x</span></li>
<li class="black" id="midi1-51"><span class="notename">D?<br>E?</span><span class="keyname">d</span></li>
<li class="white" id="midi1-52"><span class="notename">E</span><span class="keyname">c</span></li>
<li class="white" id="midi1-53"><span class="notename">F</span><span class="keyname">v</span></li>
<li class="black" id="midi1-54"><span class="notename">F?<br>G?</span><span class="keyname">g</span></li>
<li class="white" id="midi1-55"><span class="notename">G</span><span class="keyname">b</span></li>
<li class="black" id="midi1-56"><span class="notename">G?<br>A?</span><span class="keyname">h</span></li>
<li class="white" id="midi1-57"><span class="notename">A3</span><span class="keyname">n</span></li>
<li class="black" id="midi1-58"><span class="notename">A?<br>B?</span><span class="keyname">j</span></li>
<li class="white" id="midi1-59"><span class="notename">B</span><span class="keyname">m</span></li>
<li class="white" id="midi1-60"><span class="notename">C</span><span class="keyname">q</span></li>
<li class="black" id="midi1-61"><span class="notename">C?<br>D?</span><span class="keyname">2</span></li>
<li class="white" id="midi1-62"><span class="notename">D</span><span class="keyname">w</span></li>
<li class="black" id="midi1-63"><span class="notename">D?<br>E?</span><span class="keyname">3</span></li>
<li class="white" id="midi1-64"><span class="notename">E</span><span class="keyname">e</span></li>
<li class="white" id="midi1-65"><span class="notename">F</span><span class="keyname">r</span></li>
<li class="black" id="midi1-66"><span class="notename">F?<br>G?</span><span class="keyname">5</span></li>
<li class="white" id="midi1-67"><span class="notename">G</span><span class="keyname">t</span></li>
<li class="black" id="midi1-68"><span class="notename">G?<br>A?</span><span class="keyname">6</span></li>
<li class="white" id="midi1-69"><span class="notename">A4</span><span class="keyname">y</span></li>
<li class="black" id="midi1-70"><span class="notename">A?<br>B?</span><span class="keyname">7</span></li>
<li class="white" id="midi1-71"><span class="notename">B</span><span class="keyname">u</span></li>
<li class="white" id="midi1-72"><span class="notename">C</span><span class="keyname">i</span></li>
<li class="black" id="midi1-73"><span class="notename">C?<br>D?</span><span class="keyname">9</span></li>
<li class="white" id="midi1-74"><span class="notename">D</span><span class="keyname">o</span></li>
<li class="black" id="midi1-75"><span class="notename">D?<br>E?</span><span class="keyname">0</span></li>
<li class="white" id="midi1-76"><span class="notename">E</span><span class="keyname">p</span></li>
<li class="white" id="midi1-77"><span class="notename">F</span><span class="keyname"></span></li>
<li class="black" id="midi1-78"><span class="notename">F?<br>G?</span><span class="keyname"></span></li>
<li class="white" id="midi1-79"><span class="notename">G</span><span class="keyname"></span></li>
<li class="black" id="midi1-80"><span class="notename">G?<br>A?</span><span class="keyname"></span></li>
<li class="white" id="midi1-81"><span class="notename">A5</span><span class="keyname"></span></li>
</ul>
</div>
<div id="kb">
<ul id="keys0" class="labels">
<li class="whitep" id="midi0-36"><span class="notenamep">C</span><span class="keyname">C</span></li>
<li class="whitep" id="midi0-38"><span class="notenamep">D</span><span class="keyname">D</span></li>
<li class="whitep" id="midi0-40"><span class="notenamep">E</span><span class="keyname">E</span></li>
<li class="whitep" id="midi0-41"><span class="notenamep">F</span><span class="keyname">F</span></li>
<li class="whitep" id="midi0-43"><span class="notenamep">G</span><span class="keyname">G</span></li>
<li class="whitep" id="midi0-45"><span class="notenamep">A</span><span class="keyname">A</span></li>
<li class="whitep" id="midi0-46"><span class="notenamep">B?</span><span class="keyname">B?</span></li>
<li class="whitep" id="midi0-47"><span class="notenamep">B</span><span class="keyname">B</span></li>
</ul>
<font size="-2" color="maroon">Assignació de canals MIDI: <select id="ordre" name="ordre" size="1"><option id="011" selected value="011">Teclat únic: OM.1 Cad.1 No Ped.<option id="123" value="123">Ped.1 OM.2 Cad.3<option id="213" value="213">Ped.2 OM.1 Cad.3<option id="231" value="231">Ped.2 OM.3 Cad.1<option id="312" value="312">Ped.3 OM.1 Cad.2<option id="321" value="321">Ped.3 OM.2 Cad.1</select></font>
<center><button id="reactiva-audio" style="display: none; background: #ffe; border: 1px solid #999; padding: 6px 12px; font-size: 14px;">?? El so està aturat. Fes clic per a activar-lo.</button></center>
<div id="options">
<div id="toolbar">
<center><table>
<tr>
<td valign="top" width=100>
<font size="-1" color="navy">
<input type="checkbox" id="xirimia" style="position: absolute;opacity: 0.8;"><label for="xirimia"><img src="on15.gif">xirimia</label><br>
<input type="checkbox" id="baixons" style="position: absolute;opacity: 0.8;"><label for="baixons"><img src="on15.gif">baixons</label><br>
</font>
</td>
<td valign="top" width=100>
<font size="-1" color="blue">CADIRETA<br>
<input type="checkbox" id="cimbalet_c" style="position: absolute;opacity: 0.8;"><label for="cimbalet_c"><img src="on15.gif">cimbalet</label><br>
<input type="checkbox" id="vintidosena_i_vintisisena_c" style="position: absolute;opacity: 0.8;"><label for="vintidosena_i_vintisisena_c"><img src="on15.gif">22-26a</label><br>
<input type="checkbox" id="nasard19a_c" style="position: absolute;opacity: 0.8;"><label for="nasard_19a_c"><img src="on15.gif"><font color="maroon">19a_N</font></label><br>
<input type="checkbox" id="dinovena_c" style="position: absolute;opacity: 0.8;"><label for="dinovena_c"><img src="on15.gif">19a</label><br>
<input type="checkbox" id="quinzena_c" style="position: absolute;opacity: 0.8;"><label for="quinzena_c"><img src="on15.gif">15a</label><br>
<input type="checkbox" id="tapadet_c" style="position: absolute;opacity: 0.8;"><label for="tapadet_c"><img src="on15.gif"><font color="maroon">tapadet</font></label><br>
<input type="checkbox" id="octava_c" style="position: absolute;opacity: 0.8;"><label for="octava_c"><img src="on15.gif">8a</label><br>
<input type="checkbox" id="bordo_c" style="position: absolute;opacity: 0.8;"><label for="bordo_c"><img src="on15.gif"><font color="maroon">bordó</font></label><br>
</font>
</td>
<td align="center" valign="top"><img src="cadaquers_6.png">
<table><tr><td>
<!--<font size="-1" color="blue"><input type="checkbox" id="contresmajor" style="position: absolute;opacity: 0.8;"> <label for="contresmajor"><img src="../imatges/on15.gif">P-I</label> <input type="checkbox" id="contrespositiu" style="position: absolute;opacity: 0.8;"> <label for="contrespositiu"><img src="../imatges/on15.gif">P-II</label> <input type="checkbox" id="majorpositiu" style="position: absolute;opacity: 0.8;"> <label for="majorpositiu"><img src="../imatges/on15.gif">I-II</label>
</font>-->
</td></tr></table>
<div id="loading-info">Carregant...</div>
</center></td>
<td valign="top" width=100><br><br><br><br><br><br><br>
<font size="-1" color="blue"><input type="checkbox" id="tremor" style="position: absolute;opacity: 0.8;"><label for="tremor"><img src="on15.gif">trèmol</label></font>
</td>
<td valign="top" width=100>
<font size="-1" color="blue">O R G U E<hr>
<input type="checkbox" id="corneta" style="position: absolute;opacity: 0.8;"><label for="corneta"><img src="on15.gif">corneta</label><br>
<input type="checkbox" id="ple" style="position: absolute;opacity: 0.8;"><label for="ple"><img src="on15.gif">ple</label><br>
<input type="checkbox" id="dinovena" style="position: absolute;opacity: 0.8;"><label for="dinovena"><img src="on15.gif">19a</label><br>
<input type="checkbox" id="nasard15" style="position: absolute;opacity: 0.8;"><label for="nasard15"><img src="on15.gif"><font color="maroon">15a_N</font></label><br>
<input type="checkbox" id="tapadet" style="position: absolute;opacity: 0.8;"><label for="tapadet"><img src="on15.gif"><font color="maroon">tapadet</font></label><br>
<input type="checkbox" id="dotzena" style="position: absolute;opacity: 0.8;"><label for="dotzena"><img src="on15.gif">12a<label><br>
<input type="checkbox" id="nasard17" style="position: absolute;opacity: 0.8;"><label for="nasard17"><img src="on15.gif"><font color="maroon">17a_N</font></label><br>
</font>
</td>
<td valign="top" width=100>
<font size="-1" color="blue">M A J O R<hr>
<input type="checkbox" id="cimbalet" style="position: absolute;opacity: 0.8;"><label for="cimbalet"><img src="on15.gif">cimbalet</label><br>
<input type="checkbox" id="vintidosena" style="position: absolute;opacity: 0.8;"><label for="vintidosena"><img src="on15.gif">22a</label><br>
<input type="checkbox" id="octava" style="position: absolute;opacity: 0.8;"><label for="octava"><img src="on15.gif">8a</label><br>
<input type="checkbox" id="nasard12" style="position: absolute;opacity: 0.8;"><label for="nasard12"><img src="on15.gif"><font color="maroon">12a_N</font></label><br>
<input type="checkbox" id="quinzena" style="position: absolute;opacity: 0.8;"><label for="quinzena"><img src="on15.gif">15a</label><br>
<input type="checkbox" id="bordo" style="position: absolute;opacity: 0.8;"><label for="bordo"><img src="on15.gif"><font color="maroon">bordó</font><label><br>
<input type="checkbox" id="flautat" style="position: absolute;opacity: 0.8;"><label for="flautat"><img src="on15.gif">flautat</label><br>
</font>
</td>
<td valign="top" width=100>
<font size="-1" color="navy">
<input type="checkbox" id="trompeta" style="position: absolute;opacity: 0.8;"><label for="trompeta"><img src="on15.gif">trompeta</label><br>
<input type="checkbox" id="clarins" style="position: absolute;opacity: 0.8;"><label for="clarins"><img src="on15.gif">clarins</label><br><br><br>
<input type="checkbox" id="ocells" style="position: absolute;opacity: 0.8;"><label for="ocells"><img src="on15.gif">ocells</label><br><br>
<label for="llaminadures"><img src="on15.gif" onClick="llaminadures();">llaminadures</label><br><br><br>
<table><tr><td width=50><input type="checkbox" id="gaita" style="position: absolute;opacity: 0.8;"><label for="gaita"><img src="on15.gif">gaita gallega</label></td><td><font size="-2">Nota bordons:<br>
<select id="bordons" name="bordons" size="1">
<option value="C" selected>C</option>
<option value="D">D</option>
<!-- <option value="E">E</option>
<option value="F">F</option>
<option value="G">G</option>
<option value="A">A</option>-->
</select>
</font></td></tr></table></td>
<td valign="top" width=100>
<table border=2"><tr><td>
<font size="+1" color="black">Combinacions ràpides ??<hr><br>
<label for="batalla"><img src="on15.gif" onClick="batalla();">batalla</label><hr>
Plens:<br>
<label for="plens_om"><img src="on15.gif" onClick="plens_om();">o. major</label><br>
<label for="plens_c"><img src="on15.gif" onClick="plens_c();">cadireta</label><hr>
<label for="flautes"><img src="on15.gif" onClick="flautes();">flautes</label><br>
<label for="cornetes"><img src="on15.gif" onClick="cornetes();">corneta</label><hr>
<label for="tutti"><img src="on15.gif" onClick="tutti();"><i>tutti</i></label><br>
<label for="muti"><img src="on15.gif" onClick="muti();"><i>muti</i></label><br>
</font>
</td></tr></table>
<font size="-1" color="blue"><br><br><label for="acusticaSelector">Tria l'acústica:</label>
<select id="acusticaSelector"></select><br>
<label for="distanciaSlider">Distància:</label>
<input type="range" id="distanciaSlider" min="0" max="1" step="0.01" value="0.2">
</font>
</td>
</tr></table></center></p>
<font size="-1" color="red"><p><b><i>Poden passar uns quants minuts fins que tots els tubs sonin, depenent de la connexió.</i></p>
<p><i>There may be a delay (minutes!) by page loading before the pipes can sound.</i></b></p></font>
<div id="msg" style="text-align: center; font-size: small; color: darkgreen; margin-top: 20px;"></div>
<span id="showhideoptions" title="Show/hide options">?</span>
</div>
<div id="opts">
<!--<p><input type="checkbox" id="labels" checked="checked"> <label for="labels">show note names: C, A?, etc</label></p>-->
<p><input type="checkbox" id="keylabels"> <label for="keylabels">show computer keys</label></p>
<p><input type="color" id="color" value="#3ac99b"> <label for="color">pick a highlight color</label></p>
<p><input type="checkbox" id="sounds" style="display: none" checked="checked">
<label for="sounds" class="soundon">
<span id="soundisyes">??</span>
<span id="soundisnot">??</span>
play sounds</label>
</p>
<!--<p id="msg"></p>-->
</div>
</div>
</div>
<script>
const audioContext=new (window.AudioContext||window.webkitAudioContext)();
const masterGainNode=audioContext.createGain();
masterGainNode.connect(audioContext.destination);
let dest=audioContext.createMediaStreamDestination();
masterGainNode.connect(dest);
const reverbNode=audioContext.createConvolver();
let registre0=0; // flautat 0
let bufa0={};
let gaita0={};
let bufa0b={};
let gaita0b={};
let registre1=0; // octava_om 100
let bufa1={};
let gaita1={};
let registre2=0; // baixons
let bufa2={};
let gaita2={};
let registre3=0; // clarins
let bufa3={};
let gaita3={};
let registre4=0; // xirimia
let bufa4={};
let gaita4={};
let registre5=0; // trompeta
let bufa5={};
let gaita5={};
let registre6=0; // dotzena
let bufa6={};
let gaita6={};
let registre7=0; // quinzena
let bufa7={};
let gaita7={};
let registre8=0; // dinovena
let bufa8={};
let gaita8={};
let registre9=0; // vintidosena
let bufa9={};
let gaita9={};
let registre10=0; // ple
let bufa10={};
let gaita10={};
let registre11=0; // cimbalet
let bufa11={};
let gaita11={};
let registre12=0; // corneta
let bufa12={};
let gaita12={};
let registre13=0; // bordo
let bufa13={};
let gaita13={};
let registre14=0; // tapadet
let bufa14={};
let gaita14={};
let registre15=0; // nasard12
let bufa15={};
let gaita15={};
let registre16=0; // nasard15
let bufa16={};
let gaita16={};
let registre17=0; // nasard17
let bufa17={};
let gaita17={};
let registre18=0; // bordo_c
let bufa18={};
let gaita18={};
let registre19=0; // octava_c
let bufa19={};
let gaita19={};
let registre20=0; // tapadet_c
let bufa20={};
let gaita20={};
let registre21=0; // quinzena_c
let bufa21={};
let gaita21={};
let registre22=0; // dinovena_c
let bufa22={};
let gaita22={};
let registre23=0; // nasard19a_c
let bufa23={};
let gaita23={};
let registre24=0; // vintidosena_i_vintisisena_c
let bufa24={};
let gaita24={};
let registre25=0; // cimbalet_c
let bufa25={};
let gaita25={};
let registre26=0; //
let bufa26={};
let gaita26={};
let registre27=0; //
let bufa27={};
let gaita27={};
let registre28=0; //
let bufa28={};
let gaita28={};
let registre29=0; //
let bufa29={};
let gaita29={};
let registre31=0; //
let bufa31={};
let gaita31={};
let registre32=1; // contres
let bufa32={};
let gaita32={};
let bufa35={};
let gaita35={};
let sogaita0="";
let sogaita1="";
let sogaita2="";
let sogaita3="";
let sogaita4="";
let sogaita5="";
let sogaita6="";
let sogaita7="";
let sogaita8="";
let sogaita9="";
let sogaita10="";
let sogaita11="";
let sogaita12="";
let sogaita13="";
let sogaita14="";
let sogaita15="";
let sogaita16="";
let sogaita17="";
let sogaita18="";
let sogaita19="";
let sogaita20="";
let sogaita21="";
let sogaita22="";
let sogaita23="";
let sogaita24="";
let sogaita25="";
let sogaita26="";
let sogaita27="";
let sogaita28="";
let sogaita29="";
let sogaita30="";
let sogaita31="";
let sogaita32="";
let sogaita33="";
let sogaita34="";
let sogaita35="";
let sogaita36="";
let sogaita37="";
let sogaita38="";
let sogaita39="";
let distancia=0.25;
let contres=2;
let orguemajor=0;
let positiu=1;
let tremolor=0;
let teclat="";
let nota="";
let acoblament1=1;
let acoblament2=0;
let acoblament3=1;
let expressio=new Array(16).fill(1); // Valor per defecte: 1 (100%)
let loop = 20000;
const samplePaths={
// 36,48,60,72,84
1:'silenci/silenci.mp3',
34:'ocells/ocells.mp3',
35:'gaita/gaita.mp3',
36:'flautatw/36.mp3',
48:'flautatw/48.mp3',
60:'flautatw/60.mp3',
72:'flautatw/72.mp3',
84:'flautatw/84.mp3',
37:'flautatw/36g.mp3',
49:'flautatw/48g.mp3',
61:'flautatw/60g.mp3',
73:'flautatw/72g.mp3',
85:'flautatw/84g.mp3',
136:'octava/36.mp3',
148:'octava/48.mp3',
160:'octava/60.mp3',
172:'octava/72.mp3',
184:'octava/84.mp3',
137:'octava/36g.mp3',
149:'octava/48g.mp3',
161:'octava/60g.mp3',
173:'octava/72g.mp3',
185:'octava/84g.mp3',
236:'baixons/36.mp3',
248:'baixons/48.mp3',
260:'baixons/60.mp3',
360:'clarins/60.mp3',
372:'clarins/72.mp3',
384:'clarins/84.mp3',
237:'baixons/36.mp3',
249:'baixons/48.mp3',
261:'baixons/60.mp3',
361:'clarins/60.mp3',
373:'clarins/72.mp3',
385:'clarins/84.mp3',
436:'xirimia/36.mp3',
448:'xirimia/48.mp3',
460:'xirimia/60.mp3',
560:'trompeta/60.mp3',
572:'trompeta/72.mp3',
584:'trompeta/84.mp3',
437:'xirimia/36.mp3',
449:'xirimia/48.mp3',
461:'xirimia/60.mp3',
561:'trompeta/60.mp3',
573:'trompeta/72.mp3',
585:'trompeta/84.mp3',
636:'dotzena/36.mp3',
648:'dotzena/48.mp3',
660:'dotzena/60.mp3',
672:'dotzena/72.mp3',
684:'dotzena/84.mp3',
637:'dotzena/36g.mp3',
649:'dotzena/48g.mp3',
661:'dotzena/60g.mp3',
673:'dotzena/72g.mp3',
685:'dotzena/84g.mp3',
736:'quinzena/36.mp3',
748:'quinzena/48.mp3',
760:'quinzena/60.mp3',
772:'quinzena/72.mp3',
784:'quinzena/84.mp3',
737:'quinzena/36g.mp3',
749:'quinzena/48g.mp3',
761:'quinzena/60g.mp3',
773:'quinzena/72g.mp3',
785:'quinzena/84g.mp3',
836:'dinovena/36.mp3',
848:'dinovena/48.mp3',
860:'dinovena/60.mp3',
872:'dinovena/72.mp3',
884:'dinovena/84.mp3',
837:'dinovena/36g.mp3',
849:'dinovena/48g.mp3',
861:'dinovena/60g.mp3',
873:'dinovena/72g.mp3',
885:'dinovena/84g.mp3',
936:'vintidosena/36.mp3',
948:'vintidosena/48.mp3',
960:'vintidosena/60.mp3',
972:'vintidosena/72.mp3',
984:'vintidosena/84.mp3',
937:'vintidosena/36g.mp3',
949:'vintidosena/48g.mp3',
961:'vintidosena/60g.mp3',
973:'vintidosena/72g.mp3',
985:'vintidosena/84g.mp3',
1036:'ple/36.mp3',
1048:'ple/48.mp3',
1060:'ple/60.mp3',
1072:'ple/72.mp3',
1084:'ple/84.mp3',
1037:'ple/36g.mp3',
1049:'ple/48g.mp3',
1061:'ple/60g.mp3',
1073:'ple/72g.mp3',
1085:'ple/84g.mp3',
1136:'cimbalet/36.mp3',
1148:'cimbalet/48.mp3',
1160:'cimbalet/60.mp3',
1172:'cimbalet/72.mp3',
1184:'cimbalet/84.mp3',
1137:'cimbalet/36g.mp3',
1149:'cimbalet/48g.mp3',
1161:'cimbalet/60g.mp3',
1173:'cimbalet/72g.mp3',
1185:'cimbalet/84g.mp3',
1260:'corneta/60.mp3',
1272:'corneta/72.mp3',
1284:'corneta/84.mp3',
1261:'corneta/60g.mp3',
1273:'corneta/72g.mp3',
1285:'corneta/84g.mp3',
1336:'bordo/36.mp3',
1348:'bordo/48.mp3',
1360:'bordo/60.mp3',
1372:'bordo/72.mp3',
1384:'bordo/84.mp3',
1337:'bordo/36g.mp3',
1349:'bordo/48g.mp3',
1361:'bordo/60g.mp3',
1373:'bordo/72g.mp3',
1385:'bordo/84g.mp3',
1436:'tapadet/36.mp3',
1448:'tapadet/48.mp3',
1460:'tapadet/60.mp3',
1472:'tapadet/72.mp3',
1484:'tapadet/84.mp3',
1437:'tapadet/36g.mp3',
1449:'tapadet/48g.mp3',
1461:'tapadet/60g.mp3',
1473:'tapadet/72g.mp3',
1485:'tapadet/84g.mp3',
1536:'nasard12/36.mp3',
1548:'nasard12/48.mp3',
1560:'nasard12/60.mp3',
1572:'nasard12/72.mp3',
1584:'nasard12/84.mp3',
1537:'nasard12/36g.mp3',
1549:'nasard12/48g.mp3',
1561:'nasard12/60g.mp3',
1573:'nasard12/72g.mp3',
1585:'nasard12/84g.mp3',
1636:'nasard15/36.mp3',
1648:'nasard15/48.mp3',
1660:'nasard15/60.mp3',
1672:'nasard15/72.mp3',
1684:'nasard15/84.mp3',
1637:'nasard15/36g.mp3',
1649:'nasard15/48g.mp3',
1661:'nasard15/60g.mp3',
1673:'nasard15/72g.mp3',
1685:'nasard15/84g.mp3',
1736:'nasard17/36.mp3',
1748:'nasard17/48.mp3',
1760:'nasard17/60.mp3',
1772:'nasard17/72.mp3',
1784:'nasard17/84.mp3',
1737:'nasard17/36g.mp3',
1749:'nasard17/48g.mp3',
1761:'nasard17/60g.mp3',
1773:'nasard17/72g.mp3',
1785:'nasard17/84g.mp3',
1836:'bordo_c/36.mp3',
1848:'bordo_c/48.mp3',
1860:'bordo_c/60.mp3',
1872:'bordo_c/72.mp3',
1837:'bordo_c/36g.mp3',
1849:'bordo_c/48g.mp3',
1861:'bordo_c/60g.mp3',
1873:'bordo_c/72g.mp3',
1936:'octava_c/36.mp3',
1948:'octava_c/48.mp3',
1960:'octava_c/60.mp3',
1972:'octava_c/72.mp3',
1937:'octava_c/36g.mp3',
1949:'octava_c/48g.mp3',
1961:'octava_c/60g.mp3',
1973:'octava_c/72g.mp3',
2036:'tapadet_c/36.mp3',
2048:'tapadet_c/48.mp3',
2060:'tapadet_c/60.mp3',
2072:'tapadet_c/72.mp3',
2037:'tapadet_c/36g.mp3',
2049:'tapadet_c/48g.mp3',
2061:'tapadet_c/60g.mp3',
2073:'tapadet_c/72g.mp3',
2136:'quinzena_c/36.mp3',
2148:'quinzena_c/48.mp3',
2160:'quinzena_c/60.mp3',
2172:'quinzena_c/72.mp3',
2137:'quinzena_c/36g.mp3',
2149:'quinzena_c/48g.mp3',
2161:'quinzena_c/60g.mp3',
2173:'quinzena_c/72g.mp3',
2236:'dinovena_c/36.mp3',
2248:'dinovena_c/48.mp3',
2260:'dinovena_c/60.mp3',
2272:'dinovena_c/72.mp3',
2237:'dinovena_c/36g.mp3',
2249:'dinovena_c/48g.mp3',
2261:'dinovena_c/60g.mp3',
2273:'dinovena_c/72g.mp3',
2336:'nasard19a_c/36.mp3',
2348:'nasard19a_c/48.mp3',
2360:'nasard19a_c/60.mp3',
2372:'nasard19a_c/72.mp3',
2337:'nasard19a_c/36g.mp3',
2349:'nasard19a_c/48g.mp3',
2361:'nasard19a_c/60g.mp3',
2373:'nasard19a_c/72g.mp3',
2436:'vintidosena_i_vintisisena_c/36.mp3',
2448:'vintidosena_i_vintisisena_c/48.mp3',
2460:'vintidosena_i_vintisisena_c/60.mp3',
2472:'vintidosena_i_vintisisena_c/72.mp3',
2437:'vintidosena_i_vintisisena_c/36g.mp3',
2449:'vintidosena_i_vintisisena_c/48g.mp3',
2461:'vintidosena_i_vintisisena_c/60g.mp3',
2473:'vintidosena_i_vintisisena_c/72g.mp3',
2536:'cimbalet_c/36.mp3',
2548:'cimbalet_c/48.mp3',
2560:'cimbalet_c/60.mp3',
2572:'cimbalet_c/72.mp3',
2537:'cimbalet_c/36g.mp3',
2549:'cimbalet_c/48g.mp3',
2561:'cimbalet_c/60g.mp3',
2573:'cimbalet_c/72g.mp3',
3236:'contres/36.mp3',
3237:'contres/36g.mp3',
};
const sampleBuffers={};
var loadingInfo=document.getElementById('loadingInfo');
let sampleMidi=36;
let sampleMidiv=37;
document.getElementById("ordre").addEventListener("change", function (){
const valor=this.value;
acoblament3=0;
contres=2;
orguemajor=0;
positiu=1;
document.body.classList.remove("single-manual");
if(valor==="011"){
document.body.classList.add("single-manual");
acoblament3=1;
contres=2;
orguemajor=0;
positiu=1;
}else if(valor==="123"){
contres=0;
orguemajor=1;
positiu=2;
}else if(valor==="213"){
contres=1;
orguemajor=0;
positiu=2;
}else if(valor==="231"){
contres=1;
orguemajor=2;
positiu=0;
}else if(valor==="312"){
contres=2;
orguemajor=0;
positiu=1;
}else if(valor==="321"){
contres=2;
orguemajor=1;
positiu=0;
}
});
let meso=-2.1; // per C (selected per defecte)
let _bordonsInit=false; // guard per no duplicar listeners
function _initBordonsIfNeeded(){
// if(_bordonsInit) return;
const sel=document.getElementById('bordons');
if(!sel) return; // si encara no existeix al DOM, ja s’inicialitzarà a la següent crida
const apply=() =>{
switch (sel.value){
case "C": meso=-2.1; break;
case "D": meso=-0.1; break;
case "E": meso=2.1; break;
case "F": meso=-2.1; break;
case "G": meso=4.1; break;
case "A": meso=5.9; break;
}
};
apply(); // valor inicial
sel.addEventListener('change', apply,{passive:true});
_bordonsInit=true;
let suplement=0;
if(document.getElementById("415").selected==true){
suplement=-1;
}else if(document.getElementById("440").selected==true){
suplement=0;
}else if(document.getElementById("442").selected==true){
suplement=0.08;
}else if(document.getElementById("466").selected==true){
suplement=1;
}else if(document.getElementById("493").selected==true){
suplement=2;
}else if(document.getElementById("392").selected==true){
suplement=-2;
}
meso=meso + suplement;
}
function midi2rate(midi){
// NO reiniciïs meso aquí!
if(midi===35){
_initBordonsIfNeeded();
return Math.pow(2, meso / 12);
}
if(midi < 48){
sampleMidi=36;
sampleMidiv=36;
if(midi===37||midi===39||midi===41||midi===43||midi===45||midi===47){
sampleMidi=37;
}
}else if(midi < 60){
sampleMidi=48;
sampleMidiv=48;
if(midi===49||midi===51||midi===53||midi===55||midi===57||midi===59){
sampleMidi=49;
}
}else if(midi < 72){
sampleMidi=60;
sampleMidiv=60;
if(midi===61||midi===63||midi===65||midi===67||midi===69||midi===71){
sampleMidi=61;
}
}else if(midi < 84){
sampleMidi=72;
sampleMidiv=72;
if(midi===73||midi===75||midi===77||midi===79||midi===81||midi===83){
sampleMidi=73;
}
}else{
sampleMidi=84;
sampleMidiv=84;
if(midi===85||midi===87||midi===89||midi===91||midi===93||midi===95){
sampleMidi=85;
}
}
let suplement=0;
if(document.getElementById("415").selected==true){
suplement=-1;
}else if(document.getElementById("440").selected==true){
suplement=0;
}else if(document.getElementById("442").selected==true){
suplement=0.08;
}else if(document.getElementById("466").selected==true){
suplement=1;
}else if(document.getElementById("493").selected==true){
suplement=2;
}else if(document.getElementById("392").selected==true){
suplement=-2;
}
const interval=midi - sampleMidiv;
// return Math.pow(2, interval / 12);
// alert(interval);
meso=interval + suplement;
// alert(interval);
var ch="proportional";
if(document.getElementById("MeanTone 1/4").checked==true){
ch="MeanTone 1/4";
}else if(document.getElementById("Zwolle MeanTone").checked==true){
ch="Zwolle MeanTone";
}else if(document.getElementById("1/3 comma MeanTone").checked==true){
ch="1/3 comma MeanTone";
}else if(document.getElementById("1/6 comma MeanTone").checked==true){
ch="1/6 comma MeanTone";
}else if(document.getElementById("1/9 comma MeanTone").checked==true){
ch="1/9 comma MeanTone";
}else if(document.getElementById("Werckmeister III").checked==true){
ch="Werckmeister III";
}else if(document.getElementById("Kirnberger").checked==true){
ch="Kirnberger";
}
if(ch=="MeanTone 1/4"){
if(interval==1){// c#
meso=meso - 0.24;
}else if(interval==2){// d
meso=meso -0.07;
}else if(interval==3){// d#
meso=meso + 0.10;
}else if(interval==4){// e
meso=meso - 0.14;
}else if(interval==5){// f
meso=meso + 0.03;
}else if(interval==6){// f#
meso=meso - 0.20;
}else if(interval==7){// g
meso=meso - 0.03;
}else if(interval==8){// g#
meso=meso - 0.21;
}else if(interval==9){// a
meso=meso - 0.10;
}else if(interval==10){// a#
meso=meso + 0.07;
}else if(interval==11){// b
meso=meso - 0.17 ;
}
}else if(ch=="Zwolle MeanTone"){
if(interval==1){// c#
meso=meso - 0.09;
}else if(interval==2){// d
meso=meso + 0.02;
}else if(interval==3){// d#
meso=meso - 0.05;
}else if(interval==4){// e
meso=meso + 0.06;
}else if(interval==5){// f
meso=meso - 0.03;
}else if(interval==6){// f#
meso=meso - 0.11;
}else if(interval==7){// g
meso=meso + 0.01;
}else if(interval==8){// g#
meso=meso - 0.06;
}else if(interval==9){// a
meso=meso + 0.03;
}else if(interval==10){// a#
meso=meso - 0.05;
}else if(interval==11){// b
meso=meso + 0.08 ;
}
}else if(ch=="1/3 comma MeanTone"){
if(interval==1){// c#
meso=meso - 0.37;
}else if(interval==2){// d
meso=meso - 0.10;
}else if(interval==3){// d#
meso=meso + 0.16;
}else if(interval==4){// e
meso=meso - 0.21;
}else if(interval==5){// f
meso=meso + 0.05;
}else if(interval==6){// f#
meso=meso - 0.32;
}else if(interval==7){// g
meso=meso - 0.05;
}else if(interval==8){// g#
meso=meso - 0.42;
}else if(interval==9){// a
meso=meso - 0.16;
}else if(interval==10){// a#
meso=meso + 0.10;
}else if(interval==11){// b
meso=meso - 0.25 ;
}
}else if(ch=="1/6 comma MeanTone"){
if(interval==1){// c#
meso=meso - 0.13;
}else if(interval==2){// d
meso=meso - 0.04;
}else if(interval==3){// d#
meso=meso + 0.05;
}else if(interval==4){// e
meso=meso - 0.07;
}else if(interval==5){// f
meso=meso + 0.02;
}else if(interval==6){// f#
meso=meso - 0.11;
}else if(interval==7){// g
meso=meso - 0.02;
}else if(interval==8){// g#
meso=meso - 0.14;
}else if(interval==9){// a
meso=meso - 0.05;
}else if(interval==10){// a#
meso=meso + 0.04;
}else if(interval==11){// b
meso=meso - 0.09 ;
}
}else if(ch=="1/9 comma MeanTone"){
if(interval==1){// c#
meso=meso - 0.04;
}else if(interval==2){// d
meso=meso - 0.01;
}else if(interval==3){// d#
meso=meso + 0.02;
}else if(interval==4){// e
meso=meso - 0.02;
}else if(interval==5){// f
meso=meso + 0.01;
}else if(interval==6){// f#
meso=meso - 0.04;
}else if(interval==7){// g
meso=meso - 0.01;
}else if(interval==8){// g#
meso=meso - 0.05;
}else if(interval==9){// a
meso=meso - 0.02;
}else if(interval==10){// a#
meso=meso + 0.01;
}else if(interval==11){// b
meso=meso - 0.03 ;
}
}else if(ch=="Werckmeister III"){
if(interval==1){// c#
meso=meso - 0.10;
}else if(interval==2){// d
meso=meso - 0.08;
}else if(interval==3){// d#
meso=meso - 0.06;
}else if(interval==4){// e
meso=meso - 0.10;
}else if(interval==5){// f
meso=meso - 0.02;
}else if(interval==6){// f#
meso=meso - 0.12;
}else if(interval==7){// g
meso=meso - 0.04;
}else if(interval==8){// g#
meso=meso - 0.08;
}else if(interval==9){// a
meso=meso - 0.12;
}else if(interval==10){// a#
meso=meso - 0.04;
}else if(interval==11){// b
meso=meso - 0.08 ;
}
}else if(ch=="Kirnberger"){
if(interval==1){// c#
meso=meso - 0.10;
}else if(interval==2){// d
meso=meso - 0.07;
}else if(interval==3){// d#
meso=meso - 0.07;
}else if(interval==4){// e
meso=meso - 0.14;
}else if(interval==5){// f
meso=meso - 0.02;
}else if(interval==6){// f#
meso=meso - 0.12;
}else if(interval==7){// g
meso=meso + 0.02;
}else if(interval==8){// g#
meso=meso - 0.08;
}else if(interval==9){// a
meso=meso - 0.16;
}else if(interval==10){// a#
meso=meso - 0.04;
}else if(interval==11){// b
meso=meso - 0.12 ;
}
}
return Math.pow(2, meso / 12);
}
// Function to load all sample buffers asynchronously
function loadSampleBuffersInBatches(batchSize){
const batches=[];
for (let i=0; i < Object.entries(samplePaths).length; i += batchSize){
const batch=Object.entries(samplePaths).slice(i, i + batchSize);
batches.push(batch);
}
loadingInfo=document.getElementById('loading-info'); // Element per mostrar el procés de cà rrega
const promises=batches.map(batch =>{
return Promise.all(batch.map(([note, path]) =>{
return fetch(path)
.then(response => response.arrayBuffer())
.then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer))
.then(buffer =>{
sampleBuffers[note]=buffer;
// Mostra el nom del sample carregat
var percent="carregant " + path.substring(0, path.lastIndexOf('.'));
loadingInfo.style.display='block'; // Canvia el text un cop s'han carregat totes les mostres
loadingInfo.innerText=percent;
}, function(error){
console.error('Error loading sample:', error);
});
}));
});
return Promise.all(promises.flat()).then(() =>{
loadingInfo.innerText='orgue carregat'; // Canvia el text un cop s'han carregat totes les mostres
loadingInfo.style.display='none'; // Canvia el text un cop s'han carregat totes les mostres
});
}
// Function to unload sample buffers
function unloadSampleBuffers(){
for (let note in sampleBuffers){
delete sampleBuffers[note];
}
}
function scrollMiddleC(){
window.scrollTo((keys.offsetWidth - document.body.offsetWidth)/2, 0);
}
let I;
function requestMidi(){
if(!('requestMIDIAccess' in navigator)){
msg.innerHTML='MIDI access not supported in this browser';
}else{
navigator.requestMIDIAccess().then(midi =>{
refresh(midi);
midi.onstatechange=e => refresh(e.target);
});
}
}
function refresh(midi){
I=midi.inputs.size
? midi.inputs.values().next().value
: void(0);
msg.innerHTML=I
? 'Status: connected to ' + I.name
:'Status: not connected to a MIDI device'
if(I){
I.onmidimessage=msg =>{
const zero=msg.data[0];
const un=msg.data[1];
const dos=msg.data[2];
const channel=zero & 0x0F; // El canal: 0=canal 1, 1=canal 2, ..., 15=canal 16
const status=zero & 0xF0; // extreu només el tipus de missatge (ex: 0x90 per Note On)
const forcedZero=status | 0x00; // canal 0=0x00, es combina amb el tipus
// orguemajor=0;
// contres=1;
// positiu=2;
if(channel===orguemajor){
onMessage({data:[forcedZero,un,dos,1]});
if(acoblament3===1){
onMessage({data:[forcedZero,un,dos,2]});
}
}else if(channel===contres){
onMessage({data:[forcedZero,un,dos,0]});
if(acoblament1===1){
onMessage({data:[forcedZero,un,dos,1]});
}
if(acoblament2===1){
onMessage({data:[forcedZero,un,dos,2]});
}
}else if(channel===positiu){
onMessage({data:[forcedZero,un,dos,2]});
}
}
}
}
const currentlyPlaying={};
const currentlyPlaying0={};
const currentlyPlaying0b={};
const currentlyPlaying1={};
const currentlyPlaying2={};
const currentlyPlaying3={};
const currentlyPlaying4={};
const currentlyPlaying5={};
const currentlyPlaying6={};
const currentlyPlaying7={};
const currentlyPlaying8={};
const currentlyPlaying9={};
const currentlyPlaying10={};
const currentlyPlaying11={};
const currentlyPlaying12={};
const currentlyPlaying13={};
const currentlyPlaying14={};
const currentlyPlaying15={};
const currentlyPlaying16={};
const currentlyPlaying17={};
const currentlyPlaying18={};
const currentlyPlaying19={};
const currentlyPlaying20={};
const currentlyPlaying21={};
const currentlyPlaying22={};
const currentlyPlaying23={};
const currentlyPlaying24={};
const currentlyPlaying25={};
const currentlyPlaying26={};
const currentlyPlaying27={};
const currentlyPlaying28={};
const currentlyPlaying29={};
const currentlyPlaying30={};
const currentlyPlaying31={};
const currentlyPlaying32={};
const currentlyPlaying35={};
const NOTEON=144;
const NOTEOFF=128;
const MAX_VELOCITY=127;
function onMessage(msg){
console.log(msg.data);
const type=msg.data[0];
const note=msg.data[1];
const velocity=msg.data[2];
teclat=msg.data[3];
if(msg.data[0] >= 0xB0&&msg.data[1]===11){
const canal=msg.data[0] & 0x0F;
expressio[canal]=msg.data[2] / 127;
return; // no cal processar com a nota
}
let key="";
if(teclat===1){
key=document.getElementById('midi-'+ note);
}else if(teclat===0){
key=document.getElementById('midi0-'+ note);
}else{
key=document.getElementById('midi1-'+ note);
}
if(!key&&!key0&&!key1){
return;
}
let avisa=0;
if(acoblament3==1){
if(registre0==0&®istre1==0&®istre2==0&®istre3==0&®istre4==0&®istr
e5==0&®istre6==0&®istre7==0&®istre8==0&®istre9==0&®istre10==0&&re
gistre11==0&®istre12==0&®istre13==0&®istre14==0&®istre15==0&®istr
e16==0&®istre17==0&®istre18==0&®istre19==0&®istre20==0&®istre21==
0&®istre22==0&®istre23==0&®istre24==0&®istre25==0){
loadingInfo.style.display='block'; // Canvia el text un cop s'han carregat totes les mostres
loadingInfo.innerText="hauries de posar algun registre de per a que soni\nyou should pull some stop to be able to play";
}else{
// loadingInfo.innerText="www.teclats.cat";
loadingInfo.style.display='none'; // Canvia el text un cop s'han carregat totes les mostres
}
}else{
if(registre0==0&®istre1==0&®istre2==0&®istre3==0&®istre4==0&®istr
e5==0&®istre6==0&®istre7==0&®istre8==0&®istre9==0&®istre10==0&&re
gistre11==0&®istre12==0&®istre13==0&®istre14==0&®istre15==0&®istr
e16==0&®istre17==0&&teclat==1){
loadingInfo.style.display='block'; // Canvia el text un cop s'han carregat totes les mostres
loadingInfo.innerText="hauries de posar algun registre de l'orgue major per a que soni\nyou should pull some stop on the great organ to be able to play";
// loadingInfo.innerText=teclat;
avisa=1;
}else{
// loadingInfo.innerText="www.teclats.cat";
loadingInfo.style.display='none'; // Canvia el text un cop s'han carregat totes les mostres
}
if(registre18==0&®istre19==0&®istre20==0&®istre21==0&®istre22==0&&re
gistre23==0&®istre24==0&®istre25==0&&teclat==2){
loadingInfo.style.display='block'; // Canvia el text un cop s'han carregat totes les mostres
loadingInfo.innerText="hauries de posar algun registre de la cadireta per a que soni\nyou should pull some stop on the chair organ to be able to play";
// loadingInfo.innerText=teclat;
}else{
// loadingInfo.innerText="www.teclats.cat";
if(avisa==0){
loadingInfo.style.display='none'; // Canvia el text un cop s'han carregat totes les mostres
}
}
}
nota = note + teclat * 128;
if(type===NOTEON){
if(velocity===0){
key.classList.remove('activekey');
if(currentlyPlaying[nota]){
if(bufa0[nota]){
clearInterval(bufa0[nota]);
delete bufa0[nota];
}
if(gaita0[nota]){
for (const sogaita0 of gaita0[nota]){
if(!sogaita0) continue;
stop(
sogaita0.gainNode,
sogaita0.gainReverb,
sogaita0.sourceReverb
);
}
delete gaita0[nota];
}
stop(
currentlyPlaying[nota].gainNode,
currentlyPlaying[nota].gainReverb,
currentlyPlaying[nota].sourceReverb
);
delete currentlyPlaying[nota];
}
if(currentlyPlaying0[nota]){
if(bufa0[nota]){
clearInterval(bufa0[nota]);
delete bufa0[nota];
}
if(currentlyPlaying1[nota]){
if(bufa1[nota]){
clearInterval(bufa1[nota]);
delete bufa1[nota];
}
if(gaita1[nota]){
for (const sogaita1 of gaita1[nota]){
if(!sogaita1) continue;
stop(
sogaita1.gainNode,
sogaita1.gainReverb,
sogaita1.sourceReverb
);
}
delete gaita1[nota];
}
stop(
currentlyPlaying1[nota].gainNode,
currentlyPlaying1[nota].gainReverb,
currentlyPlaying1[nota].sourceReverb
);
delete currentlyPlaying1[nota];
}
if(currentlyPlaying2[nota]){
if(bufa2[nota]){
clearInterval(bufa2[nota]);
delete bufa2[nota];
}
if(gaita2[nota]){
for (const sogaita2 of gaita2[nota]){
if(!sogaita2) continue;
stop(
sogaita2.gainNode,
sogaita2.gainReverb,
sogaita2.sourceReverb
);
}
delete gaita2[nota];
}
stop(
currentlyPlaying2[nota].gainNode,
currentlyPlaying2[nota].gainReverb,
currentlyPlaying2[nota].sourceReverb
);
delete currentlyPlaying2[nota];
}
if(currentlyPlaying3[nota]){
if(bufa3[nota]){
clearInterval(bufa3[nota]);
delete bufa3[nota];
}
if(gaita3[nota]){
for (const sogaita3 of gaita3[nota]){
if(!sogaita3) continue;
stop(
sogaita3.gainNode,
sogaita3.gainReverb,
sogaita3.sourceReverb
);
}
delete gaita3[nota];
}
stop(
currentlyPlaying3[nota].gainNode,
currentlyPlaying3[nota].gainReverb,
currentlyPlaying3[nota].sourceReverb
);
delete currentlyPlaying3[nota];
}
if(currentlyPlaying4[nota]){
if(bufa4[nota]){
clearInterval(bufa4[nota]);
delete bufa4[nota];
}
if(gaita4[nota]){
for (const sogaita4 of gaita4[nota]){
if(!sogaita4) continue;
stop(
sogaita4.gainNode,
sogaita4.gainReverb,
sogaita4.sourceReverb
);
}
delete gaita4[nota];
}
stop(
currentlyPlaying4[nota].gainNode,
currentlyPlaying4[nota].gainReverb,
currentlyPlaying4[nota].sourceReverb
);
delete currentlyPlaying4[nota];
}
if(currentlyPlaying5[nota]){
if(bufa5[nota]){
clearInterval(bufa5[nota]);
delete bufa5[nota];
}
if(gaita5[nota]){
for (const sogaita5 of gaita5[nota]){
if(!sogaita5) continue;
stop(
sogaita5.gainNode,
sogaita5.gainReverb,
sogaita5.sourceReverb
);
}
delete gaita5[nota];
}
stop(
currentlyPlaying5[nota].gainNode,
currentlyPlaying5[nota].gainReverb,
currentlyPlaying5[nota].sourceReverb
);
delete currentlyPlaying5[nota];
}
if(currentlyPlaying6[nota]){
if(bufa6[nota]){
clearInterval(bufa6[nota]);
delete bufa6[nota];
}
if(gaita6[nota]){
for (const sogaita6 of gaita6[nota]){
if(!sogaita6) continue;
stop(
sogaita6.gainNode,
sogaita6.gainReverb,
sogaita6.sourceReverb
);
}
delete gaita6[nota];
}
stop(
currentlyPlaying6[nota].gainNode,
currentlyPlaying6[nota].gainReverb,
currentlyPlaying6[nota].sourceReverb
);
delete currentlyPlaying6[nota];
}
if(currentlyPlaying7[nota]){
if(bufa7[nota]){
clearInterval(bufa7[nota]);
delete bufa7[nota];
}
if(gaita7[nota]){
for (const sogaita7 of gaita7[nota]){
if(!sogaita7) continue;
stop(
sogaita7.gainNode,
sogaita7.gainReverb,
sogaita7.sourceReverb
);
}
delete gaita7[nota];
}
stop(
currentlyPlaying7[nota].gainNode,
currentlyPlaying7[nota].gainReverb,
currentlyPlaying7[nota].sourceReverb
);
delete currentlyPlaying7[nota];
}
if(currentlyPlaying8[nota]){
if(bufa8[nota]){
clearInterval(bufa8[nota]);
delete bufa8[nota];
}
if(gaita8[nota]){
for (const sogaita8 of gaita8[nota]){
if(!sogaita8) continue;
stop(
sogaita8.gainNode,
sogaita8.gainReverb,
sogaita8.sourceReverb
);
}
delete gaita8[nota];
}
stop(
currentlyPlaying8[nota].gainNode,
currentlyPlaying8[nota].gainReverb,
currentlyPlaying8[nota].sourceReverb
);
delete currentlyPlaying8[nota];
}
if(currentlyPlaying9[nota]){
if(bufa9[nota]){
clearInterval(bufa9[nota]);
delete bufa9[nota];
}
if(gaita9[nota]){
for (const sogaita9 of gaita9[nota]){
if(!sogaita9) continue;
stop(
sogaita9.gainNode,
sogaita9.gainReverb,
sogaita9.sourceReverb
);
}
delete gaita9[nota];
}
stop(
currentlyPlaying9[nota].gainNode,
currentlyPlaying9[nota].gainReverb,
currentlyPlaying9[nota].sourceReverb
);
delete currentlyPlaying9[nota];
}
if(currentlyPlaying10[nota]){
if(bufa10[nota]){
clearInterval(bufa10[nota]);
delete bufa10[nota];
}
if(gaita10[nota]){
for (const sogaita10 of gaita10[nota]){
if(!sogaita10) continue;
stop(
sogaita10.gainNode,
sogaita10.gainReverb,
sogaita10.sourceReverb
);
}
delete gaita10[nota];
}
stop(
currentlyPlaying10[nota].gainNode,
currentlyPlaying10[nota].gainReverb,
currentlyPlaying10[nota].sourceReverb
);
delete currentlyPlaying10[nota];
}
if(currentlyPlaying11[nota]){
if(bufa11[nota]){
clearInterval(bufa11[nota]);
delete bufa11[nota];
}
if(gaita11[nota]){
for (const sogaita11 of gaita11[nota]){
if(!sogaita11) continue;
stop(
sogaita11.gainNode,
sogaita11.gainReverb,
sogaita11.sourceReverb
);
}
delete gaita11[nota];
}
stop(
currentlyPlaying11[nota].gainNode,
currentlyPlaying11[nota].gainReverb,
currentlyPlaying11[nota].sourceReverb
);
delete currentlyPlaying11[nota];
}
if(currentlyPlaying12[nota]){
if(bufa12[nota]){
clearInterval(bufa12[nota]);
delete bufa12[nota];
}
if(gaita12[nota]){
for (const sogaita12 of gaita12[nota]){
if(!sogaita12) continue;
stop(
sogaita12.gainNode,
sogaita12.gainReverb,
sogaita12.sourceReverb
);
}
delete gaita12[nota];
}
stop(
currentlyPlaying12[nota].gainNode,
currentlyPlaying12[nota].gainReverb,
currentlyPlaying12[nota].sourceReverb
);
delete currentlyPlaying12[nota];
}
if(currentlyPlaying13[nota]){
if(bufa13[nota]){
clearInterval(bufa13[nota]);
delete bufa13[nota];
}
if(gaita13[nota]){
for (const sogaita13 of gaita13[nota]){
if(!sogaita13) continue;
stop(
sogaita13.gainNode,
sogaita13.gainReverb,
sogaita13.sourceReverb
);
}
delete gaita13[nota];
}
stop(
currentlyPlaying13[nota].gainNode,
currentlyPlaying13[nota].gainReverb,
currentlyPlaying13[nota].sourceReverb
);
delete currentlyPlaying13[nota];
}
if(currentlyPlaying14[nota]){
if(bufa14[nota]){
clearInterval(bufa14[nota]);
delete bufa14[nota];
}
if(gaita14[nota]){
for (const sogaita14 of gaita14[nota]){
if(!sogaita14) continue;
stop(
sogaita14.gainNode,
sogaita14.gainReverb,
sogaita14.sourceReverb
);
}
delete gaita14[nota];
}
stop(
currentlyPlaying14[nota].gainNode,
currentlyPlaying14[nota].gainReverb,
currentlyPlaying14[nota].sourceReverb
);
delete currentlyPlaying14[nota];
}
if(currentlyPlaying15[nota]){
if(bufa15[nota]){
clearInterval(bufa15[nota]);
delete bufa15[nota];
}
if(gaita15[nota]){
for (const sogaita15 of gaita15[nota]){
if(!sogaita15) continue;
stop(
sogaita15.gainNode,
sogaita15.gainReverb,
sogaita15.sourceReverb
);
}
delete gaita15[nota];
}
stop(
currentlyPlaying15[nota].gainNode,
currentlyPlaying15[nota].gainReverb,
currentlyPlaying15[nota].sourceReverb
);
delete currentlyPlaying15[nota];
}
if(currentlyPlaying16[nota]){
if(bufa16[nota]){
clearInterval(bufa16[nota]);
delete bufa16[nota];
}
if(gaita16[nota]){
for (const sogaita16 of gaita16[nota]){
if(!sogaita16) continue;
stop(
sogaita16.gainNode,
sogaita16.gainReverb,
sogaita16.sourceReverb
);
}
delete gaita16[nota];
}
stop(
currentlyPlaying16[nota].gainNode,
currentlyPlaying16[nota].gainReverb,
currentlyPlaying16[nota].sourceReverb
);
delete currentlyPlaying16[nota];
}
if(currentlyPlaying17[nota]){
if(bufa17[nota]){
clearInterval(bufa17[nota]);
delete bufa17[nota];
}
if(gaita17[nota]){
for (const sogaita17 of gaita17[nota]){
if(!sogaita17) continue;
stop(
sogaita17.gainNode,
sogaita17.gainReverb,
sogaita17.sourceReverb
);
}
delete gaita17[nota];
}
stop(
currentlyPlaying17[nota].gainNode,
currentlyPlaying17[nota].gainReverb,
currentlyPlaying17[nota].sourceReverb
);
delete currentlyPlaying17[nota];
}
if(currentlyPlaying18[nota]){
if(bufa18[nota]){
clearInterval(bufa18[nota]);
delete bufa18[nota];
}
if(gaita18[nota]){
for (const sogaita18 of gaita18[nota]){
if(!sogaita18) continue;
stop(
sogaita18.gainNode,
sogaita18.gainReverb,
sogaita18.sourceReverb
);
}
delete gaita18[nota];
}
stop(
currentlyPlaying18[nota].gainNode,
currentlyPlaying18[nota].gainReverb,
currentlyPlaying18[nota].sourceReverb
);
delete currentlyPlaying18[nota];
}
if(currentlyPlaying19[nota]){
if(bufa19[nota]){
clearInterval(bufa19[nota]);
delete bufa19[nota];
}
if(gaita19[nota]){
for (const sogaita19 of gaita19[nota]){
if(!sogaita19) continue;
stop(
sogaita19.gainNode,
sogaita19.gainReverb,
sogaita19.sourceReverb
);
}
delete gaita19[nota];
}
stop(
currentlyPlaying19[nota].gainNode,
currentlyPlaying19[nota].gainReverb,
currentlyPlaying19[nota].sourceReverb
);
delete currentlyPlaying19[nota];
}
if(currentlyPlaying20[nota]){
if(bufa20[nota]){
clearInterval(bufa20[nota]);
delete bufa20[nota];
}
if(gaita20[nota]){
for (const sogaita20 of gaita20[nota]){
if(!sogaita20) continue;
stop(
sogaita20.gainNode,
sogaita20.gainReverb,
sogaita20.sourceReverb
);
}
delete gaita20[nota];
}
stop(
currentlyPlaying20[nota].gainNode,
currentlyPlaying20[nota].gainReverb,
currentlyPlaying20[nota].sourceReverb
);
delete currentlyPlaying20[nota];
}
if(currentlyPlaying21[nota]){
if(bufa21[nota]){
clearInterval(bufa21[nota]);
delete bufa21[nota];
}
if(gaita21[nota]){
for (const sogaita21 of gaita21[nota]){
if(!sogaita21) continue;
stop(
sogaita21.gainNode,
sogaita21.gainReverb,
sogaita21.sourceReverb
);
}
delete gaita21[nota];
}
stop(
currentlyPlaying21[nota].gainNode,
currentlyPlaying21[nota].gainReverb,
currentlyPlaying21[nota].sourceReverb
);
delete currentlyPlaying21[nota];
}
if(currentlyPlaying22[nota]){
if(bufa22[nota]){
clearInterval(bufa22[nota]);
delete bufa22[nota];
}
if(gaita22[nota]){
for (const sogaita22 of gaita22[nota]){
if(!sogaita22) continue;
stop(
sogaita22.gainNode,
sogaita22.gainReverb,
sogaita22.sourceReverb
);
}
delete gaita22[nota];
}
stop(
currentlyPlaying22[nota].gainNode,
currentlyPlaying22[nota].gainReverb,
currentlyPlaying22[nota].sourceReverb
);
delete currentlyPlaying22[nota];
}
if(currentlyPlaying23[nota]){
if(bufa23[nota]){
clearInterval(bufa23[nota]);
delete bufa23[nota];
}
if(gaita23[nota]){
for (const sogaita23 of gaita23[nota]){
if(!sogaita23) continue;
stop(
sogaita23.gainNode,
sogaita23.gainReverb,
sogaita23.sourceReverb
);
}
delete gaita23[nota];
}
stop(
currentlyPlaying23[nota].gainNode,
currentlyPlaying23[nota].gainReverb,
currentlyPlaying23[nota].sourceReverb
);
delete currentlyPlaying23[nota];
}
if(currentlyPlaying24[nota]){
if(bufa24[nota]){
clearInterval(bufa24[nota]);
delete bufa24[nota];
}
if(gaita24[nota]){
for (const sogaita24 of gaita24[nota]){
if(!sogaita24) continue;
stop(
sogaita24.gainNode,
sogaita24.gainReverb,
sogaita24.sourceReverb
);
}
delete gaita24[nota];
}
stop(
currentlyPlaying24[nota].gainNode,
currentlyPlaying24[nota].gainReverb,
currentlyPlaying24[nota].sourceReverb
);
delete currentlyPlaying24[nota];
}
if(currentlyPlaying25[nota]){
if(bufa25[nota]){
clearInterval(bufa25[nota]);
delete bufa25[nota];
}
if(gaita25[nota]){
for (const sogaita25 of gaita25[nota]){
if(!sogaita25) continue;
stop(
sogaita25.gainNode,
sogaita25.gainReverb,
sogaita25.sourceReverb
);
}
delete gaita25[nota];
}
stop(
currentlyPlaying25[nota].gainNode,
currentlyPlaying25[nota].gainReverb,
currentlyPlaying25[nota].sourceReverb
);
delete currentlyPlaying25[nota];
}
if(currentlyPlaying26[nota]){
if(bufa26[nota]){
clearInterval(bufa26[nota]);
delete bufa26[nota];
}
if(gaita26[nota]){
for (const sogaita26 of gaita26[nota]){
if(!sogaita26) continue;
stop(
sogaita26.gainNode,
sogaita26.gainReverb,
sogaita26.sourceReverb
);
}
delete gaita26[nota];
}
stop(
currentlyPlaying26[nota].gainNode,
currentlyPlaying26[nota].gainReverb,
currentlyPlaying26[nota].sourceReverb
);
delete currentlyPlaying26[nota];
}
if(currentlyPlaying27[nota]){
if(bufa27[nota]){
clearInterval(bufa27[nota]);
delete bufa27[nota];
}
if(gaita27[nota]){
for (const sogaita27 of gaita27[nota]){
if(!sogaita27) continue;
stop(
sogaita27.gainNode,
sogaita27.gainReverb,
sogaita27.sourceReverb
);
}
delete gaita27[nota];
}
stop(
currentlyPlaying27[nota].gainNode,
currentlyPlaying27[nota].gainReverb,
currentlyPlaying27[nota].sourceReverb
);
delete currentlyPlaying27[nota];
}
if(currentlyPlaying28[nota]){
if(bufa28[nota]){
clearInterval(bufa28[nota]);
delete bufa28[nota];
}
if(gaita28[nota]){
for (const sogaita28 of gaita28[nota]){
if(!sogaita28) continue;
stop(
sogaita28.gainNode,
sogaita28.gainReverb,
sogaita28.sourceReverb
);
}
delete gaita28[nota];
}
stop(
currentlyPlaying28[nota].gainNode,
currentlyPlaying28[nota].gainReverb,
currentlyPlaying28[nota].sourceReverb
);
delete currentlyPlaying28[nota];
}
if(currentlyPlaying29[nota]){
if(bufa29[nota]){
clearInterval(bufa29[nota]);
delete bufa29[nota];
}
if(gaita29[nota]){
for (const sogaita29 of gaita29[nota]){
if(!sogaita29) continue;
stop(
sogaita29.gainNode,
sogaita29.gainReverb,
sogaita29.sourceReverb
);
}
delete gaita29[nota];
}
stop(
currentlyPlaying29[nota].gainNode,
currentlyPlaying29[nota].gainReverb,
currentlyPlaying29[nota].sourceReverb
);
delete currentlyPlaying29[nota];
}
if(currentlyPlaying30[nota]){
if(bufa30[nota]){
clearInterval(bufa30[nota]);
delete bufa30[nota];
}
if(gaita30[nota]){
for (const sogaita30 of gaita30[nota]){
if(!sogaita30) continue;
stop(
sogaita30.gainNode,
sogaita30.gainReverb,
sogaita30.sourceReverb
);
}
delete gaita30[nota];
}
stop(
currentlyPlaying30[nota].gainNode,
currentlyPlaying30[nota].gainReverb,
currentlyPlaying30[nota].sourceReverb
);
delete currentlyPlaying30[nota];
}
if(currentlyPlaying31[nota]){
if(bufa31[nota]){
clearInterval(bufa31[nota]);
delete bufa31[nota];
}
if(gaita31[nota]){
for (const sogaita31 of gaita31[nota]){
if(!sogaita31) continue;
stop(
sogaita31.gainNode,
sogaita31.gainReverb,
sogaita31.sourceReverb
);
}
delete gaita31[nota];
}
stop(
currentlyPlaying31[nota].gainNode,
currentlyPlaying31[nota].gainReverb,
currentlyPlaying31[nota].sourceReverb
);
delete currentlyPlaying31[nota];
}
if(currentlyPlaying32[nota]){
if(bufa32[nota]){
clearInterval(bufa32[nota]);
delete bufa32[nota];
}
if(gaita32[nota]){
for (const sogaita32 of gaita32[nota]){
if(!sogaita32) continue;
stop(
sogaita32.gainNode,
sogaita32.gainReverb,
sogaita32.sourceReverb
);
}
delete gaita32[nota];
}
stop(
currentlyPlaying32[nota].gainNode,
currentlyPlaying32[nota].gainReverb,
currentlyPlaying32[nota].sourceReverb
);
delete currentlyPlaying32[nota];
}
if(currentlyPlaying35[nota]){
if(bufa35[nota]){
clearInterval(bufa35[nota]);
delete bufa35[nota];
}
if(gaita35[nota]){
for (const sogaita35 of gaita35[nota]){
if(!sogaita35) continue;
stop(
sogaita35.gainNode,
sogaita35.gainReverb,
sogaita35.sourceReverb
);
}
delete gaita35[nota];
}
stop(
currentlyPlaying35[nota].gainNode,
currentlyPlaying35[nota].gainReverb,
currentlyPlaying35[nota].sourceReverb
);
delete currentlyPlaying35[nota];
}
/*
if(gaita0b[nota]){
for (const sogaita0b of gaita0b[nota]){
if(!sogaita0b) continue;
stop(
sogaita0b.gainNode,
sogaita0b.gainReverb,
sogaita0b.sourceReverb
);
}
delete gaita0b[nota];
}
stop(
currentlyPlaying0b[nota].gainNode,
currentlyPlaying0b[nota].gainReverb,
currentlyPlaying0b[nota].sourceReverb
);
delete currentlyPlaying0b[nota];
*/
}
}else{
////// nota
const baseRate=midi2rate(note);
if (thereBeSound&&!currentlyPlaying[nota]){ // just play once
if(sampleBuffers[sampleMidi]){
key.classList.add('activekey');
if(registre0==1&&teclat==1){
var atac=0.2/velocity; // atac
if(bufa0[nota]){
clearInterval(bufa0[nota]);
delete bufa0[nota];
}
gaita0[nota]=[];
function tocagaita0(){
const sogaita0=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi],
atac
);
currentlyPlaying[nota]=sogaita0;
gaita0[nota].push(sogaita0);
}
let desviacio=1;
function tocagaitabis0(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis0=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi],
2
);
currentlyPlaying[nota]=sogaitabis0;
gaita0[nota].push(sogaitabis0);
}
tocagaita0(); // primera amb atac
bufa0[nota]=setInterval(tocagaitabis0, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying1[nota]){ // just play once
if(sampleBuffers[sampleMidi+100]){
key.classList.add('activekey');
if(registre1==1&&teclat==1){
var atac=0.2/velocity; // atac
if(bufa1[nota]){
clearInterval(bufa1[nota]);
delete bufa1[nota];
}
gaita1[nota]=[];
function tocagaita1(){
const sogaita1=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+100],
atac
);
currentlyPlaying1[nota]=sogaita1;
gaita1[nota].push(sogaita1);
}
let desviacio=1;
function tocagaitabis1(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis1=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+100],
2
);
currentlyPlaying1[nota]=sogaitabis1;
gaita1[nota].push(sogaitabis1);
}
tocagaita1(); // primera amb atac
bufa1[nota]=setInterval(tocagaitabis1, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying2[nota]){ // just play once
if(sampleBuffers[sampleMidi+200]){
key.classList.add('activekey');
if(registre2==1&&teclat==1&¬e < 61){
var atac=0.2/velocity; // atac
if(bufa2[nota]){
clearInterval(bufa2[nota]);
delete bufa2[nota];
}
gaita2[nota]=[];
function tocagaita2(){
const sogaita2=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+200],
atac
);
currentlyPlaying2[nota]=sogaita2;
gaita2[nota].push(sogaita2);
}
let desviacio=1;
function tocagaitabis2(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis2=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+200],
2
);
currentlyPlaying2[nota]=sogaitabis2;
gaita2[nota].push(sogaitabis2);
}
tocagaita2(); // primera amb atac
bufa2[nota]=setInterval(tocagaitabis2, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying3[nota]){ // just play once
if(sampleBuffers[sampleMidi+300]){
key.classList.add('activekey');
if(registre3==1&&teclat==1&¬e > 60){
var atac=0.2/velocity; // atac
if(bufa3[nota]){
clearInterval(bufa3[nota]);
delete bufa3[nota];
}
gaita3[nota]=[];
function tocagaita3(){
const sogaita3=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+300],
atac
);
currentlyPlaying3[nota]=sogaita3;
gaita3[nota].push(sogaita3);
}
let desviacio=1;
function tocagaitabis3(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis3=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+300],
2
);
currentlyPlaying3[nota]=sogaitabis3;
gaita3[nota].push(sogaitabis3);
}
tocagaita3(); // primera amb atac
bufa3[nota]=setInterval(tocagaitabis3, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying4[nota]){ // just play once
if(sampleBuffers[sampleMidi+400]){
key.classList.add('activekey');
if(registre4==1&&teclat==1&¬e < 61){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa4[nota]){
clearInterval(bufa4[nota]);
delete bufa4[nota];
}
gaita4[nota]=[];
function tocagaita4(){
const sogaita4=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+400],
atac
);
currentlyPlaying4[nota]=sogaita4;
gaita4[nota].push(sogaita4);
}
let desviacio=1;
function tocagaitabis4(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis4=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+400],
2
);
currentlyPlaying4[nota]=sogaitabis4;
gaita4[nota].push(sogaitabis4);
}
tocagaita4(); // primera amb atac
bufa4[nota]=setInterval(tocagaitabis4, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying5[nota]){ // just play once
if(sampleBuffers[sampleMidi+500]){
key.classList.add('activekey');
if(registre5==1&&teclat==1&¬e > 60){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa5[nota]){
clearInterval(bufa5[nota]);
delete bufa5[nota];
}
gaita5[nota]=[];
function tocagaita5(){
const sogaita5=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+500],
atac
);
currentlyPlaying5[nota]=sogaita5;
gaita5[nota].push(sogaita5);
}
let desviacio=1;
function tocagaitabis5(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis5=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+500],
2
);
currentlyPlaying5[nota]=sogaitabis5;
gaita5[nota].push(sogaitabis5);
}
tocagaita5(); // primera amb atac
bufa5[nota]=setInterval(tocagaitabis5, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying6[nota]){ // just play once
if(sampleBuffers[sampleMidi+600]){
key.classList.add('activekey');
if(registre6==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa6[nota]){
clearInterval(bufa6[nota]);
delete bufa6[nota];
}
gaita6[nota]=[];
function tocagaita6(){
const sogaita6=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+600],
atac
);
currentlyPlaying6[nota]=sogaita6;
gaita6[nota].push(sogaita6);
}
let desviacio=1;
function tocagaitabis6(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis6=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+600],
2
);
currentlyPlaying6[nota]=sogaitabis6;
gaita6[nota].push(sogaitabis6);
}
tocagaita6(); // primera amb atac
bufa6[nota]=setInterval(tocagaitabis6, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying7[nota]){ // just play once
if(sampleBuffers[sampleMidi+700]){
key.classList.add('activekey');
if(registre7==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa7[nota]){
clearInterval(bufa7[nota]);
delete bufa7[nota];
}
gaita7[nota]=[];
function tocagaita7(){
const sogaita7=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+700],
atac
);
currentlyPlaying7[nota]=sogaita7;
gaita7[nota].push(sogaita7);
}
let desviacio=1;
function tocagaitabis7(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis7=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+700],
2
);
currentlyPlaying7[nota]=sogaitabis7;
gaita7[nota].push(sogaitabis7);
}
tocagaita7(); // primera amb atac
bufa7[nota]=setInterval(tocagaitabis7, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying8[nota]){ // just play once
if(sampleBuffers[sampleMidi+800]){
key.classList.add('activekey');
if(registre8==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa8[nota]){
clearInterval(bufa8[nota]);
delete bufa8[nota];
}
gaita8[nota]=[];
function tocagaita8(){
const sogaita8=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+800],
atac
);
currentlyPlaying8[nota]=sogaita8;
gaita8[nota].push(sogaita8);
}
let desviacio=1;
function tocagaitabis8(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis8=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+800],
2
);
currentlyPlaying8[nota]=sogaitabis8;
gaita8[nota].push(sogaitabis8);
}
tocagaita8(); // primera amb atac
bufa8[nota]=setInterval(tocagaitabis8, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying9[nota]){ // just play once
if(sampleBuffers[sampleMidi+900]){
key.classList.add('activekey');
if(registre9==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa9[nota]){
clearInterval(bufa9[nota]);
delete bufa9[nota];
}
gaita9[nota]=[];
function tocagaita9(){
const sogaita9=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+900],
atac
);
currentlyPlaying9[nota]=sogaita9;
gaita9[nota].push(sogaita9);
}
let desviacio=1;
function tocagaitabis9(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis9=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+900],
2
);
currentlyPlaying9[nota]=sogaitabis9;
gaita9[nota].push(sogaitabis9);
}
tocagaita9(); // primera amb atac
bufa9[nota]=setInterval(tocagaitabis9, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying10[nota]){ // just play once
if(sampleBuffers[sampleMidi+1000]){
key.classList.add('activekey');
if(registre10==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa10[nota]){
clearInterval(bufa10[nota]);
delete bufa10[nota];
}
gaita10[nota]=[];
function tocagaita10(){
const sogaita10=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1000],
atac
);
currentlyPlaying10[nota]=sogaita10;
gaita10[nota].push(sogaita10);
}
let desviacio=1;
function tocagaitabis10(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis10=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1000],
2
);
currentlyPlaying10[nota]=sogaitabis10;
gaita10[nota].push(sogaitabis10);
}
tocagaita10(); // primera amb atac
bufa10[nota]=setInterval(tocagaitabis10, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying11[nota]){ // just play once
if(sampleBuffers[sampleMidi+1100]){
key.classList.add('activekey');
if(registre11==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa11[nota]){
clearInterval(bufa11[nota]);
delete bufa11[nota];
}
gaita11[nota]=[];
function tocagaita11(){
const sogaita11=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1100],
atac
);
currentlyPlaying11[nota]=sogaita11;
gaita11[nota].push(sogaita11);
}
let desviacio=1;
function tocagaitabis11(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis11=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1100],
2
);
currentlyPlaying11[nota]=sogaitabis11;
gaita11[nota].push(sogaitabis11);
}
tocagaita11(); // primera amb atac
bufa11[nota]=setInterval(tocagaitabis11, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying12[nota]){ // just play once
if(sampleBuffers[sampleMidi+1200]){
key.classList.add('activekey');
if(registre12==1&&teclat==1&¬e > 60){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa12[nota]){
clearInterval(bufa12[nota]);
delete bufa12[nota];
}
gaita12[nota]=[];
function tocagaita12(){
const sogaita12=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1200],
atac
);
currentlyPlaying12[nota]=sogaita12;
gaita12[nota].push(sogaita12);
}
let desviacio=1;
function tocagaitabis12(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis12=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1200],
2
);
currentlyPlaying12[nota]=sogaitabis12;
gaita12[nota].push(sogaitabis12);
}
tocagaita12(); // primera amb atac
bufa12[nota]=setInterval(tocagaitabis12, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying13[nota]){ // just play once
if(sampleBuffers[sampleMidi+1300]){
key.classList.add('activekey');
if(registre13==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa13[nota]){
clearInterval(bufa13[nota]);
delete bufa13[nota];
}
gaita13[nota]=[];
function tocagaita13(){
const sogaita13=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1300],
atac
);
currentlyPlaying13[nota]=sogaita13;
gaita13[nota].push(sogaita13);
}
let desviacio=1;
function tocagaitabis13(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis13=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1300],
2
);
currentlyPlaying13[nota]=sogaitabis13;
gaita13[nota].push(sogaitabis13);
}
tocagaita13(); // primera amb atac
bufa13[nota]=setInterval(tocagaitabis13, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying14[nota]){ // just play once
if(sampleBuffers[sampleMidi+1400]){
key.classList.add('activekey');
if(registre14==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa14[nota]){
clearInterval(bufa14[nota]);
delete bufa14[nota];
}
gaita14[nota]=[];
function tocagaita14(){
const sogaita14=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1400],
atac
);
currentlyPlaying14[nota]=sogaita14;
gaita14[nota].push(sogaita14);
}
let desviacio=1;
function tocagaitabis14(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis14=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1400],
2
);
currentlyPlaying14[nota]=sogaitabis14;
gaita14[nota].push(sogaitabis14);
}
tocagaita14(); // primera amb atac
bufa14[nota]=setInterval(tocagaitabis14, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying15[nota]){ // just play once
if(sampleBuffers[sampleMidi+1500]){
key.classList.add('activekey');
if(registre15==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa15[nota]){
clearInterval(bufa15[nota]);
delete bufa15[nota];
}
gaita15[nota]=[];
function tocagaita15(){
const sogaita15=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1500],
atac
);
currentlyPlaying15[nota]=sogaita15;
gaita15[nota].push(sogaita15);
}
let desviacio=1;
function tocagaitabis15(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis15=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1500],
2
);
currentlyPlaying15[nota]=sogaitabis15;
gaita15[nota].push(sogaitabis15);
}
tocagaita15(); // primera amb atac
bufa15[nota]=setInterval(tocagaitabis15, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying16[nota]){ // just play once
if(sampleBuffers[sampleMidi+1600]){
key.classList.add('activekey');
if(registre16==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa16[nota]){
clearInterval(bufa16[nota]);
delete bufa16[nota];
}
gaita16[nota]=[];
function tocagaita16(){
const sogaita16=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1600],
atac
);
currentlyPlaying16[nota]=sogaita16;
gaita16[nota].push(sogaita16);
}
let desviacio=1;
function tocagaitabis16(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis16=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1600],
2
);
currentlyPlaying16[nota]=sogaitabis16;
gaita16[nota].push(sogaitabis16);
}
tocagaita16(); // primera amb atac
bufa16[nota]=setInterval(tocagaitabis16, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying17[nota]){ // just play once
if(sampleBuffers[sampleMidi+1700]){
key.classList.add('activekey');
if(registre17==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa17[nota]){
clearInterval(bufa17[nota]);
delete bufa17[nota];
}
gaita17[nota]=[];
function tocagaita17(){
const sogaita17=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1700],
atac
);
currentlyPlaying17[nota]=sogaita17;
gaita17[nota].push(sogaita17);
}
let desviacio=1;
function tocagaitabis17(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis17=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1700],
2
);
currentlyPlaying17[nota]=sogaitabis17;
gaita17[nota].push(sogaitabis17);
}
tocagaita17(); // primera amb atac
bufa17[nota]=setInterval(tocagaitabis17, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying18[nota]){ // just play once
if(sampleBuffers[sampleMidi+1800]){
key.classList.add('activekey');
if(registre18==1&&teclat==2){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa18[nota]){
clearInterval(bufa18[nota]);
delete bufa18[nota];
}
gaita18[nota]=[];
function tocagaita18(){
const sogaita18=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1800],
atac
);
currentlyPlaying18[nota]=sogaita18;
gaita18[nota].push(sogaita18);
}
let desviacio=1;
function tocagaitabis18(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis18=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1800],
2
);
currentlyPlaying18[nota]=sogaitabis18;
gaita18[nota].push(sogaitabis18);
}
tocagaita18(); // primera amb atac
bufa18[nota]=setInterval(tocagaitabis18, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying19[nota]){ // just play once
if(sampleBuffers[sampleMidi+1900]){
key.classList.add('activekey');
if(registre19==1&&teclat==2){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa19[nota]){
clearInterval(bufa19[nota]);
delete bufa19[nota];
}
gaita19[nota]=[];
function tocagaita19(){
const sogaita19=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+1900],
atac
);
currentlyPlaying19[nota]=sogaita19;
gaita19[nota].push(sogaita19);
}
let desviacio=1;
function tocagaitabis19(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis19=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+1900],
2
);
currentlyPlaying19[nota]=sogaitabis19;
gaita19[nota].push(sogaitabis19);
}
tocagaita19(); // primera amb atac
bufa19[nota]=setInterval(tocagaitabis19, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying20[nota]){ // just play once
if(sampleBuffers[sampleMidi+2000]){
key.classList.add('activekey');
if(registre20==1&&teclat==2){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa20[nota]){
clearInterval(bufa20[nota]);
delete bufa20[nota];
}
gaita20[nota]=[];
function tocagaita20(){
const sogaita20=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2000],
atac
);
currentlyPlaying20[nota]=sogaita20;
gaita20[nota].push(sogaita20);
}
let desviacio=1;
function tocagaitabis20(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis20=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2000],
2
);
currentlyPlaying20[nota]=sogaitabis20;
gaita20[nota].push(sogaitabis20);
}
tocagaita20(); // primera amb atac
bufa20[nota]=setInterval(tocagaitabis20, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying21[nota]){ // just play once
if(sampleBuffers[sampleMidi+2100]){
key.classList.add('activekey');
if(registre21==1&&teclat==2){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa21[nota]){
clearInterval(bufa21[nota]);
delete bufa21[nota];
}
gaita21[nota]=[];
function tocagaita21(){
const sogaita21=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2100],
atac
);
currentlyPlaying21[nota]=sogaita21;
gaita21[nota].push(sogaita21);
}
let desviacio=1;
function tocagaitabis21(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis21=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2100],
2
);
currentlyPlaying21[nota]=sogaitabis21;
gaita21[nota].push(sogaitabis21);
}
tocagaita21(); // primera amb atac
bufa21[nota]=setInterval(tocagaitabis21, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying22[nota]){ // just play once
if(sampleBuffers[sampleMidi+2200]){
key.classList.add('activekey');
if(registre22==1&&teclat==2){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa22[nota]){
clearInterval(bufa22[nota]);
delete bufa22[nota];
}
gaita22[nota]=[];
function tocagaita22(){
const sogaita22=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2200],
atac
);
currentlyPlaying22[nota]=sogaita22;
gaita22[nota].push(sogaita22);
}
let desviacio=1;
function tocagaitabis22(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis22=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2200],
2
);
currentlyPlaying22[nota]=sogaitabis22;
gaita22[nota].push(sogaitabis22);
}
tocagaita22(); // primera amb atac
bufa22[nota]=setInterval(tocagaitabis22, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying23[nota]){ // just play once
if(sampleBuffers[sampleMidi+2300]){
key.classList.add('activekey');
if(registre23==1&&teclat==2){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa23[nota]){
clearInterval(bufa23[nota]);
delete bufa23[nota];
}
gaita23[nota]=[];
function tocagaita23(){
const sogaita23=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2300],
atac
);
currentlyPlaying23[nota]=sogaita23;
gaita23[nota].push(sogaita23);
}
let desviacio=1;
function tocagaitabis23(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis23=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2300],
2
);
currentlyPlaying23[nota]=sogaitabis23;
gaita23[nota].push(sogaitabis23);
}
tocagaita23(); // primera amb atac
bufa23[nota]=setInterval(tocagaitabis23, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying24[nota]){ // just play once
if(sampleBuffers[sampleMidi+2400]){
key.classList.add('activekey');
if(registre24==1&&teclat==2){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa24[nota]){
clearInterval(bufa24[nota]);
delete bufa24[nota];
}
gaita24[nota]=[];
function tocagaita24(){
const sogaita24=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2400],
atac
);
currentlyPlaying24[nota]=sogaita24;
gaita24[nota].push(sogaita24);
}
let desviacio=1;
function tocagaitabis24(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis24=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2400],
2
);
currentlyPlaying24[nota]=sogaitabis24;
gaita24[nota].push(sogaitabis24);
}
tocagaita24(); // primera amb atac
bufa24[nota]=setInterval(tocagaitabis24, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying25[nota]){ // just play once
if(sampleBuffers[sampleMidi+2500]){
key.classList.add('activekey');
if(registre25==1&&teclat==2){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa25[nota]){
clearInterval(bufa25[nota]);
delete bufa25[nota];
}
gaita25[nota]=[];
function tocagaita25(){
const sogaita25=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2500],
atac
);
currentlyPlaying25[nota]=sogaita25;
gaita25[nota].push(sogaita25);
}
let desviacio=1;
function tocagaitabis25(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis25=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2500],
2
);
currentlyPlaying25[nota]=sogaitabis25;
gaita25[nota].push(sogaitabis25);
}
tocagaita25(); // primera amb atac
bufa25[nota]=setInterval(tocagaitabis25, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying26[nota]){ // just play once
if(sampleBuffers[sampleMidi+2600]){
key.classList.add('activekey');
if(registre26==1&&teclat==0){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa26[nota]){
clearInterval(bufa26[nota]);
delete bufa26[nota];
}
gaita26[nota]=[];
function tocagaita26(){
const sogaita26=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2600],
atac
);
currentlyPlaying26[nota]=sogaita26;
gaita26[nota].push(sogaita26);
}
let desviacio=1;
function tocagaitabis26(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis26=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2600],
2
);
currentlyPlaying26[nota]=sogaitabis26;
gaita26[nota].push(sogaitabis26);
}
tocagaita26(); // primera amb atac
bufa26[nota]=setInterval(tocagaitabis26, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying27[nota]){ // just play once
if(sampleBuffers[sampleMidi+2700]){
key.classList.add('activekey');
if(registre27==1&&teclat==0){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa27[nota]){
clearInterval(bufa27[nota]);
delete bufa27[nota];
}
gaita27[nota]=[];
function tocagaita27(){
const sogaita27=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2700],
atac
);
currentlyPlaying27[nota]=sogaita27;
gaita27[nota].push(sogaita27);
}
let desviacio=1;
function tocagaitabis27(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis27=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2700],
2
);
currentlyPlaying27[nota]=sogaitabis27;
gaita27[nota].push(sogaitabis27);
}
tocagaita27(); // primera amb atac
bufa27[nota]=setInterval(tocagaitabis27, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying28[nota]){ // just play once
if(sampleBuffers[sampleMidi+2800]){
key.classList.add('activekey');
if(registre28==1&&teclat==0){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa28[nota]){
clearInterval(bufa28[nota]);
delete bufa28[nota];
}
gaita28[nota]=[];
function tocagaita28(){
const sogaita28=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2800],
atac
);
currentlyPlaying28[nota]=sogaita28;
gaita28[nota].push(sogaita28);
}
let desviacio=1;
function tocagaitabis28(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis28=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2800],
2
);
currentlyPlaying28[nota]=sogaitabis28;
gaita28[nota].push(sogaitabis28);
}
tocagaita28(); // primera amb atac
bufa28[nota]=setInterval(tocagaitabis28, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying29[nota]){ // just play once
if(sampleBuffers[sampleMidi+2900]){
key.classList.add('activekey');
if(registre29==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa29[nota]){
clearInterval(bufa29[nota]);
delete bufa29[nota];
}
gaita29[nota]=[];
function tocagaita29(){
const sogaita29=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+2900],
atac
);
currentlyPlaying29[nota]=sogaita29;
gaita29[nota].push(sogaita29);
}
let desviacio=1;
function tocagaitabis29(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis29=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+2900],
2
);
currentlyPlaying29[nota]=sogaitabis29;
gaita29[nota].push(sogaitabis29);
}
tocagaita29(); // primera amb atac
bufa29[nota]=setInterval(tocagaitabis29, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying30[nota]){ // just play once
if(sampleBuffers[sampleMidi+3000]){
key.classList.add('activekey');
if(registre30==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa30[nota]){
clearInterval(bufa30[nota]);
delete bufa30[nota];
}
gaita30[nota]=[];
function tocagaita30(){
const sogaita30=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+3000],
atac
);
currentlyPlaying30[nota]=sogaita30;
gaita30[nota].push(sogaita30);
}
let desviacio=1;
function tocagaitabis30(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis30=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+3000],
2
);
currentlyPlaying30[nota]=sogaitabis30;
gaita30[nota].push(sogaitabis30);
}
tocagaita30(); // primera amb atac
bufa30[nota]=setInterval(tocagaitabis30, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying31[nota]){ // just play once
if(sampleBuffers[sampleMidi+3100]){
key.classList.add('activekey');
if(registre31==1&&teclat==1){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa31[nota]){
clearInterval(bufa31[nota]);
delete bufa31[nota];
}
gaita31[nota]=[];
function tocagaita31(){
const sogaita31=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+3100],
atac
);
currentlyPlaying31[nota]=sogaita31;
gaita31[nota].push(sogaita31);
}
let desviacio=1;
function tocagaitabis31(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis31=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+3100],
2
);
currentlyPlaying31[nota]=sogaitabis31;
gaita31[nota].push(sogaitabis31);
}
tocagaita31(); // primera amb atac
bufa31[nota]=setInterval(tocagaitabis31, loop / baseRate);
}
}
}
if (thereBeSound&&!currentlyPlaying32[nota]){ // just play once
if(sampleBuffers[sampleMidi+3200]){
key.classList.add('activekey');
if(registre32==1&&teclat==0){
var atac=0.2/velocity; // atac
const baseRate=midi2rate(note);
if(bufa32[nota]){
clearInterval(bufa32[nota]);
delete bufa32[nota];
}
gaita32[nota]=[];
function tocagaita32(){
const sogaita32=playSample(
baseRate,
80 / 127,
sampleBuffers[sampleMidi+3200],
atac
);
currentlyPlaying32[nota]=sogaita32;
gaita32[nota].push(sogaita32);
}
let desviacio=1;
function tocagaitabis32(){
desviacio *= -1;
const factor=Math.pow(2, desviacio * 2 / 1200);
const sogaitabis32=playSample(
baseRate * factor,
80/127,
sampleBuffers[sampleMidi+3200],
2
);
currentlyPlaying32[nota]=sogaitabis32;
gaita32[nota].push(sogaitabis32);
}
tocagaita32(); // primera amb atac
bufa32[nota]=setInterval(tocagaitabis32, loop / baseRate);
}
}
}
////// silenci activador
if(thereBeSound&&!currentlyPlaying0[nota]){// just play once
if(sampleBuffers[1]){
key.classList.add('activekey');
// if(registre1==1&&teclat==1){
// const atac=attackTime; // dinàmica
// currentlyPlaying[nota]=playSample(note, velocity / 127, sampleBuffers[nota],atac); // dinàmica
var atac=0.2 / velocity; // atac
// currentlyPlaying1[nota]=playSample((note+100), 127 / 127, sampleBuffers[(note+100)],atac);
currentlyPlaying0[nota]=playSample(midi2rate(note), 80 / 127, sampleBuffers[(1)],atac); // atac
//}
}
}
// fi silenci activador
/*
if(thereBeSound&&!currentlyPlaying31[nota]){// just play once
if(sampleBuffers[(sampleMidi+3100)]){
key.classList.add('activekey');
// if(registre31==1){
// const atac=attackTime; // dinàmica
// currentlyPlaying[nota]=playSample(note, velocity / 128, sampleBuffers[nota],atac); // dinàmica
var atac=0.2 / velocity; // atac
currentlyPlaying31[nota]=playSample(midi2rate(note), 127 / 127, sampleBuffers[(sampleMidi+3100)],atac); // atac
//}
}
}
*/
}
}
if(type===NOTEOFF){
key.classList.remove('activekey');
if (currentlyPlaying[nota]){
if(bufa0[nota]){
clearInterval(bufa0[nota]);
delete bufa0[nota];
}
if(gaita0[nota]){
for (const sogaita0 of gaita0[nota]){
if(!sogaita0) continue;
stop(
sogaita0.gainNode,
sogaita0.gainReverb,
sogaita0.sourceReverb
);
}
delete gaita0[nota];
}
stop(
currentlyPlaying[nota].gainNode,
currentlyPlaying[nota].gainReverb,
currentlyPlaying[nota].sourceReverb
);
delete currentlyPlaying[nota];
}
if(currentlyPlaying0[nota]){
if(bufa0[nota]){
clearInterval(bufa0[nota]);
delete bufa0[nota];
}
if(currentlyPlaying1[nota]){
if(bufa1[nota]){
clearInterval(bufa1[nota]);
delete bufa1[nota];
}
if(gaita1[nota]){
for (const sogaita1 of gaita1[nota]){
if(!sogaita1) continue;
stop(
sogaita1.gainNode,
sogaita1.gainReverb,
sogaita1.sourceReverb
);
}
delete gaita1[nota];
}
stop(
currentlyPlaying1[nota].gainNode,
currentlyPlaying1[nota].gainReverb,
currentlyPlaying1[nota].sourceReverb
);
delete currentlyPlaying1[nota];
}
if(currentlyPlaying2[nota]){
if(bufa2[nota]){
clearInterval(bufa2[nota]);
delete bufa2[nota];
}
if(gaita2[nota]){
for (const sogaita2 of gaita2[nota]){
if(!sogaita2) continue;
stop(
sogaita2.gainNode,
sogaita2.gainReverb,
sogaita2.sourceReverb
);
}
delete gaita2[nota];
}
stop(
currentlyPlaying2[nota].gainNode,
currentlyPlaying2[nota].gainReverb,
currentlyPlaying2[nota].sourceReverb
);
delete currentlyPlaying2[nota];
}
if(currentlyPlaying3[nota]){
if(bufa3[nota]){
clearInterval(bufa3[nota]);
delete bufa3[nota];
}
if(gaita3[nota]){
for (const sogaita3 of gaita3[nota]){
if(!sogaita3) continue;
stop(
sogaita3.gainNode,
sogaita3.gainReverb,
sogaita3.sourceReverb
);
}
delete gaita3[nota];
}
stop(
currentlyPlaying3[nota].gainNode,
currentlyPlaying3[nota].gainReverb,
currentlyPlaying3[nota].sourceReverb
);
delete currentlyPlaying3[nota];
}
if(currentlyPlaying4[nota]){
if(bufa4[nota]){
clearInterval(bufa4[nota]);
delete bufa4[nota];
}
if(gaita4[nota]){
for (const sogaita4 of gaita4[nota]){
if(!sogaita4) continue;
stop(
sogaita4.gainNode,
sogaita4.gainReverb,
sogaita4.sourceReverb
);
}
delete gaita4[nota];
}
stop(
currentlyPlaying4[nota].gainNode,
currentlyPlaying4[nota].gainReverb,
currentlyPlaying4[nota].sourceReverb
);
delete currentlyPlaying4[nota];
}
if(currentlyPlaying5[nota]){
if(bufa5[nota]){
clearInterval(bufa5[nota]);
delete bufa5[nota];
}
if(gaita5[nota]){
for (const sogaita5 of gaita5[nota]){
if(!sogaita5) continue;
stop(
sogaita5.gainNode,
sogaita5.gainReverb,
sogaita5.sourceReverb
);
}
delete gaita5[nota];
}
stop(
currentlyPlaying5[nota].gainNode,
currentlyPlaying5[nota].gainReverb,
currentlyPlaying5[nota].sourceReverb
);
delete currentlyPlaying5[nota];
}
if(currentlyPlaying6[nota]){
if(bufa6[nota]){
clearInterval(bufa6[nota]);
delete bufa6[nota];
}
if(gaita6[nota]){
for (const sogaita6 of gaita6[nota]){
if(!sogaita6) continue;
stop(
sogaita6.gainNode,
sogaita6.gainReverb,
sogaita6.sourceReverb
);
}
delete gaita6[nota];
}
stop(
currentlyPlaying6[nota].gainNode,
currentlyPlaying6[nota].gainReverb,
currentlyPlaying6[nota].sourceReverb
);
delete currentlyPlaying6[nota];
}
if(currentlyPlaying7[nota]){
if(bufa7[nota]){
clearInterval(bufa7[nota]);
delete bufa7[nota];
}
if(gaita7[nota]){
for (const sogaita7 of gaita7[nota]){
if(!sogaita7) continue;
stop(
sogaita7.gainNode,
sogaita7.gainReverb,
sogaita7.sourceReverb
);
}
delete gaita7[nota];
}
stop(
currentlyPlaying7[nota].gainNode,
currentlyPlaying7[nota].gainReverb,
currentlyPlaying7[nota].sourceReverb
);
delete currentlyPlaying7[nota];
}
if(currentlyPlaying8[nota]){
if(bufa8[nota]){
clearInterval(bufa8[nota]);
delete bufa8[nota];
}
if(gaita8[nota]){
for (const sogaita8 of gaita8[nota]){
if(!sogaita8) continue;
stop(
sogaita8.gainNode,
sogaita8.gainReverb,
sogaita8.sourceReverb
);
}
delete gaita8[nota];
}
stop(
currentlyPlaying8[nota].gainNode,
currentlyPlaying8[nota].gainReverb,
currentlyPlaying8[nota].sourceReverb
);
delete currentlyPlaying8[nota];
}
if(currentlyPlaying9[nota]){
if(bufa9[nota]){
clearInterval(bufa9[nota]);
delete bufa9[nota];
}
if(gaita9[nota]){
for (const sogaita9 of gaita9[nota]){
if(!sogaita9) continue;
stop(
sogaita9.gainNode,
sogaita9.gainReverb,
sogaita9.sourceReverb
);
}
delete gaita9[nota];
}
stop(
currentlyPlaying9[nota].gainNode,
currentlyPlaying9[nota].gainReverb,
currentlyPlaying9[nota].sourceReverb
);
delete currentlyPlaying9[nota];
}
if(currentlyPlaying10[nota]){
if(bufa10[nota]){
clearInterval(bufa10[nota]);
delete bufa10[nota];
}
if(gaita10[nota]){
for (const sogaita10 of gaita10[nota]){
if(!sogaita10) continue;
stop(
sogaita10.gainNode,
sogaita10.gainReverb,
sogaita10.sourceReverb
);
}
delete gaita10[nota];
}
stop(
currentlyPlaying10[nota].gainNode,
currentlyPlaying10[nota].gainReverb,
currentlyPlaying10[nota].sourceReverb
);
delete currentlyPlaying10[nota];
}
if(currentlyPlaying11[nota]){
if(bufa11[nota]){
clearInterval(bufa11[nota]);
delete bufa11[nota];
}
if(gaita11[nota]){
for (const sogaita11 of gaita11[nota]){
if(!sogaita11) continue;
stop(
sogaita11.gainNode,
sogaita11.gainReverb,
sogaita11.sourceReverb
);
}
delete gaita11[nota];
}
stop(
currentlyPlaying11[nota].gainNode,
currentlyPlaying11[nota].gainReverb,
currentlyPlaying11[nota].sourceReverb
);
delete currentlyPlaying11[nota];
}
if(currentlyPlaying12[nota]){
if(bufa12[nota]){
clearInterval(bufa12[nota]);
delete bufa12[nota];
}
if(gaita12[nota]){
for (const sogaita12 of gaita12[nota]){
if(!sogaita12) continue;
stop(
sogaita12.gainNode,
sogaita12.gainReverb,
sogaita12.sourceReverb
);
}
delete gaita12[nota];
}
stop(
currentlyPlaying12[nota].gainNode,
currentlyPlaying12[nota].gainReverb,
currentlyPlaying12[nota].sourceReverb
);
delete currentlyPlaying12[nota];
}
if(currentlyPlaying13[nota]){
if(bufa13[nota]){
clearInterval(bufa13[nota]);
delete bufa13[nota];
}
if(gaita13[nota]){
for (const sogaita13 of gaita13[nota]){
if(!sogaita13) continue;
stop(
sogaita13.gainNode,
sogaita13.gainReverb,
sogaita13.sourceReverb
);
}
delete gaita13[nota];
}
stop(
currentlyPlaying13[nota].gainNode,
currentlyPlaying13[nota].gainReverb,
currentlyPlaying13[nota].sourceReverb
);
delete currentlyPlaying13[nota];
}
if(currentlyPlaying14[nota]){
if(bufa14[nota]){
clearInterval(bufa14[nota]);
delete bufa14[nota];
}
if(gaita14[nota]){
for (const sogaita14 of gaita14[nota]){
if(!sogaita14) continue;
stop(
sogaita14.gainNode,
sogaita14.gainReverb,
sogaita14.sourceReverb
);
}
delete gaita14[nota];
}
stop(
currentlyPlaying14[nota].gainNode,
currentlyPlaying14[nota].gainReverb,
currentlyPlaying14[nota].sourceReverb
);
delete currentlyPlaying14[nota];
}
if(currentlyPlaying15[nota]){
if(bufa15[nota]){
clearInterval(bufa15[nota]);
delete bufa15[nota];
}
if(gaita15[nota]){
for (const sogaita15 of gaita15[nota]){
if(!sogaita15) continue;
stop(
sogaita15.gainNode,
sogaita15.gainReverb,
sogaita15.sourceReverb
);
}
delete gaita15[nota];
}
stop(
currentlyPlaying15[nota].gainNode,
currentlyPlaying15[nota].gainReverb,
currentlyPlaying15[nota].sourceReverb
);
delete currentlyPlaying15[nota];
}
if(currentlyPlaying16[nota]){
if(bufa16[nota]){
clearInterval(bufa16[nota]);
delete bufa16[nota];
}
if(gaita16[nota]){
for (const sogaita16 of gaita16[nota]){
if(!sogaita16) continue;
stop(
sogaita16.gainNode,
sogaita16.gainReverb,
sogaita16.sourceReverb
);
}
delete gaita16[nota];
}
stop(
currentlyPlaying16[nota].gainNode,
currentlyPlaying16[nota].gainReverb,
currentlyPlaying16[nota].sourceReverb
);
delete currentlyPlaying16[nota];
}
if(currentlyPlaying17[nota]){
if(bufa17[nota]){
clearInterval(bufa17[nota]);
delete bufa17[nota];
}
if(gaita17[nota]){
for (const sogaita17 of gaita17[nota]){
if(!sogaita17) continue;
stop(
sogaita17.gainNode,
sogaita17.gainReverb,
sogaita17.sourceReverb
);
}
delete gaita17[nota];
}
stop(
currentlyPlaying17[nota].gainNode,
currentlyPlaying17[nota].gainReverb,
currentlyPlaying17[nota].sourceReverb
);
delete currentlyPlaying17[nota];
}
if(currentlyPlaying18[nota]){
if(bufa18[nota]){
clearInterval(bufa18[nota]);
delete bufa18[nota];
}
if(gaita18[nota]){
for (const sogaita18 of gaita18[nota]){
if(!sogaita18) continue;
stop(
sogaita18.gainNode,
sogaita18.gainReverb,
sogaita18.sourceReverb
);
}
delete gaita18[nota];
}
stop(
currentlyPlaying18[nota].gainNode,
currentlyPlaying18[nota].gainReverb,
currentlyPlaying18[nota].sourceReverb
);
delete currentlyPlaying18[nota];
}
if(currentlyPlaying19[nota]){
if(bufa19[nota]){
clearInterval(bufa19[nota]);
delete bufa19[nota];
}
if(gaita19[nota]){
for (const sogaita19 of gaita19[nota]){
if(!sogaita19) continue;
stop(
sogaita19.gainNode,
sogaita19.gainReverb,
sogaita19.sourceReverb
);
}
delete gaita19[nota];
}
stop(
currentlyPlaying19[nota].gainNode,
currentlyPlaying19[nota].gainReverb,
currentlyPlaying19[nota].sourceReverb
);
delete currentlyPlaying19[nota];
}
if(currentlyPlaying20[nota]){
if(bufa20[nota]){
clearInterval(bufa20[nota]);
delete bufa20[nota];
}
if(gaita20[nota]){
for (const sogaita20 of gaita20[nota]){
if(!sogaita20) continue;
stop(
sogaita20.gainNode,
sogaita20.gainReverb,
sogaita20.sourceReverb
);
}
delete gaita20[nota];
}
stop(
currentlyPlaying20[nota].gainNode,
currentlyPlaying20[nota].gainReverb,
currentlyPlaying20[nota].sourceReverb
);
delete currentlyPlaying20[nota];
}
if(currentlyPlaying21[nota]){
if(bufa21[nota]){
clearInterval(bufa21[nota]);
delete bufa21[nota];
}
if(gaita21[nota]){
for (const sogaita21 of gaita21[nota]){
if(!sogaita21) continue;
stop(
sogaita21.gainNode,
sogaita21.gainReverb,
sogaita21.sourceReverb
);
}
delete gaita21[nota];
}
stop(
currentlyPlaying21[nota].gainNode,
currentlyPlaying21[nota].gainReverb,
currentlyPlaying21[nota].sourceReverb
);
delete currentlyPlaying21[nota];
}
if(currentlyPlaying22[nota]){
if(bufa22[nota]){
clearInterval(bufa22[nota]);
delete bufa22[nota];
}
if(gaita22[nota]){
for (const sogaita22 of gaita22[nota]){
if(!sogaita22) continue;
stop(
sogaita22.gainNode,
sogaita22.gainReverb,
sogaita22.sourceReverb
);
}
delete gaita22[nota];
}
stop(
currentlyPlaying22[nota].gainNode,
currentlyPlaying22[nota].gainReverb,
currentlyPlaying22[nota].sourceReverb
);
delete currentlyPlaying22[nota];
}
if(currentlyPlaying23[nota]){
if(bufa23[nota]){
clearInterval(bufa23[nota]);
delete bufa23[nota];
}
if(gaita23[nota]){
for (const sogaita23 of gaita23[nota]){
if(!sogaita23) continue;
stop(
sogaita23.gainNode,
sogaita23.gainReverb,
sogaita23.sourceReverb
);
}
delete gaita23[nota];
}
stop(
currentlyPlaying23[nota].gainNode,
currentlyPlaying23[nota].gainReverb,
currentlyPlaying23[nota].sourceReverb
);
delete currentlyPlaying23[nota];
}
if(currentlyPlaying24[nota]){
if(bufa24[nota]){
clearInterval(bufa24[nota]);
delete bufa24[nota];
}
if(gaita24[nota]){
for (const sogaita24 of gaita24[nota]){
if(!sogaita24) continue;
stop(
sogaita24.gainNode,
sogaita24.gainReverb,
sogaita24.sourceReverb
);
}
delete gaita24[nota];
}
stop(
currentlyPlaying24[nota].gainNode,
currentlyPlaying24[nota].gainReverb,
currentlyPlaying24[nota].sourceReverb
);
delete currentlyPlaying24[nota];
}
if(currentlyPlaying25[nota]){
if(bufa25[nota]){
clearInterval(bufa25[nota]);
delete bufa25[nota];
}
if(gaita25[nota]){
for (const sogaita25 of gaita25[nota]){
if(!sogaita25) continue;
stop(
sogaita25.gainNode,
sogaita25.gainReverb,
sogaita25.sourceReverb
);
}
delete gaita25[nota];
}
stop(
currentlyPlaying25[nota].gainNode,
currentlyPlaying25[nota].gainReverb,
currentlyPlaying25[nota].sourceReverb
);
delete currentlyPlaying25[nota];
}
if(currentlyPlaying26[nota]){
if(bufa26[nota]){
clearInterval(bufa26[nota]);
delete bufa26[nota];
}
if(gaita26[nota]){
for (const sogaita26 of gaita26[nota]){
if(!sogaita26) continue;
stop(
sogaita26.gainNode,
sogaita26.gainReverb,
sogaita26.sourceReverb
);
}
delete gaita26[nota];
}
stop(
currentlyPlaying26[nota].gainNode,
currentlyPlaying26[nota].gainReverb,
currentlyPlaying26[nota].sourceReverb
);
delete currentlyPlaying26[nota];
}
if(currentlyPlaying27[nota]){
if(bufa27[nota]){
clearInterval(bufa27[nota]);
delete bufa27[nota];
}
if(gaita27[nota]){
for (const sogaita27 of gaita27[nota]){
if(!sogaita27) continue;
stop(
sogaita27.gainNode,
sogaita27.gainReverb,
sogaita27.sourceReverb
);
}
delete gaita27[nota];
}
stop(
currentlyPlaying27[nota].gainNode,
currentlyPlaying27[nota].gainReverb,
currentlyPlaying27[nota].sourceReverb
);
delete currentlyPlaying27[nota];
}
if(currentlyPlaying28[nota]){
if(bufa28[nota]){
clearInterval(bufa28[nota]);
delete bufa28[nota];
}
if(gaita28[nota]){
for (const sogaita28 of gaita28[nota]){
if(!sogaita28) continue;
stop(
sogaita28.gainNode,
sogaita28.gainReverb,
sogaita28.sourceReverb
);
}
delete gaita28[nota];
}
stop(
currentlyPlaying28[nota].gainNode,
currentlyPlaying28[nota].gainReverb,
currentlyPlaying28[nota].sourceReverb
);
delete currentlyPlaying28[nota];
}
if(currentlyPlaying29[nota]){
if(bufa29[nota]){
clearInterval(bufa29[nota]);
delete bufa29[nota];
}
if(gaita29[nota]){
for (const sogaita29 of gaita29[nota]){
if(!sogaita29) continue;
stop(
sogaita29.gainNode,
sogaita29.gainReverb,
sogaita29.sourceReverb
);
}
delete gaita29[nota];
}
stop(
currentlyPlaying29[nota].gainNode,
currentlyPlaying29[nota].gainReverb,
currentlyPlaying29[nota].sourceReverb
);
delete currentlyPlaying29[nota];
}
if(currentlyPlaying30[nota]){
if(bufa30[nota]){
clearInterval(bufa30[nota]);
delete bufa30[nota];
}
if(gaita30[nota]){
for (const sogaita30 of gaita30[nota]){
if(!sogaita30) continue;
stop(
sogaita30.gainNode,
sogaita30.gainReverb,
sogaita30.sourceReverb
);
}
delete gaita30[nota];
}
stop(
currentlyPlaying30[nota].gainNode,
currentlyPlaying30[nota].gainReverb,
currentlyPlaying30[nota].sourceReverb
);
delete currentlyPlaying30[nota];
}
if(currentlyPlaying31[nota]){
if(bufa31[nota]){
clearInterval(bufa31[nota]);
delete bufa31[nota];
}
if(gaita31[nota]){
for (const sogaita31 of gaita31[nota]){
if(!sogaita31) continue;
stop(
sogaita31.gainNode,
sogaita31.gainReverb,
sogaita31.sourceReverb
);
}
delete gaita31[nota];
}
stop(
currentlyPlaying31[nota].gainNode,
currentlyPlaying31[nota].gainReverb,
currentlyPlaying31[nota].sourceReverb
);
delete currentlyPlaying31[nota];
}
if(currentlyPlaying32[nota]){
if(bufa32[nota]){
clearInterval(bufa32[nota]);
delete bufa32[nota];
}
if(gaita32[nota]){
for (const sogaita32 of gaita32[nota]){
if(!sogaita32) continue;
stop(
sogaita32.gainNode,
sogaita32.gainReverb,
sogaita32.sourceReverb
);
}
delete gaita32[nota];
}
stop(
currentlyPlaying32[nota].gainNode,
currentlyPlaying32[nota].gainReverb,
currentlyPlaying32[nota].sourceReverb
);
delete currentlyPlaying32[nota];
}
if(currentlyPlaying35[nota]){
if(bufa35[nota]){
clearInterval(bufa35[nota]);
delete bufa35[nota];
}
if(gaita35[nota]){
for (const sogaita35 of gaita35[nota]){
if(!sogaita35) continue;
stop(
sogaita35.gainNode,
sogaita35.gainReverb,
sogaita35.sourceReverb
);
}
delete gaita35[nota];
}
stop(
currentlyPlaying35[nota].gainNode,
currentlyPlaying35[nota].gainReverb,
currentlyPlaying35[nota].sourceReverb
);
delete currentlyPlaying35[nota];
}
/*
if(gaita0b[nota]){
for (const sogaita0b of gaita0b[nota]){
if(!sogaita0b) continue;
stop(
sogaita0b.gainNode,
sogaita0b.gainReverb,
sogaita0b.sourceReverb
);
}
delete gaita0b[nota];
}
stop(
currentlyPlaying0b[nota].gainNode,
currentlyPlaying0b[nota].gainReverb,
currentlyPlaying0b[nota].sourceReverb
);
delete currentlyPlaying0b[nota];
*/
}
}
}
window.addEventListener('resize', () =>{
setTimeout(scrollMiddleC, 100);
});
let thereBeSound=false;
window.addEventListener('DOMContentLoaded', () =>{
setTimeout(scrollMiddleC, 100);
loadSampleBuffersInBatches(12)
.then(() =>{
// Sample buffers loaded successfully, continue with other initialization logic
console.log('Sample buffers loaded successfully');
// Add other initialization logic here, if any
}, function(error){
console.error('Error loading sample:', error);
});
// options: flautat
keys.classList.remove('labels');
if(!localStorage.getItem('flautat')){
localStorage.setItem('flautat', false);
}
flautat.checked=localStorage.getItem('flautat')==='true';
if(flautat.checked){
registre0=1;
}
flautat.onchange=() =>{
localStorage.setItem('flautat', flautat.checked);
if(flautat.checked){
registre0=1;
if(keyflautat.checked){
keyflautat.click();
}
}else{
registre0=0;
}
};
// options: octava
keys.classList.remove('labels');
if(!localStorage.getItem('octava')){
localStorage.setItem('octava', false);
}
octava.checked=localStorage.getItem('octava')==='true';
if(octava.checked){
registre1= 1;
}
octava.onchange=() =>{
localStorage.setItem('octava', octava.checked);
if(octava.checked){
registre1= 1;
if(keyoctava.checked){
keyoctava.click();
}
}else{
registre1=0;
}
};
// options: gaita
keys.classList.remove('labels');
if(!localStorage.getItem('gaita')){
localStorage.setItem('gaita', false);
}
gaita.checked=localStorage.getItem('gaita')==='true';
if(gaita.checked){
somanxa(1);
}
gaita.onchange=() =>{
localStorage.setItem('gaita', gaita.checked);
if(gaita.checked){
somanxa(1);
if(keygaita.checked){
keygaita.click();
}
}else{
somanxa(0);
}
};
// options: ocells
let ocell;
keys.classList.remove('labels');
if(!localStorage.getItem('ocells')){
localStorage.setItem('ocells', false);
}
ocells.checked=localStorage.getItem('ocells')==='true';
if(ocells.checked){
somanxo(1);
clearInterval(ocell);
bombolles();
ocell=setInterval(bombolles, 6000);
}
ocells.onchange=() =>{
localStorage.setItem('ocells', ocells.checked);
if(ocells.checked){
somanxo(1);
clearInterval(ocell);
bombolles();
ocell=setInterval(bombolles, 6000);
if(keyocells.checked){
keyocells.click();
}
}else{
somanxo(0);
clearInterval(ocell);
}
};
// options: baixons
keys.classList.remove('labels');
if(!localStorage.getItem('baixons')){
localStorage.setItem('baixons', false);
}
baixons.checked=localStorage.getItem('baixons')==='true';
if(baixons.checked){
registre2= 1;
}
baixons.onchange=() =>{
localStorage.setItem('baixons', baixons.checked);
if(baixons.checked){
registre2= 1;
if(keybaixons.checked){
keybaixons.click();
}
}else{
registre2=0;
}
};
// options: clarins
keys.classList.remove('labels');
if(!localStorage.getItem('clarins')){
localStorage.setItem('clarins', false);
}
clarins.checked=localStorage.getItem('clarins')==='true';
if(clarins.checked){
registre3= 1;
}
clarins.onchange=() =>{
localStorage.setItem('clarins', clarins.checked);
if(clarins.checked){
registre3= 1;
if(keyclarins.checked){
keyclarins.click();
}
}else{
registre3=0;
}
};
// options: tremor
keys.classList.remove('labels');
if(!localStorage.getItem('tremor')){
localStorage.setItem('tremor', false);
}
tremor.checked=localStorage.getItem('tremor')==='true';
if(tremor.checked){
tremolor= 1;
}
tremor.onchange=() =>{
localStorage.setItem('tremor', tremor.checked);
if(tremor.checked){
tremolor= 1;
if(keytremor.checked){
keytremor.click();
}
}else{
tremolor=0;
}
};
// options: xirimia
keys.classList.remove('labels');
if(!localStorage.getItem('xirimia')){
localStorage.setItem('xirimia', false);
}
xirimia.checked=localStorage.getItem('xirimia')==='true';
if(xirimia.checked){
registre4= 1;
}
xirimia.onchange=() =>{
localStorage.setItem('xirimia', xirimia.checked);
if(xirimia.checked){
registre4= 1;
if(keyxirimia.checked){
keyxirimia.click();
}
}else{
registre4=0;
}
};
// options: trompeta
keys.classList.remove('labels');
if(!localStorage.getItem('trompeta')){
localStorage.setItem('trompeta', false);
}
trompeta.checked=localStorage.getItem('trompeta')==='true';
if(trompeta.checked){
registre5= 1;
}
trompeta.onchange=() =>{
localStorage.setItem('trompeta', trompeta.checked);
if(trompeta.checked){
registre5= 1;
if(keytrompeta.checked){
keytrompeta.click();
}
}else{
registre5=0;
}
};
// options: dotzena
keys.classList.remove('labels');
if(!localStorage.getItem('dotzena')){
localStorage.setItem('dotzena', false);
}
dotzena.checked=localStorage.getItem('dotzena')==='true';
if(dotzena.checked){
registre6= 1;
}
dotzena.onchange=() =>{
localStorage.setItem('dotzena', dotzena.checked);
if(dotzena.checked){
registre6= 1;
if(keydotzena.checked){
keydotzena.click();
}
}else{
registre6=0;
}
};
// options: quinzena
keys.classList.remove('labels');
if(!localStorage.getItem('quinzena')){
localStorage.setItem('quinzena', false);
}
quinzena.checked=localStorage.getItem('quinzena')==='true';
if(quinzena.checked){
registre7= 1;
}
quinzena.onchange=() =>{
localStorage.setItem('quinzena', quinzena.checked);
if(quinzena.checked){
registre7= 1;
if(keyquinzena.checked){
keyquinzena.click();
}
}else{
registre7=0;
}
};
// options: dinovena
keys.classList.remove('labels');
if(!localStorage.getItem('dinovena')){
localStorage.setItem('dinovena', false);
}
dinovena.checked=localStorage.getItem('dinovena')==='true';
if(dinovena.checked){
registre8= 1;
}
dinovena.onchange=() =>{
localStorage.setItem('dinovena', dinovena.checked);
if(dinovena.checked){
registre8= 1;
if(keydinovena.checked){
keydinovena.click();
}
}else{
registre8=0;
}
};
// options: vintidosena
keys.classList.remove('labels');
if(!localStorage.getItem('vintidosena')){
localStorage.setItem('vintidosena', false);
}
vintidosena.checked=localStorage.getItem('vintidosena')==='true';
if(vintidosena.checked){
registre9= 1;
}
vintidosena.onchange=() =>{
localStorage.setItem('vintidosena', vintidosena.checked);
if(vintidosena.checked){
registre9= 1;
if(keyvintidosena.checked){
keyvintidosena.click();
}
}else{
registre9=0;
}
};
// options: ple
keys.classList.remove('labels');
if(!localStorage.getItem('ple')){
localStorage.setItem('ple', false);
}
ple.checked=localStorage.getItem('ple')==='true';
if(ple.checked){
registre10= 1;
}
ple.onchange=() =>{
localStorage.setItem('ple', ple.checked);
if(ple.checked){
registre10= 1;
if(keyple.checked){
keyple.click();
}
}else{
registre10=0;
}
};
// options: cimbalet
keys.classList.remove('labels');
if(!localStorage.getItem('cimbalet')){
localStorage.setItem('cimbalet', false);
}
cimbalet.checked=localStorage.getItem('cimbalet')==='true';
if(cimbalet.checked){
registre11= 1;
}
cimbalet.onchange=() =>{
localStorage.setItem('cimbalet', cimbalet.checked);
if(cimbalet.checked){
registre11= 1;
if(keycimbalet.checked){
keycimbalet.click();
}
}else{
registre11=0;
}
};
// options: corneta
keys.classList.remove('labels');
if(!localStorage.getItem('corneta')){
localStorage.setItem('corneta', false);
}
corneta.checked=localStorage.getItem('corneta')==='true';
if(corneta.checked){
registre12= 1;
}
corneta.onchange=() =>{
localStorage.setItem('corneta', corneta.checked);
if(corneta.checked){
registre12= 1;
if(keycorneta.checked){
keycorneta.click();
}
}else{
registre12=0;
}
};
// options: bordo
keys.classList.remove('labels');
if(!localStorage.getItem('bordo')){
localStorage.setItem('bordo', false);
}
bordo.checked=localStorage.getItem('bordo')==='true';
if(bordo.checked){
registre13= 1;
}
bordo.onchange=() =>{
localStorage.setItem('bordo', bordo.checked);
if(bordo.checked){
registre13= 1;
if(keybordo.checked){
keybordo.click();
}
}else{
registre13=0;
}
};
// options: tapadet
keys.classList.remove('labels');
if(!localStorage.getItem('tapadet')){
localStorage.setItem('tapadet', false);
}
tapadet.checked=localStorage.getItem('tapadet')==='true';
if(tapadet.checked){
registre14= 1;
}
tapadet.onchange=() =>{
localStorage.setItem('tapadet', tapadet.checked);
if(tapadet.checked){
registre14= 1;
if(keytapadet.checked){
keytapadet.click();
}
}else{
registre14=0;
}
};
// options: nasard12
keys.classList.remove('labels');
if(!localStorage.getItem('nasard12')){
localStorage.setItem('nasard12', false);
}
nasard12.checked=localStorage.getItem('nasard12')==='true';
if(nasard12.checked){
registre15= 1;
}
nasard12.onchange=() =>{
localStorage.setItem('nasard12', nasard12.checked);
if(nasard12.checked){
registre15= 1;
if(keynasard12.checked){
keynasard12.click();
}
}else{
registre15=0;
}
};
// options: nasard15
keys.classList.remove('labels');
if(!localStorage.getItem('nasard15')){
localStorage.setItem('nasard15', false);
}
nasard15.checked=localStorage.getItem('nasard15')==='true';
if(nasard15.checked){
registre16= 1;
}
nasard15.onchange=() =>{
localStorage.setItem('nasard15', nasard15.checked);
if(nasard15.checked){
registre16= 1;
if(keynasard15.checked){
keynasard15.click();
}
}else{
registre16=0;
}
};
// options: nasard17
keys.classList.remove('labels');
if(!localStorage.getItem('nasard17')){
localStorage.setItem('nasard17', false);
}
nasard17.checked=localStorage.getItem('nasard17')==='true';
if(nasard17.checked){
registre17= 1;
}
nasard17.onchange=() =>{
localStorage.setItem('nasard17', nasard17.checked);
if(nasard17.checked){
registre17= 1;
if(keynasard17.checked){
keynasard17.click();
}
}else{
registre17=0;
}
};
// options: bordo_c
keys.classList.remove('labels');
if(!localStorage.getItem('bordo_c')){
localStorage.setItem('bordo_c', false);
}
bordo_c.checked=localStorage.getItem('bordo_c')==='true';
if(bordo_c.checked){
registre18= 1;
}
bordo_c.onchange=() =>{
localStorage.setItem('bordo_c', bordo_c.checked);
if(bordo_c.checked){
registre18= 1;
if(keybordo_c.checked){
keybordo_c.click();
}
}else{
registre18=0;
}
};
// options: octava_c
keys.classList.remove('labels');
if(!localStorage.getItem('octava_c')){
localStorage.setItem('octava_c', false);
}
octava_c.checked=localStorage.getItem('octava_c')==='true';
if(octava_c.checked){
registre19= 1;
}
octava_c.onchange=() =>{
localStorage.setItem('octava_c', octava_c.checked);
if(octava_c.checked){
registre19= 1;
if(keyoctava_c.checked){
keyoctava_c.click();
}
}else{
registre19=0;
}
};
// options: tapadet_c
keys.classList.remove('labels');
if(!localStorage.getItem('tapadet_c')){
localStorage.setItem('tapadet_c', false);
}
tapadet_c.checked=localStorage.getItem('tapadet_c')==='true';
if(tapadet_c.checked){
registre20= 1;
}
tapadet_c.onchange=() =>{
localStorage.setItem('tapadet_c', tapadet_c.checked);
if(tapadet_c.checked){
registre20= 1;
if(keytapadet_c.checked){
keytapadet_c.click();
}
}else{
registre20=0;
}
};
// options: quinzena_c
keys.classList.remove('labels');
if(!localStorage.getItem('quinzena_c')){
localStorage.setItem('quinzena_c', false);
}
quinzena_c.checked=localStorage.getItem('quinzena_c')==='true';
if(quinzena_c.checked){
registre21= 1;
}
quinzena_c.onchange=() =>{
localStorage.setItem('quinzena_c', quinzena_c.checked);
if(quinzena_c.checked){
registre21= 1;
if(keyquinzena_c.checked){
keyquinzena_c.click();
}
}else{
registre21=0;
}
};
// options: dinovena_c
keys.classList.remove('labels');
if(!localStorage.getItem('dinovena_c')){
localStorage.setItem('dinovena_c', false);
}
dinovena_c.checked=localStorage.getItem('dinovena_c')==='true';
if(dinovena_c.checked){
registre22= 1;
}
dinovena_c.onchange=() =>{
localStorage.setItem('dinovena_c', dinovena_c.checked);
if(dinovena_c.checked){
registre22= 1;
if(keydinovena_c.checked){
keydinovena_c.click();
}
}else{
registre22=0;
}
};
// options: nasard19a_c
keys.classList.remove('labels');
if(!localStorage.getItem('nasard19a_c')){
localStorage.setItem('nasard19a_c', false);
}
nasard19a_c.checked=localStorage.getItem('nasard19a_c')==='true';
if(nasard19a_c.checked){
registre23= 1;
}
nasard19a_c.onchange=() =>{
localStorage.setItem('nasard19a_c', nasard19a_c.checked);
if(nasard19a_c.checked){
registre23= 1;
if(keynasard19a_c.checked){
keynasard19a_c.click();
}
}else{
registre23=0;
}
};
// options: vintidosena_i_vintisisena_c
keys.classList.remove('labels');
if(!localStorage.getItem('vintidosena_i_vintisisena_c')){
localStorage.setItem('vintidosena_i_vintisisena_c', false);
}
vintidosena_i_vintisisena_c.checked=localStorage.getItem('vintidosena_i_vintisis
ena_c')==='true';
if(vintidosena_i_vintisisena_c.checked){
registre24= 1;
}
vintidosena_i_vintisisena_c.onchange=() =>{
localStorage.setItem('vintidosena_i_vintisisena_c', vintidosena_i_vintisisena_c.checked);
if(vintidosena_i_vintisisena_c.checked){
registre24= 1;
if(keyvintidosena_i_vintisisena_c.checked){
keyvintidosena_i_vintisisena_c.click();
}
}else{
registre24=0;
}
};
// options: cimbalet_c
keys.classList.remove('labels');
if(!localStorage.getItem('cimbalet_c')){
localStorage.setItem('cimbalet_c', false);
}
cimbalet_c.checked=localStorage.getItem('cimbalet_c')==='true';
if(cimbalet_c.checked){
registre25= 1;
}
cimbalet_c.onchange=() =>{
localStorage.setItem('cimbalet_c', cimbalet_c.checked);
if(cimbalet_c.checked){
registre25= 1;
if(keycimbalet_c.checked){
keycimbalet_c.click();
}
}else{
registre25=0;
}
};
// options: keylabels
keys.classList.remove('labels');
if(!localStorage.getItem('keylabels')){
localStorage.setItem('keylabels', false);
}
keylabels.checked=localStorage.getItem('keylabels')==='true';
if(keylabels.checked){
keys.classList.add('keylabels');
}
keylabels.onchange=() =>{
localStorage.setItem('keylabels', keylabels.checked);
if(keylabels.checked){
keys.classList.add('keylabels');
if(labels.checked){
labels.click();
}
}else{
keys.classList.remove('keylabels');
}
};
// options: highlight color
if(!localStorage.getItem('color')){
localStorage.setItem('color', '#3ac99b');
}
color.value=localStorage.getItem('color');
document.styleSheets[0].cssRules[0].style.background=localStorage.getItem('color');
color.onchange=function(e){
localStorage.setItem('color', e.target.value);
document.styleSheets[0].cssRules[0].style.background=localStorage.getItem('color');
};
// options: play sounds
if(!localStorage.getItem('sounds')){
localStorage.setItem('sounds', true);
}
sounds.checked=localStorage.getItem('sounds')==='true';
if(sounds.checked){
sounds.parentNode.getElementsByTagName('label')[0].className='soundon';
thereBeSound=true;
}
sounds.onchange=() =>{
localStorage.setItem('sounds', sounds.checked);
if(sounds.checked){
sounds.parentNode.getElementsByTagName('label')[0].className='soundon';
thereBeSound=true;
}else{
sounds.parentNode.getElementsByTagName('label')[0].className='';
thereBeSound=false;
}
};
showhideoptions.onclick=() =>{
opts.style.display=opts.style.display==='inline-block' ? 'none' :'inline-block';
};
requestMidi();
});
keys.onmousedown=keys.ontouchstart=keys.ondblclick=e =>{
e.preventDefault();
// teclat=1;
onMessage({data: [NOTEON, Number(e.target.id.replace('midi-', '')), MAX_VELOCITY, 1]});
e.target.classList.add('activekey');
if(acoblament3===1){
onMessage({data: [NOTEON, Number(e.target.id.replace('midi-', '')), MAX_VELOCITY, 2]});
e.target.classList.add('activekey');
}
};
keys.onmouseup=keys.ontouchend=e =>{
e.preventDefault();
// teclat=1;
onMessage({data: [NOTEOFF, Number(e.target.id.replace('midi-', '')), MAX_VELOCITY, 1]});
e.target.classList.remove('activekey');
if(acoblament3===1){
onMessage({data: [NOTEOFF, Number(e.target.id.replace('midi-', '')), MAX_VELOCITY, 2]});
e.target.classList.remove('activekey');
}
};
keys0.onmousedown=keys0.ontouchstart=keys0.ondblclick=e =>{
e.preventDefault();
// teclat=0;
onMessage({data: [NOTEON, Number(e.target.id.replace('midi0-', '')), MAX_VELOCITY, 0]});
e.target.classList.add('activekey');
if(acoblament1===1){
onMessage({data: [NOTEON, Number(e.target.id.replace('midi0-', '')), MAX_VELOCITY, 1]});
e.target.classList.add('activekey');
}
if(acoblament2===1){
onMessage({data: [NOTEON, Number(e.target.id.replace('midi0-', '')), MAX_VELOCITY, 2]});
e.target.classList.add('activekey');
}
};
keys0.onmouseup=keys0.ontouchend=e =>{
e.preventDefault();
// teclat=0;
onMessage({data: [NOTEOFF, Number(e.target.id.replace('midi0-', '')), MAX_VELOCITY, 0]});
e.target.classList.remove('activekey');
if(acoblament1===1){
onMessage({data: [NOTEOFF, Number(e.target.id.replace('midi0-', '')), MAX_VELOCITY, 1]});
e.target.classList.remove('activekey');
}
if(acoblament2===1){
onMessage({data: [NOTEOFF, Number(e.target.id.replace('midi0-', '')), MAX_VELOCITY, 2]});
e.target.classList.remove('activekey');
}
};
keys1.onmousedown=keys1.ontouchstart=keys1.ondblclick=e =>{
e.preventDefault();
// teclat=1;
onMessage({data: [NOTEON, Number(e.target.id.replace('midi1-', '')), MAX_VELOCITY, 2]});
e.target.classList.add('activekey');
};
keys1.onmouseup=keys1.ontouchend=e =>{
e.preventDefault();
// teclat=2;
onMessage({data: [NOTEOFF, Number(e.target.id.replace('midi1-', '')), MAX_VELOCITY, 2]});
e.target.classList.remove('activekey');
};
document.addEventListener('keydown', event =>{
const note=keysToMidi[event.key];
if(note){
onMessage({data: [NOTEON, note, MAX_VELOCITY, 1]});
onMessage({data: [NOTEON, note, MAX_VELOCITY, 2]});
}
}, false);
document.addEventListener('keyup', event =>{
const note=keysToMidi[event.key];
if(note){
onMessage({data: [NOTEOFF, note, MAX_VELOCITY, 1]});
onMessage({data: [NOTEOFF, note, MAX_VELOCITY, 2]});
}
}, false);
const attackTime=0.005;
const releaseTime=0.02;
function playSample(rate, volume, sampleBuffer, atac){
const drySource=audioContext.createBufferSource();
drySource.buffer=sampleBuffer;
drySource.playbackRate.value=rate;
const reverbSource=audioContext.createBufferSource();
reverbSource.buffer=sampleBuffer;
reverbSource.playbackRate.value=rate;
const dryGain=audioContext.createGain(); // Atac
const tremoloGain=audioContext.createGain(); // Tremolo actua aquí
const wetGain=audioContext.createGain();
const dryLevel=(1 - distancia) * volume;
const wetLevel=distancia * volume;
let lfo=null;
tremoloGain.gain.value=1; // La intensitat vindrà del LFO
if(tremolor===1){
lfo=audioContext.createOscillator();
const lfoDepth=audioContext.createGain();
lfo.frequency.value=2.45; // Hz del tremolo
lfoDepth.gain.value=0.13; // Intensitat màxima del tremolo
// Base de guany per mantenir el so auditiu: el volum oscil·larà entre 0.75 i 1.25
// Si vols oscil·lació més lleu: 0.1 o 0.2
const offsetGain=audioContext.createGain();
offsetGain.gain.value=0.75; // nivell mínim, s’hi suma el lfo
lfo.connect(lfoDepth);
lfoDepth.connect(tremoloGain.gain);
offsetGain.connect(tremoloGain.gain);
lfo.start();
}
dryGain.gain.value=0;
dryGain.gain.linearRampToValueAtTime(dryLevel, audioContext.currentTime + atac);
wetGain.gain.value=0;
wetGain.gain.linearRampToValueAtTime(wetLevel, audioContext.currentTime + atac);
drySource.connect(dryGain);
dryGain.connect(tremoloGain);
tremoloGain.connect(audioContext.destination);
reverbSource.connect(wetGain);
wetGain.connect(reverbNode);
reverbNode.connect(audioContext.destination);
drySource.start();
reverbSource.start();
return{
gainNode: dryGain,
gainReverb: wetGain,
sourceReverb: reverbSource,
tremoloGain: tremoloGain,
lfo: lfo
};
}
function stop(gainNode, gainReverb=null, sourceReverb=null, tremoloGain=null, lfo=null){
const now=audioContext.currentTime;
gainNode.gain.setValueAtTime(gainNode.gain.value, now);
gainNode.gain.linearRampToValueAtTime(0, now + releaseTime);
if(gainReverb&&sourceReverb){
gainReverb.gain.setValueAtTime(gainReverb.gain.value, now);
gainReverb.gain.linearRampToValueAtTime(0, now + releaseTime);
sourceReverb.stop(now + releaseTime + 0.05);
}
if(lfo){
lfo.stop(now + releaseTime + 0.05);
}
setTimeout(() =>{
gainNode.disconnect();
if(gainReverb) gainReverb.disconnect();
if(sourceReverb) sourceReverb.disconnect();
if(tremoloGain) tremoloGain.disconnect();
}, (releaseTime + 0.1) * 1000);
}
const keysToMidi={
z: 48,
s: 49,
x: 50,
d: 51,
c: 52,
v: 53,
g: 54,
b: 55,
h: 56,
n: 57,
j: 58,
m: 59,
',': 60,
l: 61,
'.': 62,
q: 60,
'2': 61,
w: 62,
'3': 63,
e: 64,
r: 65,
'5': 66,
t: 67,
'6': 68,
y: 69,
'7': 70,
u: 71,
i: 72,
'9': 73,
o: 74,
'0': 75,
p: 76,
'[': 77,
};
const fonsPerArxiu={}; // Associació: arxiu.wav -> imatge de fons
document.addEventListener("DOMContentLoaded", function (){
const selector=document.getElementById("acusticaSelector");
fetch("../catedral/llista.txt")
.then(response => response.text())
.then(text =>{
const lines=text.trim().split("\n");
lines.forEach((line) =>{
let [nom, arxiu, imatge]=line.split("|").map(x => x.trim());
// Afegeix l'opció al selector
const option=document.createElement("option");
option.textContent=nom;
option.value=arxiu;
selector.appendChild(option);
// Assigna la imatge a l'arxiu
const ruta=`../catedral/${imatge}`;
fonsPerArxiu[arxiu]=ruta;
});
// Afegeix opció "Cap"
const opcioCap=document.createElement("option");
opcioCap.textContent="Cap";
opcioCap.value="";
selector.appendChild(opcioCap);
// Selecciona la primera per defecte
selector.selectedIndex=6;
carregarImpulse(selector.value);
})
.catch(error => console.error("Error carregant llistat:", error));
selector.onchange=function (e){
carregarImpulse(e.target.value);
};
});
function carregarImpulse(nomArxiu){
nomArxiu=nomArxiu.trim();
if(!nomArxiu){
// Desactiva la reverb i recupera fons de fusta
reverbNode.buffer=null;
document.body.style.backgroundImage=`url('../imatges/fonsfust.jpg')`;
document.body.style.backgroundSize='cover';
document.body.style.backgroundRepeat='no-repeat';
document.body.style.backgroundPosition='center center';
console.log("Reverberació desactivada. Fons restaurat.");
return;
}
const rutaWav=`../catedral/${nomArxiu}`;
fetch(rutaWav)
.then(response => response.arrayBuffer())
.then(data => audioContext.decodeAudioData(data))
.then(decodedBuffer =>{
reverbNode.buffer=decodedBuffer;
console.log("Impulse carregat:", rutaWav);
// Canvia el fons si hi ha imatge associada
const rutaFons=fonsPerArxiu[nomArxiu];
if(rutaFons){
const img=new Image();
img.onload=function (){
document.body.style.backgroundImage=`url('${rutaFons}')`;
document.body.style.backgroundSize='cover';
document.body.style.backgroundRepeat='no-repeat';
document.body.style.backgroundPosition='center center';
console.log("Fons canviat:", rutaFons);
};
img.src=rutaFons + "?t=" + Date.now(); // Evita la caché
}
})
.catch(error => console.error("Error carregant impulse:", error));
}
const slider=document.getElementById('distanciaSlider');
slider.value=distancia;
slider.oninput=(e) =>{
distancia=parseFloat(e.target.value);
};
function reactivaAudio(){
audioContext.resume().then(() =>{
document.getElementById("reactiva-audio").style.display="none";
});
}
document.addEventListener('DOMContentLoaded', () =>{
// Assignem la funció al botó
document.body.classList.add("single-manual");
document.getElementById("reactiva-audio").onclick=reactivaAudio;
setTimeout(() =>{
if(audioContext.state==="suspended"){
document.getElementById("reactiva-audio").style.display="block";
}
}, 300);
document.addEventListener('visibilitychange', () =>{
if(document.visibilityState==='visible'&&audioContext.state==="suspended"){
document.getElementById("reactiva-audio").style.display="block";
}
});
audioContext.onstatechange=() =>{
if(audioContext.state==="running"){
document.getElementById("reactiva-audio").style.display="none";
}
};
});
function gaitagallega(){
const sogaita=playSample(midi2rate(35), 127 / 127, sampleBuffers[(35)],2);
// currentlyPlaying[note]=playSample(midi2rate(note), 127 / 127, sampleBuffers[sampleMidi],atac); // atac
currentlyPlaying31[35]=sogaita;
gaites.push(sogaita);
}
let bufa;
let gaites=[];
function somanxa(buf){
if(buf===1){
let suplement=0;
if(document.getElementById("415").selected==true){
suplement=-1;
}else if(document.getElementById("440").selected==true){
suplement=0;
}else if(document.getElementById("442").selected==true){
suplement=0.08;
}else if(document.getElementById("466").selected==true){
suplement=1;
}else if(document.getElementById("493").selected==true){
suplement=2;
}else if(document.getElementById("392").selected==true){
suplement=-2;
}
let gaiter=Math.pow(2, suplement / 12)
clearInterval(bufa);
gaitagallega();
bufa=setInterval(gaitagallega, 12000 * 1 / gaiter);
}else{
clearInterval(bufa);
for (const sogaita of gaites){
if (!sogaita) continue;
stop(
sogaita.gainNode,
sogaita.gainReverb,
sogaita.sourceReverb
);
}
gaites=[];
if(currentlyPlaying31[35]){
stop(
currentlyPlaying31[35].gainNode,
// currentlyPlaying31[35].gainReverb,
// currentlyPlaying31[35].sourceReverb
);
delete currentlyPlaying31[35];
}
}
}
function ocellots(){
const soocells=currentlyPlaying35[34]=playSample(midi2rate(34), 40 / 127, sampleBuffers[(34)],2);
// currentlyPlaying[note]=playSample(midi2rate(note), 127 / 127, sampleBuffers[sampleMidi],atac); // atac
currentlyPlaying31[34]=soocells;
cotorres.push(soocells);
}
let bufo;
let cotorres=[];
function somanxo(bufi){
if(bufi===1){
let suplement=0;
if(document.getElementById("415").selected==true){
suplement=-1;
}else if(document.getElementById("440").selected==true){
suplement=0;
}else if(document.getElementById("442").selected==true){
suplement=0.08;
}else if(document.getElementById("466").selected==true){
suplement=1;
}else if(document.getElementById("493").selected==true){
suplement=2;
}else if(document.getElementById("392").selected==true){
suplement=-2;
}
let gaitero=Math.pow(2, suplement / 12)
clearInterval(bufo);
ocellots();
bufo=setInterval(ocellots, 12000 * 1 / gaitero);
}else{
clearInterval(bufo);
for (const soocells of cotorres){
if (!soocells) continue;
stop(
soocells.gainNode,
soocells.gainReverb,
soocells.sourceReverb
);
}
cotorres=[];
if(currentlyPlaying35[34]){
stop(
currentlyPlaying35[34].gainNode,
// currentlyPlaying35[34].gainReverb,
// currentlyPlaying35[34].sourceReverb
);
delete currentlyPlaying35[34];
}
}
}
// somanxa(1);
(function (){
// ---------- CONFIG ----------
const CANDY_IMAGES=[
'llaminadures/c1.png',
'llaminadures/c2.png',
'llaminadures/c3.png',
'llaminadures/c4.png',
'llaminadures/c5.png'
];
const MAX_LIVE=150;
let overlay=null;
let liveCount=0;
// ---------- OVERLAY ----------
function ensureOverlay(){
if(overlay) return overlay;
overlay=document.createElement('div');
overlay.id='effects-overlay';
document.body.appendChild(overlay);
return overlay;
}
// ---------- SPAWN GENERIC ----------
function spawnFx({type='bubble', leftPct=null}){
ensureOverlay();
if(liveCount >= MAX_LIVE) return;
const el=document.createElement('div');
el.classList.add('fx-item');
const x=(leftPct != null ? leftPct : Math.random() * 100);
el.style.left=x + '%';
const dur=6 + Math.random() * 5;
el.style.setProperty('--dur', dur + 's');
if(type==='bubble'){
el.classList.add('fx-bubble');
const size=8 + Math.random() * 20;
el.style.width=size + 'px';
el.style.height=size + 'px';
}
else if(type==='candy'){
el.classList.add('fx-candy');
const img=CANDY_IMAGES[Math.floor(Math.random()*CANDY_IMAGES.length)];
const size=30 + Math.random() * 45;
el.style.width=size + 'px';
el.style.height=size + 'px';
el.style.backgroundImage=`url(${img})`;
}
el.addEventListener('animationend', () =>{
el.remove();
liveCount--;
},{once:true});
overlay.appendChild(el);
liveCount++;
}
// ---------- PUBLIC API ----------
window.birdBubblesBurst=function (x){
for (let i=0; i < 12; i++) spawnFx({type:'bubble', leftPct:x});
};
window.candyBurst=function (x){
for (let i=0; i < 10; i++) spawnFx({type:'candy', leftPct:x});
};
})();
function bombolles(){
for (let i=20; i < 81; i=i+5){
birdBubblesBurst(i);
}
}
function llaminadures(){
for (let i=20; i < 81; i=i+5){
candyBurst(i);
}
}
// birdBubblesBurst(50);
// candyBurst(50);
function batalla(){
registre0=1; // flautat 0
registre1=0; // octava_om 100
registre2=1; // baixons
registre3=1; // clarins
registre4=1; // xirimia
registre5=1; // trompeta
registre6=0; // dotzena
registre7=0; // quinzena
registre8=0; // dinovena
registre9=0; // vintidosena
registre10=0; // ple
registre11=0; // cimbalet
registre12=0; // corneta
registre13=1; // bordo
registre14=0; // tapadet
registre15=0; // nasard12
registre16=0; // nasard15
registre17=0; // nasard17
registre18=0; // bordo_c
registre19=0; // octava_c
registre20=0; // tapadet_c
registre21=0; // quinzena_c
registre22=0; // dinovena_c
registre23=0; // nasard19a_c
registre24=0; // vintidosena_i_vintisisena_c
registre25=0; // cimbalet_c
registre26=0; //
registre27=0; //
registre28=0; //
registre29=0; //
registre31=0; //
registre32=0; // contres
document.getElementById("xirimia").checked=true;
document.getElementById("baixons").checked=true;
document.getElementById("cimbalet_c").checked=false;
document.getElementById("vintidosena_i_vintisisena_c").checked=false;
document.getElementById("nasard19a_c").checked=false;
document.getElementById("dinovena_c").checked=false;
document.getElementById("quinzena_c").checked=false;
document.getElementById("tapadet_c").checked=false;
document.getElementById("octava_c").checked=false;
document.getElementById("bordo_c").checked=false;
document.getElementById("corneta").checked=false;
document.getElementById("ple").checked=false;
document.getElementById("dinovena").checked=false;
document.getElementById("nasard15").checked=false;
document.getElementById("tapadet").checked=false;
document.getElementById("dotzena").checked=false;
document.getElementById("nasard17").checked=false;
document.getElementById("cimbalet").checked=false;
document.getElementById("vintidosena").checked=false;
document.getElementById("octava").checked=false;
document.getElementById("nasard12").checked=false;
document.getElementById("quinzena").checked=false;
document.getElementById("bordo").checked=true;
document.getElementById("flautat").checked=true;
document.getElementById("trompeta").checked=true;
document.getElementById("clarins").checked=true;
apagaEspecials();
}
function plens_om(){
registre0=1; // flautat 0
registre1=1; // octava_om 100
registre2=0; // baixons
registre3=0; // clarins
registre4=0; // xirimia
registre5=0; // trompeta
registre6=1; // dotzena
registre7=1; // quinzena
registre8=1; // dinovena
registre9=1; // vintidosena
registre10=1; // ple
registre11=1; // cimbalet
registre12=0; // corneta
registre13=0; // bordo
registre14=0; // tapadet
registre15=0; // nasard12
registre16=0; // nasard15
registre17=0; // nasard17
registre18=0; // bordo_c
registre19=0; // octava_c
registre20=0; // tapadet_c
registre21=0; // quinzena_c
registre22=0; // dinovena_c
registre23=0; // nasard19a_c
registre24=0; // vintidosena_i_vintisisena_c
registre25=0; // cimbalet_c
registre26=0; //
registre27=0; //
registre28=0; //
registre29=0; //
registre31=0; //
registre32=0; // contres
document.getElementById("xirimia").checked=false;
document.getElementById("baixons").checked=false;
document.getElementById("cimbalet_c").checked=false;
document.getElementById("vintidosena_i_vintisisena_c").checked=false;
document.getElementById("nasard19a_c").checked=false;
document.getElementById("dinovena_c").checked=false;
document.getElementById("quinzena_c").checked=false;
document.getElementById("tapadet_c").checked=false;
document.getElementById("octava_c").checked=false;
document.getElementById("bordo_c").checked=false;
document.getElementById("corneta").checked=false;
document.getElementById("ple").checked=true;
document.getElementById("dinovena").checked=true;
document.getElementById("nasard15").checked=false;
document.getElementById("tapadet").checked=false;
document.getElementById("dotzena").checked=true;
document.getElementById("nasard17").checked=true;
document.getElementById("cimbalet").checked=true;
document.getElementById("vintidosena").checked=true;
document.getElementById("octava").checked=true;
document.getElementById("nasard12").checked=false;
document.getElementById("quinzena").checked=true;
document.getElementById("bordo").checked=false;
document.getElementById("flautat").checked=true;
document.getElementById("trompeta").checked=false;
document.getElementById("clarins").checked=false;
apagaEspecials();
}
function plens_c(){
registre0=0; // flautat 0
registre1=0; // octava_om 100
registre2=0; // baixons
registre3=0; // clarins
registre4=0; // xirimia
registre5=0; // trompeta
registre6=0; // dotzena
registre7=0; // quinzena
registre8=0; // dinovena
registre9=0; // vintidosena
registre10=0; // ple
registre11=0; // cimbalet
registre12=0; // corneta
registre13=0; // bordo
registre14=0; // tapadet
registre15=0; // nasard12
registre16=0; // nasard15
registre17=0; // nasard17
registre18=1; // bordo_c
registre19=1; // octava_c
registre20=0; // tapadet_c
registre21=1; // quinzena_c
registre22=1; // dinovena_c
registre23=0; // nasard19a_c
registre24=1; // vintidosena_i_vintisisena_c
registre25=1; // cimbalet_c
registre26=0; //
registre27=0; //
registre28=0; //
registre29=0; //
registre31=0; //
registre32=0; // contres
document.getElementById("xirimia").checked=false;
document.getElementById("baixons").checked=false;
document.getElementById("cimbalet_c").checked=true;
document.getElementById("vintidosena_i_vintisisena_c").checked=true;
document.getElementById("nasard19a_c").checked=false;
document.getElementById("dinovena_c").checked=true;
document.getElementById("quinzena_c").checked=true;
document.getElementById("tapadet_c").checked=false;
document.getElementById("octava_c").checked=true;
document.getElementById("bordo_c").checked=true;
document.getElementById("corneta").checked=false;
document.getElementById("ple").checked=false;
document.getElementById("dinovena").checked=false;
document.getElementById("nasard15").checked=false;
document.getElementById("tapadet").checked=false;
document.getElementById("dotzena").checked=false;
document.getElementById("nasard17").checked=false;
document.getElementById("cimbalet").checked=false;
document.getElementById("vintidosena").checked=false;
document.getElementById("octava").checked=false;
document.getElementById("nasard12").checked=false;
document.getElementById("quinzena").checked=false;
document.getElementById("bordo").checked=false;
document.getElementById("flautat").checked=false;
document.getElementById("trompeta").checked=false;
document.getElementById("clarins").checked=false;
apagaEspecials();
}
function flautes(){
registre0=0; // flautat 0
registre1=0; // octava_om 100
registre2=0; // baixons
registre3=0; // clarins
registre4=0; // xirimia
registre5=0; // trompeta
registre6=0; // dotzena
registre7=0; // quinzena
registre8=0; // dinovena
registre9=0; // vintidosena
registre10=0; // ple
registre11=0; // cimbalet
registre12=0; // corneta
registre13=1; // bordo
registre14=1; // tapadet
registre15=0; // nasard12
registre16=1; // nasard15
registre17=0; // nasard17
registre18=1; // bordo_c
registre19=0; // octava_c
registre20=1; // tapadet_c
registre21=0; // quinzena_c
registre22=0; // dinovena_c
registre23=0; // nasard19a_c
registre24=0; // vintidosena_i_vintisisena_c
registre25=0; // cimbalet_c
registre26=0; //
registre27=0; //
registre28=0; //
registre29=0; //
registre31=0; //
registre32=0; // contres
document.getElementById("xirimia").checked=false;
document.getElementById("baixons").checked=false;
document.getElementById("cimbalet_c").checked=false;
document.getElementById("vintidosena_i_vintisisena_c").checked=false;
document.getElementById("nasard19a_c").checked=false;
document.getElementById("dinovena_c").checked=false;
document.getElementById("quinzena_c").checked=false;
document.getElementById("tapadet_c").checked=true;
document.getElementById("octava_c").checked=false;
document.getElementById("bordo_c").checked=true;
document.getElementById("corneta").checked=false;
document.getElementById("ple").checked=false;
document.getElementById("dinovena").checked=false;
document.getElementById("nasard15").checked=true;
document.getElementById("tapadet").checked=true;
document.getElementById("dotzena").checked=false;
document.getElementById("nasard17").checked=false;
document.getElementById("cimbalet").checked=false;
document.getElementById("vintidosena").checked=false;
document.getElementById("octava").checked=false;
document.getElementById("nasard12").checked=false;
document.getElementById("quinzena").checked=false;
document.getElementById("bordo").checked=true;
document.getElementById("flautat").checked=false;
document.getElementById("trompeta").checked=false;
document.getElementById("clarins").checked=false;
apagaEspecials();
}
function cornetes(){
registre0=1; // flautat 0
registre1=0; // octava_om 100
registre2=0; // baixons
registre3=0; // clarins
registre4=0; // xirimia
registre5=0; // trompeta
registre6=0; // dotzena
registre7=0; // quinzena
registre8=0; // dinovena
registre9=0; // vintidosena
registre10=0; // ple
registre11=0; // cimbalet
registre12=1; // corneta
registre13=0; // bordo
registre14=0; // tapadet
registre15=0; // nasard12
registre16=0; // nasard15
registre17=0; // nasard17
registre18=0; // bordo_c
registre19=0; // octava_c
registre20=0; // tapadet_c
registre21=0; // quinzena_c
registre22=0; // dinovena_c
registre23=0; // nasard19a_c
registre24=0; // vintidosena_i_vintisisena_c
registre25=0; // cimbalet_c
registre26=0; //
registre27=0; //
registre28=0; //
registre29=0; //
registre31=0; //
registre32=0; // contres
document.getElementById("xirimia").checked=false;
document.getElementById("baixons").checked=false;
document.getElementById("cimbalet_c").checked=false;
document.getElementById("vintidosena_i_vintisisena_c").checked=false;
document.getElementById("nasard19a_c").checked=false;
document.getElementById("dinovena_c").checked=false;
document.getElementById("quinzena_c").checked=false;
document.getElementById("tapadet_c").checked=false;
document.getElementById("octava_c").checked=false;
document.getElementById("bordo_c").checked=false;
document.getElementById("corneta").checked=true;
document.getElementById("ple").checked=false;
document.getElementById("dinovena").checked=false;
document.getElementById("nasard15").checked=false;
document.getElementById("tapadet").checked=false;
document.getElementById("dotzena").checked=false;
document.getElementById("nasard17").checked=false;
document.getElementById("cimbalet").checked=false;
document.getElementById("vintidosena").checked=false;
document.getElementById("octava").checked=false;
document.getElementById("nasard12").checked=false;
document.getElementById("quinzena").checked=false;
document.getElementById("bordo").checked=false;
document.getElementById("flautat").checked=true;
document.getElementById("trompeta").checked=false;
document.getElementById("clarins").checked=false;
apagaEspecials();
}
function tutti(){
registre0=1; // flautat 0
registre1=1; // octava_om 100
registre2=1; // baixons
registre3=1; // clarins
registre4=1; // xirimia
registre5=1; // trompeta
registre6=1; // dotzena
registre7=1; // quinzena
registre8=1; // dinovena
registre9=1; // vintidosena
registre10=1; // ple
registre11=1; // cimbalet
registre12=1; // corneta
registre13=1; // bordo
registre14=1; // tapadet
registre15=1; // nasard12
registre16=1; // nasard15
registre17=1; // nasard17
registre18=1; // bordo_c
registre19=1; // octava_c
registre20=1; // tapadet_c
registre21=1; // quinzena_c
registre22=1; // dinovena_c
registre23=1; // nasard19a_c
registre24=1; // vintidosena_i_vintisisena_c
registre25=1; // cimbalet_c
registre26=1; //
registre27=1; //
registre28=1; //
registre29=1; //
registre31=1; //
registre32=1; // contres
document.getElementById("xirimia").checked=true;
document.getElementById("baixons").checked=true;
document.getElementById("cimbalet_c").checked=true;
document.getElementById("vintidosena_i_vintisisena_c").checked=true;
document.getElementById("nasard19a_c").checked=true;
document.getElementById("dinovena_c").checked=true;
document.getElementById("quinzena_c").checked=true;
document.getElementById("tapadet_c").checked=true;
document.getElementById("octava_c").checked=true;
document.getElementById("bordo_c").checked=true;
document.getElementById("corneta").checked=true;
document.getElementById("ple").checked=true;
document.getElementById("dinovena").checked=true;
document.getElementById("nasard15").checked=true;
document.getElementById("tapadet").checked=true;
document.getElementById("dotzena").checked=true;
document.getElementById("nasard17").checked=true;
document.getElementById("cimbalet").checked=true;
document.getElementById("vintidosena").checked=true;
document.getElementById("octava").checked=true;
document.getElementById("nasard12").checked=true;
document.getElementById("quinzena").checked=true;
document.getElementById("bordo").checked=true;
document.getElementById("flautat").checked=true;
document.getElementById("trompeta").checked=true;
document.getElementById("clarins").checked=true;
apagaEspecials();
}
function muti(){
registre0=0; // flautat 0
registre1=0; // octava_om 100
registre2=0; // baixons
registre3=0; // clarins
registre4=0; // xirimia
registre5=0; // trompeta
registre6=0; // dotzena
registre7=0; // quinzena
registre8=0; // dinovena
registre9=0; // vintidosena
registre10=0; // ple
registre11=0; // cimbalet
registre12=0; // corneta
registre13=0; // bordo
registre14=0; // tapadet
registre15=0; // nasard12
registre16=0; // nasard15
registre17=0; // nasard17
registre18=0; // bordo_c
registre19=0; // octava_c
registre20=0; // tapadet_c
registre21=0; // quinzena_c
registre22=0; // dinovena_c
registre23=0; // nasard19a_c
registre24=0; // vintidosena_i_vintisisena_c
registre25=0; // cimbalet_c
registre26=0; //
registre27=0; //
registre28=0; //
registre29=0; //
registre31=0; //
registre32=0; // contres
document.getElementById("xirimia").checked=false;
document.getElementById("baixons").checked=false;
document.getElementById("cimbalet_c").checked=false;
document.getElementById("vintidosena_i_vintisisena_c").checked=false;
document.getElementById("nasard19a_c").checked=false;
document.getElementById("dinovena_c").checked=false;
document.getElementById("quinzena_c").checked=false;
document.getElementById("tapadet_c").checked=false;
document.getElementById("octava_c").checked=false;
document.getElementById("bordo_c").checked=false;
document.getElementById("corneta").checked=false;
document.getElementById("ple").checked=false;
document.getElementById("dinovena").checked=false;
document.getElementById("nasard15").checked=false;
document.getElementById("tapadet").checked=false;
document.getElementById("dotzena").checked=false;
document.getElementById("nasard17").checked=false;
document.getElementById("cimbalet").checked=false;
document.getElementById("vintidosena").checked=false;
document.getElementById("octava").checked=false;
document.getElementById("nasard12").checked=false;
document.getElementById("quinzena").checked=false;
document.getElementById("bordo").checked=false;
document.getElementById("flautat").checked=false;
document.getElementById("trompeta").checked=false;
document.getElementById("clarins").checked=false;
apagaEspecials();
}
function apagaEspecials(){
const tremorCb=document.getElementById("tremor");
const ocellsCb=document.getElementById("ocells");
const gaitaCb =document.getElementById("gaita");
[tremorCb, ocellsCb, gaitaCb].forEach(cb => {
if (cb&&cb.checked) cb.click();
});
}
</script>
<script type="text/javascript" src="../documents/document.js"></script>
<div class="foot"><br>
<center><font face="Verdana" size="-2" color="blue"><a rel="license" title="Attribution-NonCommercial-NoDerivs 4.0 International" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank">Attribution-NonCommercial-NoDerivs 4.0 International <img src="../imatges/88x31.png" alt="Creative Commons License" /></a></font></center>
</div>
</body></html>
|
|
|
Consideracions generals:
Atès que web audio no permet fer loops, l'aproximació triada és treballar amb mostres llargues de 30 - 60 segons cadascuna. En el codi està programat de manera que a partir dels 20 segons d'una nota mantinguda (ajustable a la definició de la variable loop si cal), la mostra es repeteix fent un canvi amb crossfade, de manera que així són possible notes de durada infinita amb relativament poques transicions audibles. Per altra banda és del tot impossible carregar totes les mostres d'un instrument gros (el de Cadaquers ja entra en aquesta categoria) en un navegador fins i tot d'un ordinador potent. Per això cal treballar amb poques mostres representatives i obtenir les notes sense mostra enregistrada per extrapolació mitjançant la funció "midi2rate" (vegi's el codi). Concretament treballem amb una sola mostra per octava, cosa que ens permet una implementació d'afinació i tempraments centralitzada. Pels instruments més petits sí que es poden incloure mostres de tots els tubs. Per a experimentar amb un instrument gros: http://www.casacota.net/mostres/sants_just_i_pastor/justipastor.atm - 1632 tubs mostrejats un per un amb tempraments i afinacions. Es pot fer el script, però no funcionarà en la majoria d'ordinadors. Versió reduïda: http://www.casacota.net/mostres/sants_just_i_pastor/index.atm Així mateix cal treballar amb mostres en MP3 de 192 Kb/s si volem evitar problemes de memòria. Potser en el futur amb ordinadors més potents serà possible treballar amb arxius wave i sense aquests equilibris. Essent però que treballar amb només una mostra per octava dona un resultat acústicament pobre i tenint en compte que en els orgues els tubs estan repartits simètricament amb els tubs grossos als extrems, disminuint de mida cap el centre (per a repartir pes i espai), el que fem és modificar cada mostra de manera a obtenir dues sèries alternes de mostres amb aquest script, que simplement genera una nova mostra amb els canals intercanviats que el script usarà en notes alternes segons la distribució en l'instrument (costat C contra costat C#): Code: C:\ffmpeg\bin\ffmpeg.exe -i C:\lighttpd\htdocs\mostres\36.mp3 ^ -af "pan=stereo|c0=c1|c1=c0" ^ -c:a libmp3lame -b:a 192k -y ^ C:\lighttpd\htdocs\mostres\36g.mp3 C:\ffmpeg\bin\ffmpeg.exe -i C:\lighttpd\htdocs\mostres\48.mp3 ^ -af "pan=stereo|c0=c1|c1=c0" ^ -c:a libmp3lame -b:a 192k -y ^ C:\lighttpd\htdocs\mostres\48g.mp3 C:\ffmpeg\bin\ffmpeg.exe -i C:\lighttpd\htdocs\mostres\60.mp3 ^ -af "pan=stereo|c0=c1|c1=c0" ^ -c:a libmp3lame -b:a 192k -y ^ C:\lighttpd\htdocs\mostres\60g.mp3 C:\ffmpeg\bin\ffmpeg.exe -i C:\lighttpd\htdocs\mostres\72.mp3 ^ -af "pan=stereo|c0=c1|c1=c0" ^ -c:a libmp3lame -b:a 192k -y ^ C:\lighttpd\htdocs\mostres\72g.mp3 C:\ffmpeg\bin\ffmpeg.exe -i C:\lighttpd\htdocs\mostres\84.mp3 ^ -af "pan=stereo|c0=c1|c1=c0" ^ -c:a libmp3lame -b:a 192k -y ^ C:\lighttpd\htdocs\mostres\84g.mp3 On caldrà naturalment ajustar els camins a la nostra disposició. Binaris necessaris aquí sota. |
|
ffmpeg.rar
|
|
En principi doncs no cal definir loops, i la feina és ràpida: només calen uns 45 segons de cada "do" ben enregistrat: net, amb la mínima reverberació possible, sense sorolls paràsits (motor, mecànica) i sense normalitzar respectant els nivells relatius als altres registres.
Si les mostres són més curtes, llavors sí, caldrà definir loops i "fabricar" mostres amb algun reproductor de mostres que els pugui reproduir (kontakt, hauptwerk, etc). Per la resta, el codi és ben clar i es veu el que fa, a més d'estar comentat. Per a fer instruments nous doncs el millor és treballar sobre una còpia de tot plegat, posar-hi les mostres del nou instrument a les carpetes corresponents, canviant els noms que s'escaigui, i anar adaptant segons necessitats. És evident doncs la distància amb els samplers professionals, en alta resolució i amb mostres completes. Aquí el camí és totalment invers: aconseguir el mateix efecte de manera convincent amb el mínim de recursos possibles. |
|
screenshot_2026-04-19_09_19_43_0001.png