caminhos de áudio nos instrumentos em projetos
Deploy / Deploy (push) Successful in 47s Details

This commit is contained in:
JotaChina 2025-05-22 17:08:53 -03:00
parent fafa6528fa
commit 337946a91a
1 changed files with 67 additions and 8 deletions

View File

@ -114,16 +114,75 @@ title: "{{ page.file }}"
<a href="{{ '/instruments/?instrument=' | append: instrument_slug | relative_url }}" class="tag is-info is-light">
<code>{{ instrument.instrument_name }}</code>
</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 track in page.tracks %}
{% assign tem_instr = false %}
{% if track.instruments and track.instruments.size > 0 %}
{% assign tem_instr = true %}
{% endif %}
{% if instrument.audiofileprocessor and instrument.audiofileprocessor.src %}
<!-- Exibir player de áudio para o instrumento -->
<div class="audio-player-section mt-3">
<audio controls>
<source src="{{ instrument.audiofileprocessor.src | relative_url }}" type="audio/wav">
Seu navegador não suporta o elemento <code>audio</code>.
</audio>
{% if track.bassline_name or tem_instr %}
<li class="mb-5">
{% 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>
{% endif %}
</section>
{% endif %}
</li>
{% endif %}
{% endfor %}