Hello, everybody. Sorry to disturb you all.

Currently, I have a speech recording and playback software developed by Microsoft Visual C++ 6.0. The software is used to train children with speech problem and scores will be calculated and showed at the end of each practice session. The software is able to record and playback real-time.

Children use this software at home and save their practice records in a single floppy disk. Then, children will bring the floppy disk with practice records inside when they return to our centre. There are 20 wave files that must be saved in a single floppy disk. Due to space insifficiency, one floppy disk is 1.44M in capacity.
Total size of 20 wave files = 20*188k = 3,760,000 bytes
Total floppy disk needed = (3,760,000)/1,440,000 = 2.6 floppy disks
But, I must save all the 20 wave files into a single floppy disk

Our problem is we are not able to save all 20 wave files in a single floppy disk. We cant afford a CD-RW for each child and we must use floppy disk. The solution is we have to compress the wave file to save the files in a floppy and decompress the files back to wave file in order to listen to how the children practice at home.

I am totally new to this as the software is written by one of my previous friend who worked together with me in a voluntary speech rehabilitation centre. We need this software to train children in the centre. I work part time there.

But, my problem is how to call any CODEC dll into correct place into my current project platform without causing any bugs? Please forgive me if I have asked a very silly question, I am sorry. After I have added the cpp and h files into my current project paltform, I dont know what should I do next.

My final destination is to save all 20 wave files in a single floppy disk. I didnt restrict that I must use compression/decompression methods but I dont know what else should I use.

Hope you can give me some guidances on how to do it or you please link me to pages that help me to do so. I promise I can learn as independent as possible but I really need your guidance at this very beginning, please.

Please, I really appreciate all your help.

So do you want a DLL that converts MP3 to and from Wav format?
Or Do you want to know how to call a DLL that you already have?

So do you want a DLL that converts MP3 to and from Wav format?
Or Do you want to know how to call a DLL that you already have?

Hi, WolfPack, thank you very much for your reply, really appreciate much.

I didnt write a dll on our own but I managed to find some CODEC source codes from the websites but my problem is I dont know how to call a DLL from my software project platform.

Could you please guide me some or link me to the page that got the DLL together with its tutorial or details on how to call the DLL from my software?

Please help, I really need some guidance at this very beginning, I promise I will learn as independent as possible. But I just need helps in this very beginning, please, appreciate

Okay then I assume you have the DLL with you. So you should have the documentation of that DLL also. That is you must know the functions available, what the functions do, and what are the parameters the functions need to execute properly. After looking up for those in the documentation you can refer this site, which is an example on How to call the

myPuts

function in the

Myputs DLL

. I think it is fairly straightforward, but you can ask if you run into further problems.

I must also say that I appreciate what you are doing to help those kids with speech problems.

Okay then I assume you have the DLL with you. So you should have the documentation of that DLL also. That is you must know the functions available, what the functions do, and what are the parameters the functions need to execute properly. After looking up for those in the documentation you can refer this site, which is an example on How to call the

myPuts

function in the

Myputs DLL

. I think it is fairly straightforward, but you can ask if you run into further problems.

I must also say that I appreciate what you are doing to help those kids with speech problems.

Hi, WolfPack, thank you very much for your reply, appreciate.

I am still 'digesting' what you said here and I will read about the documentation if I could find one and I hope I can understand.

I try my best and will tell you how I am doing

Hi, WolfPack, Sorry to disturb, May I ask?

I was confused with the dll. I just want to call the third-party software.exe to help me do the compression and decompression part. Do I need to call the dll? Or, Can I just call the .exe from my software?

Sorry for causing any confusion, I was not clear with dll before I put this thread, after I read the pdf about dll, I think that maybe I dont need to call dll but just call the exe.

Please forgive me, I apologized for the trouble caused by me.

Do you think it is possible to call any CODEC software exe from my software? Which one is easier for a newbie like me?

But, I dont know how can I do so, do you mind to give me some guidance? Please, Please forgive me for my ignorance. I try my best in doing it. Hope you can teach me some. Please.

Hi, WolfPack, Sorry to disturb, May I ask?

I was confused with the dll. I just want to call the third-party software.exe to help me do the compression and decompression part. Do I need to call the dll? Or, Can I just call the .exe from my software?

Sorry for causing any confusion, I was not clear with dll before I put this thread, after I read the pdf about dll, I think that maybe I dont need to call dll but just call the exe.

Please forgive me, I apologized for the trouble caused by me.

Do you think it is possible to call any CODEC software exe from my software? Which one is easier for a newbie like me?

But, I dont know how can I do so, do you mind to give me some guidance? Please, Please forgive me for my ignorance. I try my best in doing it. Hope you can teach me some. Please.

This depends on the DLL or exe that you are using. So I can't say anything specific. But it is possible to call any DLL or EXE from another program. You could post the documentation in this thread, so that we can take a look and give any specific advice if possible.

HI, WolfPack, thanks for your post.

I would like to call the lame.exe into my current software and I know where or which location to call the lame.exe from my software.

After I put the lame.exe into my project folder, what codes or command that I should write in order to call the lame.exe to come out?

Hi, WolfPack, actually it is not necessary for me to use lame. I managed to find many source codes of CODEC from website.

My problem is I dont know how to call the third-party software from my software project.

I could send you the source codes if they help.

I really need some guidance, hope you can guide, I appreciate. Please

Okay since you are using lame, I will tell you how to use it.
The syntax for using lame.exe is

lame [options] inputfile [outputfile]

So say for example you want to convert the exampleinput.wav to exampleoutput.mp3.

What you have to do is this.
add the line

system( "lame.exe exampleinput.wav exampleoutput.mp3" );

into your program and compile.

put lame.exe and exampleinput.wav to the folder where you have put your program, and run your program. You should find the exampleoutput.mp3 file created inside that folder.

here is a minimal example.

int main()
{
       system( "lame.exe exampleinput.wav exampleoutput.mp3" );
return 0;
}

Compile the above program and put the lame.exe and exampleinput.wav file to the same folder where your program is. Then run it. You should see the results.
For more information refer the usage.txt file that came with the dll file. I have attached it in this post too.

Attachments
% lame [options] inputfile [outputfile]

For more options, just type:
% lame --help


=======================================================================
Constant Bitrate Examples:
=======================================================================
fixed bit rate jstereo 128 kbps encoding:
% lame sample.wav  sample.mp3      

fixed bit rate jstereo 128 kbps encoding, higher quality:  (recommended)
% lame -h sample.wav  sample.mp3      

Fast encode, low quality  (no noise shaping)
% lame -f sample.wav  sample.mp3     

=======================================================================
Variable Bitrate Examples:
=======================================================================
LAME has two types of variable bitrate: ABR and VBR.

ABR is the type of variable bitrate encoding usually found in other
MP3 encoders, Vorbis and AAC.  The number of bits is determined by
some metric (like perceptual entropy, or just the number of bits
needed for a certain set of encoding tables), and it is not based on
computing the actual encoding/quantization error.  ABR should always
give results equal or better than CBR:

ABR:   (--abr <x> means encode with an average bitrate of around x kbps)
lame -h --abr 128  sample.wav sample.mp3


VBR is a true variable bitrate mode which bases the number of bits for
each frame on the measured quantization error relative to the
estimated allowed masking.  VBR is currently under heavy development.
It can on occasion result in too much compression, so it should be
used with a minimum bitrate of 112 kbps.  This will let LAME increase
the bitrate for difficult-to-encode frames, but prevent LAME from
being too aggressive for simple frames:

Variable Bitrate (VBR): (use -V n to adjust quality/filesize)
% lame -h -v -b 112 sample.wav sample.mp3



=======================================================================
LOW BITRATES
=======================================================================
At lower bitrates, (like 24 kbps per channel), it is recommended that
you use a 16 kHz sampling rate combined with lowpass filtering.  LAME,
as well as commercial encoders (FhG, Xing) will do this automatically.
However, if you feel there is too much (or not enough) lowpass
filtering, you may need to try different values of the lowpass cutoff
and passband width (--resample, --lowpass and --lowpass-width options).


=======================================================================
STREAMING EXAMPLES
=======================================================================

% cat inputfile | lame [options] - - > output




=======================================================================
Scripts are included (in the 'misc' subdirectory)
to run lame on multiple files:

bach script:  mlame     Run "mlame -?" for instructions.
sh script:    auenc     Run auenc for instructions
sh script:    mugeco.sh

Pearl script which will re-encode mp3 files and preserve id3 tags:
lameid3.pl 

Windows scripts:
lame4dos.bat  
Lame.vbs   (and an HTML frontend: LameGUI.html)


=======================================================================
options guide:
=======================================================================
These options are explained in detail below.


Quality related:

-m m/s/j/f/a   mode selection
-k             disable all filtering
-d             allow block types to differ between channels
--athonly      ignore psy-model output, only use masking from the ATH
--voice        (obsolete, try --preset voice instead)
--noshort      disable short blocks
-q n           Internal algorithm quality setting 0..9. 
               0 = slowest algorithms, but potentially highest quality
               9 = faster algorithms, very poor quality
-h             same as -q2
-f             same as -q7


Constant Bit Rate (CBR)
-b  n          set bitrate (8, 16, 24, ..., 320)
--freeformat   produce a free format bitstream.  User must also specify
               a bitrate with -b, between 8 and 640 kbps.

Variable Bit Rate (VBR)
-v             VBR
--vbr-old      use old variable bitrate (VBR) routine (default)
--vbr-new      use new variable bitrate (VBR) routine
-V n           VBR quality setting  (0=highest quality, 9=lowest)
-b  n          specify a minimum allowed bitrate (8,16,24,...,320)
-B  n          specify a maximum allowed bitrate (8,16,24,...,320)
-F             strictly enforce minimum bitrate
-t             disable VBR informational tag 
--nohist       disable display of VBR bitrate histogram

--abr n        specify average bitrate desired


Experimental (undocumented):  may work better or worse:

-X n           try different quality measures (when comparing quantizations)
-Y             
-Z             


Operational:

-r              assume input file is raw PCM
-s  n           input sampling frequency in kHz (for raw PCM input files)
--resample n    output sampling frequency
--mp3input      input file is an MP3 file.  decode using mpglib/mpg123
--ogginput      input file is an Ogg Vorbis file.  decode using libvorbis
-x              swap bytes of input file
--scale <arg>   multiply PCM input by <arg>
--scale-l <arg> scale channel 0 (left) input (multiply PCM data) by <arg>
--scale-r <arg> scale channel 1 (right) input (multiply PCM data) by <arg>
-a              downmix stereo input file to mono .mp3
-e  n/5/c       de-emphasis
-p              add CRC error protection
-c              mark the encoded file as copyrighted
-o              mark the encoded file as a copy
-S              don't print progress report, VBR histogram
--strictly-enforce-ISO   comply as much as possible to ISO MPEG spec
--replaygain-fast   compute RG fast but slightly inaccurately (default)
--replaygain-accurate   compute RG more accurately and find the peak sample
--noreplaygain  disable ReplayGain analysis
--clipdetect    enable --replaygain-accurate and print a message whether
                clipping occurs and how far the waveform is from full scale

--decode        assume input file is an mp3 file, and decode to wav.
-t              disable writing of WAV header when using --decode
                (decode to raw pcm, native endian format (use -x to swap))

--ogg           Encode using Ogg Vorbis (.ogg) instead of mp3.



ID3 tagging:

