Giter Club home page Giter Club logo

nspeex's Introduction

NSpeex

早在11-12年,由于一个游戏项目要使用到语音压缩库,当时选用了speex,我们当时使用的是Unity3D游戏引擎,由于市面上没有.Net平台下的speex的库,于是我便将jspeex翻译成NSpeex。但是后来由于种种原因不再维护项目,前段时间有人问我这个库该怎么用,我就使用别人的NSpeex库来进行解释说明,毕竟我之前的代码太像Java风格了,于是我将别人的代码复制过来,自己写点文档方便别人

例子(example)

见 Test/SpeexTest.cs,将male.wav 转化为result.spx文件,然后使用foobar播放器可以播放

编码(encode)

// byte[] dataIn -> byte[] dataOut
// convert to short
short[] data = new short[dataIn.Length / 2];
Buffer.BlockCopy(dataIn, 0, data, 0, dataIn.Length);
byte[] dataOut = new byte[dataIn.Length];
int encSize = speexEncoder.Encode(data, 0, data.Length, dataOut, 0, dataOut.Length);
if(encSize > 0){
    // encode success
    // todo with dataOut[0-encSize]
}

解码(decode)

// byte[] dataIn -> byte[] dataOut
short[] data =  new short[1024];
int decSize = speexEncoder.Decode(dataIn, 0, dataIn.Length, data, 0, false);

if(decSize > 0 ){
    byte[] dataOut = new byte[1024];
    Buffer.BlockCopy(data, 0, dataOut, 0, decSize);
    // todo with dataOut[0-decSize]
}

nspeex's People

Contributors

aijingsun6 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.