[music-dsp] Calculating the gains for an XY-pad mixer

2013-01-17 Thread Aengus Martin
Hi Everyone,

This may be a fairly idiosyncratic issue, but I think someone here
might be able to comment on the correctness of what I've done.

I am implementing a mixer in which the gains of four sounds are
controlled using a single XY-pad. There is one sound associated with
each corner of the XY-pad and placing the cursor at a corner sets gain
of the corresponding sound to 1 and all others to 0; whereas placing
it in the middle mixes all four sounds equally; and placing it on an
edge mixes the sounds at the two nearest corners only. I have two
schemes for calculating the four gains from the cursor position, one
for correlated sounds and the other for uncorrelated sounds. I'm
hoping that someone might flag any problems--theoretical or
otherwise--with either of them (though they seem to me to sound ok)

For correlated sounds (such as four waveforms in a subtractive
synthesiser), I understand that a linear crossfade is appropriate and
the four gains should sum to 1. The scheme I came up with for doing
this is to divide the XY-pad rectangle into four smaller rectangles by
drawing a horizontal line and a vertical line through the cursor
position, and then to use the areas of the rectangles as the gains.
The gain for a given corner is the area of the 'opposite' rectangle,
e.g. the gain for the sound associated with the bottom left corner is
given by the area of the top right rectangle, etc.; I can supply a
figure if necessary. Of course the areas need to be normalised so that
they sum to 1.

Now for uncorrelated sounds, I understand that the squares of the
gains should sum to 1. My solution is to use the previous scheme but
with the gain being given by the square root of the area of the
corresponding rectangle. This somehow seems a bit too simple, but
maybe it's correct.

Do these seem like reasonable ways to get the gains for the two cases?

Thanks,

Aengus.


www.am-process.org
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] Calculating the gains for an XY-pad mixer

2013-01-17 Thread Alan Wolfe
What you are trying to calculate is called barycentric coordinates,
you might give them a google (:

As far as them all adding to one (which barycentric coordinates do),
I'm not sure if that's appropriate or not, because you have to
remember that volume is linear, but the perception of that linear
scale is not linear.  Normally when you are trying to work with the
perception of volume (in this case, trying to keep it the same
loudness), you work in decibels, which are a non linear scale, but are
linear to the ear.

Hope this helps.  Someone will surely chime in if i've misled you on
the second part :P

On Thu, Jan 17, 2013 at 8:59 PM, Aengus Martin aen...@am-process.org wrote:
 Hi Everyone,

 This may be a fairly idiosyncratic issue, but I think someone here
 might be able to comment on the correctness of what I've done.

 I am implementing a mixer in which the gains of four sounds are
 controlled using a single XY-pad. There is one sound associated with
 each corner of the XY-pad and placing the cursor at a corner sets gain
 of the corresponding sound to 1 and all others to 0; whereas placing
 it in the middle mixes all four sounds equally; and placing it on an
 edge mixes the sounds at the two nearest corners only. I have two
 schemes for calculating the four gains from the cursor position, one
 for correlated sounds and the other for uncorrelated sounds. I'm
 hoping that someone might flag any problems--theoretical or
 otherwise--with either of them (though they seem to me to sound ok)

 For correlated sounds (such as four waveforms in a subtractive
 synthesiser), I understand that a linear crossfade is appropriate and
 the four gains should sum to 1. The scheme I came up with for doing
 this is to divide the XY-pad rectangle into four smaller rectangles by
 drawing a horizontal line and a vertical line through the cursor
 position, and then to use the areas of the rectangles as the gains.
 The gain for a given corner is the area of the 'opposite' rectangle,
 e.g. the gain for the sound associated with the bottom left corner is
 given by the area of the top right rectangle, etc.; I can supply a
 figure if necessary. Of course the areas need to be normalised so that
 they sum to 1.

 Now for uncorrelated sounds, I understand that the squares of the
 gains should sum to 1. My solution is to use the previous scheme but
 with the gain being given by the square root of the area of the
 corresponding rectangle. This somehow seems a bit too simple, but
 maybe it's correct.

 Do these seem like reasonable ways to get the gains for the two cases?

 Thanks,

 Aengus.

 
 www.am-process.org
 --
 dupswapdrop -- the music-dsp mailing list and website:
 subscription info, FAQ, source code archive, list archive, book reviews, dsp 
 links
 http://music.columbia.edu/cmc/music-dsp
 http://music.columbia.edu/mailman/listinfo/music-dsp
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] Calculating the gains for an XY-pad mixer

