Click here to Skip to main content
15,893,668 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: build a c++ app in managed c++ ide Pin
Nuri Ismail23-Sep-09 2:44
Nuri Ismail23-Sep-09 2:44 
GeneralRe: build a c++ app in managed c++ ide Pin
SummerBulb23-Sep-09 3:06
SummerBulb23-Sep-09 3:06 
GeneralRe: build a c++ app in managed c++ ide Pin
Nuri Ismail23-Sep-09 3:24
Nuri Ismail23-Sep-09 3:24 
GeneralRe: build a c++ app in managed c++ ide Pin
SummerBulb23-Sep-09 4:12
SummerBulb23-Sep-09 4:12 
QuestionInsert blank line in text file Pin
choramale_vs23-Sep-09 2:30
choramale_vs23-Sep-09 2:30 
AnswerRe: Insert blank line in text file Pin
Roger Allen23-Sep-09 2:41
Roger Allen23-Sep-09 2:41 
QuestionCopy Large string to VARIANT data type Pin
Pryabu23-Sep-09 1:20
Pryabu23-Sep-09 1:20 
AnswerRe: Copy Large string to VARIANT data type Pin
theCPkid23-Sep-09 1:32
theCPkid23-Sep-09 1:32 
AnswerRe: Copy Large string to VARIANT data type Pin
KarstenK23-Sep-09 1:58
mveKarstenK23-Sep-09 1:58 
AnswerRe: Copy Large string to VARIANT data type Pin
CPallini23-Sep-09 2:19
mveCPallini23-Sep-09 2:19 
Questionone doubt Pin
programmer20223-Sep-09 0:59
programmer20223-Sep-09 0:59 
AnswerRe: one doubt Pin
Maximilien23-Sep-09 1:09
Maximilien23-Sep-09 1:09 
AnswerRe: one doubt Pin
theCPkid23-Sep-09 1:40
theCPkid23-Sep-09 1:40 
AnswerRe: one doubt Pin
KarstenK23-Sep-09 1:55
mveKarstenK23-Sep-09 1:55 
AnswerRe: one doubt Pin
jon_fallon23-Sep-09 2:25
jon_fallon23-Sep-09 2:25 
GeneralRe: one doubt Pin
Nuri Ismail23-Sep-09 3:02
Nuri Ismail23-Sep-09 3:02 
AnswerRe: one doubt Pin
Richard MacCutchan23-Sep-09 3:02
mveRichard MacCutchan23-Sep-09 3:02 
QuestionRotate Metafile displayed in a Static Control Pin
Erik22-Sep-09 23:47
Erik22-Sep-09 23:47 
QuestionWhy Messagebox display twice It's Urgent Pin
jadhavjitendrar22-Sep-09 22:59
jadhavjitendrar22-Sep-09 22:59 
AnswerRe: Why Messagebox display twice It's Urgent [modified] PinPopular
CPallini22-Sep-09 23:39
mveCPallini22-Sep-09 23:39 
AnswerRe: Why Messagebox display twice It's Urgent Pin
theCPkid23-Sep-09 1:25
theCPkid23-Sep-09 1:25 
AnswerRe: Why Messagebox display twice It's Urgent Pin
David Crow23-Sep-09 4:41
David Crow23-Sep-09 4:41 
QuestionHow to write mic data to .wav file ? Pin
Souldrift22-Sep-09 22:18
Souldrift22-Sep-09 22:18 
AnswerRe: How to write mic data to .wav file ? Pin
Souldrift22-Sep-09 22:39
Souldrift22-Sep-09 22:39 
Well, nevermind. I just fixed it Smile | :) .

Modified the save function like this:

bool save()
{
	int bitsPerSample = 16;
	int subchunk1size = 16;
	int numChannels = 1;
	int subchunk2size = WaveInHdr.dwBufferLength*numChannels;
	int chunksize = 36+subchunk2size;
	int audioFormat = 1;
	int byteRate = sampleRate*numChannels*bitsPerSample/8;
	int blockAlign = numChannels*bitsPerSample/8;


	fstream myFile ("test.wav", ios::out | ios::binary);

	// write the wav file per the wav file format
	myFile.seekp (0, ios::beg); 
	myFile.write ("RIFF", 4);					// chunk id
	myFile.write ((char*) &chunksize, 4);	        	// chunk size (36 + SubChunk2Size))
	myFile.write ("WAVE", 4);					// format
	myFile.write ("fmt ", 4);					// subchunk1ID
	myFile.write ((char*) &subchunk1size, 4);			// subchunk1size (16 for PCM)
	myFile.write ((char*) &audioFormat, 2);			// AudioFormat (1 for PCM)
	myFile.write ((char*) &numChannels, 2);			// NumChannels
	myFile.write ((char*) &sampleRate, 4);			// sample rate
	myFile.write ((char*) &byteRate, 4);			// byte rate (SampleRate * NumChannels * BitsPerSample/8)
	myFile.write ((char*) &blockAlign, 2);			// block align (NumChannels * BitsPerSample/8)
	myFile.write ((char*) &bitsPerSample, 2);			// bits per sample
	myFile.write ("data", 4);					// subchunk2ID
	myFile.write ((char*) &subchunk2size, 4);			// subchunk2size (NumSamples * NumChannels * BitsPerSample/8)
		
	myFile.write (WaveInHdr.lpData, WaveInHdr.dwBufferLength);	// data

	return true;
}


Cheers

Souldrift
QuestionString split functionality Pin
NarVish22-Sep-09 21:07
NarVish22-Sep-09 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.