国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
串聯(lián)波文件使用CSharp 2005
RIFF file starts out with a file header followed by a sequence of data chunks. A WAVE file is often just a RIFF file with a single "WAVE" chunk which consists of two sub-chunks -- a "fmt" chunk specifying the data format and a "data" chunk containing the actual sample data. Call this form the "Canonical form".
該WAVE文件格式是微軟的多媒體文件的存儲(chǔ)釜山國(guó)際電影節(jié)規(guī)范的子集。阿RIFF格式的文件開始進(jìn)行,由一組數(shù)據(jù)塊序列后一個(gè)文件頭。波形文件通常只是一個(gè)單一的“浪潮”一塊它由兩個(gè)分塊-一個(gè)“禁產(chǎn)條約”塊指定數(shù)據(jù)格式和“數(shù)據(jù)”塊包含實(shí)際示例數(shù)據(jù)RIFF格式文件。稱這種形式的“典型”的形式。
The main idea is to create only one header for all WAV files that you want to concatenate and then write data of each file in a single file.
其主要思想是只能創(chuàng)建一個(gè)WAV文件頭的所有文件,您要連接,然后寫在每一個(gè)文件文件中的數(shù)據(jù)。
Wave file headers follow the standard RIFF file format structure. The first 8 bytes in the file are the standard RIFF chunk header which have a chunk ID of "RIFF" and a chunk size equal to the file size minus the 8 bytes used by the header.
波形文件頭遵循標(biāo)準(zhǔn)RIFF格式的文件格式結(jié)構(gòu)。前8個(gè)字節(jié)的文件是標(biāo)準(zhǔn)的釜山國(guó)際電影節(jié)塊頭有一大塊的“釜山國(guó)際電影節(jié)ID”和1塊的大小等于文件大小減去八日頭使用的字節(jié)。
So we need to know the total length of all files to define ChunkSize and read NumChannels, SampleRate and BitsPerSample.
因此,我們需要知道的所有文件的總長(zhǎng)度來定義ChunkSize和閱讀NumChannels,采樣頻率和bitspersample的。
private void WaveHeaderIN(string spath)
{
FileStream fs = new FileStream(spath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
length = (int)fs.Length - 8;
fs.Position = 22;
channels = br.ReadInt16();
fs.Position = 24;
samplerate = br.ReadInt32();
fs.Position = 34;
BitsPerSample = br.ReadInt16();
DataLength = (int)fs.Length - 44;
br.Close ();
fs.Close();
}

As we know channels are stored in the WAV header in byte number 22, we move the current position of the file to this location and the size of it is 2 bytes so we use br.ReadInt16() to read only 2 bytes and so on....
我們知道渠道均是在字節(jié)數(shù)22 WAV文件頭存儲(chǔ),我們將文件的當(dāng)前位置,這個(gè)位置和它的大小為2字節(jié),因此我們使用br.ReadInt16()為只讀2字節(jié)等....
Construct the Header of Merged File
構(gòu)建頁(yè)眉合并的文件
private void WaveHeaderOUT(string sPath)
{
FileStream fs = new FileStream(sPath, FileMode.Create, FileAccess.Write );
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(new char[4] { 'R', 'I', 'F', 'F' });
bw.Write(length);
bw.Write(new char[8] {'W','A','V','E','f','m','t',' '});
bw.Write((int)16);
bw.Write((short)1);
bw.Write(channels);
bw.Write(samplerate );
bw.Write((int)(samplerate * ((BitsPerSample * channels) / 8)));
bw.Write((short )((BitsPerSample * channels) / 8));
bw.Write(BitsPerSample);
            bw.Write(new char[4] {'d','a','t','a'});
bw.Write(DataLength);
bw.Close();
fs.Close();
}
We must be careful when wrriting the header. If there is any small mistake, the merged file doesn't work, so we write "RIFF" as an array of char, not as string and use int type for storing 4 bytes and short type for storing 2 bytes.
我們必須小心寫頭。如果有任何小小的失誤,合并后的文件不工作,所以我們寫“釜山國(guó)際電影節(jié)”作為一個(gè)char數(shù)組,而不是字符串,用于存儲(chǔ)4字節(jié),存放2字節(jié)短型int類型。
Write Data of all Files in the Merged File
寫入數(shù)據(jù)合并的文件中的所有文件
  public void Merge(string[] files, string outfile)
{
WaveIO wa_IN = new WaveIO();
WaveIO wa_out = new WaveIO();
wa_out.DataLength = 0;
wa_out.length = 0;
//Gather header data
foreach (string path in files)
{
wa_IN.WaveHeaderIN(@path);
wa_out.DataLength += wa_IN.DataLength;
wa_out.length += wa_IN.length;
}
//Reconstruct new header
wa_out.BitsPerSample = wa_IN.BitsPerSample;
wa_out.channels = wa_IN.channels;
wa_out.samplerate = wa_IN.samplerate;
wa_out.WaveHeaderOUT(@outfile);
foreach (string path in files)
{
FileStream fs = new FileStream(@path, FileMode.Open, FileAccess.Read);
byte[] arrfile = new byte[fs.Length - 44];
fs.Position = 44;
fs.Read(arrfile, 0, arrfile.Length);
fs.Close();
FileStream fo =
new FileStream(@outfile, FileMode.Append, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fo);
bw.Write(arrfile);
bw.Close();
fo.Close();
}
}

First we need to calculate the total length and data length of all files and then specify the channels, SampleRate and BitsPerSample of the output file.The last thing is to start reading data that is stored after byte number 44 and append it to the merged file.
首先,我們需要計(jì)算的總長(zhǎng)度和數(shù)據(jù)長(zhǎng)度的所有文件,然后指定的渠道,采樣頻率和輸出file.The bitspersample的最后一件事是開始讀取存儲(chǔ)的字節(jié)數(shù)后44和追加到文件中的數(shù)據(jù)合并。
All we need to do is call the Merge method and specify the input files and output file.
所有我們需要做的就是調(diào)用合并方法,并指定輸入文件和輸出文件。
string[] files = new string[2] { @"C:\WINDOWS\Media\Windows XP Startup.wav",
@"C:\WINDOWS\Media\Windows XP Shutdown.wav" };
WaveIO wa = new WaveIO();
wa.Merge(files,@"c:\oou.wav");

Play the Merged File
合并文件播放
Visual Studio 2005 provides a new class to play sound. Therefore, we don't need an API or anything else.
Visual Studio 2005提供一個(gè)新類播放聲音。因此,我們并不需要一個(gè)API或任何東西。
FileStream fs = new FileStream(@"c:\oou.wav", FileMode.Open,FileAccess.Read);
System.Media.SoundPlayer sp = new System.Media.SoundPlayer(fs);
sp.Play();
fs.Close();

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
.NET實(shí)現(xiàn)word在線對(duì)比
c# binaryreader之readint32與readint16區(qū)別
文件轉(zhuǎn)化成二進(jìn)制以及base64編碼字符串返回
最快比較兩個(gè)文件內(nèi)容
c# 存取結(jié)構(gòu)體 二進(jìn)制文件
FileStream 類 (System.IO)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服