--tt <title>    audio/song title (max 30 chars for version 1 tag)
--ta <artist>   audio/song artist (max 30 chars for version 1 tag)
--tl <album>    audio/song album (max 30 chars for version 1 tag)
--ty <year>     audio/song year of issue (1 to 9999)
--tc <comment>  user-defined text (max 30 chars for v1 tag, 28 for v1.1)
--tn <track>    audio/song track number (1 to 255, creates v1.1 tag)
--tg <genre>    audio/song genre (name or number in list)
--add-id3v2     force addition of version 2 tag
--id3v1-only    add only a version 1 tag
--id3v2-only    add only a version 2 tag
--space-id3v1   pad version 1 tag with spaces instead of nulls
--pad-id3v2     pad version 2 tag with extra 128 bytes
--genre-list    print alphabetically sorted ID3 genre list and exit

Note: A version 2 tag will NOT be added unless one of the input fields
won't fit in a version 1 tag (e.g. the title string is longer than 30
characters), or the '--add-id3v2' or '--id3v2-only' options are used,
or output is redirected to stdout.

OS/2-specific options:
    --priority <type>     sets the process priority


options not yet described:
--nores            disable bit reservoir
--noath            disable ATH
--athlower <n db>  lower the ATH by n db.  
--athshort         use only the ATH for short blocks
--cwlimit <freq>   specify range of tonality calculation
--disptime
--notemp           disable temporal masking

--lowpass
--lowpass-width
--highpass
--highpass-width





=======================================================================
Detailed description of all options in alphabetical order
=======================================================================


=======================================================================
downmix
=======================================================================
-a  

mix the stereo input file to mono and encode as mono.  

This option is only needed in the case of raw PCM stereo input 
(because LAME cannot determine the number of channels in the input file).
To encode a stereo PCM input file as mono, use "lame -m s -a"

For WAV and AIFF input files, using "-m m" will always produce a
mono .mp3 file from both mono and stereo input.


=======================================================================
average bitrate encoding (aka Safe VBR)
=======================================================================
--abr n

turns on encoding with a targeted average bitrate of n kbps, allowing
to use frames of different sizes.  The allowed range of n is 8...320 
kbps, you can use any integer value within that range.





=======================================================================
ATH only
=======================================================================
--athonly

This option causes LAME to ignore the output of the psy-model and
only use masking from the ATH.  (absolute threshold of hearing)

Using --athonly is NOT RECOMMENDED.  It is designed for testing
different ATH curves.



=======================================================================
bitrate
=======================================================================
-b  n

For MPEG-1 (sampling frequencies of 32, 44.1 and 48 kHz)
n =   32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320

For MPEG-2 and MPEG-2.5 (sampling frequencies of 8, 11.025, 
12, 16, 22.05 and 24 kHz)
n = 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160


The bitrate to be used.  Default is 128 kbps MPEG1, 80 kbps MPEG2.

When used with variable bitrate encodings (VBR), -b specifies the
minimum bitrate to use.  This is useful to prevent LAME VBR from
using some very aggressive compression which can cause some distortion
due to small flaws in

Hi, WolfPack, I have tried to implement in my current software followed the instrustions given in your post, appreciate your help.

For your info, I put the code in the OnSave so that the lame exe will be executed whenever I click the button 'Save'.

But, what happens is after I record one sentence, I click 'Save', the software prompt me for save file name and the lame.exe came out very fast and disappeared in just a blink. And, I went to check the folder, I couldnt find any .mp3 file.

I am sorry, I think I must have made some mistakes. I wonder where I did wrong. still searching...

Hi, WolfPack, I have tried to implement in my current software followed the instrustions given in your post, appreciate your help.

For your info, I put the code in the OnSave so that the lame exe will be executed whenever I click the button 'Save'.

But, what happens is after I record one sentence, I click 'Save', the software prompt me for save file name and the lame.exe came out very fast and disappeared in just a blink. And, I went to check the folder, I couldnt find any .mp3 file.

I am sorry, I think I must have made some mistakes. I wonder where I did wrong. still searching...