2013-01-17 Thread Aengus Martin
Thanks--it's good to have that term. It looks like I am calculating
the barycentric coordinates of the cursor in the XY-pad square.

As regards the perception issue, standard way of crossfading between
two correlated sounds (I think) is just linear in amplitude, and for
uncorrelated ones, it's linear in the square of the amplitude. That's
basically what I'm trying to extend to four sounds, and I suppose
that's my question: does this seem appropriate?


On Fri, Jan 18, 2013 at 4:06 PM, Alan Wolfe alan.wo...@gmail.com wrote:
 What you are trying to calculate is called barycentric coordinates,
 you might give them a google (:

 As far as them all adding to one (which barycentric coordinates do),
 I'm not sure if that's appropriate or not, because you have to
 remember that volume is linear, but the perception of that linear
 scale is not linear.  Normally when you are trying to work with the
 perception of volume (in this case, trying to keep it the same
 loudness), you work in decibels, which are a non linear scale, but are
 linear to the ear.

 Hope this helps.  Someone will surely chime in if i've misled you on
 the second part :P

 On Thu, Jan 17, 2013 at 8:59 PM, Aengus Martin aen...@am-process.org wrote:
 Hi Everyone,

 This may be a fairly idiosyncratic issue, but I think someone here
 might be able to comment on the correctness of what I've done.

 I am implementing a mixer in which the gains of four sounds are
 controlled using a single XY-pad. There is one sound associated with
 each corner of the XY-pad and placing the cursor at a corner sets gain
 of the corresponding sound to 1 and all others to 0; whereas placing
 it in the middle mixes all four sounds equally; and placing it on an
 edge mixes the sounds at the two nearest corners only. I have two
 schemes for calculating the four gains from the cursor position, one
 for correlated sounds and the other for uncorrelated sounds. I'm
 hoping that someone might flag any problems--theoretical or
 otherwise--with either of them (though they seem to me to sound ok)

 For correlated sounds (such as four waveforms in a subtractive
 synthesiser), I understand that a linear crossfade is appropriate and
 the four gains should sum to 1. The scheme I came up with for doing
 this is to divide the XY-pad rectangle into four smaller rectangles by
 drawing a horizontal line and a vertical line through the cursor
 position, and then to use the areas of the rectangles as the gains.
 The gain for a given corner is the area of the 'opposite' rectangle,
 e.g. the gain for the sound associated with the bottom left corner is
 given by the area of the top right rectangle, etc.; I can supply a
 figure if necessary. Of course the areas need to be normalised so that
 they sum to 1.

 Now for uncorrelated sounds, I understand that the squares of the
 gains should sum to 1. My solution is to use the previous scheme but
 with the gain being given by the square root of the area of the
 corresponding rectangle. This somehow seems a bit too simple, but
 maybe it's correct.

 Do these seem like reasonable ways to get the gains for the two cases?

 Thanks,

 Aengus.

 
 www.am-process.org
 --
 dupswapdrop -- the music-dsp mailing list and website:
 subscription info, FAQ, source code archive, list archive, book reviews, dsp 
 links
 http://music.columbia.edu/cmc/music-dsp
 http://music.columbia.edu/mailman/listinfo/music-dsp
 --
 dupswapdrop -- the music-dsp mailing list and website:
 subscription info, FAQ, source code archive, list archive, book reviews, dsp 
 links
 http://music.columbia.edu/cmc/music-dsp
 http://music.columbia.edu/mailman/listinfo/music-dsp



-- 

www.am-process.org
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] Calculating the gains for an XY-pad mixer

2013-01-17 Thread Alan Wolfe
Barycentric coordinates don't just apply to triangles.  Trust me, I'm
a (video game) engineer (tm) hehe

