cross fade in MSP

rob t's icon

I am working on interactive installation using MSP and Jitter and we are trying to generate a cross fade between two separate audio files, the cross fading will be effected by midi sensor input. I have had success in the past with video files using the crossfade in Jitter but I have been unable to duplicate a similar effect with audio.

The desired effect is as the video fades from one to another the audio accompanying the video will cross fade with it in sync.

If anyone has any feedback on how I might begin or if there is a patch or tutorial that would be helpful I would appreciate it.

thank you

Timothy Place's icon

There are a lot of ways to do this depending on your aptitute, patience, background, etc. Arguably, the easiest way is to use tap.crossfade~ from Tap.Tools (URL should be in the signature).

This will give you a few attributes to control the shape, performance, etc. and is easy to drop in and apply to MSP signals. As an external rather than a patch-based solution it is very efficient.

ComfortableInClouds's icon

Quote: Timothy Place wrote on Tue, 17 February 2009 14:44
----------------------------------------------------
>Arguably, the easiest way is to use tap.crossfade~ from Tap.Tools
----------------------------------------------------

Arguably being the key word in this sentence. Check out the [!- ] object. Here's a patch that illustrates its use for cross fading.

Max Patch
Copy patch and select New From Clipboard in Max.

Timothy Place's icon

Agreed. And like with any advice on the list, I would collect all of the responses and then try them:

* which is faster?
* which sounds better?
* does the one which is faster also sound better? (bonus!)
* etc.

best,
Tim

________________________________________________________
Timothy Place
Cycling '74 | Electrotap

Chris Muir's icon

On Feb 17, 2009, at 11:02 AM, Rob Trumbour wrote:

> If anyone has any feedback on how I might begin or if there is a
> patch or tutorial that would be helpful I would appreciate it.

At one point I wanted to find a good xfader to replace a placeholder
one that I slapped together. Several years later, I'm still using the
placeholder. It's designed to hook up to a pair of gain~ faders:

Max Patch
Copy patch and select New From Clipboard in Max.

Chris Muir
cbm@well.com    
http://www.xfade.com

Holland Hopson's icon

Here's the abstraction I often use for crossfading. Input is 0-127. Enjoy.

Max Patch
Copy patch and select New From Clipboard in Max.

Jean-Francois Charles's icon

Another option is to use the panning engine inside the pan2 example.

Trond Lossius's icon

Hi Rob,

I recommend that you read MSP tutorial 22 on panning. Crossfades are
really the same as panning, only difference being that you fade
between two input signals instead of two output signals (left and
right speaker).

So, the patch posted by Kyle will be a linear crossfade, and might
cause a - 3db dip in perceived intensity during the crossfade, while
tap.crossfade~ will also offer equal intensity crossfade. And you'll
easily be able to wrap your own crossfade patch from the tutorial and
use that. But as of Max5 and the most recent version of tap.tools
tap.crossfade~ takes an argument to set how many channels the sources
have, which is kind of nice. And, tap.tools use 64 bit floats
internally.

When you have the crossfade working, spend a few hours watching a
movie or two, and look at how audio crossfades actually are synced to
images. You will see that audio often crossfades from one cut to the
next prior to or after the image switch or crossfade rather than in
sync. This often gives a more continuous flow to the narrative of
audio and image.

Best,
Trond

On Feb 17, 2009, at 8:02 PM, Rob Trumbour wrote:

>
> I am working on interactive installation using MSP and Jitter and we
> are trying to generate a cross fade between two separate audio
> files, the cross fading will be effected by midi sensor input. I
> have had success in the past with video files using the crossfade in
> Jitter but I have been unable to duplicate a similar effect with
> audio.
>
> The desired effect is as the video fades from one to another the
> audio accompanying the video will cross fade with it in sync.
>
> If anyone has any feedback on how I might begin or if there is a
> patch or tutorial that would be helpful I would appreciate it.
>
> thank you
>

Jean-Francois Charles's icon

By the way, there was also an example in the reverb-example.pat in the Max 4 distribution. There was a cross-fade between wet & dry signals. This section of the patch disappeared in the Max 5 distribution. But as Trond said, it's the same logic as panning.
J-F.

f.e's icon
Jonny's icon

Thanks Holland Hopson, yours is working for me in max6.

simonkemper's icon

It is really easy to do that on your own ... Crossfading with equal power can be done with the help of a sine/cosine function.

For fading 2 signals you need a float input source reaching from 0 to 1. multiply this input with Pi/2 (we just need half a wave) and the result of the multiplication is used to drive a sine and cosine function. And that result can be use to control the gain of both signal, where one signal gain is controlled by the sine function and the other by our cosine function. At the end you just need to add both signals to one ... Your crossfade is ready ..

Simon