Click here to Skip to main content
15,918,596 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
I am developing an application in Vb.net in which I take a 16-bit mono wav file and I am using two buttons. The first button is for reading the wav file (including its header values and samples). The header values are being read in text-boxes (that I have placed on my form) and the sample values are being written (in their integer form as positive and negative values) in a textfile. Basically my Textfile works as a database for wav samples. The second button is for writing a new wav file, which will be the same as original (since, at this point I am not processing the sample values).
The problem is that I am not getting how to write the code for my second button. Any help or suggestions would be most appreciated. Thanks in advance.
Posted

1 solution

You have everything you need in this artice: Concatenating Wave Files Using C# 2005[^]. You just have to fill the stream with your sample data from the text file instead.
 
Share this answer
 
Comments
Member 8244358 23-May-12 2:11am    
thanks, i am already doing that. Do i need to convert the samples into little endian format? if yes, then how can i accomplish that?
Zoltán Zörgő 23-May-12 12:08pm    
Yes, you need little endian format. You can use this:
byte[] INT2LE(int data)
{
byte[] b = new byte[4];
b[0] = (byte)data;
b[1] = (byte)(((uint)data >> 8) & 0xFF);
b[2] = (byte)(((uint)data >> 16) & 0xFF);
b[3] = (byte)(((uint)data >> 24) & 0xFF);
return b;
}

https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
Member 8244358 24-May-12 6:07am    
ok..i'll give it a try then.
Zoltán Zörgő 27-May-12 13:33pm    
Any progress?
Member 8244358 28-May-12 12:40pm    
actually i got a new idea where i m converting array of Short values into a byte array, and then writing these byte values into a memory stream. The final wav file can be created using the memory stream. :)
But I appreciate your suggestion. it was of great help too. thanks a lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900