DSPRelated.com
Forums

Waveform (de)mixing

Started by dave March 19, 2005
I have a really simple problem to solve, name the appropriate algorithm.

1)

I want to mix 24 raw audio waveforms. The present simplistic summing 
algorithm doesn't manage the amplitudes correctly.

What, if any, are the modern algorithms for digitally mixing waveforms.

2)

What algorithms would I use to allow one waveform to oscillate another 
and to extract one waveform from another. Ie: When an audio signal 
oscillates a radio waveform for FM broadcast and when an FM receiver 
removes the FM content from a waveform to reveal the audio again.

Any pointers, websites, books that can help?
dave wrote:
> I have a really simple problem to solve, name the appropriate algorithm. > > 1) > > I want to mix 24 raw audio waveforms. The present simplistic summing > algorithm doesn't manage the amplitudes correctly.
Why not? What's the problem?
> What, if any, are the modern algorithms for digitally mixing waveforms.
Addition, possibly with scaling, rounding, and dithering.
> 2) > > What algorithms would I use to allow one waveform to oscillate another > and to extract one waveform from another. Ie: When an audio signal > oscillates a radio waveform for FM broadcast and when an FM receiver > removes the FM content from a waveform to reveal the audio again.
It appears that when you write "oscillate" you mean "modulate". By extension, I can guess that you mean demodulate (detect) when you write "extract".
> Any pointers, websites, books that can help?
Clarify your statement of the problem. A sensible recommendation is hard to when there are too many possibilities. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
dave wrote:
> > I have a really simple problem to solve, name the appropriate algorithm. > > 1) > > I want to mix 24 raw audio waveforms. The present simplistic summing > algorithm doesn't manage the amplitudes correctly. > > What, if any, are the modern algorithms for digitally mixing waveforms.
For absolute safety when mixing N channels, multiply each channel by 1/N. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow away your whole leg!" -- Bjarne Stroustrup
Erik de Castro Lopo wrote:
> dave wrote: > >>I have a really simple problem to solve, name the appropriate algorithm. >> >>1) >> >>I want to mix 24 raw audio waveforms. The present simplistic summing >>algorithm doesn't manage the amplitudes correctly. >> >>What, if any, are the modern algorithms for digitally mixing waveforms. > > > For absolute safety when mixing N channels, multiply each channel by > 1/N. > > Erik
Fixed it. Thanks for the reply.
Jerry Avins wrote:
> dave wrote: > >> I have a really simple problem to solve, name the appropriate algorithm. >> >> 1) >> >> I want to mix 24 raw audio waveforms. The present simplistic summing >> algorithm doesn't manage the amplitudes correctly. > > > Why not? What's the problem? >
Don't worry, fixed it. Thanks for the reply.
>> What, if any, are the modern algorithms for digitally mixing waveforms. > > > Addition, possibly with scaling, rounding, and dithering. > >> 2) >> >> What algorithms would I use to allow one waveform to oscillate another >> and to extract one waveform from another. Ie: When an audio signal >> oscillates a radio waveform for FM broadcast and when an FM receiver >> removes the FM content from a waveform to reveal the audio again. > > > It appears that when you write "oscillate" you mean "modulate". By > extension, I can guess that you mean demodulate (detect) when you write > "extract". > >> Any pointers, websites, books that can help? > > > Clarify your statement of the problem. A sensible recommendation is hard > to when there are too many possibilities. > > Jerry
Can any members of this newsgroup recommend websites, books, e-documents etc that would detail numerical method(s) to assist in performing the following: ---------------- 2a) create two functions e "encode" and d "decode" each with three waveform parameters w1 "carrier", w2 "audio" and w3 "signal"; such that: w3 = func e( w1, w2) w2 = func d( w3, w1) assuming also that w1 = func d( w3, w2) eg. if w1 = 100Khz sine and w2 = 10Khz sine then func e( 100000, 10000) would result in w3 = 110000 sine and func d( 110000, 100000) would result in w2 = 10000 sine. Note: for func e that w3 must equal w1 modulated by w2. Further that for func d, w2 must equal w3 demodulated by w2. ----------------
dave wrote:
> Jerry Avins wrote: > >> dave wrote: >> >>> I have a really simple problem to solve, name the appropriate algorithm. >>> >>> 1) >>> >>> I want to mix 24 raw audio waveforms. The present simplistic summing >>> algorithm doesn't manage the amplitudes correctly. >> >> >> >> Why not? What's the problem? >> > Don't worry, fixed it. Thanks for the reply. > >>> What, if any, are the modern algorithms for digitally mixing waveforms. >> >> >> >> Addition, possibly with scaling, rounding, and dithering. >> >>> 2) >>> >>> What algorithms would I use to allow one waveform to oscillate >>> another and to extract one waveform from another. Ie: When an audio >>> signal oscillates a radio waveform for FM broadcast and when an FM >>> receiver removes the FM content from a waveform to reveal the audio >>> again. >> >> >> >> It appears that when you write "oscillate" you mean "modulate". By >> extension, I can guess that you mean demodulate (detect) when you >> write "extract". >> >>> Any pointers, websites, books that can help? >> >> >> >> Clarify your statement of the problem. A sensible recommendation is >> hard to when there are too many possibilities. >> >> Jerry > > > Can any members of this newsgroup recommend websites, books, e-documents > etc that would detail numerical method(s) to assist in performing the > following: > > ---------------- > > 2a) create two functions e "encode" and d "decode" each with three > waveform parameters w1 "carrier", w2 "audio" and w3 "signal"; such that: > > w3 = func e( w1, w2) > w2 = func d( w3, w1) > assuming also that w1 = func d( w3, w2) > > eg. if w1 = 100Khz sine and w2 = 10Khz sine then > > func e( 100000, 10000) would result in w3 = 110000 sine > > and > > func d( 110000, 100000) would result in w2 = 10000 sine. > > Note: for func e that w3 must equal w1 modulated by w2. Further that for > func d, w2 must equal w3 demodulated by w2.
"func e( 100000, 10000) would result in w3 = 110000 sine" implies single-sideband suppressed-carrier modulation, abbreviated SSSC. There's a good explanation on a beginning level in the ARRL Handbook*. There's a brief description at http://webclass.lakeland.cc.il.us/mbeavers/SSB.html Ordinary amplitude modulation (AM) is much simpler to do and the result is easier to demodulate. With your example, it would produce frequencies at 90, 100, and 110 KHz. Jerry _________________________________ * American Radio Relay League. http://www.arrl.org/catalog/?item=9280 -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
On Sun, 20 Mar 2005 14:43:41 +0000, dave <dave@dave.dave> wrote:

