k_sivarasah at October 15th, 2010 04:35 — #1
i'd like to play 2 audio files at the same time, but want them to have different volumes. i found a way to play them with wavOutOpen, Prepare Header...
but if i try to adjust the volume, the master wave-volume of both files are changed. that means both audio files have the same volume.
is there a way to set volume for those waves individually?
thx for any help
rouncer at October 15th, 2010 08:46 — #2
sure, you should just use a software implementation for audio, cause its not very computationally intense.
if you get access to the primary sound buffer manually, you can mix the sounds yourself and get anything you want out of them, even changing frequency or maybe adding a few small effects.
sol_hsa at October 15th, 2010 09:09 — #3
Alternatively, grab some audio library like bass or fmod and let it do the mixing for you.
k_sivarasah at October 19th, 2010 07:53 — #4
thanks a lot for ur replies. my internet was not working, so i couldnt check for replies.
do u know any tutorial-sites for audio library like bass or fmod, or software implementation of audio u mentioned? otherwise I'll google, try it out and post again if i have questions
rouncer at October 19th, 2010 10:27 — #5
If you want to go the software method (its as easy as adding samples together then digitally limiting if you really need it, but + by itself works.) direct sound is fine, thats how I did all my software DSP work! Just get any old direct x sdk and itll work, direct sound hasnt been updated since 10 years ago or something chronic like that. Dont worry it comes with full documentation.
k_sivarasah at October 21st, 2010 09:58 — #6
i read a lot and tried to write a code to simply playback an audio file with direct sound. but i just dont know how to load a file into the buffer. here is my code:
using namespace std;
LPDIRECTSOUND lpdSound = 0;
LPDIRECTSOUNDBUFFER lpdsBuffer = NULL;
FILE* filePtr; // file pointer for wave-file
int _tmain(int argc, _TCHAR* argv)
// waveformat settings
memset(&wfx, 0, sizeof(WAVEFORMATEX));
wfx.nSamplesPerSec = 44100; /* sample rate */
wfx.wBitsPerSample = 16; /* sample size */
wfx.nChannels = 2; /* channels */
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nBlockAlign = 4;
// DSBUFFERDESC structure settings
memset(&dsBufferDesc, 0, sizeof(DSBUFFERDESC));
dsBufferDesc.dwSize = sizeof(DSBUFFERDESC);
dsBufferDesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;
dsBufferDesc.dwBufferBytes = 0;
dsBufferDesc.lpwfxFormat = &wfx;
DirectSoundCreate(NULL, &lpdSound, NULL);
lpdSound->CreateSoundBuffer(&dsBufferDesc, &lpdsBuffer, 0);
thanks for any help.
k_sivarasah at October 21st, 2010 10:18 — #7
is LPDIRECTSOUNDBUFFER lpdsBuffer = NULL; just my primary buffer and i also need a secondarybuffer (LPDIRECTSOUNDBUFFER8) for playback?