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 "tone.h"
#include "audio.h" #include "audio.h"
#include "pcmdma.h" #include "pcmdma.h"
//#include "filtr.h" #include "pwmconfig.h"
/** /**
* @file * @file
* @brief Jednoduchý přehrávač midi souborů. * @brief Jednoduchý přehrávač midi souborů.
@ -48,18 +48,17 @@ static unsigned pwm_sd (const int input) {
/******************************************************************/ /******************************************************************/
/// Konstruktor /// Konstruktor
MidiPlayer::MidiPlayer() noexcept : OneWay() /*, but(GpioPortA, 2, GPIO_Mode_IN)*/ { MidiPlayer::MidiPlayer() noexcept : OneWay() {
//but.setPuPd(GPIO_PuPd_UP);
index = 0; index = 0;
pause = 0; pause = 0;
melody = scores[index++]; melody = scores[index++];
running = true; running = true;
} }
unsigned MidiPlayer::Send (uint16_t * const ptr, const unsigned len) { 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) { 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; return len;
} }
@ -70,7 +69,7 @@ unsigned MidiPlayer::Send (uint16_t * const ptr, const unsigned len) {
return len; return len;
} }
void MidiPlayer::stop (void) { void MidiPlayer::stop (void) {
//running = false; //running = false; // cyklicky, furt
melody = scores[index++]; melody = scores[index++];
if (!melody) { if (!melody) {
index = 0; index = 0;