>Jerry Avins wrote: >> dave wrote: >> >>> I have a really simple problem to solve, name the appropriate algorithm. >>> >>> 1) >>> >>> I want to mix 24 raw audio waveforms. The present simplistic summing >>> algorithm doesn't manage the amplitudes correctly. >> >> >> Why not? What's the problem? >> >Don't worry, fixed it. Thanks for the reply.
Care to tell us what the problem was? (this is one of the more frustrating things you can post to Usenet, you ask a question without giving enough info, you get responses, then you just say "Never mind, I fixed it.") Scaling? Are you doing this in fixed point or floating point? Try reading the 'more bits please', 'dither' and perhaps a few others of the articles at http://www.digido.com These are aimed at getting the best possible sound for high-end recording, but they are also applicable for getting near-theoretical (or better-than-theoretical, depending on what theory you apply) performance from smaller, 4-bit, 8-bit or 16-bit systems.
>>> What, if any, are the modern algorithms for digitally mixing waveforms. >> >> >> Addition, possibly with scaling, rounding, and dithering. >> >>> 2) >>> >>> What algorithms would I use to allow one waveform to oscillate another >>> and to extract one waveform from another. Ie: When an audio signal >>> oscillates a radio waveform for FM broadcast and when an FM receiver >>> removes the FM content from a waveform to reveal the audio again. >> >> >> It appears that when you write "oscillate" you mean "modulate". By >> extension, I can guess that you mean demodulate (detect) when you write >> "extract".
FM modulation is (relatively) easy, presuming you're generating the carrier using a phase accumulator with a sine function or (more likely) lookup table. For this purpose I'm presuming both the carrier and modulation signals are sine waves generated in software. The function for each output sample is: modulating_signal = sin (modulating_phase) modulating_phase += modulating_frequency sample = sin (carrier_phase + (modulating_signal * modulation_depth)) carrier_phase += carrier_frequency I did this many years ago to generate FM-type musical sounds (as from the Yamaha DX-7 synthesizer, very popular at the time) on a Macintosh. FM demodulation in software is a bit more complex, I've never done it or given it any thought, but a near-worst-case that comes to mind is simulating a ratio detector. There's also PLL which may be more appropriate.
>> >>> Any pointers, websites, books that can help? >> >> >> Clarify your statement of the problem. A sensible recommendation is hard >> to when there are too many possibilities. >> >> Jerry > >Can any members of this newsgroup recommend websites, books, e-documents >etc that would detail numerical method(s) to assist in performing the >following: > >---------------- > >2a) create two functions e "encode" and d "decode" each with three >waveform parameters w1 "carrier", w2 "audio" and w3 "signal"; such that: > >w3 = func e( w1, w2) >w2 = func d( w3, w1) >assuming also that w1 = func d( w3, w2) > >eg. if w1 = 100Khz sine and w2 = 10Khz sine then > >func e( 100000, 10000) would result in w3 = 110000 sine > >and > >func d( 110000, 100000) would result in w2 = 10000 sine. > >Note: for func e that w3 must equal w1 modulated by w2. Further that for >func d, w2 must equal w3 demodulated by w2. > >----------------
----- http://mindspring.com/~benbradley
Thank you. Reading that website now. No algorithms, but helpful none the 
less.