Well without any code I can't say anything from here. So please post your code. Anyway I have attached a simple script file inside a zip file. You can extract it and put
1. All your wav files
2. Lame.exe
3. the script file Convert_To_MP3.cmd
into a single folder and double click the Script file. All the wav files in that folder will be converted to MP3 files.
If you find that enough for your requirements you can use it freely. Otherwise if you want to find the error in your code, you should post your code.

Hi, WolfPack, I have tried steps as stated in your last post.

But, After I double click the script file, it generated LAME REPORT.txt but I didnt get any .mp3 file converted.

Can I paste the code here? I afraid I will be scolded for the big space wasted.

HI, WolfPack. I mean it generated a file name LAME_REPORT.txt but when I opened, it is empty and nothing inside.

HI, WolfPack. I mean it generated a file name LAME_REPORT.txt but when I opened, it is empty and nothing inside.

:eek: Beats me. It worked at my computer.
Anyway zip your code and attach it in this thread if it is too big. If a wave file is not that big, attach a sample wave file too.

Hi, WolfPack, thanks for your reply.

I have run it successfully with your latest zip file, thanks.

May I ask some more?

1. After the children complete their practices, they will use your codes to compress and then save in a floppy. Then, they bring the floppy to our centre on the next visits. We (Me and the therapist) need to decompress the MP3 file back to Wave file because our software is designed to play the wave.
May I know how can I decompress back? Is it a big problem?

2. I still get the LAME_REPORT.txt which is empty, did I make any mistake? (I am just asking)

Hi, WolfPack, thanks for your reply.

I have run it successfully with your latest zip file, thanks.

You are welcome. Glad it worked.

1. After the children complete their practices, they will use your codes to compress and then save in a floppy. Then, they bring the floppy to our centre on the next visits. We (Me and the therapist) need to decompress the MP3 file back to Wave file because our software is designed to play the wave.
May I know how can I decompress back? Is it a big problem?

No. It is not a problem. I have attached a decoding script in this message. Put it to the folder where the MP3 files and the lame.exe file contains and run as before. You should get the WAV files.

2. I still get the LAME_REPORT.txt which is empty, did I make any mistake? (I am just asking)

No. I put it there so that if there are any errors and messages they will be stored in that file. That was just for debugging puposes. Don't worry about it.

Hi, WolfPack, thank you very much for your reply, appreciate. I hope I can do something to thank you.

I have downloaded your MP to Wav zip file and I can run it successfully to convert MP3 to wave, thanks.

After I converted back to wave file, I tried to play the wave file in the software but it said that "Unsupported Wave File Format". As I said in previous post, We (Me and the therapist) need to decompress the MP3 file back to Wave file because our software is designed to play the wave of mono, 16kHz and 16 bits.

Forgive my stupidness, in my opinion, I get the error message is due to different format in the wave file that written in your codes and wave file format written in my software before.

About the text file, thanks for your explanation, I am just asking. Thanks.

Okay. I think you have to specify the options you want to LAME.exe in order to get the required MP3 and WAV quality. I am not much of an audio expert but I did some changes to the script files. They are attached here. You can try them and see. After running them in the sample file you gave before I got a new WAV file of the following qualities.

Bit Rate 256 kbps
Audio Sample Size 16 bits
Channels 1 ( mono )
Audio Sample Rate 16kHz
Audio Format PCM

If they are not of the required quality, I suggest you read the usage.txt file I attached in a previous reply and see what are the options that need to be set. There is a place called

SET OPTIONS=

in both the script files so you can change them and try. If you run into any difficulty just ask. Tell me how it comes along.

Hi, WolfPack, thanks for your reply.

I have tried for the latest zip file and I still get the same error.

I have checked the wave files recorded by my software before any conversion (I checked by right click Properties -> Summary) . The format details are just the same after the coversion, 256kbps, 16 bit, 16kHz, 1(mono) and PCM.

Since the format are the same, is it that the error is not caused by this reason? What else should I check or do?

Hi, WolfPack,sorry me again.

I searched in web if I can find any reason. This is what I can find. Maybe I am wrong as I am very new to this. Correct me if I am wrong.

