Click here to Skip to main content
12,293,588 members (65,090 online)
Click here to Skip to main content
Add your own
alternative version


219 bookmarked

Sound visualizer in C#

, 15 Aug 2007 GPL3
Rate this:
Please Sign up or sign in to vote.
Simple sound sampler with visualization
Screenshot - SoundViewer.jpg


This project demonstrates the use of the Fast Fourier Transform and Windows GDI to produce near real-time visualizations of the time and frequency domains of sound.


While looking for information on signal processing for a robotics project, it became apparent that examples written in C# were hard to find. This led me to create some of my own classes, which I have provided here for this demonstration.

Using the Code

Audio input for this demonstration is provided by the Wave classes developed by Ianier Munoz. Wave samples are further processed using the AudioFrame class.

class AudioFrame
    private Bitmap _canvasTimeDomain;
    private Bitmap _canvasFrequencyDomain;
    private double[] _waveLeft;
    private double[] _waveRight;
    private double[] _fftLeft;
    private double[] _fftRight;
    private SignalGenerator _signalGenerator;
    private bool _isTest = false;
    public AudioFrame(bool isTest)
        _isTest = isTest;

    /// <span class="code-SummaryComment"><summary>


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Jeff Morton
Systems / Hardware Administrator
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

Questionwhat are the values representing in arrays? [modified] Pin
D__I___O31-Aug-11 0:11
memberD__I___O31-Aug-11 0:11 
Hi Jeff!


In AudioFrame.cs u got 2 arrays per channel:

private double[] _waveLeft;
private double[] _waveRight;
private double[] _fftLeft;
private double[] _fftRight;

What are the double-values u are extracting out of the stream represent?

I monitored the vals from _waveLeft and if its quiet in the room, its between -250 and 250.
If I clap my hands it raises up to 2000 or down to -2000.

I search for the loudest sound in lets say 10 seconds.

Are these vals the loudness of a signal?

what is the difference to the Fouriertransformed Vals in _fftLeft/_fftRight?

True or False?

The samplingrate of 44100 means that the electric signal from the microphone
is caught 44100 times per second. Or in another way : 44100 int-values in array represent a second
of sound.

If I set the samplingrate to 1000, every millisecond a currencyvalue is writen into an arrayelement.

thxALot in advance


PS: Just found you SoundActivated... this answers the question about the loudness!
But still asking for the samplerate.

modified on Wednesday, August 31, 2011 6:35 AM

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 15 Aug 2007
Article Copyright 2007 by Jeff Morton
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid