Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Quad, TipmyPip, degenerate_762, AndrewAMD, Nymphodora), 997 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
OpenAL documentation? #466242
06/02/17 16:22
06/02/17 16:22
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I'm currently trying to port some code to OpenAL but I'm having a few problems.

I want to write generated data into a sound buffer. It works when using snd_buffer(...); but I don't know how to use the OpenAL-equivalent asnd_buffer(...);.

snd_buffer(); gives access to the sound data aswell as the DSBUFFERDESC (which is used in DirectSound8) but I don't know how to set the same parameters using asnd_buffer();.
In the manual I can't find anything about OpenAL and the header file (ackoal.h) doesn't help either (which is the reason why I'm asking here).

So how exactly does it work or is there some kind of documentation I can look up?


POTATO-MAN saves the day! - Random
Re: OpenAL documentation? [Re: Kartoffel] #466368
06/12/17 08:03
06/12/17 08:03
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Here's the source code of the asnd_buffer function:

Code:
#include "OpenAl.h"

int OpenAl::asnd_buffer(OpenAl::ASOUND *snd, void **pDesc, void ***ppSample) {
	//check whether the snd argument is valid
	if(OpenAl::helpFunctions::find(OpenAl::Settings::asoundStorage, snd) == false) {
		return -1;
	}

	//if snd is a streaming sound -> return
	if(snd->stream != 0) {
		*pDesc = 0;
		*ppSample = 0;
		return -2;
	}

	//assign the pointer to the pointer that points to the wave data
	*ppSample = &(snd->waveData);


	//search the dsbufferdescStorage for a matching pair, using the snd pointer
	std::map<OpenAl::ASOUND *, DSBUFFERDESC *>::iterator iteratorPosition =
		OpenAl::Settings::dsbufferdescStorage->find(snd);

	if(iteratorPosition != OpenAl::Settings::dsbufferdescStorage->end()) {
		//if a pair was found, store the pointer to the given pDesc variable
		*pDesc = (*iteratorPosition).second;
	} else {
		//else create such a pair, store it and save the pointer in the pDesc variable
		DSBUFFERDESC *tempBuffer = new DSBUFFERDESC;
		tempBuffer->lpwfxFormat = new WAVEFORMATEX;
		tempBuffer->lpwfxFormat->cbSize = 0;
		tempBuffer->lpwfxFormat->nAvgBytesPerSec = 0;
		tempBuffer->lpwfxFormat->nBlockAlign = 0;
		tempBuffer->lpwfxFormat->nChannels = 0;	//all sounds are mono, therefore this variable is useless
		tempBuffer->lpwfxFormat->nSamplesPerSec = snd->sampleRate;
		tempBuffer->lpwfxFormat->wBitsPerSample = 8 * OpenAl::getSizeOfOneSample(snd->format);

		tempBuffer->lpwfxFormat->wFormatTag = 0;

		tempBuffer->dwBufferBytes = snd->length;
		tempBuffer->dwFlags = 0;
		tempBuffer->dwReserved = 0;
		tempBuffer->dwSize = 0;
		tempBuffer->guid3DAlgorithm.Data1 = 0;
		tempBuffer->guid3DAlgorithm.Data2 = 0;
		tempBuffer->guid3DAlgorithm.Data3 = 0;
		tempBuffer->guid3DAlgorithm.Data4[0] = 'u';
		tempBuffer->guid3DAlgorithm.Data4[1] = 'n';
		tempBuffer->guid3DAlgorithm.Data4[2] = 'u';
		tempBuffer->guid3DAlgorithm.Data4[3] = 's';
		tempBuffer->guid3DAlgorithm.Data4[4] = 'e';
		tempBuffer->guid3DAlgorithm.Data4[5] = 'd';
		tempBuffer->guid3DAlgorithm.Data4[6] = ' ';
		tempBuffer->guid3DAlgorithm.Data4[7] = '!';

		OpenAl::Settings::dsbufferdescStorage->insert( std::pair<OpenAl::ASOUND *, DSBUFFERDESC *>(snd, tempBuffer) );

		*pDesc = tempBuffer;
	}

	return 0;
}


Re: OpenAL documentation? [Re: jcl] #466388
06/12/17 15:10
06/12/17 15:10
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Oh, so the engine's asound implementation actually uses the same buffer descriptor that direct sound uses (DSBUFFERDESC).

This should be all I need, thank's a lot!


POTATO-MAN saves the day! - Random

Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1