Skip to content Skip to navigation

Connexions

You are here: Home » Content » Modeling flange in Matlab

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

Modeling flange in Matlab

Module by: Brent Stephens, Rob Smith, Barron Stone, Neil Narayan. E-mail the authors

Summary: An implementation of flange in Matlab as written by Stephen G. McGovern, date: 08.03.03

Flanging is performed by taking the original copy of the signal and adding it to a time delayed version of itself. However, this effect differs from reverb, which is just adding a signal to a time-delayed version of itself with a set delay, because the delay gradually changes and is usually determined with a low frequency oscillator. Flanging is a type of phasing, which is where a signal is filtered with an all-pass filter with a non-linear phase responce. The phasing effect can be easily observed in the spectrogram of the signal.

Figure 1: The spectrogram of a guitar chord being played
Spectrogram of a Guitar Chord
Spectrogram of a Guitar Chord (specgram.png)
Figure 2: The spectrogram of a guitar chord after flanging
Spectrogram of a Guitar Chord after Flanging
Spectrogram of a Guitar Chord after Flanging (flangedspec.png)

As for the actual Matlab implementation of flanging, Stephen G. McGovern had already created an implementation, and because the main point of this project is not to create guitar effects, but to implement adaptive guitar effects.

This is Stephen G. McGovern's (slightly modified) code:

function [y]=flanger(fs, y, wet)
v = 0.002;
r = 0.5;
orig = y;

%[y] = flange(fs, v, x, r)
%
%   This is a basic flanging effect.
%
%      fs = Sample rate
%      v = Variation.
%      x = Input audio signal. This should be a column 
%          vector.
%      r = Rate.
%
%   Example:
%     
%      >>y = flange(fs,0.002,x,0.5);
%
%
%   See also WAVREAD and SOUND
%
%Version 1.0
%Coded by: Stephen G. McGovern, date: 08.03.03

md= ceil(v*fs);
n=1:length(y)+md;
v=round(v*fs);
z=zeros(md,1);
m=max(abs(y));
y=[z;y;z];
rr=2*pi/round(fs*r);
b=round((v/2)*(1-cos(rr.*n)));
y=y(n+md)+y(n+md-b);
m=m/max(abs(y));
y=m*y;

y = y(1:length(orig));

y = wet * y + (1 - wet) * orig;

This is the only thing that cannot be immediately converted into real time. In order to do that, another implementation using circular buffer would be needed.

Link to Stephen G. McGovern's implementation of Flange

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks