Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Write my own function to read WAV files

Posted on 1997-08-07
11
Medium Priority
?
533 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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
 

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 300 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

864 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