Re: about wave
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/23/05
- Next message: Joseph M. Newcomer: "Re: USB Programming with C++/MFC"
- Previous message: Joseph M. Newcomer: "Re: Unique computer identifier?"
- In reply to: Scott McPhillips [VC++ MVP]: "Re: about wave"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Feb 2005 01:50:48 -0500
When I was doing this we had a problem if the two 16-bit values added up to > 32767 or <
-32768. We converted both integers to floats, did the add, then scaled it by a "volume
level" the user set with a slider. If it was outside the bounds, it was set to the max
value rather than letting it overflow. In another app, we had the leisure to read the two
files, build an internal "wave" entirely in floating point, keep track of the max, and
select the scaling automatically.
I believe there is an audio mixer capability in XP which can combine two or more streams
itself, but I've not done anything in the DirectSound area so I'm not sure how to use it.
joe
On Tue, 22 Feb 2005 20:30:09 -0500, "Scott McPhillips [VC++ MVP]" <scottmcp@mvps.org>
wrote:
>"john_wong" <john_wong@192.168.1.2> wrote in message
>news:%230PmWRKGFHA.1528@TK2MSFTNGP09.phx.gbl...
>>I want to combine two or more wave files into a .wave file,and play it.
>> The source .wav file is dynamic,so I need write code to combine them by
>> myself.
>> I read the document about .wav file format,and find it is complex.
>> Who can give me a easy way to do it?
>> or give me some code as reference.
>> Thanks.
>
>Sample code for reading and writing a WAV file and manipulating the audio
>samples is in MSDN. Search for "Reverse" sample.
>
>If you want to mix two sounds together, and if the data format is 16-bit PCM
>samples, simply add the sample values together.
>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: Joseph M. Newcomer: "Re: USB Programming with C++/MFC"
- Previous message: Joseph M. Newcomer: "Re: Unique computer identifier?"
- In reply to: Scott McPhillips [VC++ MVP]: "Re: about wave"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|