将字节数组转换为WAV文件 [英] Convert byte array to wav file

查看:111
本文介绍了将字节数组转换为WAV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试播放wav声音,该声音存储在称为bytes的字节数组中.我知道我应该将字节数组转换为wav文件并将其保存在本地驱动器中,然后调用已保存的文件,但是我无法将字节数组转换为wav文件.

I'm trying to play a wav sound that stored in byte array called bytes. I know that I should convert the byte array to wav file and save it in my local drive then called the saved file but I was not able to convert the byte array to wav file.

请帮助我提供示例代码,以将wav声音的字节杂音转换为wav文件.

please help me to give sample code to convert byte arrary of wav sound to wav file.

这是我的代码:

protected void Button1_Click(object sender, EventArgs e)
{
    byte[] bytes = GetbyteArray();

   //missing code to convert the byte array to wav file

    .....................

    System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(myfile);
    myPlayer.Stream = new MemoryStream();
    myPlayer.Play();
}

推荐答案

尝试一下:

System.IO.File.WriteAllBytes("yourfilepath.wav", bytes);

这篇关于将字节数组转换为WAV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