It stated that "The wave file saved from one program can be played by other programs (such as media player). However, the wave file saved by other programs may not be opened by this program. That is because this program only check basic wave file structure. It does not support the wave file with optional wave file structure."

I searched in web if I can find any reason. This is what I can find. Maybe I am wrong as I am very new to this. Correct me if I am wrong.

I don't know. You are the expert in audio.

It stated that "The wave file saved from one program can be played by other programs (such as media player). However, the wave file saved by other programs may not be opened by this program. That is because this program only check basic wave file structure. It does not support the wave file with optional wave file structure."

Okay. Try replacing the

SET OPTIONS="--decode"

line in the Convert_MP3_TO_Wav.cmd file with

SET OPTIONS="--decode -t"

.

Hi, WolfPack, thanks for your reply.

I tried to change by right click "edit" and then change 'decode' to 'decode -t'. I wonder if I edit it in wrong way.

I get the error message of " An invalid file handle was associated with wave file 5c.wav"

I will try on other options based on the usage.txt that you sent me before.

Hi, WolfPack, I wonder is it the little and big endian problem? So, I tried to change to "-x" but the problem is still the same.

still searching on how to fix my problem....

Hi, WolfPack, I wonder is it the little and big endian problem? So, I tried to change to "-x" but the problem is still the same.

still searching on how to fix my problem....

No it is not a little or big endian problem. Can you tell me what is the software you are using to read the wav file? maybe i can search for it's valid wav file format.

Hi, WolfPack, thanks for your post.

The software is written in Micorsoft Visual C++ 6.0 to play wave.

After I add "-t", and after I convert the mp3 abck to wave (the wave file is only 19kB after conversion, I guess something wrong), I use WinAmp to play but it said "Invalid File Type".

I also tried to play wave using my C++ software, it said "Unsupported File Format".

The codes are as below:

void CSpeechDlg::OnPlayWave() 
{
    // TODO: Add your control notification handler code here
    //load the file
    CFileDialog openfile(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"Wave File (*.wav)|*.wav|");
 
    if (openfile.DoModal()==IDOK) //prerecorded
    {
        CWave wave;
        wave.Load(openfile.GetFileName());
        if ((wave.GetFormat().nChannels!=1) || (wave.GetFormat().nSamplesPerSec!=16000)
            || (wave.GetFormat().wBitsPerSample!=16) ||(wave.GetFormat().wFormatTag!=1)
            || (wave.m_buffer.GetNumSamples()!=6*16000))
        {
            MessageBox("Unsupported File Format!");
            return;
        }        
         memcpy(wavedata1,wave.GetBuffer(),6*16000*2);
    }
 
    else
    {
        return;
    }
 
    if (openfile.DoModal()==IDOK)
    {
        CWave wave;
        wave.Load(openfile.GetFileName());
        if ((wave.GetFormat().nChannels!=1) || (wave.GetFormat().nSamplesPerSec!=16000)
            || (wave.GetFormat().wBitsPerSample!=16) ||(wave.GetFormat().wFormatTag!=1)
            || (wave.m_buffer.GetNumSamples()!=6*16000))
        {
            MessageBox("Unsupported File Format!");
            return;
        }        
         memcpy(wavedata2,wave.GetBuffer(),6*16000*2);
 
            //open waveform audio for output
        waveform.wFormatTag        =    WAVE_FORMAT_PCM;
        waveform.nChannels        =    1;
        waveform.nSamplesPerSec    =16000;
        waveform.nAvgBytesPerSec=16000*2;
        waveform.nBlockAlign    =2;
        waveform.wBitsPerSample    =16;
        waveform.cbSize            =0;
 
        playtype=2;
 
        if (waveOutOpen(&hWaveOut,WAVE_MAPPER,&waveform,(DWORD)this->m_hWnd,NULL,CALLBACK_WINDOW)) {
            MessageBox("Wave Out Error\n");    }
    }        
    //play both of them at one time
}
This article has been dead for over six months. Start a new discussion instead.