コード例 #1
0
ファイル: testalut.c プロジェクト: Aye1/RVProject
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;
}
コード例 #2
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;
}
コード例 #3
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;
}
コード例 #4
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;
}
コード例 #5
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;
}