int main(void) { ALCdevice *dev; ALCcontext *context_id; ALuint bid; int i; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } context_id = alcCreateContext( dev, NULL); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); fprintf(stderr, "alGenBuffers(0, &bid): should be a NOP\n"); /* Should be a NOP */ alGenBuffers(0, &bid); fprintf(stderr, " result : %s\n", alGetString(alGetError())); fprintf(stderr, "alGenBuffers(-1, &bid): should error\n"); /* Should be an error */ alGenBuffers(-1, &bid); fprintf(stderr, " result : %s\n", alGetString(alGetError())); fprintf(stderr, "alDeleteBuffers(0, &bid): should be a NOP\n"); /* Should be a NOP */ alDeleteBuffers(0, &bid); fprintf(stderr, " result : %s\n", alGetString(alGetError())); fprintf(stderr, "alDeleteBuffers(-1, &bid): should error\n"); /* Should be an error */ alDeleteBuffers(-1, &bid); fprintf(stderr, " result : %s\n", alGetString(alGetError())); alcDestroyContext(context_id); alcCloseDevice( dev ); return 0; }
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[] ) { ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 22050, ALC_INVALID }; time_t shouldend; int i; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ 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]); } alSourcePlay(moving_source); for(i = 0; i < 100; i++ ) { ALfloat gain = (sin(i) / 2.0) + .5; fprintf(stderr, "%f\n", gain); alListenerf(AL_GAIN_LINEAR_LOKI, gain); micro_sleep(800000); } cleanup(); alcCloseDevice( dev ); return 0; }
int main(void) { ALCdevice *dev; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } context_id = alcCreateContext( dev, NULL); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); setposition(-10.0, 10, 10); setposition(10.0, 10, 10); setposition(0.0, 10, 10); setposition(0.0, 0, 0); setorientation(0.0, 0, -1, 0, 1, 0); setorientation(0.0, 0, 1, 0, 1, 0); setorientation(0.0, 0, 1, 0, 1, 0); setposition(2, 2, 2); setorientation(0.0, 0, 1, 0, 1, 0); setposition(0, 0, 0); setorientation(0.0, 0, 1, 0, 1, 0); setposition(0, -10, 0); setorientation(1, 1, -1, 0, 1, 0); setposition(0, 0, 0); setorientation(0.0, 0, 1, 0, 1, 0); alcDestroyContext(context_id); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; int attrlist[] = { ALC_SYNC, AL_TRUE, 0 }; time_t shouldend; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ 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]); } alSourcef(moving_source, AL_PITCH, 1.19); alSourcePlay( moving_source ); shouldend = time(NULL); while((shouldend - start) < 4) { shouldend = time(NULL); iterate(); } cleanup(); alcCloseDevice( dev ); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; time_t start; time_t shouldend; start = time(NULL); shouldend = time(NULL); 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]); } alSourcePlay(rightSid); while(shouldend - start < 20) { shouldend = time(NULL); iterate(); } cleanup(); alcCloseDevice( dev ); 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 i; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } 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]); } alSourcePlay(reverb_sid); for(i = 0; i < 10; i++) { micro_sleep(1000000); } cleanup(); alcCloseDevice( dev ); 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; }
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; time_t start; time_t now; float sinsamp; int i; int blah = 0; int rsamps = 0; int nsamps = 0; unsigned int waitfor = 0; int attrlist[] = { ALC_FREQUENCY, 44100, ALC_SYNC, AL_TRUE, 0 }; int delay = 0; dev = alcOpenDevice( (const ALubyte *) "'((sampling-rate 44100))" ); 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 == 2 ) { init( argv[1] ); } else { init( RAWPCM ); } alSourcePlay( moving_source ); do { nsamps = fread(buf, 1, DATABUFSIZE, fh) / 2; rsamps = 0; while(rsamps < nsamps) { micro_sleep( delay ); waitfor = talBufferAppendWriteData(stereo, AL_FORMAT_STEREO16, &buf[rsamps], nsamps - rsamps, 44100, AL_FORMAT_STEREO16 ); rsamps += waitfor; if( waitfor == 0 ) { delay += 500; /* add 500 millisecs */ } else { /* decrease wait time */ delay -= 500; } } } while(feof(fh) == 0); fclose(fh); fprintf(stderr, "rsamps = %d\n", nsamps); /* loop for 20 seconds */ start = time(NULL); now = time(NULL); for( ; now <= start + 20; now = time(NULL)) { fprintf(stderr, "now - start = %ld\n", (long int) (now - start)); sleep(1); } alSourceStop(moving_source); cleanup(); 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[]) { ALCcontext *default_context = 0, *custom_context = 0; ALCdevice *dev; int attrlist[] = { ALC_FREQUENCY, 44100, ALC_SYNC, AL_TRUE, 0 }; dev = alcOpenDevice( (const ALubyte *) "'((sampling-rate 44100))" ); if( dev == NULL ) { return 1; } /* Initialize ALUT. */ default_context = alcCreateContext(dev, NULL); if(default_context == NULL) { alcCloseDevice( dev ); return 1; } free(malloc(4)); alcMakeContextCurrent(default_context); { ALint NumFlags = 0; ALint *Flags = 0; int i; printf("default context\n"); alcGetIntegerv(dev, ALC_ATTRIBUTES_SIZE, sizeof NumFlags, &NumFlags ); printf("NumFlags %d\n", NumFlags); if(NumFlags) { Flags = malloc(sizeof NumFlags * sizeof *Flags); assert(Flags); alcGetIntegerv(dev, ALC_ALL_ATTRIBUTES, sizeof NumFlags * sizeof *Flags, Flags ); } for(i = 0; i < NumFlags-1; i += 2) { printf("key 0x%x : value %d\n", Flags[i], Flags[i+1]); } /* must be 0 terminated */ assert(Flags[NumFlags-1] == 0); } custom_context = alcCreateContext(dev, attrlist); if(custom_context == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent(custom_context); { ALint NumFlags = 0; ALint *Flags = 0; int i; printf("custom context\n"); alcGetIntegerv(dev, ALC_ATTRIBUTES_SIZE, sizeof NumFlags, &NumFlags ); printf("NumFlags %d\n", NumFlags); if(NumFlags) { Flags = malloc(sizeof NumFlags * sizeof *Flags); assert(Flags); alcGetIntegerv(dev, ALC_ALL_ATTRIBUTES, sizeof NumFlags * sizeof *Flags, Flags ); } for(i = 0; i < NumFlags-1; i += 2) { printf("key 0x%x : value %d\n", Flags[i], Flags[i+1]); } /* must be 0 terminated */ assert(Flags[NumFlags-1] == 0); } fixup_function_pointers(); alcDestroyContext(default_context); alcDestroyContext(custom_context); return 0; }
int main( int argc, char* argv[] ) { ALCdevice *dev; time_t shouldend; int attrlist[] = { ALC_FREQUENCY, DEFFREQ, ALC_INVALID }; char *musicitr = musicstr; ALfloat pitch = 1.0; int beats; char note; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } cc = alcCreateContext( dev, attrlist); if(cc == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( cc ); fixup_function_pointers(); if(argc == 1) { init(WAVEFILE); } else { init(argv[1]); } while(*musicitr) { alSourceStop( moving_source ); while(*musicitr == ' ') { musicitr++; } switch(*musicitr) { case 'c': pitch = 0.500010; break; case 'd': pitch = 0.561223; break; case 'e': pitch = 0.629967; break; case 'f': pitch = 0.667425; break; case 'g': pitch = 0.749164; break; case 'a': pitch = 0.840898; break; case 'b': pitch = 0.943870; break; case 'C': pitch = 1.0; break; case 'D': pitch = 1.122465; break; case 'E': pitch = 1.259933; break; case 'F': pitch = 1.339704; break; case 'G': pitch = 1.498309; break; case 'A': pitch = 1.681796; break; case 'B': pitch = 1.897754; break; default: fprintf(stderr, "unknown note %d\n", *musicitr); break; } note = *musicitr; musicitr++; /* skip note */ while(*musicitr == ' ') { musicitr++; } beats = (int) *musicitr - '0'; musicitr++; fprintf(stderr, "note %c beats %d\n", note, beats); alSourcef(moving_source, AL_PITCH, pitch); alSourcePlay( moving_source ); micro_sleep(beats / 4.0 * 1000000); } 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; 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; 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; }