IOS - 德code PCM字节数组 [英] IOS - Decode PCM byte array

查看:270
本文介绍了IOS - 德code PCM字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林停留在一个问题上我的目标C应用程序。

Im stuck on an issue on my objective C App.

我在读从serveur(插槽C#)一个字节数组,谁给我一个PCM连接$ C $的CD音响,目前我正在寻找一个样本code是德code对我来说这个字节数组(NSData的),并播放它。

I'm reading a byte array from a serveur (Socket c#) who send me an PCM encoded sound, and i'm currently looking for a sample code that decode for me this byte array (NSData), and play it.

有谁知道一个解决方案吗?或者我怎么可以读取U-法音?

Does anyone know a solution ? Or how can I read a u-Law audio?

非常感谢! :D

推荐答案

该链接有关于μ定律编码和解码的信息:

This link has information about mu-law encoding and decoding:

http://dystopian$c$c.blogspot.com.es/2012/02/pcm-law-and-u-law-companding-algorithms.html

#define MULAW_BIAS 33
/*
 * Description:
 *  Decodes an 8-bit unsigned integer using the mu-Law.
 * Parameters:
 *  number - the number who will be decoded
 * Returns:
 *  The decoded number
 */
int16_t MuLaw_Decode(int8_t number)
{
 uint8_t sign = 0, position = 0;
 int16_t decoded = 0;
 number=~number;
 if(number&0x80)
 {
  number&=~(1<<7);
  sign = -1;
 }
 position = ((number & 0xF0) >>4) + 5;
 decoded = ((1<<position)|((number&0x0F)<<(position-4))|(1<<(position-5)))
            - MULAW_BIAS;
 return (sign==0)?(decoded):(-(decoded));
}

当你有uncom pressed音频,你应该能够使用音频队列API来播放它。

When you have the uncompressed audio you should be able to play it using the Audio Queue API.

祝你好运!

这篇关于IOS - 德code PCM字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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