• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

Write my own function to read WAV files

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
stephany080397
Asked:
stephany080397
  • 4
  • 3
  • 2
  • +2
1 Solution
 
cymbolicCommented:
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
 
stephany080397Author Commented:
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
 
ESICommented:
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
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
stephany080397Author Commented:
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
 
twardCommented:
If you have functions to do this in Visual C/C++ you can make those a DLL and simply call them from VB...
0
 
stephany080397Author Commented:
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
 
twardCommented:
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
 
ESICommented:
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
 
DTaylorCommented:
Just use Sound Recorder and delete the silence then save your .wav file. Then use VB to play it as is
0
 
stephany080397Author Commented:
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
 
ESICommented:
Hi Steph,
Thanks for your reply, and I'm glad to see the modules I sent you helped !!
My pleasure !
Bye
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now