int main( int argc, char* argv[] ) { ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 22050, ALC_INVALID }; time_t shouldend; dev = alcOpenDevice( NULL ); if( dev == NULL ) { fprintf(stderr, "Could not open device\n"); return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, attrlist ); if(context_id == NULL) { fprintf(stderr, "Could not open context: %s\n", alGetString( alcGetError(dev) )); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); talBombOnError(); if(argc == 1) { init("sample.wav"); } else { init(argv[1]); } alSourcePlay( moving_source ); while(SourceIsPlaying( moving_source ) == AL_TRUE) { iterate(); shouldend = time(NULL); if((shouldend - start) > 30) { alSourceStop(moving_source); } } cleanup(); alcDestroyContext( context_id ); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 44100, ALC_INVALID }; time_t shouldend; void *dummy; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, attrlist); if(context_id == NULL) { return 1; } dummy = alcCreateContext( dev, attrlist); alcMakeContextCurrent(dummy); alcDestroyContext(context_id); fixup_function_pointers(); talBombOnError(); if(argc == 1) { init("sample.wav"); } else { init(argv[1]); } alSourcePlay( moving_source ); while(SourceIsPlaying( moving_source ) == AL_TRUE) { iterate(); shouldend = time(NULL); if((shouldend - start) > 10) { alSourceStop(moving_source); } } cleanup(); return 0; }
int main( int argc, char* argv[] ) { int attrlist[] = { ALC_FREQUENCY, 22050, 0 }; int i = 5; #if 0 const ALubyte *devspec = (const ALubyte *) "'( ( sampling-rate 22050 ) ( devices '(null)))"; #else const ALubyte *devspec = NULL; #endif /* Initialize device and context. */ dev = alcOpenDevice( devspec ); if( dev == NULL ) { return 1; } context_id = alcCreateContext( dev, attrlist ); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } iterate(); while(SourceIsPlaying(multis) == AL_TRUE) { micro_sleep(1000000); } cleanup(); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; int i = 5; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, NULL ); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } iterate(); while(SourceIsPlaying(multis) == AL_TRUE) { micro_sleep(1000000); } cleanup(); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 22050, 0 }; time_t shouldend, start; ALint test = AL_FALSE; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, attrlist); if(context_id == NULL) { alcCloseDevice( dev ); exit(1); } alcMakeContextCurrent( context_id ); fixup_function_pointers(); talBombOnError(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } fprintf( stderr, "Loop for 4 seconds\n"); alSourcePlay( moving_source ); shouldend = start = time( NULL ); while( shouldend - start <= 4 ) { shouldend = time(NULL); micro_sleep( 1000000 ); } alSourceStop( moving_source ); test = -1; alGetSourceiv( moving_source, AL_LOOPING, &test ); fprintf(stderr, "is looping? getsi says %s\n", (test == AL_TRUE)?"AL_TRUE":"AL_FALSE"); /* part the second */ fprintf( stderr, "Play once\n"); micro_sleep( 1000000 ); alSourcei( moving_source, AL_LOOPING, AL_FALSE ); alSourcePlay( moving_source ); do { micro_sleep( 1000000 ); } while( SourceIsPlaying( moving_source ) ); alcDestroyContext(context_id); alcCloseDevice( dev ); cleanup(); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 22050 , ALC_INVALID, 0 }; time_t shouldend; float sinsamp; ALshort buf[DATABUFSIZE]; int blah = 0; void *data = NULL; struct stat sbuf; FILE *fh; int speed; int size; int i = 0; const int microsecs = 50000; char *fname; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, attrlist); if(context_id == NULL) { return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if(argc == 1) { fname = ADPCM_FILE; } else { fname = argv[1]; } init(); talBombOnError(); if(stat(fname, &sbuf) == -1) { perror("stat"); return errno; } size = sbuf.st_size; data = malloc(size); if(data == NULL) { perror("malloc"); return errno; } fh = fopen(fname, "rb"); if(fh == NULL) { fprintf(stderr, "Could not open %s\n", fname); exit(1); } fread(data, 1, size, fh); speed = *(int *) data; if(talutLoadRAW_ADPCMData(stereo, (char*)data+4, size-4, speed, AL_FORMAT_MONO16) == AL_FALSE) { fprintf(stderr, "Could not alutLoadADPCMData_LOKI\n"); exit(-2); } free(data); alSourcePlay( moving_source[0] ); while(SourceIsPlaying(moving_source[0]) == AL_TRUE) { sleep(1); } cleanup(); alcDestroyContext( context_id ); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; ALuint cpid; ALuint sid = 0; ALuint cbid; ALuint sbid; ALuint retval; ALvoid *buffer = NULL; FILE *fh; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize openal. */ context_id = alcCreateContext( dev, NULL); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); if ( ! alCaptureInit(AL_FORMAT_MONO16, FREQ, 1024) ) { alcCloseDevice( dev ); printf("Unable to initialize capture\n"); return 1; } buffer = malloc(SAMPLES * 2); /* test 1 */ fprintf(stderr, "test1\n"); fprintf(stderr, "recording..."); alCaptureStart(); retval = 0; while ( retval < (SAMPLES*2) ) { retval += alCaptureGetData(&((char *)buffer)[retval], (SAMPLES*2)-retval, AL_FORMAT_MONO16, FREQ); } alCaptureStop(); fprintf(stderr, "\n"); fh = fopen("outpcm.pcm", "wb"); if(fh != NULL) { fwrite(buffer, retval, 1, fh); fclose(fh); } fprintf(stderr, "Sleeping for 5 seconds\n"); sleep(5); /* test 2 */ fprintf(stderr, "test2\n"); fprintf(stderr, "recording..."); alCaptureStart(); retval = 0; while ( retval < (SAMPLES*2) ) { retval += alCaptureGetData(&((char *)buffer)[retval], (SAMPLES*2)-retval, AL_FORMAT_MONO16, FREQ); } alCaptureStop(); fprintf(stderr, "\n"); fprintf(stderr, "playback..."); alGenSources(1, &sid); alGenBuffers(1, &sbid); alSourcei(sid, AL_BUFFER, sbid); alBufferData(sbid, AL_FORMAT_MONO16, buffer, retval, FREQ); alSourcePlay(sid); while(SourceIsPlaying(sid) == AL_TRUE) { sleep(1); } fprintf(stderr, "\n"); free(buffer); cleanup(); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; FILE *fh; time_t shouldend; int blah = 0; struct stat sbuf; int speed; void *data; int size; char *fname; int i = 0; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, NULL ); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); init( ); if(argc == 1) { fname = MP3_FILE; } else { fname = argv[1]; } if(stat(fname, &sbuf) == -1) { perror(fname); return errno; } size = sbuf.st_size; data = malloc(size); if(data == NULL) { exit(1); } fh = fopen(fname, "rb"); if(fh == NULL) { fprintf(stderr, "Could not open %s\n", fname); free(data); exit(1); } fread(data, 1, size, fh); alutLoadMP3p = (mp3Loader *) alGetProcAddress((ALubyte *) MP3_FUNC); if(alutLoadMP3p == NULL) { free(data); fprintf(stderr, "Could not GetProc %s\n", (ALubyte *) MP3_FUNC); exit(-4); } for(i = 0; i < MAX_SOURCES; i++) { if(alutLoadMP3p(mp3buf[i], data, size) != AL_TRUE) { fprintf(stderr, "alutLoadMP3p failed\n"); exit(-2); } alSourcePlay(mp3source[i]); micro_sleep(80000); } free( data ); while(SourceIsPlaying(mp3source[0]) == AL_TRUE) { sleep(1); } cleanup(); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 44100, ALC_INVALID }; time_t shouldend; time_t start; int i; ALboolean done = AL_FALSE; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ for(i = 0; i < NUMCONTEXTS; i++) { context_ids[i] = alcCreateContext( dev, attrlist ); if(context_ids[i] == NULL) { return 1; } } fixup_function_pointers(); talBombOnError(); if(argc == 1) { init("sample.wav"); } else { init(argv[1]); } start = time(NULL); for(i = 0; i < NUMCONTEXTS; i++) { alcMakeContextCurrent(context_ids[i]); alSourcePlay( moving_sources[i] ); sleep(1); } #if 0 while(done == AL_FALSE) { iterate(); shouldend = time(NULL); if((shouldend - start) > 10) { for(i = 0; i < NUMCONTEXTS; i++) { alcMakeContextCurrent(context_ids[i]); alSourceStop(moving_sources[i]); } } done = AL_TRUE; for(i = 0; i < NUMCONTEXTS; i++) { alcMakeContextCurrent(context_ids[i]); done = done && !SourceIsPlaying( moving_sources[i] ); } } #else for(i = 0; i < 10; i++) { fprintf(stderr, "i = %d\n", i); sleep(1); } #endif cleanup(); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; FILE *fh; struct stat sbuf; void *data; char *fname; int size; int i = 0; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ context_id = alcCreateContext( dev, NULL ); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); init( ); if(argc == 1) { fname = VORBIS_FILE; } else { fname = argv[1]; } if(stat(fname, &sbuf) == -1) { perror(fname); return errno; } size = sbuf.st_size; data = malloc(size); if(data == NULL) { exit(1); } fh = fopen(fname, "rb"); if(fh == NULL) { fprintf(stderr, "Could not open %s\n", fname); free(data); exit(1); } fread(data, size, 1, fh); alutLoadVorbisp = (vorbisLoader *) alGetProcAddress((ALubyte *) VORBIS_FUNC); if(alutLoadVorbisp == NULL) { free(data); fprintf(stderr, "Could not GetProc %s\n", (ALubyte *) VORBIS_FUNC); exit(-4); } if(alutLoadVorbisp(vorbbuf, data, size) != AL_TRUE) { fprintf(stderr, "alutLoadVorbis failed\n"); exit(-2); } free(data); alSourcePlay( vorbsource ); while(SourceIsPlaying(vorbsource) == AL_TRUE) { sleep(1); } cleanup(); alcCloseDevice( dev ); return 0; }