Jerry Avins wrote:
> dave wrote: > >> Jerry Avins wrote: >> >>> dave wrote: >>> >>>> I have a really simple problem to solve, name the appropriate >>>> algorithm. >>>> >>>> 1) >>>> >>>> I want to mix 24 raw audio waveforms. The present simplistic summing >>>> algorithm doesn't manage the amplitudes correctly. >>> >>> >>> >>> >>> Why not? What's the problem? >>> >> Don't worry, fixed it. Thanks for the reply. >> >>>> What, if any, are the modern algorithms for digitally mixing waveforms. >>> >>> >>> >>> >>> Addition, possibly with scaling, rounding, and dithering. >>> >>>> 2) >>>> >>>> What algorithms would I use to allow one waveform to oscillate >>>> another and to extract one waveform from another. Ie: When an audio >>>> signal oscillates a radio waveform for FM broadcast and when an FM >>>> receiver removes the FM content from a waveform to reveal the audio >>>> again. >>> >>> >>> >>> >>> It appears that when you write "oscillate" you mean "modulate". By >>> extension, I can guess that you mean demodulate (detect) when you >>> write "extract". >>> >>>> Any pointers, websites, books that can help? >>> >>> >>> >>> >>> Clarify your statement of the problem. A sensible recommendation is >>> hard to when there are too many possibilities. >>> >>> Jerry >> >> >> >> Can any members of this newsgroup recommend websites, books, >> e-documents etc that would detail numerical method(s) to assist in >> performing the following: >> >> ---------------- >> >> 2a) create two functions e "encode" and d "decode" each with three >> waveform parameters w1 "carrier", w2 "audio" and w3 "signal"; such that: >> >> w3 = func e( w1, w2) >> w2 = func d( w3, w1) >> assuming also that w1 = func d( w3, w2) >> >> eg. if w1 = 100Khz sine and w2 = 10Khz sine then >> >> func e( 100000, 10000) would result in w3 = 110000 sine >> >> and >> >> func d( 110000, 100000) would result in w2 = 10000 sine. >> >> Note: for func e that w3 must equal w1 modulated by w2. Further that >> for func d, w2 must equal w3 demodulated by w2. > > > "func e( 100000, 10000) would result in w3 = 110000 sine" implies > single-sideband suppressed-carrier modulation, abbreviated SSSC. There's > a good explanation on a beginning level in the ARRL Handbook*. There's a > brief description at http://webclass.lakeland.cc.il.us/mbeavers/SSB.html > Ordinary amplitude modulation (AM) is much simpler to do and the result > is easier to demodulate. With your example, it would produce frequencies > at 90, 100, and 110 KHz. > > Jerry > _________________________________ > * American Radio Relay League. http://www.arrl.org/catalog/?item=9280
Thanks.

