# HG changeset patch # User Matti Hamalainen # Date 1274656719 -10800 # Node ID 561fa061caf66fb1c16f899bf33fe7f41408f4ff # Parent d803c129c1e294502e2d4c81b43cd9b9f38b582a Fix the audio rendering callback function, etc. diff -r d803c129c1e2 -r 561fa061caf6 pwpzax/zaxplay.c --- a/pwpzax/zaxplay.c Mon May 24 01:23:01 2010 +0300 +++ b/pwpzax/zaxplay.c Mon May 24 02:18:39 2010 +0300 @@ -165,7 +165,7 @@ void player_set_tempo(int tempo) { player.tempo = tempo; - player.frag = (player.freq) / 30; + player.frag = (player.freq * tempo) / 73; } void player_newnote() @@ -200,31 +200,20 @@ } } -void player_tick(void) -{ - if (player.tick == 0) - player_newnote(); - - player.tick++; - if (player.tick >= player.tempo) - player.tick=0; -} - void player_render_cb(void *udata, Uint8 * buf, int len) { (void) udata; while (len > 0) { - if (player.curr > len) { + if (player.curr >= len) { player.curr -= len; gb_genwave((char *)buf, len); len = 0; - player_tick(); } else { gb_genwave((char *)buf, player.curr); buf += player.curr; len -= player.curr; player.curr = player.frag; - player_tick(); + player_newnote(); } } } @@ -251,8 +240,8 @@ if (argc != 2) { - fprintf(stderr,"usage: %s \n", - argv[0], ntunes - 1); + fprintf(stderr, "Usage: %s \n", + argv[0], ntunes - 1); return 0; } @@ -266,7 +255,7 @@ "Channels: %d\n", i, tune->title, tune->tempo, tune->numchans); - if (SDL_Init(SDL_INIT_EVENTTHREAD | SDL_INIT_AUDIO) != 0) + if (SDL_Init(SDL_INIT_AUDIO) != 0) { fprintf(stderr, "* SDL could not be initialized.\n"); return 1; @@ -305,6 +294,7 @@ break; } } - + + sdlaudio_close(); return 0; }