예제 #1
0
void audiocb(void *userdata, Uint8 *buf, int len) {
	int i;

	for(i = 0; i < len; i++) {
		buf[i] = interrupthandler();
	}
}
예제 #2
0
void audiocb(void *userdata, Uint8 *buf, int len) {
    (void) userdata;        /* Unused parameter */
	int i;

	for(i = 0; i < len; i++) {
		buf[i] = interrupthandler();
	}
}
int j_process(jack_nframes_t nframes, void *arg){
	// grab our output buffer
	sample_t *out = (sample_t *) jack_port_get_buffer(output_port, nframes);

	// For each required sample
	for(jack_nframes_t i=0; i<nframes; i++){
		out[i] = (sample_t) interrupthandler();
	}
	return 0;
}
예제 #4
0
int main(int argc, char **argv) {
	initchip();
	initgui();

	if(!strcmp("--audio", argv[1])) {
		loadfile(argv[2]);

        char *pcmname = (argc > 2) ? argv[3] : "audio" ;
        FILE *f = fopen(pcmname, "w");

        startplaysong(0);

        while(playsong) {
            u8 res = interrupthandler();
            fwrite(&res, 1, 1, f);
        }
        fclose(f);
	} else {
		if(argc != 2) {
			err(1, "usage: %s <filename>\n", argv[0]);
		}

	    SDL_AudioSpec requested, obtained;
    	SDL_Init(SDL_INIT_AUDIO);
	    atexit(SDL_Quit);

		requested.freq = 16000;
		requested.format = AUDIO_U8;
		requested.samples = 256;
		requested.callback = audiocb;
		requested.channels = 1;
		if(SDL_OpenAudio(&requested, &obtained) == -1) {
			err(1, "SDL_OpenAudio");
		}
		
		fprintf(stderr, "freq %d\n", obtained.freq);
		fprintf(stderr, "samples %d\n", obtained.samples);
		
		loadfile(argv[1]);
		SDL_PauseAudio(0);
		guiloop();
	}
	
	return 0;
}