void m1sdr_FlushAudio(void) { memset(samples, 0, nDSoundSegLen * 4); m1sdr_TimeCheck(); m1sdr_TimeCheck(); m1sdr_TimeCheck(); m1sdr_TimeCheck(); m1sdr_TimeCheck(); }
void m1sdr_FlushAudio(void) { int oldpause = oss_pause; oss_pause = 1; memset(samples, 0, nDSoundSegLen * 4); m1sdr_TimeCheck(); m1sdr_TimeCheck(); m1sdr_TimeCheck(); m1sdr_TimeCheck(); m1sdr_TimeCheck(); oss_pause = oldpause; }
int main(int argv, char *argc[]) { FILE *file; uint8 *buffer; uint32 size, filesig; printf("AOSDK test program v1.0 by R. Belmont [AOSDK release 1.4.8]\nCopyright (c) 2007-2009 R. Belmont and Richard Bannister - please read license.txt for license details\n\n"); // check if an argument was given if (argv < 2) { printf("Error: must specify a filename!\n"); return -1; } file = fopen(argc[1], "rb"); if (!file) { printf("ERROR: could not open file %s\n", argc[1]); return -1; } // get the length of the file by seeking to the end then reading the current position fseek(file, 0, SEEK_END); size = ftell(file); // reset the pointer fseek(file, 0, SEEK_SET); buffer = malloc(size); if (!buffer) { fclose(file); printf("ERROR: could not allocate %d bytes of memory\n", size); return -1; } // read the file fread(buffer, size, 1, file); fclose(file); // now try to identify the file type = 0; filesig = buffer[0]<<24 | buffer[1]<<16 | buffer[2]<<8 | buffer[3]; while (types[type].sig != 0xffffffff) { if (filesig == types[type].sig) { break; } else { type++; } } // now did we identify it above or just fall through? if (types[type].sig != 0xffffffff) { printf("File identified as %s\n", types[type].name); } else { printf("ERROR: File is unknown, signature bytes are %02x %02x %02x %02x\n", buffer[0], buffer[1], buffer[2], buffer[3]); free(buffer); return -1; } void *handle = (*types[type].start)(argc[1], buffer, size); if (!handle) { free(buffer); printf("ERROR: Engine rejected file!\n"); return -1; } #if 0 m1sdr_Init(44100); m1sdr_SetCallback(do_frame); m1sdr_PlayStart(); printf("\n\nPlaying. Press CTRL-C to stop.\n"); while (1) { m1sdr_TimeCheck(); } #endif free(buffer); return 1; }
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; }