Giter Site home page Giter Site logo

aaudiodemo-1's Introduction

AAudioDemo

1.简介

AAuido demo Blog介绍基于官方Demo的AAudio API使用总结

包含录放音,写Wav音频头,回声处理(录音流立刻用于播放流),官网介绍

2.注意事项

(1)录音回调中如下代码中的返回值AAUDIO_CALLBACK_RESULT_CONTINUE表示继续录音或放音

返回AAUDIO_CALLBACK_RESULT_STOP则表示停止录音或停止放音,音频流状态将转为停止

aaudio_data_callback_result_t EchoAudioEngine::dataToRecordCallback(AAudioStream *stream,
                                                                    void *audioData,
                                                                    int32_t numFrames) {
    static uint64_t logging_flag;
    if (isRecordIng) {
        fwrite(audioData, 1, 2 * numFrames * sizeof(short), recordFile);
        if ((logging_flag++) % 100 == 0) {
            LOGI("AAudioEngineCPP recordIng, numFrames: %d.", numFrames);
        }
        return AAUDIO_CALLBACK_RESULT_CONTINUE;
    } else {
        LOGI("AAudioEngineCPP isRecordIng status:%d", isRecordIng);
    }
    return AAUDIO_CALLBACK_RESULT_STOP;
}

(2)由于AAudio录音数据为原始数据,能保存成原始PCM文件,若需要保存成普通音频格式需自行处理

如Wav格式:Wav格式编码

(3)AAudio API并非线程安全,使用时需自行处理并发场景,否则可能出现crash

3.Demo使用

1.开始录音:启动单独录音

2.开始重放:开始录音回放

3.开启回声:录音流传入放音流将形成刺耳回声

4.通过Spinner选择音频设备,貌似无法生效,音频框架可能未适配,设置指定设备id后未生效

aaudiodemo-1's People

Contributors

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