Skip to content

Commit

Permalink
Little fix in the generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Aug 30, 2018
1 parent b09da81 commit 65ca735
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/opl/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Generator::Generator(uint32_t sampleRate, OPL_Chips initialChip)
};
m_regBD = 0;
memset(m_ins, 0, sizeof(uint16_t)*NUM_OF_CHANNELS);
memset(m_pit, 0, sizeof(uint8_t)*NUM_OF_CHANNELS);
memset(m_keyBlockFNumCache, 0, sizeof(uint8_t)*NUM_OF_CHANNELS);
memset(m_four_op_category, 0, NUM_OF_CHANNELS * 2);

uint32_t p = 0;
Expand Down Expand Up @@ -278,7 +278,7 @@ void Generator::NoteOff(uint32_t c)
return;
}

WriteReg(0xB0 + g_Channels[cc], m_pit[c] & 0xDF);
WriteReg(0xB0 + g_Channels[cc], m_keyBlockFNumCache[c] & 0xDF);
}

void Generator::NoteOn(uint32_t c1, uint32_t c2, double hertz) // Hertz range: 0..131071
Expand Down Expand Up @@ -346,8 +346,12 @@ void Generator::NoteOn(uint32_t c1, uint32_t c2, double hertz) // Hertz range: 0
}
}

WriteReg(0xA0 + chn, ftone & 0xFF);
WriteReg(0xB0 + chn, m_pit[c1] = static_cast<uint8_t>(ftone >> 8));
if(chn != 0xFFF)
{
WriteReg(0xA0 + chn, ftone & 0xFF);
WriteReg(0xB0 + chn, (ftone >> 8));
m_keyBlockFNumCache[c1] = static_cast<uint8_t>(ftone >> 8);
}

if(cc1 >= OPL3_CHANNELS_RHYTHM_BASE)
{
Expand Down
2 changes: 1 addition & 1 deletion src/opl/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class Generator
//! index of operators pair, cached, needed by Touch()
uint16_t m_ins[NUM_OF_CHANNELS];
//! value poked to B0, cached, needed by NoteOff)(
uint8_t m_pit[NUM_OF_CHANNELS];
uint8_t m_keyBlockFNumCache[NUM_OF_CHANNELS];
};

#endif // GENERATOR_H

0 comments on commit 65ca735

Please sign in to comment.