Ben Bradley wrote:
> On Sun, 20 Mar 2005 14:43:41 +0000, dave <dave@dave.dave> wrote: > > >>Jerry Avins wrote: >> >>>dave wrote: >>> >>> >>>>I have a really simple problem to solve, name the appropriate algorithm. >>>> >>>>1) >>>> >>>>I want to mix 24 raw audio waveforms. The present simplistic summing >>>>algorithm doesn't manage the amplitudes correctly. >>> >>> >>>Why not? What's the problem? >>> >> >>Don't worry, fixed it. Thanks for the reply. > > > Care to tell us what the problem was? (this is one of the more > frustrating things you can post to Usenet, you ask a question without > giving enough info, you get responses, then you just say "Never mind, > I fixed it.") Scaling? Are you doing this in fixed point or floating > point? > > Try reading the 'more bits please', 'dither' and perhaps a few > others of the articles at http://www.digido.com These are aimed at > getting the best possible sound for high-end recording, but they are > also applicable for getting near-theoretical (or > better-than-theoretical, depending on what theory you apply) > performance from smaller, 4-bit, 8-bit or 16-bit systems. > > > >>>>What, if any, are the modern algorithms for digitally mixing waveforms. >>> >>> >>>Addition, possibly with scaling, rounding, and dithering. >>> >>> >>>>2) >>>> >>>>What algorithms would I use to allow one waveform to oscillate another >>>>and to extract one waveform from another. Ie: When an audio signal >>>>oscillates a radio waveform for FM broadcast and when an FM receiver >>>>removes the FM content from a waveform to reveal the audio again. >>> >>> >>>It appears that when you write "oscillate" you mean "modulate". By >>>extension, I can guess that you mean demodulate (detect) when you write >>>"extract". > > > FM modulation is (relatively) easy, presuming you're generating the > carrier using a phase accumulator with a sine function or (more > likely) lookup table. For this purpose I'm presuming both the carrier > and modulation signals are sine waves generated in software. The > function for each output sample is: > > modulating_signal = sin (modulating_phase) > modulating_phase += modulating_frequency > > sample = sin (carrier_phase + (modulating_signal * modulation_depth)) > carrier_phase += carrier_frequency > > I did this many years ago to generate FM-type musical sounds (as > from the Yamaha DX-7 synthesizer, very popular at the time) on a > Macintosh. > > FM demodulation in software is a bit more complex, I've never done > it or given it any thought, but a near-worst-case that comes to mind > is simulating a ratio detector. There's also PLL which may be more > appropriate. > > >>>>Any pointers, websites, books that can help? >>> >>> >>>Clarify your statement of the problem. A sensible recommendation is hard >>>to when there are too many possibilities. >>> >>>Jerry >> >>Can any members of this newsgroup recommend websites, books, e-documents >>etc that would detail numerical method(s) to assist in performing the >>following: >> >>---------------- >> >>2a) create two functions e "encode" and d "decode" each with three >>waveform parameters w1 "carrier", w2 "audio" and w3 "signal"; such that: >> >>w3 = func e( w1, w2) >>w2 = func d( w3, w1) >>assuming also that w1 = func d( w3, w2) >> >>eg. if w1 = 100Khz sine and w2 = 10Khz sine then >> >>func e( 100000, 10000) would result in w3 = 110000 sine >> >>and >> >>func d( 110000, 100000) would result in w2 = 10000 sine. >> >>Note: for func e that w3 must equal w1 modulated by w2. Further that for >>func d, w2 must equal w3 demodulated by w2. >> >>---------------- > > > ----- > http://mindspring.com/~benbradle
dave wrote:
> Jerry Avins wrote: > > dave wrote: > > > >> I have a really simple problem to solve, name the appropriate
algorithm.
> >> > >> 1) > >> > >> I want to mix 24 raw audio waveforms. The present simplistic
summing
> >> algorithm doesn't manage the amplitudes correctly. > > > > > > Why not? What's the problem? > > > Don't worry, fixed it. Thanks for the reply. > > >> What, if any, are the modern algorithms for digitally mixing
waveforms.
> > > > > > Addition, possibly with scaling, rounding, and dithering. > > > >> 2) > >> > >> What algorithms would I use to allow one waveform to oscillate
another
> >> and to extract one waveform from another. Ie: When an audio signal
> >> oscillates a radio waveform for FM broadcast and when an FM
receiver
> >> removes the FM content from a waveform to reveal the audio again. > > > > > > It appears that when you write "oscillate" you mean "modulate". By > > extension, I can guess that you mean demodulate (detect) when you
write
> > "extract". > > > >> Any pointers, websites, books that can help? > > > > > > Clarify your statement of the problem. A sensible recommendation is
hard
> > to when there are too many possibilities. > > > > Jerry > > Can any members of this newsgroup recommend websites, books,
e-documents
> etc that would detail numerical method(s) to assist in performing the
> following: > > ---------------- > > 2a) create two functions e "encode" and d "decode" each with three > waveform parameters w1 "carrier", w2 "audio" and w3 "signal"; such
that:
> > w3 = func e( w1, w2) > w2 = func d( w3, w1) > assuming also that w1 = func d( w3, w2) > > eg. if w1 = 100Khz sine and w2 = 10Khz sine then > > func e( 100000, 10000) would result in w3 = 110000 sine > > and > > func d( 110000, 100000) would result in w2 = 10000 sine. > > Note: for func e that w3 must equal w1 modulated by w2. Further that
for
> func d, w2 must equal w3 demodulated by w2. > > ----------------
Try using the formula for the sine of the difference of two angles. Sin ( A - B ) = Sin ( A) Cos ( B ) - Cos ( A ) Sin ( B ) where Cos ( x ) = Sin ( x + pi/2 ) Herbert