Compression/Decompression Wave File and MP3

This is a discussion on Compression/Decompression Wave File and MP3 within the Projects and Job Recruitment forums, part of the Community Boards category; Hi, Anonytmouse, thanks for your post, appreciate. I have read the manual pdf file but I still dont know where ...

  1. #16
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Hi, Anonytmouse, thanks for your post, appreciate.

    I have read the manual pdf file but I still dont know where can I write any command line. I run the exe but it disappeared in blink and I couldnt manage to write any command line on it. Therefore, I cant test whether the command line works for me or not.

    I have listened to the examples of male and female for the encoding quality. It is good enough for our application.

    Please forgive me if I did any mistake.
    Last edited by cindy_16051988; 04-25-2006 at 10:58 PM. Reason: spelling

  2. #17
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    To run the exe file,
    - Go to Start -> Run...
    - At the prompt, type "command" which will open an MS DOS command prompt.
    - type "cd" and type the directory the .exe is in
    - At the prompt, type the exe's name, followed by the parameters you want. Parameters are usually separated by spaces.
    - Press Enter. Yay.

  3. #18
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Quote Originally Posted by citizen
    To run the exe file,
    - Go to Start -> Run...
    - At the prompt, type "command" which will open an MS DOS command prompt.
    - type "cd" and type the directory the .exe is in
    - At the prompt, type the exe's name, followed by the parameters you want. Parameters are usually separated by spaces.
    - Press Enter. Yay.
    Sorry, please forgive me, I still could not run the exe file, sorry, please forgive me.
    I attached the file as I could not figure out where I did wrong.
    Attached Images Attached Images  

  4. #19
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Run "cmd" instead of "command" and then type:
    Code:
    cd "D:\Program Files\Speex"
    This should get you to the correct directory where you can try out command lines.

  5. #20
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Quote Originally Posted by anonytmouse
    Run "cmd" instead of "command" and then type:
    Code:
    cd "D:\Program Files\Speex"
    This should get you to the correct directory where you can try out command lines.
    Hi, Anonytmouse, thank you for your post. I am now manage to go in the correct directory and will try out the command lines. Thanks.

  6. #21
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Hi, I have tried to type "speexenc -w wave file 1c.wav wave file 1c.spx" but nothing happen.

    From my understanding of the command lines in the web, there are many options, right? I f I need to use more than one, should I implement it one by one or together?

    What is expected to be happened if I get the command line functions correctly?

    You mean I have to test one option by one option? Sorry, I know I am slow in learning but I try my best to do it, please forgive me.
    Last edited by cindy_16051988; 04-26-2006 at 04:07 AM. Reason: spelling

  7. #22
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You need to use quotes around file names (which my example should have included). Try this command line:
    Code:
    speexenc "wave file 1c.wav" "wave file 1c.spx"
    and this command line for decompression:
    Code:
    speexdec "wave file 1c.spx" "decoded wave file 1c.wav"
    I don't think you'll need to use any options, but if so, they go before the file names:
    Code:
    speexenc -w "wave file 1c.wav" "wave file 1c.spx"
    You can use multiple options:
    Code:
    speexenc -V -w "wave file 1c.wav" "wave file 1c.spx"
    If it works, you will get a message similar to:
    Code:
    Encoding 8000 Hz audio using narrowband mode (mono)
    and the output file will apear in the directory.
    Last edited by anonytmouse; 04-26-2006 at 09:57 AM.

  8. #23
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Hi, Anonytmouse, thank you so much, I have managed to use the command lines correctly. The program converted wave file to mp3 and vice versa successfully. Thanks so much.

    How could I call the encode and decode function from my software itself?

    May I ask? Is it possible to directly convert the wave to mp3 when the children click the button "save"? I worried that the small children dont know how to do this and that. We hope to make it as simple as possible. so that they are motivated to use this software.

  9. #24
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Hi, Could you tell me how to integrate the speex into my software? How to call the speex from my software? Please help, please. I will try my best, please

  10. #25
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    You may want to try something like:

    Code:
    STARTUPINFO si = {0};
    PROCESS_INFORMATION pi;
    si.cb = sizeof(STARTUPINFO);
    
    CreateProcess("speex",NULL,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);

  11. #26
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I created a function for you that will call speexenc. It needs to be pasted in your source code above the save function.
    Code:
    /*
     * Helper function that finds the last instance of a character in a string.
     */
    LPTSTR FindLastOf(LPCTSTR haystack, TCHAR needle)
    {
    	int i = lstrlen(haystack) - 1;
    
    	while (i > 0)
    	{
    		if (haystack[i] == needle)
    			return (LPTSTR) &haystack[i];
    
    		i--;
    	}
    
    	return (LPTSTR) &haystack[0];
    }
    
    
    /*
     * Function to call speexenc.
     * First argument is the location of the .wav file. eg. "C:\\Temp\\wave file.wav"
     * Second argument is output directory. No trailing backslash should be used. eg. "A:"
     */
    BOOL SpeexEncode(LPCTSTR szInputFile, LPCTSTR szOutputPath)
    {
    	STARTUPINFO         si = { sizeof(STARTUPINFO) };
    	PROCESS_INFORMATION pi = { 0 };
    	TCHAR               szCommandLine[MAX_PATH * 4 + 100];
    	TCHAR               szPath[MAX_PATH];
    	TCHAR               szOutputFile[MAX_PATH];
    	TCHAR*              p;
    
    	/* Get the path of the currently running executable
    	 * which is where we expect speexenc to be located. */
    	GetModuleFileName(NULL, szPath, MAX_PATH);
    	p = FindLastOf(szPath, TEXT('\\')); p[0] = TEXT('\0');
    
    	/* Get the input file name (excluding path) so that we can
    	 * use the same file name for the output as the input. */
    	p = FindLastOf(szInputFile, TEXT('\\'));
    	lstrcpy(szOutputFile, p + 1);
    
    	/* Change extension from .wav to .spx */
    	p = FindLastOf(szOutputFile, TEXT('.'));
    	lstrcpy(p, TEXT(".spx"));
    
    	/* Create command line. */
    	wsprintf(szCommandLine, TEXT("\"%s\\speexenc\" \"%s\" \"%s\\%s\""),
    	         szPath, szInputFile, szOutputPath, szOutputFile);
    
    	/* Execute command line. */
    	CreateProcess(NULL, szCommandLine, NULL,
    	              NULL, FALSE, 0, NULL, NULL, &si, &pi);
    
    	/* Uncomment this line, if you want to pause here while the command completes. */
    	// WaitForSingleObject(pi.hProcess, INFINITE);
    
    	/* Uncomment this line for debugging, it will show the exact command line used. */
    	// MessageBox(NULL, szCommandLine, NULL, 0);
    
    	/* Cleanup. */
    	CloseHandle(pi.hThread);
    	CloseHandle(pi.hProcess);
    
    	return TRUE;
    }
    You then need to call this function from your save function. It takes two arguments:
    - The first is the location of the input wave file. That is, the path where the program has saved the wave recording.
    - The second is the output directory. This may be a constant such as "A:" or a location provided by the user.

    It is a impossible to provide the exact details of the call without seeing the save function code. If you can't work it out and it is possible, you could post the save function code, or attach the entire project.

  12. #27
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Hi, Anonytmouse, thank you for your reply.

    I have tried to put the codes at the location But I have two compile errors, I will search if I could fix it.

    error C2601: 'FindLastOf' : local function definitions are illegal
    error C2601: 'SpeexEncode' : local function definitions are illegal

  13. #28
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You're trying to put them inside another function which is illegal. You need to paste them outside any function.
    Last edited by anonytmouse; 04-27-2006 at 09:19 PM.

  14. #29
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Hi, I think I must put the codes after the button "save wave", isnt it?

    Code:
    void CSpeechDlg::OnSaveWave() 
    {
    	// TODO: Add your control notification handler code here
    	
    	savebuffer.save();
    	
    }
    I have tried to put it in another location but the problem still there.
    I have attached it.
    Attached Files Attached Files

  15. #30
    Registered User
    Join Date
    Apr 2006
    Posts
    28
    Hi, I think I should attache the cpp file without adding the speex codes .

    This is the original cpp file without adding any codes of speex purpsoe.
    Attached Files Attached Files

Page 2 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening an MP3 file for bit access
    By gaza2k1 in forum C Programming
    Replies: 13
    Last Post: 02-24-2008, 09:08 PM
  2. mp3 file renamer
    By Loic in forum C++ Programming
    Replies: 6
    Last Post: 10-17-2007, 01:52 PM
  3. MP3 file searching question
    By panfilero in forum C Programming
    Replies: 4
    Last Post: 11-27-2005, 01:19 PM
  4. Edit mp3 File Names
    By willc0de4food in forum C Programming
    Replies: 20
    Last Post: 04-11-2005, 12:45 AM
  5. wave player or mp3 player using C
    By lliero in forum C Programming
    Replies: 5
    Last Post: 02-27-2002, 11:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21