mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-24 11:20:54 +00:00
3bfcc5c09c
spc_amp from a x.4 fixed point number to a normal float. - Switched SPC playback from the external SNESAPU.DLL to Blargg's LGPL snes_spc library. I've compiled it with the fast DSP rather than the highly accurate one, since I didn't notice a meaningful difference between the two in my limited testing. In short: SPC playback is now built in to ZDoom. You don't need to download anything extra to make it work, and it also works on Linux as well as Windows (though building with Linux is currently untested). - Fixed: Stereo separation was calculated very wrongly when in 2D sound mode. SVN r794 (trunk)
58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
/* Measures performance of SPC emulator. Takes about 4 seconds.
|
|
NOTE: This assumes that the program is getting all processor time; you might need to
|
|
arrange for this or else the performance will be reported lower than it really is.
|
|
|
|
Usage: benchmark [test.spc]
|
|
*/
|
|
|
|
#include "snes_spc/spc.h"
|
|
|
|
#include "demo_util.h" /* error(), load_file() */
|
|
#include <time.h>
|
|
|
|
clock_t start_timing( int seconds );
|
|
|
|
int main( int argc, char** argv )
|
|
{
|
|
/* Load SPC */
|
|
long spc_size;
|
|
void* spc = load_file( (argc > 1) ? argv [1] : "test.spc", &spc_size );
|
|
SNES_SPC* snes_spc = spc_new();
|
|
if ( !snes_spc ) error( "Out of memory" );
|
|
spc_load_spc( snes_spc, spc, spc_size );
|
|
free( spc );
|
|
|
|
{
|
|
/* Repeatedly fill buffer for 4 seconds */
|
|
int const seconds = 4;
|
|
#define BUF_SIZE 4096
|
|
clock_t end = start_timing( seconds );
|
|
int count = 0;
|
|
while ( clock() < end )
|
|
{
|
|
static short buf [BUF_SIZE];
|
|
error( spc_play( snes_spc, BUF_SIZE, buf ) );
|
|
count++;
|
|
}
|
|
|
|
/* Report performance based on how many buffer fills were possible */
|
|
{
|
|
double rate = (double) count * BUF_SIZE / (spc_sample_rate * 2 * seconds);
|
|
printf( "Performance: %.3fx real-time, or %.0f%% CPU for normal rate\n",
|
|
rate, 100.0 / rate );
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* Synchronizes with host clock and returns clock() time that is duration seconds from now */
|
|
clock_t start_timing( int duration )
|
|
{
|
|
clock_t clock_dur = duration * CLOCKS_PER_SEC;
|
|
clock_t time = clock();
|
|
while ( clock() == time ) { }
|
|
if ( clock() - time > clock_dur )
|
|
error( "Insufficient clock() time resolution" );
|
|
return clock() + clock_dur;
|
|
}
|