updateBufferCount += cycles;
if (updateBufferCount >= updateBufferLimit)
{
if (bufferPosition < BUFFERSIZE)
playbackBuffer[bufferPosition] = tone*3000;
bufferPosition++;
updateBufferCount = updateBufferLimit - updateBufferCount ;
}
Blip_Buffer implements an efficient band-limited sound buffer for high-quality emulation of sound chips. After setting the source clock rate and output sample rate, sound waves are made by specifying the time points where amplitude changes occur.
updateBufferCount = updateBufferLimit - updateBufferCount ;
updateBufferCount = updateBufferCount - updateBufferLimit;
Frequency = 65536/(2048-x) Hz
frequency = (65536/(2048-x)*32) Hz
// Channel 3
if (chanOn[2])
{
static double polarity[] = { -1, -0.8667, -0.7334, -0.6, -0.4668, -0.3335, -0.2, -0.067, 0.0664, 0.2, 0.333, 0.4668, 0.6, 0.7334, 0.8667, 1 } ;
if (chanVol[2] != 0)
{
// Read the sample from ram
int wavTone = ioRam[0x30+(chan3WavPos/2)];
wavTone = chan3WavPos%2? wavTone&0xF : wavTone>>4;
// Add the sample to the output
if (chanToOut1[2])
toneSO1 += (polarity[wavTone])*(0xF >> (chanVol[2]-1));
if (chanToOut2[2])
toneSO2 += (polarity[wavTone])*(0xF >> (chanVol[2]-1));
}
chanPolarityCounter[2] -= cycles;
// Update polarity
if (chanPolarityCounter[2] <= 0)
{
chanPolarityCounter[2] = clockSpeed/(65536/(2048-chanFreq[2])*32);
chan3WavPos++;
if (chan3WavPos >= 32)
chan3WavPos = 0;
}
// Check that it hasn't timed out
if (chanUseLen[2])
{
chanLenCounter[2] -= cycles;
if (chanLenCounter[2] <= 0)
{
chanOn[2] = 0;
chanPolarityCounter[2] = 0;
clearChan3();
}
}
}
well i can approve of that because i already wrote a nes emu . Cpu is quite accurate (luckily NES community has a lot of testroms) but well graphic is glitchy as hell. It runs a few games but to get more games running withought extensive hacks oh my... Like battletoads, your off by one 1 cycle and the screen starts shacking weird etc... So id rather not go back to the nesbut just more frusterating/time consuming