Exemple #1
0
        private void AddFile(string fullFilePath)
        {
            WaveSound sound = new WaveSound();
            sound.Name = Path.GetFileNameWithoutExtension(fullFilePath);
            sound.Read(fullFilePath);

            ListViewItem item = new ListViewItem(sound.Name);
            item.SubItems.Add(sound.NumChannels.ToString());
            item.SubItems.Add(sound.SampleRate.ToString());
            item.SubItems.Add(sound.BitsPerSample.ToString());
            item.Tag = sound;
            listView.Items.Add(item);
        }
Exemple #2
0
        private void BuildWavConcat(string fileName, ref List<WaveSound> waveList)
        {
            WaveSound outputSound = new WaveSound();
            WavConcat wavConcatInfo = new WavConcat();
            FileInfo fileInfo = new FileInfo(fileName);

            outputSound.Name = fileInfo.FullName;
            wavConcatInfo.Name = Path.GetFileNameWithoutExtension(fileInfo.Name);
            outputSound.ChunkID = waveList[0].ChunkID;
            outputSound.ChunkSize = waveList[0].ChunkSize;
            outputSound.Format = waveList[0].Format;
            outputSound.Subchunk1ID = waveList[0].Subchunk1ID;
            outputSound.Subchunk1Size = waveList[0].Subchunk1Size;
            outputSound.AudioFormat = waveList[0].AudioFormat;
            outputSound.NumChannels = waveList[0].NumChannels;
            outputSound.SampleRate = waveList[0].SampleRate;
            outputSound.ByteRate = waveList[0].ByteRate;
            outputSound.BlockAlign = waveList[0].BlockAlign;
            outputSound.BitsPerSample = waveList[0].BitsPerSample;
            outputSound.Subchunk2ID = waveList[0].Subchunk2ID;

            foreach (WaveSound sound in waveList)
            {
                outputSound.Subchunk2Size += sound.Subchunk2Size;
            }

            outputSound.Data = new byte[outputSound.Subchunk2Size];

            int waveSize = 0;
            foreach (WaveSound sound in waveList)
            {
                WavConcat.Effect effect = new WavConcat.Effect();
                effect.Name = sound.Name;
                effect.Start = waveSize;
                Buffer.BlockCopy(sound.Data, 0, outputSound.Data, waveSize, sound.Subchunk2Size);
                waveSize += sound.Subchunk2Size;
                effect.End = (waveSize - 1);

                wavConcatInfo.EffectList.Add(effect);
            }

            outputSound.Write(fileName);

            XmlSerializer serializer = new XmlSerializer(typeof(WavConcat));
            string xmlFileName = Path.ChangeExtension(fileName, ".xml");
            TextWriter writer = new StreamWriter(xmlFileName, false);

            serializer.Serialize(writer, wavConcatInfo);
            writer.Close();
        }