caminhos de áudio nos instrumentos em projetos
This commit is contained in:
1 parent
17f4e147bd
commit
b6e1a7d14e
2 files changed
+60
-79
No files matched your search
+32
-79
@@ -88,8 +88,9 @@ title: "{{ page.file }}"
|
|||||||
<!-- Instrumentos -->
|
<!-- Instrumentos -->
|
||||||
{% if page.tracks and page.tracks.size > 0 %}
|
{% if page.tracks and page.tracks.size > 0 %}
|
||||||
<section class="instruments-section">
|
<section class="instruments-section">
|
||||||
<h2 class="title is-5"><code>🎚️ Instrumentos</h2></code>
|
<h2 class="title is-5"><code>🎚️ Instrumentos</code></h2>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
||||||
<ul style="list-style: none; padding-left: 0;">
|
<ul style="list-style: none; padding-left: 0;">
|
||||||
{% for track in page.tracks %}
|
{% for track in page.tracks %}
|
||||||
{% assign tem_instr = false %}
|
{% assign tem_instr = false %}
|
||||||
@@ -104,89 +105,41 @@ title: "{{ page.file }}"
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if tem_instr %}
|
{% if tem_instr %}
|
||||||
<ul class="pl-4">
|
<ul class="pl-4">
|
||||||
{% for instrument in track.instruments %}
|
{% for instrument in track.instruments %}
|
||||||
{% if instrument.instrument_name %}
|
{% if instrument.instrument_name %}
|
||||||
<li style="margin-bottom: 0.4rem;">
|
<li style="margin-bottom: 0.4rem;">
|
||||||
<!-- Gerar link para filtro por instrumento -->
|
<!-- Gerar link para filtro por instrumento -->
|
||||||
{% assign instrument_slug = instrument.instrument_name | replace: ' ', '+' %}
|
{% assign instrument_slug = instrument.instrument_name | replace: ' ', '+' %}
|
||||||
|
<a href="{{ '/instruments/?instrument=' | append: instrument_slug | relative_url }}" class="tag is-info is-light">
|
||||||
|
<code>{{ instrument.instrument_name }}</code>
|
||||||
|
</a>
|
||||||
|
|
||||||
<a href="{{ '/instruments/?instrument=' | append: instrument_slug | relative_url }}" class="tag is-info is-light">
|
<!-- Buscar o caminho do áudio no arquivo JSON -->
|
||||||
<code>{{ instrument.instrument_name }}</code>
|
{% assign found_audio = false %}
|
||||||
</a>
|
|
||||||
<!-- Instrumentos -->
|
|
||||||
{% if page.tracks and page.tracks.size > 0 %}
|
|
||||||
<section class="instruments-section">
|
|
||||||
<h2 class="title is-5"><code>🎚️ Instrumentos</code></h2>
|
|
||||||
<div class="content">
|
|
||||||
|
|
||||||
<ul style="list-style: none; padding-left: 0;">
|
{% for audio_file in site.data.audio_files %}
|
||||||
{% for track in page.tracks %}
|
{% if audio_file contains instrument.instrument_name %}
|
||||||
{% assign tem_instr = false %}
|
{% assign audio_file_path = audio_file %}
|
||||||
{% if track.instruments and track.instruments.size > 0 %}
|
{% assign found_audio = true %}
|
||||||
{% assign tem_instr = true %}
|
<div class="audio-player-section mt-3">
|
||||||
{% endif %}
|
<audio controls>
|
||||||
|
<source src="{{ audio_file_path }}" type="audio/wav">
|
||||||
{% if track.bassline_name or tem_instr %}
|
Seu navegador não suporta o elemento <code>audio</code>.
|
||||||
<li class="mb-5">
|
</audio>
|
||||||
{% if track.bassline_name %}
|
|
||||||
<p class="has-text-weight-bold mb-2">🎼 {{ track.bassline_name }}</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if tem_instr %}
|
|
||||||
<ul class="pl-4">
|
|
||||||
{% for instrument in track.instruments %}
|
|
||||||
{% if instrument.instrument_name %}
|
|
||||||
<li style="margin-bottom: 0.4rem;">
|
|
||||||
<!-- Gerar link para filtro por instrumento -->
|
|
||||||
{% assign instrument_slug = instrument.instrument_name | replace: ' ', '+' %}
|
|
||||||
<a href="{{ '/instruments/?instrument=' | append: instrument_slug | relative_url }}" class="tag is-info is-light">
|
|
||||||
<code>{{ instrument.instrument_name }}</code>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<!-- Gerar o caminho absoluto para o áudio -->
|
|
||||||
{% assign base_path = "/usr/share/lmms/" %}
|
|
||||||
{% assign found_audio = false %}
|
|
||||||
|
|
||||||
<!-- Vamos tentar procurar em diferentes subpastas -->
|
|
||||||
{% assign subfolders = "instrumentos/sintetizadores, instrumentos/bateria, outros" | split: ", " %}
|
|
||||||
|
|
||||||
{% for folder in subfolders %}
|
|
||||||
{% assign audio_file_path = base_path | append: folder | append: "/" | append: instrument.instrument_name | append: ".wav" %}
|
|
||||||
|
|
||||||
<!-- Verificar se o arquivo de áudio existe no caminho gerado -->
|
|
||||||
{% if audio_file_path %}
|
|
||||||
{% assign found_audio = true %}
|
|
||||||
<div class="audio-player-section mt-3">
|
|
||||||
<audio controls>
|
|
||||||
<source src="{{ audio_file_path }}" type="audio/wav">
|
|
||||||
Seu navegador não suporta o elemento <code>audio</code>.
|
|
||||||
</audio>
|
|
||||||
</div>
|
|
||||||
{% break %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% if found_audio == false %}
|
|
||||||
<p>Áudio não encontrado para este instrumento.</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
{% break %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if found_audio == false %}
|
||||||
|
<p>Áudio não encontrado para este instrumento.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
# Caminho base onde os arquivos .wav estão localizados
|
||||||
|
base_dir = "/usr/share/lmms/"
|
||||||
|
|
||||||
|
# Caminho para salvar o arquivo JSON na pasta metadata (na raiz do seu site)
|
||||||
|
output_file = "metadata/src_audio_files.json" # Substitua com o caminho correto
|
||||||
|
|
||||||
|
# Função para percorrer o diretório e suas subpastas
|
||||||
|
def find_audio_files(base_dir):
|
||||||
|
audio_files = []
|
||||||
|
for root, dirs, files in os.walk(base_dir):
|
||||||
|
for file in files:
|
||||||
|
if (file.endswith(".wav") or file.endswith(".ogg") or
|
||||||
|
file.endswith(".flac") or file.endswith(".mp3")):
|
||||||
|
# Adiciona o caminho completo do arquivo
|
||||||
|
audio_files.append(os.path.join(root, file))
|
||||||
|
return audio_files
|
||||||
|
|
||||||
|
# Chama a função para encontrar os arquivos
|
||||||
|
audio_files = find_audio_files(base_dir)
|
||||||
|
|
||||||
|
# Salva a lista de arquivos encontrados em um arquivo JSON
|
||||||
|
with open(output_file, "w") as f:
|
||||||
|
json.dump(audio_files, f, indent=4)
|
||||||
|
|
||||||
|
print(f"Arquivo JSON gerado com sucesso em: {output_file}")
|
||||||
Reference in new issue
Block a user