In geometry, the barycentric coordinate system is a coordinate system
in which the location of a point is specified as the center of mass,
or barycenter, of masses placed at the vertices of a simplex(a
triangle, tetrahedron, etc.) - from wikipedia

On Thu, Jan 17, 2013 at 9:22 PM, Ross Bencina
rossb-li...@audiomulch.com wrote:
 On 18/01/2013 4:06 PM, Alan Wolfe wrote:

 What you are trying to calculate is called barycentric coordinates,


 Actually I don't think so.

 Barycentric coordinates apply to triangles (or simplices), not squares (XY).

 http://en.wikipedia.org/wiki/Barycentric_coordinate_system_(mathematics)
 http://en.wikipedia.org/wiki/Simplex


 Aengus wrote:
 Do these seem like reasonable ways to get the gains for the two cases?

 They seem reasonable to me. Do you have a reason for doubting?

 Ross

 --
 dupswapdrop -- the music-dsp mailing list and website:
 subscription info, FAQ, source code archive, list archive, book reviews, dsp
 links
 http://music.columbia.edu/cmc/music-dsp
 http://music.columbia.edu/mailman/listinfo/music-dsp
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp


Re: [music-dsp] Calculating the gains for an XY-pad mixer

2013-01-17 Thread robert bristow-johnson

On 1/17/13 11:59 PM, Aengus Martin wrote:

This may be a fairly idiosyncratic issue, but I think someone here
might be able to comment on the correctness of what I've done.

I am implementing a mixer in which the gains of four sounds are
controlled using a single XY-pad. There is one sound associated with
each corner of the XY-pad and placing the cursor at a corner sets gain
of the corresponding sound to 1 and all others to 0; whereas placing
it in the middle mixes all four sounds equally; and placing it on an
edge mixes the sounds at the two nearest corners only.


sounds like the Prophet VS.  a nice old implementation of wavetable 
synthesis.


their square was turned 45 degrees into a baseball diamond position.


  I have two
schemes for calculating the four gains from the cursor position, one
for correlated sounds and the other for uncorrelated sounds. I'm
hoping that someone might flag any problems--theoretical or
otherwise--with either of them (though they seem to me to sound ok)

For correlated sounds (such as four waveforms in a subtractive
synthesiser), I understand that a linear crossfade
well, it doesn't *have* to be linear (in the sense of straight-line 
mapping), but it should be *complementary*.



is appropriate and the four gains should sum to 1.


that's what we mean by complementary in a voltage sense.


  The scheme I came up with for doing
this is to divide the XY-pad rectangle into four smaller rectangles by
drawing a horizontal line and a vertical line through the cursor
position, and then to use the areas of the rectangles as the gains.
The gain for a given corner is the area of the 'opposite' rectangle,
e.g. the gain for the sound associated with the bottom left corner is
given by the area of the top right rectangle, etc.; I can supply a
figure if necessary. Of course the areas need to be normalised so that
they sum to 1.


that's a clever way to look at it.  it's straight-line linear and it's 
complementary.



Now for uncorrelated sounds, I understand that the squares of the
gains should sum to 1. My solution is to use the previous scheme but
with the gain being given by the square root of the area of the
corresponding rectangle. This somehow seems a bit too simple, but
maybe it's correct.


it is for *totally* uncorrelated sounds.  not partially correlated or 
negatively correlated.



Do these seem like reasonable ways to get the gains for the two cases


i don't think this has anything to do with barycentric coordinates, but 
i thought it might deal with your mixing gain issue:


 http://music.columbia.edu/pipermail/music-dsp/2010-December/069419.html

for me, the issue was splicing more than mixing, but i think this 
issue of the linear values adding to 1 vs. the squares of the linear 
values adding to 1 is addressed.  take a look at the whole thread in the 
archive and tell us if this speaks to your issue at all.  splicing is 
the same as 1-dimensional mixing as you move your crossfade fader from 
one end to the other.


one thing you probably want to do is align your different sounds so that 
the have the best cross-correlation.  you should always be able to avoid 
a negative crosscorrelation.  if one sound is pure white noise, the 
cross-correlation will be pretty much zero and that would be the fully 
uncorrelated case.


--

r b-j  r...@audioimagination.com

Imagination is more important than knowledge.



--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp