Advertisement

whats wrong with this code? (ogg vorbis and openAL)

Started by December 28, 2002 08:40 AM
1 comment, last by billybob 22 years ago

    vorbis_info * vi = ov_info(&vf, -1);

	DWORD sizeofFile = (DWORD)ov_pcm_total(&vf, 0);

	DWORD position;
	char * tempBuffer = new char[sizeofFile];
	int p = 1;

	while(position < sizeofFile)
    {
        p = ov_read(&vf, tempBuffer + position, sizeofFile - position, 0, 2, 1, 0);
        position += p;
    }

	alBufferData(ALbuf, AL_FORMAT_STEREO16, (ALvoid*)tempBuffer, sizeofFile, vi->rate);
	alSourcei (ALsrc, AL_BUFFER,   g_vALbuffer );

	delete [] tempBuffer;
 
i got a ogg vorbis player class off flipcode''s cotd archive, and i''m trying to make it work with openAL instead of directx. i''ve tested it by replacing the ogg reading part with a load wav, and it played, so thats not the problem. its somwhere along the lines getting tempBuffer into the AL buffer. i''m almost positive its because when i was using directsound, it had a lot of variables like channels, and some others. but with openal, i either can''t figure out how to set them or it doesn''t have them. i also assume ogg''s format is stereo 16 bit? well, the above code doesn''t work and i can''t figure out why, i need your help
DOH!!!!!!!!!!!!!!!!!!!!!

i''m a flippin dumbass, i didn''t init position to 0. i noticed it while checking the post for spelling errors
Advertisement
a new prob has cropped up though, i need to find out how far into a buffer a sound is playing. how do i do that with openAL?

This topic is closed to new replies.

Advertisement