码迷,mamicode.com
首页 > 其他好文 > 详细

Huawei .V3 Extention audio Play

时间:2018-01-18 01:01:47      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:init   int   huawei   http   creat   ada   bsp   space   bytes   

 

相关dll下载 链接

using System.IO;
using System.Threading;
using Alvas.Audio;
using NAudio.Wave;

namespace Test
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            //测试
            playV3File(@"D:\1404033.v3");
        }

        public static void playV3File(string voxFile)
        {
            //设置采样率
            var samplesPerSec = 6000;
            var wavFile = voxFile + ".tmp";
            using (var br = new BinaryReader(File.OpenRead(voxFile)))
            {
                var format = AudioCompressionManager.GetPcmFormat(1, 16, samplesPerSec);
                using (var ww = new WaveWriter(File.Create(wavFile), AudioCompressionManager.FormatBytes(format)))
                {
                    Vox.Vox2Wav(br, ww);
                }
            }
            var audiodata = File.ReadAllBytes(wavFile);
            File.Delete(wavFile);
            using (var Stream = new MemoryStream(audiodata))
            {
                using (var wavFileReader = new WaveFileReader(Stream))
                {
                    using (var outputDevice = new WaveOutEvent())
                    {
                        outputDevice.Init(wavFileReader);
                        outputDevice.Play();
                        while (outputDevice.PlaybackState == PlaybackState.Playing) Thread.Sleep(100);
                    }
                }
            }
        }
    }
}

Huawei .V3 Extention audio Play

标签:init   int   huawei   http   creat   ada   bsp   space   bytes   

原文地址:https://www.cnblogs.com/czytcn/p/8306814.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!