Skip to content Skip to navigation

Connexions

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

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of a lens

      Lenses

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

      What is in a lens?

      Lens makers point to Connexions 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 Connexions 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
  • E-mail the authors
  • Rate this module (How does the rating system work?)

    Rating system

    Ratings

    Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

    How to rate a module

    Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

    (0 ratings)

Recently Viewed

This feature requires Javascript to be enabled.

Modeling flange in Matlab

Module by: Brent Stephens, Rob Smith, Barron Stone, Neil Narayan

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

Comments, questions, feedback, criticisms?

Send feedback