失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > PCM双声道分离为单声道

PCM双声道分离为单声道

时间:2023-11-03 21:15:59

相关推荐

PCM双声道分离为单声道

双声道的数据存储格式

/chinabinlang/article/details/72932947

有两种类型, LRLR...每个采样点交替, LLL...RRR 每个通道隔离

C++的实现;

为了简单,我这里先知实现一个声道的获取:

unsigned char * get_oneChannel_left_from_doubleChannel(unsigned char * pDoubleChannelBuf, int nLen, int nPerSampleBytesPerChannle)

{

int nOneChannelLen = nLen / 2;

unsigned char * pOneChannelBuf = new unsigned char[nOneChannelLen];

for ( int i = 0 ; i < nOneChannelLen/2; i++ )

{//target: uint16, source: uint32, 指针数据类型变量的增加

memcpy((uint16_t*)pOneChannelBuf + i, ((uint32_t *)(pDoubleChannelBuf)) + i, nPerSampleBytesPerChannle);

}

return pOneChannelBuf;

}

Java的实现

/p/369062109 :Java 中 NIO 看这一篇就够了

ByteBuffer

CharBuffer

ShortBuffer

IntBuffer

LongBuffer

FloatBuffer

DoubleBuffer

想用Bytebuffer实现对双声道的处理操作,已知byte[],怎样创建 Bytebuffer?

public static ByteBuffer wrap(byte[] array); 把一个现成的数组放到缓冲区中使用

public static ByteBuffer wrap(byte[] var0) {return wrap(var0, 0, var0.length);}

public static ByteBuffer allocate(int var0) {if (var0 < 0) {throw new IllegalArgumentException();} else {return new HeapByteBuffer(var0, var0);}}

怎样从ByteBuffer得到 byte[]

public final short[] array() {if (this.hb == null) {throw new UnsupportedOperationException();} else if (this.isReadOnly) {throw new ReadOnlyBufferException();} else {return this.hb;}}

如果觉得《PCM双声道分离为单声道》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。