/***************************************************************************** * * * Atari800 Atari 800XL, etc. emulator * * ---------------------------------------------------------------------- * * POKEY Chip Emulator, * * "POKEYBENCH" Test and benchmark program for developers, V1.3 * * by Michael Borisov * * * *****************************************************************************/ /***************************************************************************** * * * License Information and Copyright Notice * * ======================================== * * * * Pokeybench is Copyright(c) 2002 by Michael Borisov * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * * * *****************************************************************************/ #include "pokeysnd.h" #include "mzpokeysnd.h" #include #include #include #include #include #include /* How many seconds of sound to generate per each test trial */ #define MZM_TRIAL_TIME 2 /* How many samples per each buffer run */ #define MZM_BUF_SAMPLES 100 /* How many test trials to run for statistics */ #define TEST_TRIALS 5 /* How many seconds of sound to save in the outfile */ #define MZM_SAVE_TIME 10 /* Wrapper for fgets, removes trailing whitespace */ char* fgetl(char* s, int len, FILE* fs) { char* s2; int i; s2 = fgets(s,len,fs); if(s2 == NULL) return s2; for(i=strlen(s)-1; i>=0; i--) if(isspace(s[i])) s[i] = '\0'; return s2; } int pktest(unsigned char *audf, unsigned char *audc, unsigned char audctl, const char* ofn8, const char* ofn16, unsigned short samplerate) { unsigned char* buf; short* buf16; double rate; double rasum; double rasum2; double varian; double stddev; unsigned long samremain, samproc; int i; time_t start,finish; FILE* ft; buf = malloc(MZM_BUF_SAMPLES); if(buf == NULL) { printf("Out of memory\n"); return 1; } if(i=Pokey_sound_init(1790000,samplerate,1,0,1)) { printf("Error initializing Pokey sound: %d\n",i); return 1; } Update_pokey_sound(_AUDF1,audf[0],0,1); Update_pokey_sound(_AUDC1,audc[0],0,1); Update_pokey_sound(_AUDF2,audf[1],0,1); Update_pokey_sound(_AUDC2,audc[1],0,1); Update_pokey_sound(_AUDF3,audf[2],0,1); Update_pokey_sound(_AUDC3,audc[2],0,1); Update_pokey_sound(_AUDF4,audf[3],0,1); Update_pokey_sound(_AUDC4,audc[3],0,1); Update_pokey_sound(_AUDCTL,audctl,0,1); Pokey_debugreset(0); rasum = 0.0; rasum2 = 0.0; for(i=0; i0) { if(samremain>=MZM_BUF_SAMPLES) { samproc = MZM_BUF_SAMPLES; } else { samproc = samremain; } Pokey_process(buf,(unsigned short)samproc); i = fwrite(buf,1,samproc,ft); if(i0) { if(samremain>=MZM_BUF_SAMPLES) { samproc = MZM_BUF_SAMPLES; } else { samproc = samremain; } Pokey_process(buf16,(unsigned short)samproc); i = fwrite(buf16,2,samproc,ft); if(i