解码GSM 6.10部件n音讯 [英] Decoding GSM 6.10 parts in NAudio
问题描述
我如何去code GSM 6.10(全速率)codeC音频字节在n音讯飞阵列?来源说,波解码在同一时间处理,我不能处理波数个字节(整我,如果我错了)。
我的情况是我从服务器接收GSM 6.10音频的字节数组,数组的大小可以指定,但我怎么能去code,并写入设备?
编辑:
我是什么做错了吗?
据马克的解决方案,这应该工作,但我听到的是失真的音色:
waveout的waveO =新waveout的();
BufferedWaveProvider waveP =新BufferedWaveProvider(新WAVEFORMAT(8000,16,1));
waveO.Init(waveP);
waveO.Play(); INetworkChat codeC鳕鱼=新Gsm610Chat codeC(); 新的Thread(委托()
{
HttpWebRequest的要求=(HttpWebRequest的)WebRequest.Create(http://www.nch.com.au/acm/8kgsm.wav);
HttpWebResponse响应=(HttpWebResponse)request.GetResponse();
使用(流resStream = response.GetResponseStream())
{
如果(resStream.CanRead)
{
字节[] buf中=新的字节[65];
诠释计数= 0;
做
{
数= resStream.Read(BUF,0,buf.Length);
如果(计数!= 0)
{
字节[]德codeD = cod.De code(BUF,0,计数);
waveP.AddSamples(德codeD,0,德coded.Length);
Thread.sleep代码(50);
}
}
而(计数大于0);
}
}
})。开始();
您可以使用 AcmStream
类做到这一点,传递 Gsm610WaveFormat
作为源格式和8kHz的16位单声道作为输出格式。在n音讯源$ C $ C在网络聊天演示展示了这个动作脱code的飞行。
How can I decode GSM 6.10 (Full-Rate) codec audio byte array on the fly in NAudio? Sources says that wave decoding is processed at one time and I can't process several bytes of wave (fix me if I'm wrong).
My situation is that I receive bytes array of GSM 6.10 audio from the server, array size can be specified, but how can i decode it and write to the device?
Edit:
What am I doing wrong? According to Mark's solution this should work but all I hear is distorted sounds:
WaveOut waveO = new WaveOut();
BufferedWaveProvider waveP = new BufferedWaveProvider(new WaveFormat(8000, 16, 1));
waveO.Init(waveP);
waveO.Play();
INetworkChatCodec cod = new Gsm610ChatCodec();
new Thread(delegate()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.nch.com.au/acm/8kgsm.wav");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (Stream resStream = response.GetResponseStream())
{
if (resStream.CanRead)
{
byte[] buf = new byte[65];
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
byte[] decoded = cod.Decode(buf, 0, count);
waveP.AddSamples(decoded, 0, decoded.Length);
Thread.Sleep(50);
}
}
while (count > 0);
}
}
}).Start();
You can do this with the AcmStream
class, passing in Gsm610WaveFormat
as the source format and 8kHz 16 bit mono as the output format. The network chat demo in the NAudio source code shows this in action to decode on the fly.
这篇关于解码GSM 6.10部件n音讯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!