![]() |
|
#1
|
|||
|
|||
Saving a .wav fileHi,
I am trying to create a CLI to record and save audio to a wav file. I am successful in recording audio but am not able to save the audio. Here are the files I used. These are open source. www.codeproject.com juhara.com( Explaination of code ) Here is my main.cpp code The second main.cpp directly records the audio to buffer and plays it back. I need to use sleep so that it can record "time" seconds. Please help me out. Thanks Nikhil CPP / C++ / C Code:
CPP / C++ / C Code:
|
|||
|
#2
|
||||
|
||||
Re: Help with saving a wav file**Urgent**Is CreateFile returning a valid file handle? I don't suppose that you would ever know, since you're not checking it.
If this is so urgent, I'd recommend that you at least ASK ONE QUESTION. Something other than the implied "need for help." Imagine that you are dialing an automated 911 service (to receive "urgent assistance"). The voice at the other end of the line says: "911 state your emergency" That's what this forum does. We're waiting to hear from those who have problems. How you present your problem is important. What you've done is provided an information dump and a very ambiguous statement of your emergency. You apparently are not "saving a wav file." We don't even know if your code compiles cleanly or if you have any runtime exceptions. We don't even know WHAT the urgency is. Is it a matter of a few minutes, hours, days? Do you even have time to wait for the ambulance to arrive? If you believe that you need an ambulance, perhaps you should at least give clear directions as to WHERE YOU ARE so that the ambulance can find you! MxB |
|
#3
|
|||
|
|||
Re: Help with saving a wav file**Urgent**Thanks Mexican Bob.
Create File is able to create a new file and load the header into it. I do not know if its returning a valid handle. I do know that my statement of urgency was vague. I think I do not have to explain myself to everyone in this forum. I just want people to know that its a little urgent. And if they know anything about what I am having a problem, let me know.That's all I have to communicate. You seem to have good communication skills. Keep it up. I actually attached two links where you could download my project. They are not working. I am sorry about that. I did not check. rapidshare.com rapidshare.com/files/206200528/VoiceRecording.rar.htm As I have told you before, I am able to record and play back audio. I am not able to save it to a file. NO ERRORS. Its not saving. Thats all. Do not worry about my urgency, if you can, help me out. I placed WriteFile in VoicePlaying.cpp file Thanks anyways Nikhil |
|
#4
|
|||
|
|||
Re: Help with saving a wav file**Urgent**Quote:
In main.cpp: CPP / C++ / C Code:
In VoiceRecording.h: CPP / C++ / C Code:
In VoiceBase.h: CPP / C++ / C Code:
Bottom line: After the header, the number of bytes that it writes is equal to the size of a pointer to char (probably 4 unless you are compiling with a 64-bit compiler on a 64-bit operating system, in which case it will probably be 8). The size of the header is 44 bytes, right? What is the size of audio.wav after the program finishes? Regards, Dave Last edited by davekw7x : 07-Mar-2009 at 14:16.
|
|
#5
|
|||
|
|||
Re: Help with saving a wav file**Urgent**Hi Dave,
Thank you for your reply. I have been working on that buffer since yesterday. I have changed a part of the code. rapidshare.com/files/206565930/Voice.rar.html I have put the WriteFile code in VoicePlaying.cpp. I assume that the buffer is cleared after it plays and as such I wanted to access that buffer before its cleared. I get no errors. I recorded for 60 seconds and it gave me a file size of 937KB. I thought it was recording but when I try to play it, its not working. I think my header is corrupted. I am currently working to get the header right. ![]() img9.imageshack.us/img9/9392/72813742.jpg I opened the wav file using HEXEDIT and am not sure of the header there. The other set of bytes show there is some data ( I do not know how to read wav files) chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm#download ( place www. before the link) Thanks and let me know Nikhil P.S. I just used a hex editor and changed the first 44 bytes of the recorded file to a sample wav file ( downloaded from internet) and I was able to play it. Its obvious that the header is corrupted. |
|
#6
|
|||
|
|||
Re: Help with saving a wav file**Urgent**Quote:
For single-channel recording: (number of bits) = (number of seconds) times (samples per second) times (bits per sample) Your "blocksize" is the number of data bytes, so you divide the number of bits by eight, right? Maybe you could go back and change the following section in Main.cpp: CPP / C++ / C Code:
Or some such thing. For ten seconds recording (single channel), blocksize = 160,000 and the file size will be exactly 160,044 bytes. Regards, Dave |
|
#7
|
|||
|
|||
Re: Help with saving a wav file**Urgent**Hi Dave,
I changed the below in my VoicePlaying.cpp and it worked. I was supposed to look at the header buffer pointer and size of it. CPP / C++ / C Code:
Its working perfectly fine. Thanks a lot !! Nikhil |
|
#8
|
|||
|
|||
Re: Help with saving a wav file**Urgent**Hi,
I saw your thread and it looked like it could be a life saver.. Currrently i'm doing a project on speech recognition and for a few days now I'm battling trying to sharpen me C++ programming.. I'm now down to the programming part which i'm not too good at and I really need help acquiring the source codes needed for recording and saving a wave file using c++. I see you did the same thing so any help you could render would be GREATLY APPRECIATED! Gratefully, kwesi |
|
#9
|
|||
|
|||
Re: Help with saving a wav file**Urgent**Hi Kwesi,
Could you give me more information about your project. I mean, do you need a CLI or a GUI of the program. I haven't made an EXE of the code as I need to use it with another program. Let me know and I shall send you the code Nikhil |
|
#10
|
|||
|
|||
Re: Help with saving a wav file**Urgent**Hi,
Thank you for your support. Kindly check this thread. I need help with creating a Win32 console output which can be executed on any computer. http://www.gidforums.com/showthread.php?p=80877 Thanks Nikhil |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Saving http responses in a file | thisisme | C Programming Language | 2 | 09-Sep-2008 21:01 |
| Saving widget graphics | silverstar | FLTK Forum | 3 | 12-Jun-2007 14:45 |
| Saving 2D array of doubles to text for MS Excel | markiebbc | MS Visual C++ / MFC Forum | 3 | 20-Aug-2006 15:45 |
| STL troubles saving and finding | Clive73 | C++ Forum | 2 | 19-May-2005 09:50 |
| saving html text | dopee | MySQL / PHP Forum | 1 | 17-Jan-2005 05:15 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The