Thread View: borland.public.cppbuilder.multimedia
5 messages
5 total messages
Started by feklar
Mon, 03 Mar 2003 06:46
BCB3 Mixing sound streams together before sending to sound card
Author: feklar
Date: Mon, 03 Mar 2003 06:46
Date: Mon, 03 Mar 2003 06:46
14 lines
1547 bytes
1547 bytes
How is this done? Say I have 200 different WAV sounds of frogs, crickets, and other swamp or jungle critters, and I want to simulate a swamp by choosing these sounds randomly and mixing them all together into a single output stream and then sending the stream to the sound card. Say at any given random second I might want to be sending 10 different cricket sounds at 10 different volumes and three different frog sounds. What are the considerations, anyone ever done this before? I have some experience with BCB3 but I have never tried anything multimedia before.
Re: BCB3 Mixing sound streams together before sending to sound card
Author: Maynard Philbrook
Date: Mon, 03 Mar 2003 07:06
Date: Mon, 03 Mar 2003 07:06
24 lines
2171 bytes
2171 bytes
all audio grams have to be in PCM format. (Pulse Coded Modulation). this is the bases for uncompressed Wave data. simply ADD destination and source and average the PCM bits. ( DestinationPCMBit+=SourcePCMBit) >> 1; use the WaveOutOpen, WaveReset,WaveOut etc. functions. feklar wrote: > How is this done? > > Say I have 200 different WAV sounds of frogs, crickets, and other > swamp or jungle critters, and I want to simulate a swamp by choosing > these sounds randomly and mixing them all together into a single > output stream and then sending the stream to the sound card. > > Say at any given random second I might want to be sending 10 different > cricket sounds at 10 different volumes and three different frog > sounds. > > What are the considerations, anyone ever done this before? I have > some experience with BCB3 but I have never tried anything multimedia > before.
Re: BCB3 Mixing sound streams together before sending to sound card
Author: Tim Reago
Date: Mon, 03 Mar 2003 14:18
Date: Mon, 03 Mar 2003 14:18
13 lines
1390 bytes
1390 bytes
I think this is the basic idea.
int OutSample = 0;
for (int i=0; i<nSamples; i++)
{
for (int j=0; j<nSounds; j++)
{
// SoundMixLevel is from 0 to 1, one for each sound
OutSample += (__int16)((float)SoundMixLevel[j] * (float)Sample[i][j]);
}
OutSample /= nSounds;
// play out sample
}
Re: BCB3 Mixing sound streams together before sending to sound card
Author: feklar
Date: Mon, 03 Mar 2003 21:18
Date: Mon, 03 Mar 2003 21:18
44 lines
2929 bytes
2929 bytes
Thanks, there are some useful infoZ in there.
I was thinking along the lines of a continuous FIFO ring buffer and
monitoring the buffer pointer's position, so there is continuous
output to the sound card, and so I know where the timebase of the
buffer is so when the buffer can accept new data I can put it in
there.
Will using repeated calls to the Borland sound playing functions to
send a buffer segment indroduce audible clicks? Are you suggesting
sending the data to the soundcard one byte at a time, and is this the
most commonly used method?
The sounds would be in internal and external resources, all in the
same bitrate / frequency / format. Since they will be reasonable in
size I will load them all into RAM on loading / startup, maybe
addressing them as
WAVSOUND sounds[250];
(The WAV data lengths will be different)
using a struct for WAVSOUND
#define struct WAVSOUND {
LONG soundlength;
SOUND * sounddata;
};
SOUND will be a SHORT PTR pointing to the start of the sound data for
each sound, initialized to the address of the sound resource.
At any time at most I might be in the process of sending as many as 50
or 55 different waveforms to the buffer out of the 150. (Say 30
crickets chirping at 30 different sound levels, 10 frogs singing
(sounds like crickets almost) at 10 different volume levels, and three
frogs croaking at 3 different levels and maybe a couple of nighthawks
calling or mabe a roll of thunder in the distance). I need to keep
track of all the data pointers and introduce new streams and end those
that are finished.
What you suggest, it sounds like it will be faster than the soundcard
can handle so I will have to wait for the sound card to be ready,
which is what I want of course.
What is the function to check whether the card is ready to accept new
data?
Re: BCB3 Mixing sound streams together before sending to sound card
Author: Tim Reago
Date: Tue, 04 Mar 2003 15:41
Date: Tue, 04 Mar 2003 15:41
20 lines
2015 bytes
2015 bytes
> send a buffer segment indroduce audible clicks? Don't know. > At any time at most I might be in the process of sending as many as 50 > or 55 different waveforms to the buffer out of the 150. (Say 30 > crickets chirping at 30 different sound levels, 10 frogs singing > (sounds like crickets almost) at 10 different volume levels, and three > frogs croaking at 3 different levels and maybe a couple of nighthawks > calling or mabe a roll of thunder in the distance). It would be nice if they were all sequenced together, like a group of musicians might do. You maybe could do this with midi templates that trigger specific sounds. > I need to keep track of all the data pointers and introduce new > streams and end those that are finished. Still not sure what your question is. Are you asking how to keep varying length wav files sync'd up?
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads