Posted: Tue Aug 31, 2010 7:38 pm
HOLD ON A DAMN SECOND.
It appears I was reading them the wrong way. I set the buffer size to each spc's compressed file size instead of actual size....
But now i just get 'emulation error' when I try to play a spc file.
It appears I was reading them the wrong way. I set the buffer size to each spc's compressed file size instead of actual size....
But now i just get 'emulation error' when I try to play a spc file.
Code: Select all
protected int play_( byte out [], int count )
{
dsp.setOutput( out );
// Run for count/2*32 clocks + extra to get DSP time half-way between samples,
// since CPU might run for slightly less than requested
int clockCount = count * (32 / 2) + 16 - ((time - dspTime) & 31);
time -= clockCount;
dspTime -= clockCount;
timers [0].time -= clockCount;
timers [1].time -= clockCount;
timers [2].time -= clockCount;
runCpu();
if ( time < 0 ) // emulation error
{
logError();
return 0;
}
// Catch up to CPU
runTimer( timers [0], time );
runTimer( timers [1], time );
runTimer( timers [2], time );
// Run DSP to present
int delta;
if ( (delta = time - dspTime) >= 0 )
{
delta = (delta >> 5) + 1;
dspTime += delta << 5;
dsp.run( delta );
}
assert dsp.sampleCount() == count;
return dsp.sampleCount();
}Code: Select all
public void run()
{
line.start();
// play track until stop signal
byte [] buf = new byte [8192];
while ( playing_ && !emu.trackEnded() )
{
int count = emu.play( buf, buf.length / 2 );
line.write( buf, 0, count * 2 );
idle();
}
playing_ = false;
line.stop();
}