Click here to Skip to main content
11,639,593 members (62,093 online)
Click here to Skip to main content

Sound visualizer in C#

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

Introduction

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.

Background

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>
</span>

License

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

Share

About the Author

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

You may also be interested in...

Comments and Discussions

 
GeneralShutdown addition Pin
firmwaredsp31-Oct-07 22:26
memberfirmwaredsp31-Oct-07 22:26 
GeneralRe: Shutdown addition Pin
Ri Qen-Sin20-Nov-07 17:39
memberRi Qen-Sin20-Nov-07 17:39 
GeneralRe: Shutdown addition Pin
Jeff Morton27-Nov-07 2:57
memberJeff Morton27-Nov-07 2:57 
GeneralRe: Shutdown addition Pin
firmwaredsp27-Nov-07 23:21
memberfirmwaredsp27-Nov-07 23:21 
QuestionHow it works?? Pin
Ibrahim Dwaikat28-Oct-07 9:22
memberIbrahim Dwaikat28-Oct-07 9:22 
AnswerRe: How it works?? Pin
j_morton28-Oct-07 9:29
memberj_morton28-Oct-07 9:29 
GeneralRe: How it works?? Pin
Ibrahim Dwaikat28-Oct-07 9:34
memberIbrahim Dwaikat28-Oct-07 9:34 
GeneralRe: How it works?? Pin
firmwaredsp31-Oct-07 22:47
memberfirmwaredsp31-Oct-07 22:47 
GeneralRe: How it works?? Pin
Jeff Morton28-Nov-07 3:44
memberJeff Morton28-Nov-07 3:44 
GeneralVery nice Pin
blackjack215023-Oct-07 1:01
memberblackjack215023-Oct-07 1:01 
QuestionHow To Get Frequency, or Period of the Wave? Pin
Paul Chin PC29-Sep-07 4:45
memberPaul Chin PC29-Sep-07 4:45 
QuestionDoesn't work :( Pin
Vladimir Grankovsky27-Aug-07 1:39
memberVladimir Grankovsky27-Aug-07 1:39 
AnswerRe: Doesn't work :( Pin
JeffMorton28-Aug-07 7:08
memberJeffMorton28-Aug-07 7:08 
GeneralRe: Doesn't work :( [modified] Pin
meliton gavia8-Jan-09 17:08
membermeliton gavia8-Jan-09 17:08 
i followed the instructions the in the link... but it still gives me the same error..

1/9/2009 12:29:43 PM : Audio exception
System.NullReferenceException: Object reference not set to an instance of an object.
at SoundViewer.WaveNative.waveInOpen(IntPtr& phwi, Int32 uDeviceID, WaveFormat lpFormat, WaveDelegate dwCallback, IntPtr dwInstance, Int32 dwFlags)
at SoundViewer.WaveInRecorder..ctor(Int32 device, WaveFormat format, Int32 bufferSize, Int32 bufferCount, BufferDoneEventHandler doneProc) in D:\Tests\Study\SoundViewer\SoundViewer\WaveIn.cs:line 145
at SoundViewer.Form1.Start() in D:\Tests\Study\SoundViewer\SoundViewer\Form1.cs:line 69

modified on Thursday, January 8, 2009 11:30 PM

AnswerRe: Doesn't work :( Pin
ajgreen198723-Jul-09 5:36
memberajgreen198723-Jul-09 5:36 
AnswerRe: Doesn't work :( Pin
Terricide15-Oct-09 22:11
memberTerricide15-Oct-09 22:11 
Questionquestion about wav using Pin
headburster21-Aug-07 23:29
memberheadburster21-Aug-07 23:29 
AnswerRe: question about wav using Pin
Jaguar++29-Aug-07 22:18
memberJaguar++29-Aug-07 22:18 
Questionvs version? Pin
headburster21-Aug-07 23:02
memberheadburster21-Aug-07 23:02 
AnswerRe: vs version? Pin
JeffMorton28-Aug-07 7:12
memberJeffMorton28-Aug-07 7:12 
GeneralThanks Pin
merlin98116-Aug-07 3:57
membermerlin98116-Aug-07 3:57 
GeneralThanks. this is what I was looking for. Pin
Michael Sync15-Aug-07 20:22
memberMichael Sync15-Aug-07 20:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web03 | 2.8.150731.1 | Last Updated 15 Aug 2007
Article Copyright 2007 by Jeff Morton
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid