| | |
Splitting of wav files
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2008
Posts: 17
Reputation:
Solved Threads: 0
Hi,
i am working on splitting .wav files with bitrate 13 kbps,mono,
sample rate 8 khz and audio format GSM 6.10.my code is like this
private void SplitFile(string FileInputPath, string FolderOutputPath, int OutputFiles)
{
string inputFile = FileInputPath; // Substitute this with your Input File
FileStream fs = new FileStream(inputFile, FileMode.Open, FileAccess.Read);
int numberOfFiles = Convert.ToInt32(OutputFiles);
int sizeOfEachFile = (int)Math.Ceiling((double)fs.Length / numberOfFiles);
for (int i = 1; i <= numberOfFiles; i++)
{
string baseFileName = Path.GetFileNameWithoutExtension(inputFile);
string extension = Path.GetExtension(inputFile);
FileStream outputFile = new FileStream(Path.GetDirectoryName(inputFile) + "\\" + baseFileName + "." + i.ToString().PadLeft(5, Convert.ToChar("0")) + "." + extension, FileMode.Create, FileAccess.Write);
int bytesRead = 0;
byte[] buffer = new byte[sizeOfEachFile];
if ((bytesRead = fs.Read(buffer, 0, sizeOfEachFile)) > 0)
{
outputFile.Write(buffer, 0, bytesRead);
}
outputFile.Close();
}
fs.Close();
using this code the second splitting file is not playing and giving error like Codec data corrupted error.
i am working on splitting .wav files with bitrate 13 kbps,mono,
sample rate 8 khz and audio format GSM 6.10.my code is like this
private void SplitFile(string FileInputPath, string FolderOutputPath, int OutputFiles)
{
string inputFile = FileInputPath; // Substitute this with your Input File
FileStream fs = new FileStream(inputFile, FileMode.Open, FileAccess.Read);
int numberOfFiles = Convert.ToInt32(OutputFiles);
int sizeOfEachFile = (int)Math.Ceiling((double)fs.Length / numberOfFiles);
for (int i = 1; i <= numberOfFiles; i++)
{
string baseFileName = Path.GetFileNameWithoutExtension(inputFile);
string extension = Path.GetExtension(inputFile);
FileStream outputFile = new FileStream(Path.GetDirectoryName(inputFile) + "\\" + baseFileName + "." + i.ToString().PadLeft(5, Convert.ToChar("0")) + "." + extension, FileMode.Create, FileAccess.Write);
int bytesRead = 0;
byte[] buffer = new byte[sizeOfEachFile];
if ((bytesRead = fs.Read(buffer, 0, sizeOfEachFile)) > 0)
{
outputFile.Write(buffer, 0, bytesRead);
}
outputFile.Close();
}
fs.Close();
using this code the second splitting file is not playing and giving error like Codec data corrupted error.
•
•
Join Date: Jul 2009
Posts: 903
Reputation:
Solved Threads: 144
0
#10 Oct 9th, 2009
This download demonstrates how to read/write wave file headers: Wave File Headers...
![]() |
Other Threads in the C# Forum
- Previous Thread: Counting instances of a value in DB
- Next Thread: Dockable windows (just like in Visual Stusio)
| Thread Tools | Search this Thread |
.net access algorithm array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop picturebox pixelinversion platform post programming radians regex remote remoting resourcefile richtextbox server sleep socket sql statistics stream string system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml






