添加一些关于midi播放的项目

This commit is contained in:
terryLP
2025-03-24 14:30:56 +08:00
parent e31eb22077
commit 498b4ef13b
699 changed files with 186162 additions and 1 deletions
+58
View File
@@ -0,0 +1,58 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <avr/io.h>
#include "SynthCore.h"
#include "Player.h"
#include "PeriodTimer.h"
void PlayerProcess(Player *player)
{
uint8_t temp;
if (decayGenTick >= DECAY_TIME_FACTOR)
{
GenDecayEnvlopeAsm();
decayGenTick = 0;
}
if (player->status == STATUS_PLAYING)
{
if (PlayNoteTimingCheck(player))
{
do
{
temp = pgm_read_byte(player->scorePointer);
player->scorePointer++;
if (temp == 0xFF)
{
player->status = STATUS_STOP;
}
else
{
NoteOnAsm(temp);
}
} while ((temp & 0x80) == 0);
PlayUpdateNextScoreTick(player);
}
}
}
void PlayerPlay(Player *player, uint8_t *score)
{
player->lastScoreTick = 0;
player->scorePointer = score;
currentTick = 0;
PlayUpdateNextScoreTick(player);
player->status = STATUS_PLAYING;
}
void PlayerInit(Player *player, Synthesizer *synthesizer)
{
player->status = STATUS_STOP;
player->lastScoreTick = 0;
currentTick = 0;
player->scorePointer = NULL;
player->synthesizerPointer = synthesizer;
SynthInit(synthesizer);
}