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
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
Please log in or register to post a reply.
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.
Alternatively, grab some audio library like bass or fmod and let it do
the mixing for you.
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 :)
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.
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.
is LPDIRECTSOUNDBUFFER lpdsBuffer = NULL; just my primary buffer and i
also need a secondarybuffer (LPDIRECTSOUNDBUFFER8) for playback?