mirror of
https://github.com/tildearrow/furnace.git
synced 2025-01-03 06:01:29 +00:00
YM2612: fix negative octaves
This commit is contained in:
parent
52e35fdf04
commit
c84ff399d9
3 changed files with 16 additions and 1 deletions
|
@ -426,7 +426,8 @@ class DivDispatch {
|
|||
#define NOTE_PERIODIC(x) round(parent->calcBaseFreq(chipClock,CHIP_DIVIDER,x,true))
|
||||
#define NOTE_PERIODIC_NOROUND(x) parent->calcBaseFreq(chipClock,CHIP_DIVIDER,x,true)
|
||||
#define NOTE_FREQUENCY(x) parent->calcBaseFreq(chipClock,CHIP_FREQBASE,x,false)
|
||||
#define NOTE_FNUM_BLOCK(x,bits) ((((int)parent->calcBaseFreq(chipClock,CHIP_FREQBASE,(x)%12,false))&((1<<bits)-1))|((MAX(x,0)/12)<<bits))
|
||||
|
||||
#define NOTE_FNUM_BLOCK(x,bits) parent->calcBaseFreqFNumBlock(chipClock,CHIP_FREQBASE,x,bits)
|
||||
|
||||
#define COLOR_NTSC (315000000.0/88.0)
|
||||
#define COLOR_PAL (283.75*15625.0+25.0)
|
||||
|
|
|
@ -887,6 +887,17 @@ double DivEngine::calcBaseFreq(double clock, double divider, int note, bool peri
|
|||
base*(divider/clock);
|
||||
}
|
||||
|
||||
unsigned short DivEngine::calcBaseFreqFNumBlock(double clock, double divider, int note, int bits) {
|
||||
int bf=calcBaseFreq(clock,divider,note,false);
|
||||
int block=note/12;
|
||||
if (block<0) block=0;
|
||||
if (block>7) block=7;
|
||||
bf>>=block;
|
||||
if (bf<0) bf=0;
|
||||
if (bf>((1<<bits)-1)) bf=(1<<bits)-1;
|
||||
return bf|(block<<bits);
|
||||
}
|
||||
|
||||
int DivEngine::calcFreq(int base, int pitch, bool period, int octave) {
|
||||
if (song.linearPitch) {
|
||||
// global pitch multiplier
|
||||
|
|
|
@ -367,6 +367,9 @@ class DivEngine {
|
|||
// calculate base frequency/period
|
||||
double calcBaseFreq(double clock, double divider, int note, bool period);
|
||||
|
||||
// calculate base frequency in f-num/block format
|
||||
unsigned short calcBaseFreqFNumBlock(double clock, double divider, int note, int bits);
|
||||
|
||||
// calculate frequency/period
|
||||
int calcFreq(int base, int pitch, bool period=false, int octave=0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue