Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / How do you properly use GetSoundData() and SetSoundData() ?

Author
Message
D Ogre
15
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 27th Apr 2011 01:56
DBProSoundDebug.dll contains the following:

?GetSoundData@@YAXHPAK00PAPAD0_NPAUtWAVEFORMATEX@@@Z

DARKSDK void GetSoundData( int iID, DWORD* dwBitsPerSecond, DWORD* Frequency, DWORD* Duration, LPSTR* pData, DWORD* dwDataSize, bool bLockData, WAVEFORMATEX* wfx)

Correct me if I wrong. Here is what I think is how these function work:

After passing the image ID in and setting bLockData to TRUE, the following parameters are filled:

DWORD* dwBitsPerSecond = nAvgBytesPerSec * 8
DWORD* Frequency = nAvgBytesPerSec /(wBitsPerSample / 8)
DWORD* Duration = dwSourceSize / nAvgBytesPerSec
LPSTR* pData = Pointer to a copy of sound data in memory
DWORD* dwDataSize = dwSourceSize
WAVEFORMATEX* wfx = WAVEFORMATEX structure of the Sound

It appears you need to call this function again to free the *pData memory with bLockData = FALSE.

?SetSoundData@@YAXHKKKPADKUtWAVEFORMATEX@@@Z

DARKSDK void SetSoundData( int iID, DWORD dwBitsPerSecond, DWORD Frequency, DWORD Duration, LPSTR pData, DWORD dwDataSize, WAVEFORMATEX wfx )

This just does the opposite by deleting the existing sound in that ID slot and saving the new wav in memory passed to the function as a temp file, then loading the temp file back into the DIRECTSOUND buffer.

Do I have this right?
IanM
Retired Moderator
17
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Apr 2011 15:26
That look about right, except that wfx needs to be allocated by you when you call the function.

D Ogre
15
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 27th Apr 2011 15:40
I confused on this part...

If I have two of my own plugin functions that call getsounddata{}, one with bool bLockData=TRUE and another with bLockData=FALSE. Do I need hold and pass *PData to the second function so it knows to delete that memory? or is it defined globally or something?
IanM
Retired Moderator
17
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Apr 2011 21:01
Once the pData pointer is passed back to you, you own the memory pointed to until you release it back. So yes, you need to keep track of it, and when done, pass it back with pLockData set to false.

D Ogre
15
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 27th Apr 2011 22:43
I thought so. I have it kept in my specialized global plugin struct.

One last question... Do you know of any way to get the audio after it has been mixed?
IanM
Retired Moderator
17
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Apr 2011 15:21
No, and with the possibility that DirectSound might or might not be using hardware acceleration on any machine your plug-in is executed on, I'm not sure it would be possible anyway - don't let that stop you looking for a way though as I could certainly be wrong about that.

D Ogre
15
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 28th Apr 2011 17:16
So far, my research has told me the same. I thought it couldn't hurt to ask anyways. However, there must be some kind of way to do it. There seems to be a number of software programs that can capture the mixed audio output. The question is exactly what resources are they pulling from and how? I'll keep digging and see what I stumble on.

Thanks again for all your help!
D Ogre
15
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 30th Apr 2011 20:52
Although it's not a perfect solution, the WinMM library can capture the mixed audio output, but only at 16 bit integer sampling with 2 channel audio up to 48 khz. So, no 32 bit or better with floating point unfortunately. It's the old WaveIn/Out technology migrated from Windows 95/98. It's not as sophisticated as let's say WASAPI in Vista and 7, but the library still functionally exists with XP and up. With some set up, buffer allocation, and maybe using Windows callbacks, I don't think it will be too much trouble to make a plugin with it.

If someone has a better solution that's free, let me know.
chunks chunks
12
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 1st Aug 2011 15:48
Hi , i have used them two functions before with direct sound .
for info you could look on the music board at the posts with the midi music program i posted something on the usage of them , also attached is a bit of code i used to make a dll to record .

chunks

nvidia geforce 9500gt + amd athlon 64
windows vista ultimate.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2019-10-16 22:35:00
Your offset time is: 2019-10-16 22:35:00