Add Auxiliary code to the YMF262 To properly tune the IC

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2026-03-25 18:49:07 -03:00
parent 72f9200d09
commit 93f1496dc7
5 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,19 @@
//
// Created by gustavohenriquesantossouzademir on 24/03/2026.
//
#ifndef YMF262DEVBOARDSOFTWARE_FNUMBERBLOCK_H
#define YMF262DEVBOARDSOFTWARE_FNUMBERBLOCK_H
enum FNumberBlock {
BLOCK1,
BLOCK2,
BLOCK3,
BLOCK4,
BLOCK5,
BLOCK6,
BLOCK7,
BLOCK8,
};
#endif //YMF262DEVBOARDSOFTWARE_FNUMBERBLOCK_H

View File

@ -0,0 +1,21 @@
//
// Created by gustavohenriquesantossouzademir on 24/03/2026.
//
#ifndef YMF262DEVBOARDSOFTWARE_NOTES_H
#define YMF262DEVBOARDSOFTWARE_NOTES_H
enum Notes {
NoteDo,
NoteDoSharp,
NoteRe,
NoteReSharp,
Note,Mi,
NoteFa,
NoteFaSharp,
NoteSol,
NoteSolSharp,
NoteLa,
NoteLaSharp,
NoteSi
};
#endif //YMF262DEVBOARDSOFTWARE_NOTES_H

View File

@ -0,0 +1,48 @@
//
// Created by gustavohenriquesantossouzademir on 24/03/2026.
//
#ifndef YMF262DEVBOARDSOFTWARE_OPL3TUNNING_H
#define YMF262DEVBOARDSOFTWARE_OPL3TUNNING_H
#include <cstdint>
template <uint32_t TCLOCK = 14'318'180UL>
class OPL3Tunning {
private:
/*!
* @brief Precomputed power-of-two values for each F-Number block octave.
*
* Each entry corresponds to \f$ 2^{(octave - 1)} \f$, used in the F-Number formula:
* \f[
* F_{number} = \frac{f \cdot 2^{19}}{f_s \cdot 2^{octave - 1}}
* \f]
* Index 0 corresponds to Octave1, index 7 to Octave8.
*/
static constexpr uint16_t POW2_BLOCKMINUS1[8] = {
1,2,4,8,16,32,64,128
};
/*!
* @brief Precomputed number for the \f$ 2^{19} \f$
* This number is precomputed due the STM32 not having a POW function and this number is used
* on the formula:
* \f[
* F_{number} = \frac{f \cdot 2^{19}}{f_s \cdot 2^{octave - 1}}
* \f]
* so it was added as static constexpr
*/
static constexpr uint32_t POW2_19 = 524288;
/*!
* @brief Calculated Sampling Frequency
*
* This Number is dependent on the Clock and is also used on the formula to calculate the F-Number
* * \f[
* f_s = \frac{T_{CLOCK}}{288}
* \f]
*/
static constexpr uint32_t FS = TCLOCK / 288;
};
#endif //YMF262DEVBOARDSOFTWARE_OPL3TUNNING_H

View File

View File

@ -0,0 +1,5 @@
//
// Created by gustavohenriquesantossouzademir on 24/03/2026.
//
#include "../include/YMF262/OPL3Tunning.h"