0

Hi, WolfPack, thanks for your reply, appreciate.

I have added the above codes (the play wave button) but there are 3 compile errors.

error C2440: 'initializing' : cannot convert from 'class CString' to 'char *'
error C2440: 'initializing' : cannot convert from 'class CString' to 'char *'
fatal error C1004: unexpected end of file found

I will try to search if I could fix the error.

0

Try this

char* mp3FileName  = (LPCTSTR)(openfile.GetFileName());
	char* waveFileName = (LPCTSTR)(openfile.GetFileName());
0

Hi, WolfPack, thanks for your reply, appreciate.

I have tried to replace the two lines as above, but the compile errors are still the same.

0

Hi, WolfPack, thanks for your reply, appreciate.

I have tried to replace the two lines as above, but the compile errors are still the same.

Okay Try to see if you can find it yourself. I don't have MSDN or MFC at home. Will look at it tomorrow. Good luck. Hopefully someone else will help.

0

Hi, WolfPack, thanks for your reply.

OK, I will try my best to find out and will tell you how I am going.

0

Hi, WolfPack.

It stated that
"No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called"

So, I tried to include afx.h but it still didnt help. Will keep on searching

0

Hi, WolfPack, May I ask one thing?

Where can I set the bit rate in the lame.exe?

=======================================================================
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 the psycho-acoustic model.

=======================================================================
max bitrate
=======================================================================
-B n

see also option "-b" for allowed bitrates.

Maximum allowed bitrate when using VBR/ABR.

Using -B is NOT RECOMMENDED. A 128 kbps CBR bitstream, because of the
bit reservoir, can actually have frames which use as many bits as a
320 kbps frame. ABR/VBR modes minimize the use of the bit reservoir, and
thus need to allow 320 kbps frames to get the same flexability as CBR
streams.

You can set it by changing this line in the software.

sprintf (command, "%s\\lame.exe -b 96\"%s\" \"C:\\%s.mp3\"", FilePath, filename, filename);
0

Hi, WolfPack, thanks for your reply.

Sorry, I still dont understand. I thought the codes in your post and the codes I used yesterday are different. Forgive me if I am wrong. The codes that worked yesterday is

sprintf (command, "%s \"%s\" \"C:\\Debug\\%s.mp3\"", "lame.exe" , filename, filename );

And, How to know it is using what bit rate? And How to change the bit rate with the sentence above?

0

Hi, WolfPack, thanks for your reply.

Sorry, I still dont understand. I thought the codes in your post and the codes I used yesterday are different. Forgive me if I am wrong. The codes that worked yesterday is

And, How to know it is using what bit rate? And How to change the bit rate with the sentence above?

What I marked in red were the changes you should make to have a bit rate of 96kbps. So your new command should be

sprintf (command, "%s -b 96\"%s\" \"C:\\Debug\\%s.mp3\"", "lame.exe" , filename, filename );
0

Hi, WolfPack, thanks for your explanation. Thank you very much.

I still cant figure out the decompression part errors. Still searcing on web if others have faced the same problem before. Will tell you how I am going.

Thank you.

0

Try this. My MFC is a bit rusty.

//load the file
if (openfile.DoModal()==IDOK) //prerecorded
{
    CWave wave;
    CString mp3FileName  = openfile.GetFileName();
    CString waveFileName  = openfile.GetFileName();
    waveFileName.Delete( waveFileName.ReverseFind( '.' ), waveFileName.GetLength() + 1 );
    waveFileName.Append( ".wav" );

    char FilePath[ MAX_PATH ] = "";
    DWORD dwLength = GetModuleFileName(NULL, FilePath, MAX_PATH);
    if (dwLength)
    {
        while (dwLength && FilePath[dwLength] != '\\')
            dwLength--;

        if (dwLength)
            FilePath[dwLength + 1] = '\0';
    }

    char command[MAX_PATH] = "";
    sprintf (command, "%s\\lame.exe --decode \"%s\" \"%s\"", FilePath, (LPCTSTR)mp3FileName, (LPCTSTR)waveFileName);

    system( command );
        wave.Load((LPCTSTR)waveFileName);
0

Hi, WolfPack, thanks for your reply, appreciate.

I have replaced the codes with the codes above. But I get 6 compile errors.

error C2065: 'openfile' : undeclared identifier
error C2228: left of '.DoModal' must have class/struct/union type
error C2228: left of '.GetFileName' must have class/struct/union type
error C2228: left of '.GetFileName' must have class/struct/union type
error C2039: 'Append' : is not a member of 'CString'
d:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
fatal error C1004: unexpected end of file found
Error executing cl.exe.

SpeechDlg.obj - 6 error(s), 0 warning(s)

0

Hi, WolfPack, thanks for your reply, appreciate.

I have replaced the codes with the codes above. But I get 6 compile errors.

error C2065: 'openfile' : undeclared identifier

Looks like you have deleted the openfile declaration. See what happened to it. You should be able to correct errors like this.

0

Hi, WolfPack, thanks for your reply.

Sorry, my mistake. I still have two errors.

error C2039: 'Append' : is not a member of 'CString'
d:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
fatal error C1004: unexpected end of file found

Sorry, my programming knowledge is very limited. I understand that I should initialize Append under CString constructor, is it?

0

Hi, WolfPack, thanks for your reply.

Sorry, my mistake. I still have two errors.

error C2039: 'Append' : is not a member of 'CString'
d:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
fatal error C1004: unexpected end of file found

Sorry, my programming knowledge is very limited. I understand that I should initialize Append under CString constructor, is it?

Looks like Append is not supported in Visual Studio 6.0.
Replace the line with Append with

waveFileName +=  ".wav";

If you still find that unexpected end of file found error, I think it is because of a missing semicolon or something. You will have to find that yourself.

0

Hi, WolfPack, thanks for reply.

I have managed to compile it with error free, thanks alot!

But, When I click "Play wave", the software prompts to open MP3 file.

As I said in previous posts, When the child bring the floppy disk back to centre, the therapist will click button "play wave". This button will prompt twice for each click. First prompt is to open wave recorded by therapist's own voice and the second prompt is to open wave recorded by children at home.

Currently, the software prompts for MP3 file format directly. Therefore, I couldnt open the file for pre-recorded wave file.

My original codes at PlayWave contains this:

CFileDialog openfile(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"Wave File (*.wav)|*.wav|");

If I put it before your MP3 codes, it caused this error: error C2086: 'openfile' : redefinition

0

First prompt is to open wave recorded by therapist's own voice and the second prompt is to open wave recorded by children at home.

Right now what the Play button does is ask for a MP3 file and convert it to wav and load the new wave file. This is to select the MP3 file recorded by the children at home. It is prompting for an MP3 file because that is the format they have recorded it. I did that because you wanted a way to directly convert the MP3 file to wave at the Play Wave button.

As for the wave file pre-recorded by the therapist, since it a wave file, you should create another button to play that file, rather than using the same file usedto load the mp3 file.
For Example
"Play MP3" for the file recorded by the children
"Play Wav" for the file recorded by the therapist.

0

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

I have tried your approach. I have managed to compile in error free. But, I think I have did something wrong because the MVC++6.0 closed itself after I clicked on the Play wave and Play MP3 buttons. I will try on and will tell you how I am going.

My codes are as below:

void CSpeechDlg::OnPlayWave()
{
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;
}
}
void CSpeechDlg::OnPlayMP3()
{
CFileDialog openfile(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,"MP3 File (*.mp3)|*.mp3|");
if (openfile.DoModal()==IDOK) //prerecorded
{
CWave wave;
CString mp3FileName  = openfile.GetFileName();
CString waveFileName  = openfile.GetFileName();
waveFileName.Delete( waveFileName.ReverseFind( '.' ), waveFileName.GetLength() + 1 );
waveFileName +=  ".wav";
char FilePath[ MAX_PATH ] = "";
DWORD dwLength = GetModuleFileName(NULL, FilePath, MAX_PATH);
if (dwLength)
{
while (dwLength && FilePath[dwLength] != '\\')
dwLength--;
if (dwLength)
FilePath[dwLength + 1] = '\0';
}
char command[MAX_PATH] = "";
sprintf (command, "%s\\lame.exe --decode \"%s\" \"%s\"", FilePath, (LPCTSTR)mp3FileName, (LPCTSTR)waveFileName);
system( command );
wave.Load((LPCTSTR)waveFileName);
}
// TODO: Add your control notification handler code here
//load the file
// TODO: Add your control notification handler code here
}

Edited by happygeek: fixed formatting

0

Hi, WolfPack.

I think the problem was with the exception Breakpoint. When I play the mp3, a breakpoint has been reached. This is the little information I can get for this moment

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.