Solved

Write my own function to read WAV files

Posted on 1997-08-07
11
506 Views
Last Modified: 2012-05-04
In an WAV file containing a word, I need to erase the silence that appears before the word is pronunced and at the end of the file, due to the reaction time of the man who speaks to start to speak and to stop his record.
I hope I am clear enougth!!!
I do not want to do this by displaying the file, I want something automatic without intervention of the user.
I have thougth of writing my own function to read a WAV file instead of using the commands that VB provides. This can allows me to detect the level of the sound and remove all the sounds below a predefined value.
I got some functions doing this but they are written with Visual C++, they are called MMIO. I would like to know if I can find the same functions written with Visual Basic 4, and most important, Where??.
Thanks.
stephanie.
0
Comment
Question by:stephany080397
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 9

Expert Comment

by:cymbolic
ID: 1430024
Steph:

WAV files have a very simple format.  If you look at them with a hex viewer (Such as the hex mode in Verne Buerg's DOS List Program), you can see the repeating patterns in the file.  Basically, they have a fixed header, and then individual bytes for relative amplitude off the origin.  It's hard to explain this without a graph, but here goes:

Consider a simple sine wave on a cartesian coordinate system.  Let's start at y=0.  Your y measures are your amplitude, and your x measures are your samples.  So, reading from left to right, as the x value increases, depending on your phase, y first increases, reaches peak amplitude, then decreases, then crosses the x axis at 0, continues to decrease, reaches minimum amplitude at -peak amplitude, then climbs back to 0, then repeats.

Well, in a wave file, each byte following the header is an ascii value that represents an amplitude.  Since the maximum ascii value you can achieve is 255, the middle of this range is 127 (hex 7F).  SOo.. in a wave file your origin value is 127, and your max amplitude is 0, and your minimum amplitude is 255.  

This is experimental knowledge that comes from study and experimentation of wav file formats, in order to generate my own wavs, and in wondering how I could apply an algorithm that make's Bill Clinton sound like Donald Duck (or whatever).

Anyway, to acheive what you want to do, you can use a preprogram to process your wav files before you send them to your player.  Just copy the file, opening and writing in binary mode.  Always copy the header (You can determine it's length by examining multiple wav files on your system, and comparing the beginning parts of each to find the initial pattern that's the same in all your wav files. I forget what the actual length is, but that's the way we figured it out).  Then, don't copy through those bytes that are real close to 127 in absolute value.  Then copy everything else through, until you get into extremely low amplitudes again. No noise should be ascii 127 (hex FF).

You don't need libraries to do this, you can do it yourself.
0
 

Author Comment

by:stephany080397
ID: 1430025
Thanks a lot for your answer, you understood exactly what I want to do, but i'm under pressure of time, and cannot waste time examining the format of a wav file. What I want to find are the functions already writtten to read wav file, so I just have to add a little piece of code, or even better functions that do what I want: remove the silence at the beginning and the end of my wav file written with VB4, but maybe I'm dreaming.
Stephanie
0
 
LVL 3

Expert Comment

by:ESI
ID: 1430026
Hi Steph,
U wrote VB provides functions to read WAV files ? Wich ones ?
I figure out u use the LoadResData(x,10) function as your waves are encapsulated into a .RES file ?
btw, I have basic modules performing some low-pass filter, echo, reverberate, aso.. functions so all the bloody things are done and u can easily modify it to fit your needs.
0
 

Author Comment

by:stephany080397
ID: 1430027
Sorry for the confusion, I wanted to say that I used the basic VB commands to "play" WAV files.
Maybe some of yours modules could help me, but how can I get them?
stephanie.
0
 
LVL 7

Expert Comment

by:tward
ID: 1430028
If you have functions to do this in Visual C/C++ you can make those a DLL and simply call them from VB...
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:stephany080397
ID: 1430029
Sorry again, I do not want to seem difficult, but I am asked to make the software with Visual Basic 4 only. I am quite sure that if these functions have been written with VC++, they must exist with VB4. Somewhere...
Stephanie.

0
 
LVL 7

Expert Comment

by:tward
ID: 1430030
All I was saying if you have the stuff in VC++ just simply make it a DLL and then you can call the functions from within VB.  I've made several DLLs here that I call from VB, it is just like making an API call...
0
 
LVL 3

Expert Comment

by:ESI
ID: 1430031
Steph
Email at this address : eessii@mailexcite.com and I'll reply & attach the zip'd VB4 modules.
Btw, tward is right, if u already have the source u need...
CU

0
 

Expert Comment

by:DTaylor
ID: 1430032
Just use Sound Recorder and delete the silence then save your .wav file. Then use VB to play it as is
0
 

Author Comment

by:stephany080397
ID: 1430033
I do not want to have to display the sounds to do it, I want something done automatically, without intervention of the user. Any way, ESI has answered my question by sending me some modules, I just do not know how to give him his points. So the question is closed.
Thanks everybody.
Stephanie.
0
 
LVL 3

Accepted Solution

by:
ESI earned 100 total points
ID: 1430034
Hi Steph,
Thanks for your reply, and I'm glad to see the modules I sent you helped !!
My pleasure !
Bye
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now