Giter VIP home page Giter VIP logo

audiobox's Introduction

AudioBox

1. 关于

AudioBox是一个专为Android平台编写的音频库,支持播放和录音,目前包含以下组件:

播放

AudioPlayer: 用于播放磁盘文件

RawPlayer: 用于播放裸数据

录音

AudioRecorder

2. 快速开始

2.1 添加依赖

settings.gradle

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

build.gradle[module]

dependencies {
    implementation 'com.github.TTTUUUIII:audiobox:v1.1.0'
}

2.2 播放

AudioPlayer

AudioPlayer player = new AudioPlayer();
player.setAudioSource("path/to/audio.pcm");
player.play();

RawPlayer

RawPlayer player = new RawPlayer();
player.setAudioSource(new RawPacket.Builder()
        .setBody(new byte[]{0, 0, 0})
        .build());
player.play();

注:默认播放格式为立体声,48000Hz

2.3 录音

v1.0.*

AudioRecorder<Short, short[]> recorder = new AudioRecorder<>(Short.class);

recorder.setCaptureListener(new CaptureListener<short[]>() {
    @Override
    public void onCapture(short[] data) {
        /*handle audio data*/
    }
});

recorder.start();

v1.1.*

AudioRecorder<short[]> recorder = new AudioRecorder<>();

recorder.setCaptureListener(new CaptureListener<short[]>() {
    @Override
    public void onCapture(short[] data) {
        /*handle audio data*/
    }
}, short[].class);

recorder.start();

注:录音需要android.permission.RECORD_AUDIO权限。


audiobox's People

Contributors

tttuuuiii avatar

Watchers

 avatar  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.