Adiciona site de loops
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aa05552170
commit
5f5850fd02
45 files changed
+1281
No files matched your search
+17
@@ -0,0 +1,17 @@
|
|||||||
|
_site/
|
||||||
|
.jekyll-cache/
|
||||||
|
.sass-cache/
|
||||||
|
.bundle/
|
||||||
|
vendor/
|
||||||
|
|
||||||
|
# Gravações inteiras e projetos de edição ficam fora do repositório.
|
||||||
|
*.aup3
|
||||||
|
*.aup3-shm
|
||||||
|
*.aup3-wal
|
||||||
|
*.mmpz
|
||||||
|
assets/audio/Ijexa/
|
||||||
|
assets/audio/ixejá batucada/
|
||||||
|
assets/audio/Samba/
|
||||||
|
assets/audio/sinos/
|
||||||
|
assets/audio/Baião/*.wav
|
||||||
|
!assets/audio/Baião/*_loop.wav
|
||||||
+163
@@ -0,0 +1,163 @@
|
|||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
addressable (2.9.2)
|
||||||
|
public_suffix (>= 2.0.2, < 8.0)
|
||||||
|
base64 (0.3.0)
|
||||||
|
bigdecimal (4.1.3)
|
||||||
|
colorator (1.1.0)
|
||||||
|
concurrent-ruby (1.3.8)
|
||||||
|
csv (3.3.7)
|
||||||
|
em-websocket (0.5.3)
|
||||||
|
eventmachine (>= 0.12.9)
|
||||||
|
http_parser.rb (~> 0)
|
||||||
|
eventmachine (1.2.7)
|
||||||
|
ffi (1.17.4)
|
||||||
|
ffi (1.17.4-aarch64-linux-gnu)
|
||||||
|
ffi (1.17.4-aarch64-linux-musl)
|
||||||
|
ffi (1.17.4-arm-linux-gnu)
|
||||||
|
ffi (1.17.4-arm-linux-musl)
|
||||||
|
ffi (1.17.4-arm64-darwin)
|
||||||
|
ffi (1.17.4-x86-linux-gnu)
|
||||||
|
ffi (1.17.4-x86-linux-musl)
|
||||||
|
ffi (1.17.4-x86_64-darwin)
|
||||||
|
ffi (1.17.4-x86_64-linux-gnu)
|
||||||
|
ffi (1.17.4-x86_64-linux-musl)
|
||||||
|
forwardable-extended (2.6.0)
|
||||||
|
google-protobuf (4.36.2)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
google-protobuf (4.36.2-aarch64-linux-gnu)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
google-protobuf (4.36.2-aarch64-linux-musl)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
google-protobuf (4.36.2-arm64-darwin)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
google-protobuf (4.36.2-x86-linux-gnu)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
google-protobuf (4.36.2-x86-linux-musl)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
google-protobuf (4.36.2-x86_64-darwin)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
google-protobuf (4.36.2-x86_64-linux-gnu)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
google-protobuf (4.36.2-x86_64-linux-musl)
|
||||||
|
bigdecimal
|
||||||
|
rake (~> 13.3)
|
||||||
|
http_parser.rb (0.8.1)
|
||||||
|
i18n (1.15.2)
|
||||||
|
concurrent-ruby (~> 1.0)
|
||||||
|
jekyll (4.4.1)
|
||||||
|
addressable (~> 2.4)
|
||||||
|
base64 (~> 0.2)
|
||||||
|
colorator (~> 1.0)
|
||||||
|
csv (~> 3.0)
|
||||||
|
em-websocket (~> 0.5)
|
||||||
|
i18n (~> 1.0)
|
||||||
|
jekyll-sass-converter (>= 2.0, < 4.0)
|
||||||
|
jekyll-watch (~> 2.0)
|
||||||
|
json (~> 2.6)
|
||||||
|
kramdown (~> 2.3, >= 2.3.1)
|
||||||
|
kramdown-parser-gfm (~> 1.0)
|
||||||
|
liquid (~> 4.0)
|
||||||
|
mercenary (~> 0.3, >= 0.3.6)
|
||||||
|
pathutil (~> 0.9)
|
||||||
|
rouge (>= 3.0, < 5.0)
|
||||||
|
safe_yaml (~> 1.0)
|
||||||
|
terminal-table (>= 1.8, < 4.0)
|
||||||
|
webrick (~> 1.7)
|
||||||
|
jekyll-sass-converter (3.1.0)
|
||||||
|
sass-embedded (~> 1.75)
|
||||||
|
jekyll-watch (2.2.1)
|
||||||
|
listen (~> 3.0)
|
||||||
|
json (2.21.2)
|
||||||
|
kramdown (2.5.2)
|
||||||
|
rexml (>= 3.4.4)
|
||||||
|
kramdown-parser-gfm (1.1.0)
|
||||||
|
kramdown (~> 2.0)
|
||||||
|
liquid (4.0.4)
|
||||||
|
listen (3.10.1)
|
||||||
|
logger
|
||||||
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||||
|
rb-inotify (~> 0.9, >= 0.9.10)
|
||||||
|
logger (1.7.0)
|
||||||
|
mercenary (0.4.0)
|
||||||
|
pathutil (0.16.2)
|
||||||
|
forwardable-extended (~> 2.6)
|
||||||
|
public_suffix (7.0.5)
|
||||||
|
rake (13.4.2)
|
||||||
|
rb-fsevent (0.11.2)
|
||||||
|
rb-inotify (0.11.1)
|
||||||
|
ffi (~> 1.0)
|
||||||
|
rexml (3.4.4)
|
||||||
|
rouge (4.7.0)
|
||||||
|
safe_yaml (1.0.5)
|
||||||
|
sass-embedded (1.108.1)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
rake (~> 13.3)
|
||||||
|
sass-embedded (1.108.1-aarch64-linux-android)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-aarch64-linux-gnu)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-aarch64-linux-musl)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-arm-linux-androideabi)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-arm-linux-gnueabihf)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-arm-linux-musleabihf)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-arm64-darwin)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-riscv64-linux-android)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-riscv64-linux-gnu)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-riscv64-linux-musl)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-x86_64-darwin)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-x86_64-linux-android)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-x86_64-linux-gnu)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
sass-embedded (1.108.1-x86_64-linux-musl)
|
||||||
|
google-protobuf (~> 4.31)
|
||||||
|
terminal-table (3.0.2)
|
||||||
|
unicode-display_width (>= 1.1.1, < 3)
|
||||||
|
unicode-display_width (2.6.0)
|
||||||
|
webrick (1.9.2)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
aarch64-linux-android
|
||||||
|
aarch64-linux-gnu
|
||||||
|
aarch64-linux-musl
|
||||||
|
arm-linux-androideabi
|
||||||
|
arm-linux-gnu
|
||||||
|
arm-linux-gnueabihf
|
||||||
|
arm-linux-musl
|
||||||
|
arm-linux-musleabihf
|
||||||
|
arm64-darwin
|
||||||
|
riscv64-linux-android
|
||||||
|
riscv64-linux-gnu
|
||||||
|
riscv64-linux-musl
|
||||||
|
ruby
|
||||||
|
x86-linux-gnu
|
||||||
|
x86-linux-musl
|
||||||
|
x86_64-darwin
|
||||||
|
x86_64-linux-android
|
||||||
|
x86_64-linux-gnu
|
||||||
|
x86_64-linux-musl
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
jekyll (~> 4.4)
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.5.22
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
title: Loops
|
||||||
|
lang: pt-BR
|
||||||
|
description: Escolha os loops e toque no tempo que quiser.
|
||||||
|
|
||||||
|
# Só os loops cortados vão para o _site.
|
||||||
|
# Gravações inteiras e projetos do Audacity/LMMS ficam apenas na pasta.
|
||||||
|
exclude:
|
||||||
|
- "assets/audio/*/*.aup3"
|
||||||
|
- "assets/audio/*/*.aup3-shm"
|
||||||
|
- "assets/audio/*/*.aup3-wal"
|
||||||
|
- "assets/audio/*/*.mmpz"
|
||||||
|
- "assets/audio/Baião/*[!p].wav"
|
||||||
|
- "assets/audio/Ijexa"
|
||||||
|
- "assets/audio/ixejá batucada"
|
||||||
|
- "assets/audio/Samba"
|
||||||
|
- "assets/audio/sinos"
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# Cada loop precisa dizer quantos tempos tem, para tocar junto com os outros.
|
||||||
|
# "ate" (opcional) corta o arquivo nesse segundo.
|
||||||
|
- ritmo: Baião
|
||||||
|
pasta: Baião
|
||||||
|
cor: "#ffc61a"
|
||||||
|
loops:
|
||||||
|
- { id: bai-zabumba, nome: Zabumba, arquivo: "03-Zabumba base_loop.wav", tempos: 12, volume: 0.9 }
|
||||||
|
- { id: bai-pandeiro, nome: Pandeiro, arquivo: "02-Baião Pandeiro_loop.wav", tempos: 6, volume: 0.9 }
|
||||||
|
- { id: bai-triangulo, nome: Triângulo, arquivo: "05-Triangulo prototipo_loop.wav", tempos: 4, ate: 2.41, volume: 0.8 }
|
||||||
|
- { id: bai-agogo, nome: Agogô, arquivo: "06-Agogô prototipo do bloco_loop.wav", tempos: 8, volume: 0.8 }
|
||||||
|
- { id: bai-contra, nome: Agogô contra, arquivo: "07-Agogô Contra_loop.wav", tempos: 8, volume: 0.8 }
|
||||||
|
- ritmo: Samba
|
||||||
|
pasta: cortes/Samba
|
||||||
|
cor: "#7fd6a0"
|
||||||
|
loops:
|
||||||
|
- { id: sam-shake, nome: Shake, arquivo: "shake.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-tamborim, nome: Tamborim, arquivo: "tamborim.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-pandeiro-nylon, nome: Pandeiro nylon, arquivo: "pandeiro-nylon.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-pandeiro-corte, nome: Pandeiro de corte, arquivo: "pandeiro-corte.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-agogo, nome: Agogô, arquivo: "agogo.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-pandeiro-couro, nome: Pandeiro couro, arquivo: "pandeiro-couro.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-couro-variacao, nome: Couro variação, arquivo: "couro-variacao.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-partido-couro, nome: Partido couro, arquivo: "partido-couro.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-partido-nylon, nome: Partido nylon, arquivo: "partido-nylon.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-partido-abafado, nome: Partido abafado, arquivo: "partido-abafado.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: sam-partido-preenchido, nome: Partido preenchido, arquivo: "partido-preenchido.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- ritmo: Ixejá
|
||||||
|
pasta: cortes/Ixejá
|
||||||
|
cor: "#f79ac0"
|
||||||
|
loops:
|
||||||
|
- { id: ixe-agogo, nome: Agogô, arquivo: "agogo.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: ixe-le, nome: Lé, arquivo: "le.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: ixe-rum-pi, nome: Rum pi, arquivo: "rum-pi.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: ixe-xequere, nome: Xequerê, arquivo: "xequere.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: ixe-tamborim, nome: Tamborim, arquivo: "tamborim.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: ixe-surdo, nome: Surdo, arquivo: "surdo.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- { id: ixe-surdo-variacao, nome: Surdo variação, arquivo: "surdo-variacao.wav", tempos: 8, volume: 0.85 }
|
||||||
|
- ritmo: Sinos
|
||||||
|
pasta: cortes/Sinos
|
||||||
|
cor: "#8fd0f5"
|
||||||
|
disparo: true
|
||||||
|
loops:
|
||||||
|
- { id: sin-pilar-badalada, nome: Pilar badalada, arquivo: "pilar/badalada.mp3", volume: 0.85 }
|
||||||
|
- { id: sin-pilar-repique, nome: Pilar repique, arquivo: "pilar/repique.mp3", volume: 0.85 }
|
||||||
|
- { id: sin-carmo-badalada, nome: Carmo badalada, arquivo: "carmo/badalada.mp3", volume: 0.85 }
|
||||||
|
- { id: sin-merces-repique, nome: Mercês repique, arquivo: "merces/repique.mp3", volume: 0.85 }
|
||||||
|
- { id: sin-rosario-repique, nome: Rosário repique, arquivo: "rosario/repique.mp3", volume: 0.85 }
|
||||||
|
- { id: sin-santo-antonio-badalada, nome: Santo Antônio badalada, arquivo: "santo-antonio/badalada.mp3", volume: 0.85 }
|
||||||
|
- { id: sin-sao-francisco-badalada, nome: São Francisco badalada, arquivo: "sao-francisco/badalada.mp3", volume: 0.85 }
|
||||||
|
- { id: sin-sao-goncalo-badalada, nome: São Gonçalo badalada, arquivo: "sao-goncalo/badalada.mp3", volume: 0.85 }
|
||||||
|
- { id: sin-sao-goncalo-repique, nome: São Gonçalo repique, arquivo: "sao-goncalo/repique.mp3", volume: 0.85 }
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>{{ page.title | default: site.title }}</title>
|
||||||
|
<meta name="description" content="{{ site.description }}">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Alfa+Slab+One&family=Karla:wght@400;700&display=swap">
|
||||||
|
<link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}">
|
||||||
|
</head>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="{{ site.lang }}">
|
||||||
|
{% include head.html %}
|
||||||
|
<body>
|
||||||
|
{{ content }}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
:root {
|
||||||
|
--anil: #1c2b8f;
|
||||||
|
--anil-fundo: #15216f;
|
||||||
|
--creme: #fff4d6;
|
||||||
|
--sol: #ffc61a;
|
||||||
|
--tinta: #1a1408;
|
||||||
|
--display: "Alfa Slab One", Georgia, serif;
|
||||||
|
--texto: "Karla", system-ui, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
background: var(--anil);
|
||||||
|
color: var(--creme);
|
||||||
|
font: 400 1.0625rem/1.45 var(--texto);
|
||||||
|
}
|
||||||
|
|
||||||
|
button, input { font: inherit; color: inherit; }
|
||||||
|
button:not(:disabled) { cursor: pointer; }
|
||||||
|
:focus-visible { outline: 3px solid var(--creme); outline-offset: 3px; }
|
||||||
|
input[type="range"] { width: 100%; accent-color: var(--sol); }
|
||||||
|
|
||||||
|
.mixer {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(18rem, 22rem) 1fr;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
height: 100vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 1.5rem 2rem;
|
||||||
|
background: var(--anil-fundo);
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--sol);
|
||||||
|
font: 400 clamp(2.75rem, 5vw, 3.75rem)/1 var(--display);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.andamento { display: grid; gap: .4rem; }
|
||||||
|
|
||||||
|
.bpm {
|
||||||
|
font: 400 clamp(4rem, 8vw, 5.75rem)/.95 var(--display);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bpm-linha {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 2.75rem 1fr 2.75rem;
|
||||||
|
gap: .75rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.passo, .tap {
|
||||||
|
background: none;
|
||||||
|
border: 2px solid var(--creme);
|
||||||
|
border-radius: 999px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.passo { height: 2.75rem; font-size: 1.5rem; line-height: 1; }
|
||||||
|
.tap { min-height: 2.75rem; padding: .25rem 1.25rem; }
|
||||||
|
.passo:active, .tap:active, .tap[aria-pressed="true"] { background: var(--creme); color: var(--anil-fundo); }
|
||||||
|
|
||||||
|
.tocar {
|
||||||
|
flex: none;
|
||||||
|
min-height: 4.25rem;
|
||||||
|
border: 0;
|
||||||
|
background: var(--sol);
|
||||||
|
color: var(--tinta);
|
||||||
|
font: 400 2rem/1 var(--display);
|
||||||
|
// Borda irregular, como um corte de xilogravura.
|
||||||
|
clip-path: polygon(1% 7%, 22% 2%, 48% 6%, 76% 0, 99% 5%, 100% 48%, 98% 94%, 71% 100%, 44% 95%, 19% 99%, 0 93%, 2% 46%);
|
||||||
|
|
||||||
|
&:disabled { opacity: .6; }
|
||||||
|
&[aria-pressed="true"] { background: var(--creme); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.status { margin: -.25rem 0 0; min-height: 2.9em; }
|
||||||
|
|
||||||
|
.inicio-bloco { display: grid; gap: .4rem; font-weight: 700; }
|
||||||
|
|
||||||
|
.inicio {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(12, 1fr);
|
||||||
|
gap: 3px;
|
||||||
|
|
||||||
|
button {
|
||||||
|
min-width: 0;
|
||||||
|
height: 1.75rem;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
background: rgba(255, 244, 214, .16);
|
||||||
|
font-size: .75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
|
||||||
|
&.forte { background: rgba(255, 244, 214, .34); }
|
||||||
|
&.atual { background: var(--sol); color: var(--tinta); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bip-linha {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: max-content 1fr;
|
||||||
|
gap: .75rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.geral { display: grid; gap: .25rem; font-weight: 700; margin-top: auto; }
|
||||||
|
|
||||||
|
.ritmos {
|
||||||
|
display: grid;
|
||||||
|
gap: 2.5rem;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 1.5rem clamp(1.25rem, 3vw, 3rem) 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ritmo h2 {
|
||||||
|
margin: 0 0 1rem;
|
||||||
|
color: var(--cor);
|
||||||
|
font: 400 2.25rem/1.1 var(--display);
|
||||||
|
}
|
||||||
|
|
||||||
|
.roda {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(9.75rem, 1fr));
|
||||||
|
gap: 1.5rem clamp(1rem, 2vw, 1.75rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.canal { display: grid; gap: .5rem; min-width: 0; }
|
||||||
|
|
||||||
|
.disco {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: rgba(255, 244, 214, .07);
|
||||||
|
color: var(--cor);
|
||||||
|
transition: background-color .12s linear, color .12s linear;
|
||||||
|
|
||||||
|
svg { position: absolute; inset: 0; width: 100%; height: 100%; }
|
||||||
|
|
||||||
|
&:disabled { opacity: .45; }
|
||||||
|
&:not(:disabled):hover { background: rgba(255, 244, 214, .15); }
|
||||||
|
|
||||||
|
.aceso { display: none; }
|
||||||
|
|
||||||
|
&[aria-pressed="true"], &.soando {
|
||||||
|
background: var(--cor);
|
||||||
|
color: var(--tinta);
|
||||||
|
|
||||||
|
.base .barras { opacity: .32; }
|
||||||
|
.aceso {
|
||||||
|
display: block;
|
||||||
|
-webkit-mask: conic-gradient(#000 var(--p, 0deg), transparent 0);
|
||||||
|
mask: conic-gradient(#000 var(--p, 0deg), transparent 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.barras { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
|
||||||
|
.pontos { fill: currentColor; }
|
||||||
|
|
||||||
|
.nome {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
margin: auto;
|
||||||
|
width: 50%;
|
||||||
|
height: max-content;
|
||||||
|
font-size: .875rem;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.1;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.volume {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1.5rem 1fr;
|
||||||
|
gap: .5rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
kbd {
|
||||||
|
color: var(--cor);
|
||||||
|
font: 700 .875rem/1 var(--texto);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
[hidden] { display: none !important; }
|
||||||
|
|
||||||
|
.palco { min-width: 0; }
|
||||||
|
|
||||||
|
.abas {
|
||||||
|
display: flex;
|
||||||
|
gap: 1.75rem;
|
||||||
|
padding: 1.25rem clamp(1.25rem, 3vw, 3rem) 0;
|
||||||
|
|
||||||
|
button {
|
||||||
|
padding: 0 0 .25rem;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 4px solid transparent;
|
||||||
|
background: none;
|
||||||
|
font: 400 1.25rem/1.2 var(--display);
|
||||||
|
opacity: .7;
|
||||||
|
|
||||||
|
&[aria-selected="true"] { border-color: var(--sol); color: var(--sol); opacity: 1; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.joystick {
|
||||||
|
display: grid;
|
||||||
|
gap: 1rem;
|
||||||
|
justify-items: start;
|
||||||
|
padding: 1.5rem clamp(1.25rem, 3vw, 3rem) 3rem;
|
||||||
|
|
||||||
|
h2 { margin: 0; color: var(--sol); font: 400 2.25rem/1.1 var(--display); }
|
||||||
|
p { margin: 0; max-width: 34rem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.joy-paineis { display: grid; gap: 2.5rem; width: 100%; }
|
||||||
|
|
||||||
|
.joy-painel {
|
||||||
|
display: grid;
|
||||||
|
gap: 1rem;
|
||||||
|
justify-items: start;
|
||||||
|
|
||||||
|
h3 { margin: 0; font: 400 1.5rem/1.2 var(--display); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.joy-botoes {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
|
||||||
|
gap: 1rem 2rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.joy-linha {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 3.5rem 1fr;
|
||||||
|
gap: .75rem;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
select {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 2.75rem;
|
||||||
|
padding: 0 .5rem;
|
||||||
|
border: 2px solid var(--creme);
|
||||||
|
background: var(--anil-fundo);
|
||||||
|
color: var(--creme);
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.joy-tecla {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 3.5rem;
|
||||||
|
height: 3.5rem;
|
||||||
|
border: 3px solid var(--creme);
|
||||||
|
border-radius: 50%;
|
||||||
|
font-size: .875rem;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
&.apertado { background: var(--sol); border-color: var(--sol); color: var(--tinta); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 52rem) {
|
||||||
|
.abas { padding: 1rem 1rem 0; }
|
||||||
|
.joystick { padding: 1.25rem 1rem 7rem; }
|
||||||
|
.mixer { display: block; }
|
||||||
|
.console { position: static; height: auto; padding: 1.25rem 1rem; }
|
||||||
|
.geral { margin-top: 0; }
|
||||||
|
.ritmos { padding: 1.25rem 1rem 7rem; }
|
||||||
|
.roda { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||||
|
.volume { grid-template-columns: 1fr; }
|
||||||
|
kbd { display: none; }
|
||||||
|
|
||||||
|
.tocar {
|
||||||
|
position: fixed;
|
||||||
|
right: 1rem;
|
||||||
|
bottom: 1rem;
|
||||||
|
left: 1rem;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.disco { transition: none; }
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
---
|
||||||
|
@use "base";
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
(() => {
|
||||||
|
const $ = (id) => document.getElementById(id);
|
||||||
|
const { loops, comandos } = window.loopsMixer;
|
||||||
|
|
||||||
|
/* Abas */
|
||||||
|
const abas = [['aba-loops', 'painel-loops'], ['aba-joystick', 'painel-joystick']];
|
||||||
|
abas.forEach(([aba]) => $(aba).addEventListener('click', () => {
|
||||||
|
abas.forEach(([a, p]) => {
|
||||||
|
$(a).setAttribute('aria-selected', a === aba);
|
||||||
|
$(p).hidden = a !== aba;
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
const CONTROLES = [
|
||||||
|
['transporte', 'Tocar ou pausar', () => comandos.transporte()],
|
||||||
|
['adiantar', 'Adiantar 4 tempos', () => comandos.saltar(4)],
|
||||||
|
['voltar', 'Voltar 4 tempos', () => comandos.saltar(-4)],
|
||||||
|
['mais', 'Aumentar andamento', () => comandos.andamento(1)],
|
||||||
|
['menos', 'Diminuir andamento', () => comandos.andamento(-1)],
|
||||||
|
['bip', 'Ligar ou desligar o bip', () => comandos.bip()],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Nomes do layout padrão de controles, na ordem da Gamepad API.
|
||||||
|
const NOMES = ['A', 'B', 'X', 'Y', 'LB', 'RB', 'LT', 'RT', 'Select', 'Start', 'L3', 'R3', 'Cima', 'Baixo', 'Esq.', 'Dir.', 'Home'];
|
||||||
|
const RITMOS = [...new Set(loops.map((l) => l.ritmo))];
|
||||||
|
const TEXTO_VAZIO = 'Conecte o joystick e aperte qualquer botão dele. O navegador só mostra o controle depois do primeiro botão.';
|
||||||
|
|
||||||
|
// Cada joystick começa com um ritmo: o 1 com o primeiro, o 2 com o segundo...
|
||||||
|
function mapaPadrao(pad, posicao) {
|
||||||
|
if (pad.mapping !== 'standard') return {};
|
||||||
|
const doRitmo = loops.filter((l) => l.ritmo === RITMOS[posicao % RITMOS.length]);
|
||||||
|
const mapa = { 8: 'bip', 9: 'transporte', 12: 'mais', 13: 'menos', 14: 'voltar', 15: 'adiantar' };
|
||||||
|
[0, 1, 2, 3, 4, 5].forEach((botao, i) => {
|
||||||
|
if (doRitmo[i]) mapa[botao] = `loop:${doRitmo[i].id}`;
|
||||||
|
});
|
||||||
|
return mapa;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ler(chave) {
|
||||||
|
try { return JSON.parse(localStorage.getItem(chave)); } catch (e) { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function gravar(chave, valor) {
|
||||||
|
try { localStorage.setItem(chave, JSON.stringify(valor)); } catch (e) { /* segue sem salvar */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
function montarOpcoes(select) {
|
||||||
|
select.add(new Option('Sem função', ''));
|
||||||
|
const controles = document.createElement('optgroup');
|
||||||
|
controles.label = 'Controles';
|
||||||
|
CONTROLES.forEach(([v, nome]) => controles.append(new Option(nome, v)));
|
||||||
|
select.append(controles);
|
||||||
|
RITMOS.forEach((ritmo) => {
|
||||||
|
const g = document.createElement('optgroup');
|
||||||
|
g.label = ritmo;
|
||||||
|
loops.filter((l) => l.ritmo === ritmo).forEach((l) => g.append(new Option(l.nome, `loop:${l.id}`)));
|
||||||
|
select.append(g);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function montarControle(pad, posicao) {
|
||||||
|
// Modelos iguais têm o mesmo id; a vaga separa as configurações.
|
||||||
|
const chave = `loops-joystick:${pad.id}:${posicao}`;
|
||||||
|
const padrao = mapaPadrao(pad, posicao);
|
||||||
|
const controle = {
|
||||||
|
index: pad.index,
|
||||||
|
mapa: ler(chave) || { ...padrao },
|
||||||
|
anteriores: pad.buttons.map((b) => b.pressed), // quem já estava apertado não dispara
|
||||||
|
};
|
||||||
|
|
||||||
|
const painel = document.createElement('section');
|
||||||
|
painel.className = 'joy-painel';
|
||||||
|
const titulo = document.createElement('h3');
|
||||||
|
titulo.textContent = `Joystick ${posicao + 1}: ${pad.id.split('(')[0].trim() || 'sem nome'}`;
|
||||||
|
const lista = document.createElement('div');
|
||||||
|
lista.className = 'joy-botoes';
|
||||||
|
const nomes = pad.mapping === 'standard' ? NOMES : [];
|
||||||
|
|
||||||
|
controle.linhas = pad.buttons.map((_, i) => {
|
||||||
|
const nome = nomes[i] || String(i + 1);
|
||||||
|
const linha = document.createElement('div');
|
||||||
|
linha.className = 'joy-linha';
|
||||||
|
const tecla = document.createElement('span');
|
||||||
|
tecla.className = 'joy-tecla';
|
||||||
|
tecla.textContent = nome;
|
||||||
|
const select = document.createElement('select');
|
||||||
|
select.setAttribute('aria-label', `Joystick ${posicao + 1}, função do botão ${nome}`);
|
||||||
|
montarOpcoes(select);
|
||||||
|
select.value = controle.mapa[i] || '';
|
||||||
|
select.addEventListener('change', () => {
|
||||||
|
controle.mapa[i] = select.value;
|
||||||
|
gravar(chave, controle.mapa);
|
||||||
|
});
|
||||||
|
linha.append(tecla, select);
|
||||||
|
lista.append(linha);
|
||||||
|
return { tecla, select };
|
||||||
|
});
|
||||||
|
|
||||||
|
const restaurar = document.createElement('button');
|
||||||
|
restaurar.type = 'button';
|
||||||
|
restaurar.className = 'tap';
|
||||||
|
restaurar.textContent = 'Voltar ao padrão';
|
||||||
|
restaurar.addEventListener('click', () => {
|
||||||
|
controle.mapa = { ...padrao };
|
||||||
|
gravar(chave, controle.mapa);
|
||||||
|
controle.linhas.forEach((l, i) => { l.select.value = controle.mapa[i] || ''; });
|
||||||
|
});
|
||||||
|
|
||||||
|
painel.append(titulo, lista, restaurar);
|
||||||
|
$('joy-paineis').append(painel);
|
||||||
|
return controle;
|
||||||
|
}
|
||||||
|
|
||||||
|
let assinatura = '';
|
||||||
|
let controles = [];
|
||||||
|
|
||||||
|
function remontar(pads) {
|
||||||
|
$('joy-paineis').replaceChildren();
|
||||||
|
// A vaga do navegador não muda se outro joystick sair.
|
||||||
|
controles = pads.map((pad) => montarControle(pad, pad.index));
|
||||||
|
if (!pads.length) {
|
||||||
|
$('joy-nome').textContent = 'Nenhum joystick encontrado';
|
||||||
|
$('joy-status').textContent = TEXTO_VAZIO;
|
||||||
|
} else {
|
||||||
|
$('joy-nome').textContent = pads.length === 1 ? '1 joystick conectado' : `${pads.length} joysticks conectados`;
|
||||||
|
$('joy-status').textContent = 'Aperte um botão para ver qual é. Depois escolha o que ele faz. Todos controlam a mesma música.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function executar(valor) {
|
||||||
|
if (!valor) return;
|
||||||
|
if (valor.startsWith('loop:')) {
|
||||||
|
comandos.loop(valor.slice(5));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const acao = CONTROLES.find(([v]) => v === valor);
|
||||||
|
if (acao) acao[2]();
|
||||||
|
}
|
||||||
|
|
||||||
|
function lerControles() {
|
||||||
|
const pads = navigator.getGamepads ? [...navigator.getGamepads()].filter(Boolean) : [];
|
||||||
|
const atual = pads.map((p) => `${p.index}|${p.id}|${p.buttons.length}`).join('\n');
|
||||||
|
if (atual !== assinatura) {
|
||||||
|
assinatura = atual;
|
||||||
|
remontar(pads);
|
||||||
|
}
|
||||||
|
pads.forEach((pad, p) => {
|
||||||
|
const controle = controles[p];
|
||||||
|
pad.buttons.forEach((b, i) => {
|
||||||
|
controle.linhas[i].tecla.classList.toggle('apertado', b.pressed);
|
||||||
|
if (b.pressed && !controle.anteriores[i]) executar(controle.mapa[i]);
|
||||||
|
controle.anteriores[i] = b.pressed;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
requestAnimationFrame(lerControles);
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(lerControles);
|
||||||
|
})();
|
||||||
@@ -0,0 +1,475 @@
|
|||||||
|
(() => {
|
||||||
|
const $ = (id) => document.getElementById(id);
|
||||||
|
const base = document.querySelector('.mixer').dataset.base || '';
|
||||||
|
const grupos = JSON.parse($('loops-dados').textContent);
|
||||||
|
const TECLAS = '1234567890qwertyuiopasd';
|
||||||
|
|
||||||
|
const ctx = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
const limitador = ctx.createDynamicsCompressor();
|
||||||
|
limitador.threshold.value = -3;
|
||||||
|
limitador.ratio.value = 12;
|
||||||
|
limitador.attack.value = 0.003;
|
||||||
|
const geral = ctx.createGain();
|
||||||
|
geral.gain.value = Number($('volume-geral').value);
|
||||||
|
geral.connect(limitador).connect(ctx.destination);
|
||||||
|
|
||||||
|
const loops = grupos.flatMap((g) => g.loops.map((l) => ({
|
||||||
|
...l,
|
||||||
|
ritmo: g.ritmo,
|
||||||
|
disparo: Boolean(g.disparo),
|
||||||
|
url: encodeURI(`${base}/assets/audio/${g.pasta}/${l.arquivo}`),
|
||||||
|
disco: document.querySelector(`.disco[data-id="${l.id}"]`),
|
||||||
|
selecionado: false,
|
||||||
|
voz: null,
|
||||||
|
cache: new Map(),
|
||||||
|
})));
|
||||||
|
|
||||||
|
// O bip toca como um loop de 4 tempos: pausa, salta e muda de andamento junto.
|
||||||
|
const bip = {
|
||||||
|
id: 'bip', bip: true, tempos: 4, selecionado: false, voz: null, cache: new Map(), saida: ctx.createGain(),
|
||||||
|
};
|
||||||
|
bip.saida.gain.value = Number($('volume-bip').value);
|
||||||
|
bip.saida.connect(geral);
|
||||||
|
const vozes = [...loops, bip];
|
||||||
|
|
||||||
|
const mdc = (a, b) => (b ? mdc(b, a % b) : a);
|
||||||
|
const CICLO = loops.filter((l) => !l.disparo).reduce((a, l) => (a * l.tempos) / mdc(a, l.tempos), 4);
|
||||||
|
const emCiclo = (b, c = CICLO) => ((b % c) + c) % c;
|
||||||
|
|
||||||
|
let tocando = false;
|
||||||
|
let bpm = 100;
|
||||||
|
let posicao = 0;
|
||||||
|
let ancoraTempo = 0;
|
||||||
|
let ancoraBatida = 0;
|
||||||
|
let celulaAtual = -1;
|
||||||
|
|
||||||
|
const batidaEm = (t) => ancoraBatida + ((t - ancoraTempo) * bpm) / 60;
|
||||||
|
const batidaAgora = () => (tocando ? batidaEm(ctx.currentTime) : posicao);
|
||||||
|
|
||||||
|
function proximaBatida() {
|
||||||
|
const agora = ctx.currentTime + 0.03;
|
||||||
|
return ancoraTempo + ((Math.ceil(batidaEm(agora)) - ancoraBatida) * 60) / bpm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Encontra os ataques de cada golpe, em amostras. */
|
||||||
|
function acharAtaques(canal, fim, taxa) {
|
||||||
|
const salto = Math.round(taxa * 0.005);
|
||||||
|
const janela = salto * 2;
|
||||||
|
const env = [];
|
||||||
|
for (let i = 0; i + janela < fim; i += salto) {
|
||||||
|
let soma = 0;
|
||||||
|
for (let j = i; j < i + janela; j++) soma += canal[j] * canal[j];
|
||||||
|
env.push(Math.sqrt(soma / janela));
|
||||||
|
}
|
||||||
|
const maximo = env.reduce((a, b) => Math.max(a, b), 0);
|
||||||
|
const fluxo = env.slice(1).map((v, i) => Math.max(0, Math.log(v + 1e-3) - Math.log(env[i] + 1e-3)));
|
||||||
|
const media = fluxo.reduce((a, b) => a + b, 0) / fluxo.length;
|
||||||
|
const desvio = Math.sqrt(fluxo.reduce((a, b) => a + (b - media) ** 2, 0) / fluxo.length);
|
||||||
|
const limiar = Math.max(0.35, media + 1.5 * desvio);
|
||||||
|
const distancia = Math.round(taxa * 0.06);
|
||||||
|
const ataques = [0];
|
||||||
|
for (let i = 1; i < fluxo.length - 1; i++) {
|
||||||
|
const forte = env[Math.min(i + 4, env.length - 1)] > 0.04 * maximo;
|
||||||
|
if (fluxo[i] > limiar && fluxo[i] >= fluxo[i - 1] && fluxo[i] >= fluxo[i + 1] && forte) {
|
||||||
|
const pos = Math.max(0, i * salto - Math.round(taxa * 0.003));
|
||||||
|
if (pos - ataques[ataques.length - 1] > distancia) ataques.push(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ataques;
|
||||||
|
}
|
||||||
|
|
||||||
|
function criarBip(novoBpm) {
|
||||||
|
const taxa = ctx.sampleRate;
|
||||||
|
const total = Math.round((4 * 60 * taxa) / novoBpm);
|
||||||
|
const saida = ctx.createBuffer(1, total, taxa);
|
||||||
|
const dados = saida.getChannelData(0);
|
||||||
|
const n = Math.round(taxa * 0.05);
|
||||||
|
for (let b = 0; b < 4; b++) {
|
||||||
|
const inicio = Math.round((b * total) / 4);
|
||||||
|
const freq = b === 0 ? 1568 : 1047;
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
const t = i / taxa;
|
||||||
|
dados[inicio + i] = Math.sin(2 * Math.PI * freq * t) * Math.exp(-t * 90) * Math.min(1, i / 40);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return saida;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Muda o andamento sem mudar o tom: cada golpe vai para o novo lugar. */
|
||||||
|
function criarBuffer(l, novoBpm) {
|
||||||
|
const { original, fim, ataques, tempos } = l;
|
||||||
|
const taxa = original.sampleRate;
|
||||||
|
const total = Math.round((tempos * 60 * taxa) / novoBpm);
|
||||||
|
const razao = total / fim;
|
||||||
|
const saida = ctx.createBuffer(original.numberOfChannels, total, taxa);
|
||||||
|
const queda = Math.round(taxa * 0.006);
|
||||||
|
for (let c = 0; c < original.numberOfChannels; c++) {
|
||||||
|
const de = original.getChannelData(c);
|
||||||
|
const para = saida.getChannelData(c);
|
||||||
|
ataques.forEach((inicio, k) => {
|
||||||
|
const proximo = k + 1 < ataques.length ? ataques[k + 1] : fim;
|
||||||
|
const destino = Math.round(inicio * razao);
|
||||||
|
const vaga = Math.min(total, Math.round(proximo * razao)) - destino;
|
||||||
|
const n = Math.min(proximo - inicio, vaga);
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
const f = n - i <= queda ? (n - i) / queda : 1;
|
||||||
|
para[destino + i] = de[inicio + i] * f;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return saida;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderizar(l, novoBpm) {
|
||||||
|
if (l.cache.has(novoBpm)) return l.cache.get(novoBpm);
|
||||||
|
const buffer = l.bip ? criarBip(novoBpm) : criarBuffer(l, novoBpm);
|
||||||
|
if (l.cache.size >= 3) l.cache.clear();
|
||||||
|
l.cache.set(novoBpm, buffer);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
function iniciarVoz(l, quando, suave) {
|
||||||
|
const src = ctx.createBufferSource();
|
||||||
|
src.buffer = renderizar(l, bpm);
|
||||||
|
src.loop = true;
|
||||||
|
const ganho = ctx.createGain();
|
||||||
|
if (suave) {
|
||||||
|
ganho.gain.setValueAtTime(0, quando);
|
||||||
|
ganho.gain.linearRampToValueAtTime(1, quando + 0.02);
|
||||||
|
}
|
||||||
|
src.connect(ganho).connect(l.saida);
|
||||||
|
src.start(quando, (emCiclo(batidaEm(quando), l.tempos) * 60) / bpm);
|
||||||
|
l.voz = { src, ganho };
|
||||||
|
}
|
||||||
|
|
||||||
|
function pararVoz(l, quando) {
|
||||||
|
if (!l.voz) return;
|
||||||
|
const { src, ganho } = l.voz;
|
||||||
|
ganho.gain.setValueAtTime(1, quando);
|
||||||
|
ganho.gain.linearRampToValueAtTime(0, quando + 0.02);
|
||||||
|
src.stop(quando + 0.03);
|
||||||
|
l.voz = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const prontas = () => vozes.filter((l) => l.selecionado && (l.bip || l.original));
|
||||||
|
|
||||||
|
function reiniciarVozes(quando) {
|
||||||
|
vozes.filter((l) => l.voz).forEach((l) => {
|
||||||
|
pararVoz(l, quando);
|
||||||
|
iniciarVoz(l, quando, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Andamento */
|
||||||
|
let espera = 0;
|
||||||
|
function mudarBpm(valor) {
|
||||||
|
const novo = Math.min(200, Math.max(50, Math.round(valor)));
|
||||||
|
$('bpm-valor').textContent = novo;
|
||||||
|
$('bpm').value = novo;
|
||||||
|
clearTimeout(espera);
|
||||||
|
espera = setTimeout(() => aplicarBpm(novo), tocando ? 90 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function aplicarBpm(novo) {
|
||||||
|
if (novo === bpm) return;
|
||||||
|
if (!tocando) {
|
||||||
|
bpm = novo;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vozes.filter((l) => l.voz).forEach((l) => renderizar(l, novo));
|
||||||
|
const quando = ctx.currentTime + 0.05;
|
||||||
|
ancoraBatida = batidaEm(quando);
|
||||||
|
ancoraTempo = quando;
|
||||||
|
bpm = novo;
|
||||||
|
reiniciarVozes(quando);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transporte */
|
||||||
|
function atualizarStatus() {
|
||||||
|
const n = loops.filter((l) => l.selecionado).length;
|
||||||
|
let texto;
|
||||||
|
if (tocando) texto = n ? 'Tocando. Ligue ou desligue loops: eles entram na próxima batida.' : 'Nenhum loop ligado. Toque em um disco.';
|
||||||
|
else if (n) texto = `Aperte Tocar para começar no tempo ${Math.floor(emCiclo(posicao)) + 1}.`;
|
||||||
|
else texto = 'Escolha os loops nos discos e aperte Tocar.';
|
||||||
|
$('status').textContent = texto;
|
||||||
|
}
|
||||||
|
|
||||||
|
function alternarTransporte() {
|
||||||
|
const botao = $('tocar');
|
||||||
|
if (botao.disabled) return;
|
||||||
|
if (tocando) {
|
||||||
|
const quando = ctx.currentTime + 0.005;
|
||||||
|
posicao = emCiclo(batidaEm(quando));
|
||||||
|
vozes.forEach((l) => pararVoz(l, quando));
|
||||||
|
calarSinos(quando);
|
||||||
|
tocando = false;
|
||||||
|
botao.textContent = 'Tocar';
|
||||||
|
botao.setAttribute('aria-pressed', 'false');
|
||||||
|
} else {
|
||||||
|
ctx.resume();
|
||||||
|
ancoraTempo = ctx.currentTime + 0.08;
|
||||||
|
ancoraBatida = posicao;
|
||||||
|
tocando = true;
|
||||||
|
prontas().forEach((l) => iniciarVoz(l, ancoraTempo, true));
|
||||||
|
botao.textContent = 'Pausar';
|
||||||
|
botao.setAttribute('aria-pressed', 'true');
|
||||||
|
requestAnimationFrame(animar);
|
||||||
|
// O navegador só libera som depois de um clique ou tecla na página.
|
||||||
|
setTimeout(() => {
|
||||||
|
if (tocando && ctx.state !== 'running') $('status').textContent = 'Clique uma vez na página para liberar o som.';
|
||||||
|
}, 400);
|
||||||
|
}
|
||||||
|
pintar();
|
||||||
|
atualizarStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function irPara(batida) {
|
||||||
|
if (!tocando) {
|
||||||
|
posicao = batida;
|
||||||
|
pintar();
|
||||||
|
atualizarStatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const quando = proximaBatida();
|
||||||
|
ancoraBatida = batida;
|
||||||
|
ancoraTempo = quando;
|
||||||
|
reiniciarVozes(quando);
|
||||||
|
}
|
||||||
|
|
||||||
|
function saltar(tempos) {
|
||||||
|
const agora = batidaAgora();
|
||||||
|
irPara(emCiclo((tocando ? Math.ceil(agora) : Math.floor(agora)) + tempos));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sinos: entram na próxima batida e soam até o fim, sem mudar de andamento. */
|
||||||
|
const sinosSoando = new Set();
|
||||||
|
|
||||||
|
function animarSinos() {
|
||||||
|
sinosSoando.forEach((s) => {
|
||||||
|
const p = Math.min(1, Math.max(0, (ctx.currentTime - s.inicio) / s.src.buffer.duration));
|
||||||
|
if (s.l.soando === s) s.l.disco.style.setProperty('--p', `${p * 360}deg`);
|
||||||
|
});
|
||||||
|
if (sinosSoando.size) requestAnimationFrame(animarSinos);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dispararSino(l) {
|
||||||
|
ctx.resume();
|
||||||
|
const inicio = tocando ? proximaBatida() : ctx.currentTime + 0.01;
|
||||||
|
const src = ctx.createBufferSource();
|
||||||
|
src.buffer = l.original;
|
||||||
|
const ganho = ctx.createGain();
|
||||||
|
src.connect(ganho).connect(l.saida);
|
||||||
|
src.start(inicio);
|
||||||
|
const s = { l, src, ganho, inicio };
|
||||||
|
src.onended = () => {
|
||||||
|
sinosSoando.delete(s);
|
||||||
|
if (l.soando === s) {
|
||||||
|
l.soando = null;
|
||||||
|
l.disco.classList.remove('soando');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
l.soando = s;
|
||||||
|
l.disco.classList.add('soando');
|
||||||
|
sinosSoando.add(s);
|
||||||
|
if (sinosSoando.size === 1) requestAnimationFrame(animarSinos);
|
||||||
|
}
|
||||||
|
|
||||||
|
function calarSinos(quando) {
|
||||||
|
sinosSoando.forEach(({ src, ganho }) => {
|
||||||
|
ganho.gain.setValueAtTime(1, quando);
|
||||||
|
ganho.gain.linearRampToValueAtTime(0, quando + 0.05);
|
||||||
|
src.stop(quando + 0.06);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function alternar(l) {
|
||||||
|
if (l.disco && l.disco.disabled) return;
|
||||||
|
if (l.disparo) {
|
||||||
|
dispararSino(l);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
l.selecionado = !l.selecionado;
|
||||||
|
(l.disco || $('bip')).setAttribute('aria-pressed', l.selecionado);
|
||||||
|
if (tocando) {
|
||||||
|
const quando = l.bip ? ctx.currentTime + 0.02 : proximaBatida();
|
||||||
|
if (l.selecionado) iniciarVoz(l, quando, true);
|
||||||
|
else pararVoz(l, quando);
|
||||||
|
}
|
||||||
|
pintar();
|
||||||
|
atualizarStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desenho */
|
||||||
|
const celulas = Array.from({ length: CICLO }, (_, i) => {
|
||||||
|
const b = document.createElement('button');
|
||||||
|
b.type = 'button';
|
||||||
|
b.textContent = i + 1;
|
||||||
|
b.setAttribute('aria-label', `Tempo ${i + 1}`);
|
||||||
|
if (i % 4 === 0) b.classList.add('forte');
|
||||||
|
b.addEventListener('click', () => irPara(i));
|
||||||
|
$('inicio').append(b);
|
||||||
|
return b;
|
||||||
|
});
|
||||||
|
|
||||||
|
function pintar() {
|
||||||
|
const batida = Math.max(0, emCiclo(batidaAgora()));
|
||||||
|
const celula = Math.floor(batida);
|
||||||
|
if (celula !== celulaAtual) {
|
||||||
|
if (celulaAtual >= 0) celulas[celulaAtual].classList.remove('atual');
|
||||||
|
celulas[celula].classList.add('atual');
|
||||||
|
celulaAtual = celula;
|
||||||
|
}
|
||||||
|
loops.forEach((l) => {
|
||||||
|
if (l.selecionado) l.disco.style.setProperty('--p', `${(emCiclo(batida, l.tempos) / l.tempos) * 360}deg`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function animar() {
|
||||||
|
if (!tocando) return;
|
||||||
|
pintar();
|
||||||
|
requestAnimationFrame(animar);
|
||||||
|
}
|
||||||
|
|
||||||
|
function criarSvg(classe, d, pontos) {
|
||||||
|
const NS = 'http://www.w3.org/2000/svg';
|
||||||
|
const svg = document.createElementNS(NS, 'svg');
|
||||||
|
svg.setAttribute('viewBox', '-100 -100 200 200');
|
||||||
|
svg.setAttribute('aria-hidden', 'true');
|
||||||
|
svg.setAttribute('class', classe);
|
||||||
|
const barras = document.createElementNS(NS, 'path');
|
||||||
|
barras.setAttribute('class', 'barras');
|
||||||
|
barras.setAttribute('d', d);
|
||||||
|
svg.append(barras);
|
||||||
|
if (pontos) svg.append(pontos);
|
||||||
|
return svg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desenha a onda real do áudio como barras em volta do disco. */
|
||||||
|
function desenharDisco(l) {
|
||||||
|
const NS = 'http://www.w3.org/2000/svg';
|
||||||
|
const canal = l.original.getChannelData(0);
|
||||||
|
const partes = 84;
|
||||||
|
const picos = Array.from({ length: partes }, (_, i) => {
|
||||||
|
const a = Math.floor((i / partes) * l.fim);
|
||||||
|
const b = Math.floor(((i + 1) / partes) * l.fim);
|
||||||
|
let soma = 0;
|
||||||
|
let qtd = 0;
|
||||||
|
for (let j = a; j < b; j += 8) { soma += canal[j] * canal[j]; qtd++; }
|
||||||
|
return Math.sqrt(soma / qtd);
|
||||||
|
});
|
||||||
|
const maior = picos.reduce((a, b) => Math.max(a, b), 0) || 1;
|
||||||
|
const xy = (r, ang) => `${(r * Math.sin(ang)).toFixed(1)} ${(-r * Math.cos(ang)).toFixed(1)}`;
|
||||||
|
let d = '';
|
||||||
|
picos.forEach((p, i) => {
|
||||||
|
const ang = ((i + 0.5) / partes) * 2 * Math.PI;
|
||||||
|
const h = 1.5 + 19 * Math.sqrt(p / maior);
|
||||||
|
d += `M${xy(73 - h, ang)}L${xy(73 + h, ang)}`;
|
||||||
|
});
|
||||||
|
const pontos = document.createElementNS(NS, 'g');
|
||||||
|
pontos.setAttribute('class', 'pontos');
|
||||||
|
for (let i = 0; i < l.tempos; i++) {
|
||||||
|
const ang = (i / l.tempos) * 2 * Math.PI;
|
||||||
|
const c = document.createElementNS(NS, 'circle');
|
||||||
|
c.setAttribute('cx', (97 * Math.sin(ang)).toFixed(1));
|
||||||
|
c.setAttribute('cy', (-97 * Math.cos(ang)).toFixed(1));
|
||||||
|
c.setAttribute('r', i === 0 ? 3 : 1.6);
|
||||||
|
pontos.append(c);
|
||||||
|
}
|
||||||
|
l.disco.prepend(criarSvg('base', d, pontos), criarSvg('aceso', d));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function carregar(l) {
|
||||||
|
const r = await fetch(l.url);
|
||||||
|
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
||||||
|
l.original = await ctx.decodeAudioData(await r.arrayBuffer());
|
||||||
|
const taxa = l.original.sampleRate;
|
||||||
|
l.fim = l.ate ? Math.min(Math.round(l.ate * taxa), l.original.length) : l.original.length;
|
||||||
|
if (!l.disparo) l.ataques = acharAtaques(l.original.getChannelData(0), l.fim, taxa);
|
||||||
|
l.saida = ctx.createGain();
|
||||||
|
l.saida.gain.value = l.volume;
|
||||||
|
l.saida.connect(geral);
|
||||||
|
desenharDisco(l);
|
||||||
|
l.disco.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Controles */
|
||||||
|
loops.forEach((l) => {
|
||||||
|
l.disco.addEventListener('click', () => alternar(l));
|
||||||
|
document.querySelector(`[data-volume="${l.id}"]`).addEventListener('input', (e) => {
|
||||||
|
l.volume = Number(e.target.value);
|
||||||
|
if (l.saida) l.saida.gain.setTargetAtTime(l.volume, ctx.currentTime, 0.01);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('tocar').addEventListener('click', alternarTransporte);
|
||||||
|
$('bip').addEventListener('click', () => alternar(bip));
|
||||||
|
$('volume-bip').addEventListener('input', (e) => {
|
||||||
|
bip.saida.gain.setTargetAtTime(Number(e.target.value), ctx.currentTime, 0.01);
|
||||||
|
});
|
||||||
|
$('bpm').addEventListener('input', (e) => mudarBpm(Number(e.target.value)));
|
||||||
|
$('bpm-menos').addEventListener('click', () => mudarBpm(Number($('bpm').value) - 1));
|
||||||
|
$('bpm-mais').addEventListener('click', () => mudarBpm(Number($('bpm').value) + 1));
|
||||||
|
$('volume-geral').addEventListener('input', (e) => {
|
||||||
|
geral.gain.setTargetAtTime(Number(e.target.value), ctx.currentTime, 0.01);
|
||||||
|
});
|
||||||
|
|
||||||
|
let toques = [];
|
||||||
|
$('tap').addEventListener('click', () => {
|
||||||
|
const agora = performance.now();
|
||||||
|
if (toques.length && agora - toques[toques.length - 1] > 2000) toques = [];
|
||||||
|
toques.push(agora);
|
||||||
|
toques = toques.slice(-5);
|
||||||
|
if (toques.length >= 2) {
|
||||||
|
const media = (toques[toques.length - 1] - toques[0]) / (toques.length - 1);
|
||||||
|
mudarBpm(60000 / media);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if (e.repeat || e.ctrlKey || e.metaKey || e.altKey || e.target.closest('select')) return;
|
||||||
|
const k = e.key.toLowerCase();
|
||||||
|
const i = TECLAS.indexOf(k);
|
||||||
|
if (k.length === 1 && i >= 0 && i < loops.length) {
|
||||||
|
alternar(loops[i]);
|
||||||
|
} else if (k === 'b') {
|
||||||
|
alternar(bip);
|
||||||
|
} else if (e.code === 'Space' && !e.target.closest('button, input')) {
|
||||||
|
e.preventDefault();
|
||||||
|
alternarTransporte();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pintar();
|
||||||
|
Promise.allSettled(loops.map(carregar)).then((res) => {
|
||||||
|
const falhas = loops.filter((_, i) => res[i].status === 'rejected');
|
||||||
|
const botao = $('tocar');
|
||||||
|
if (falhas.length === loops.length) {
|
||||||
|
botao.textContent = 'Sem áudio';
|
||||||
|
$('status').textContent = 'Os áudios não abriram. Confira se o site está sendo servido pelo _site.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
botao.disabled = false;
|
||||||
|
botao.textContent = 'Tocar';
|
||||||
|
if (falhas.length) $('status').textContent = `Não abriu: ${falhas.map((l) => l.nome).join(', ')}.`;
|
||||||
|
else atualizarStatus();
|
||||||
|
});
|
||||||
|
|
||||||
|
['pointerdown', 'keydown'].forEach((ev) => document.addEventListener(ev, () => {
|
||||||
|
if (ctx.state === 'suspended' && tocando) ctx.resume().then(atualizarStatus);
|
||||||
|
}));
|
||||||
|
|
||||||
|
window.loopsMixer = {
|
||||||
|
loops,
|
||||||
|
bip,
|
||||||
|
renderizar,
|
||||||
|
CICLO,
|
||||||
|
estado: () => ({ tocando, bpm, posicao, batida: batidaAgora() }),
|
||||||
|
comandos: {
|
||||||
|
transporte: alternarTransporte,
|
||||||
|
saltar,
|
||||||
|
bip: () => alternar(bip),
|
||||||
|
loop: (id) => { const l = loops.find((x) => x.id === id); if (l) alternar(l); },
|
||||||
|
andamento: (d) => mudarBpm(Number($('bpm').value) + d),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
})();
|
||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
---
|
||||||
|
layout: default
|
||||||
|
---
|
||||||
|
{% assign teclas = "1234567890qwertyuiopasd" | split: "" %}{% assign n = 0 %}
|
||||||
|
<main class="mixer" data-base="{{ site.baseurl }}">
|
||||||
|
<section class="console" aria-label="Controles gerais">
|
||||||
|
<h1>{{ site.title }}</h1>
|
||||||
|
|
||||||
|
<div class="andamento">
|
||||||
|
<output id="bpm-valor" class="bpm" for="bpm">100</output>
|
||||||
|
<span>batidas por minuto</span>
|
||||||
|
<div class="bpm-linha">
|
||||||
|
<button type="button" class="passo" id="bpm-menos" aria-label="Diminuir andamento">−</button>
|
||||||
|
<input id="bpm" type="range" min="50" max="200" step="1" value="100" aria-label="Andamento em batidas por minuto">
|
||||||
|
<button type="button" class="passo" id="bpm-mais" aria-label="Aumentar andamento">+</button>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="tap" id="tap">Marcar o tempo</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" class="tocar" id="tocar" disabled>Carregando</button>
|
||||||
|
<p class="status" id="status" role="status">Preparando os loops.</p>
|
||||||
|
|
||||||
|
<div class="inicio-bloco">
|
||||||
|
<span id="inicio-titulo">Começar no tempo</span>
|
||||||
|
<div class="inicio" id="inicio" role="group" aria-labelledby="inicio-titulo"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bip-linha">
|
||||||
|
<button type="button" class="tap" id="bip" aria-pressed="false">Bip</button>
|
||||||
|
<input id="volume-bip" type="range" min="0" max="1" step="0.01" value="0.5" aria-label="Volume do bip">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label class="geral">Volume geral
|
||||||
|
<input id="volume-geral" type="range" min="0" max="1" step="0.01" value="0.9">
|
||||||
|
</label>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="palco">
|
||||||
|
<div class="abas" role="tablist" aria-label="Seções">
|
||||||
|
<button type="button" role="tab" id="aba-loops" aria-controls="painel-loops" aria-selected="true">Loops</button>
|
||||||
|
<button type="button" role="tab" id="aba-joystick" aria-controls="painel-joystick" aria-selected="false">Joystick</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ritmos" id="painel-loops" role="tabpanel" aria-labelledby="aba-loops">
|
||||||
|
{% for grupo in site.data.loops %}
|
||||||
|
<section class="ritmo" style="--cor: {{ grupo.cor }}" aria-labelledby="ritmo-{{ forloop.index }}">
|
||||||
|
<h2 id="ritmo-{{ forloop.index }}">{{ grupo.ritmo }}</h2>
|
||||||
|
<div class="roda">
|
||||||
|
{% for loop in grupo.loops %}
|
||||||
|
<div class="canal">
|
||||||
|
<button type="button" class="disco" data-id="{{ loop.id }}"{% unless grupo.disparo %} aria-pressed="false"{% endunless %}{% if teclas[n] %} aria-keyshortcuts="{{ teclas[n] }}"{% endif %} disabled>
|
||||||
|
<span class="nome">{{ loop.nome }}</span>
|
||||||
|
</button>
|
||||||
|
<div class="volume">
|
||||||
|
{% if teclas[n] %}<kbd>{{ teclas[n] | upcase }}</kbd>{% else %}<span></span>{% endif %}
|
||||||
|
<input type="range" min="0" max="1" step="0.01" value="{{ loop.volume }}" data-volume="{{ loop.id }}" aria-label="Volume de {{ loop.nome }}, {{ grupo.ritmo }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% assign n = n | plus: 1 %}{% endfor %}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section class="joystick" id="painel-joystick" role="tabpanel" aria-labelledby="aba-joystick" hidden>
|
||||||
|
<h2 id="joy-nome">Nenhum joystick encontrado</h2>
|
||||||
|
<p id="joy-status" role="status">Conecte o joystick e aperte qualquer botão dele. O navegador só mostra o controle depois do primeiro botão.</p>
|
||||||
|
<div class="joy-paineis" id="joy-paineis"></div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<script type="application/json" id="loops-dados">{{ site.data.loops | jsonify }}</script>
|
||||||
|
<script src="{{ '/assets/js/mixer.js' | relative_url }}"></script>
|
||||||
|
<script src="{{ '/assets/js/joystick.js' | relative_url }}"></script>
|
||||||
Reference in new issue
Block a user