Click here to Skip to main content
15,884,237 members
Articles / Desktop Programming / ATL

MMWaveEditX - Advanced Wave File Editor Control

Rate me:
Please Sign up or sign in to vote.
4.25/5 (20 votes)
20 Aug 20012 min read 287.9K   6.4K   91   78
A control for editing wave files which uses peak values for visual display

Sample Image

Introduction

I have loads of ActiveX controls laying around that I have written.  Some seem somewhat useful, others are wasted drive space.  I came across this one the other day and decided somebody out there might be able to use it.

Audio programming is somewhat of a black art, it took me a while to figure out that "Peak" files are used by waveform editing software to visualize the waveform.

What are peak files? Well essentially you comb through a wave file and take snapshots of averages at different intervals.

The benefit is obvious, by using a peak file we can visualize a .wav file using a much smaller dataset than the 'pcm' data contained in it.

Here is an example: a .wav file whose size is 41.6 megabytes can be visualized with peak data totaling just under 333k. That is how we are able to do really fast zooms and selections on what is in reality a huge amount of data.

I tested my peak file algorithms against SoundForge ( a well known audio editor) and they come pretty close to matching the speed at which
a peak file can be built.

This control is not finished, has bugs, and in general should be used as a starting point for creating your own editor (or just as a learning tool). I do not have time to fully document (or partially) the code, so you will have to dig through it to figure it out (sorry).  I wrote this code more than a year ago and just by looking at it I can see numerous places for optimization.

The control itself contains all the visualization/wave file parsing/peak creation routines.  I included a dialog based app to show how you can use it.

Being a black art it is notoriously hard to find out how the sound coding wizards do the things they do, hopefully my little control will help you in some way.

You are free to use the code as you wish, just drop me an email if you use it in something interesting, extended its usefulness, hate me for not documenting it, love me for giving it away, just want to say "hey!".


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerDownload link is wrong, here are the working links Pin
teschner12-Oct-16 8:36
teschner12-Oct-16 8:36 
QuestionDownload link is wrong, here are the working links Pin
teschner12-Oct-16 8:36
teschner12-Oct-16 8:36 
QuestionDownload Error Pin
evan36915-Jul-14 18:28
evan36915-Jul-14 18:28 
Questionpeak file algorithm Pin
Hazem210119-Mar-10 9:24
Hazem210119-Mar-10 9:24 
GeneralEditor control for wma file Pin
raj157631-Jan-10 23:50
raj157631-Jan-10 23:50 
Generalset the width static Pin
Andri Már30-Oct-09 7:46
Andri Már30-Oct-09 7:46 
QuestionHow to play wave file Pin
Neeraj Soam23-Oct-09 1:56
Neeraj Soam23-Oct-09 1:56 
Generali cant see visualize audio file Pin
Neeraj Soam22-Oct-09 1:30
Neeraj Soam22-Oct-09 1:30 
GeneralQuestion about resizing control Pin
Patrick Fox5-Nov-08 5:44
Patrick Fox5-Nov-08 5:44 
I've obtained your wave file viewer control, and I must say this is excellent work. I am writing a C# application for simple wave file modifying (mostly normalizing and removing silence from the beginning and end of files) and this control is an excellent way to visualize the files. I imported it into .Net as a wrapped OCX control, but I am having a strange problem:

When the control resizes, the viewer doesn't seem to take this into account when drawing the waveform. This is strange because the scale and db lines DO change in size and look correct, but the waveform does not change. I found a (not so elegant) workaround, I can call LoadWaveFile on the control when it resizes and it paints correctly. But this doesn't make any sense because nothing in LoadWaveFile has to do with the size of the control. Since I am loading a file I already had loaded, a peak file will exist, it will find it and return TRUE pretty quickly, and not update any variables related to its size. Any idea why this might happen?

Also... the wave form appears inverted. When I load up a wave file in sound forge and this viewer, they look similar but inverted, where sound forge shows a peak, this control shows a valley, but other than that they look the same.

PS - I had to modify the control to work with 8 and 16 bit files in stereo or mono. My code isn't perfect, but it's getting there. If you'd like the updated source, you can email me and I'll be glad to send it along.
GeneralRe: Question about resizing control Pin
Patrick Fox5-Nov-08 6:06
Patrick Fox5-Nov-08 6:06 
QuestionC# Examples maybe? Pin
T0mYtI27-May-08 0:53
T0mYtI27-May-08 0:53 
AnswerRe: C# Examples maybe? Pin
dswigger9-Jun-08 10:01
dswigger9-Jun-08 10:01 
Questionwant to use in mono (single channel ) Pin
puneet agrawal7-May-08 19:35
puneet agrawal7-May-08 19:35 
Generalcant download Pin
samwipro1-May-08 6:52
samwipro1-May-08 6:52 
Generalhelp me plz............ Pin
Le@rner21-Jan-08 19:42
Le@rner21-Jan-08 19:42 
GeneralMIDI Renderer Pin
charliev4-Feb-07 6:09
charliev4-Feb-07 6:09 
Generalit doesn't open any file Pin
mahila4-Oct-06 23:34
mahila4-Oct-06 23:34 
Generalcompare similar wave graphs Pin
kkkkg15-Jul-06 20:53
kkkkg15-Jul-06 20:53 
QuestionHow about midi file? Pin
wahaha_ts13-Apr-05 23:49
wahaha_ts13-Apr-05 23:49 
AnswerRe: How about midi file? Pin
dswigger14-Apr-05 12:29
dswigger14-Apr-05 12:29 
Generali need help in Advanced Wave File Editor Control Pin
shortwave2-Apr-05 4:43
shortwave2-Apr-05 4:43 
GeneralSir! do i have chance to..... Pin
mssu24-Mar-05 19:50
mssu24-Mar-05 19:50 
GeneralSir! can you help me! Pin
mssu24-Mar-05 18:47
mssu24-Mar-05 18:47 
GeneralSir! can you help me! Pin
mssu24-Mar-05 16:42
mssu24-Mar-05 16:42 
QuestionHow to convert wav files in xls files Pin
bsmits10-Nov-04 13:20
bsmits10-Nov-04 13:20 

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.