void m1sdr_SetSamplesPerTick(UINT32 spf) { if (spf != (nDSoundFps/10)) { m1sdr_Exit(); nDSoundFps = spf * 10; m1sdr_Init(nDSoundSamRate); } }
int main(int argc, char *argv[]) { struct termios tp; struct timeval tv; int fds; fd_set watchset; char ch = 0; int song; MAGENTA(); printf("NDS Music Player, libao edition\n"); printf("Version 4.0\n"); printf("Using vio2sf 0.15\n"); NORMAL(); // check if an argument was given if (argc < 2) { RED(); printf("Error: must specify a filename or names!\n"); NORMAL(); return -1; } GREEN(); printf("Press ESC or Q to stop. p = previous song, n = next song\n\n", argv[1]); NORMAL(); if (setup_playback(argv[1]) < 0) { return -1; } tcgetattr(STDIN_FILENO, &tp); tp.c_lflag &= ~ICANON; tp.c_lflag &= ~(ECHO | ECHOCTL | ECHONL); tcsetattr(STDIN_FILENO, TCSANOW, &tp); ch = 0; song = 1; while ((ch != 27) && (ch != 'q') && (ch != 'Q')) { fds = STDIN_FILENO; FD_ZERO(&watchset); FD_SET(fds, &watchset); tv.tv_sec = 0; tv.tv_usec = 16666/2; // timeout every 1/120th of a second if (select(fds+1, &watchset, NULL, NULL, &tv)) { ch = getchar(); // (blocks until something is pressed) } else { ch = 0; } m1sdr_TimeCheck(); // Added the ability to press the n key to goto the next song if ((ch == 'n') && ((song+1) < argc)) { xsf_term(); m1sdr_Exit(); if (c) { free(c); c = NULL; } free(buffer); song++; if (setup_playback(argv[song]) < 0) { ch = 27; } } if ((ch == 'p') && (song > 1)) { xsf_term(); m1sdr_Exit(); if (c) { free(c); c = NULL; } free(buffer); song--; if (setup_playback(argv[song]) < 0) { ch = 27; } } } xsf_term(); tcgetattr(STDIN_FILENO, &tp); tp.c_lflag |= ICANON; tp.c_lflag |= (ECHO | ECHOCTL | ECHONL); tcsetattr(STDIN_FILENO, TCSANOW, &tp); free(buffer); return 1; }