clean midiplayer

This commit is contained in:
Kizarm 2024-03-09 13:41:24 +01:00
parent 4a3aaa1a0e
commit edf51f4704

View file

@ -2,7 +2,7 @@
#include "tone.h"
#include "audio.h"
#include "pcmdma.h"
//#include "filtr.h"
#include "pwmconfig.h"
/**
* @file
* @brief Jednoduchý přehrávač midi souborů.
@ -48,18 +48,17 @@ static unsigned pwm_sd (const int input) {
/******************************************************************/
/// Konstruktor
MidiPlayer::MidiPlayer() noexcept : OneWay() /*, but(GpioPortA, 2, GPIO_Mode_IN)*/ {
//but.setPuPd(GPIO_PuPd_UP);
MidiPlayer::MidiPlayer() noexcept : OneWay() {
index = 0;
pause = 0;
melody = scores[index++];
running = true;
}
unsigned MidiPlayer::Send (uint16_t * const ptr, const unsigned len) {
// if (!but.get()) running = true;
//if (!but.get()) running = true; // případně spouštět tlačítkem, není implementováno
if (!running) {
for (unsigned n=0; n<len; n++) ptr [n] = 1000;
for (unsigned n=0; n<len; n++) ptr [n] = MAXPWM >> 1;
return len;
}
@ -70,7 +69,7 @@ unsigned MidiPlayer::Send (uint16_t * const ptr, const unsigned len) {
return len;
}
void MidiPlayer::stop (void) {
//running = false;
//running = false; // cyklicky, furt
melody = scores[index++];
if (!melody) {
index = 0;