Git Product home page Git Product logo

aaudiodemo's Introduction

AAudioDemo

AAudio 验证低Android原生延迟音频

修改内容

  • MainActivity.java

         @Override
         public boolean onTouch(View view, MotionEvent motionEvent) {
             switch (motionEvent.getAction()){
                 case MotionEvent.ACTION_MOVE:
    
                     break;
                 case MotionEvent.ACTION_UP:
    
                     break;
                 case MotionEvent.ACTION_DOWN:
                     if (mEngineHandle != INVALID_PTR) {
                         nativeAAudioEngineStop(mEngineHandle);
                         nativeDestroyAAudioEngine(mEngineHandle);
                         mEngineHandle = INVALID_PTR;
                     }
                     if (mEngineHandle == INVALID_PTR) {
                         mEngineHandle = nativeCreateAAudioEngine(getAssets(), TEST_FILE_PATH, AUDIO_SAMPLERATE, AUDIO_CHANNELS, AUDIO_FORMAT);
                     }
                     if (mEngineHandle != INVALID_PTR) {
                         nativeAAudioEnginePlay(mEngineHandle);
                     }
                     break;
                 default:break;
             }
             return true;
         }
     });
    
  • Project build.gradle

      dependencies {    
          classpath "com.android.tools.build:gradle:7.0.2"
    
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
    
  • gradle-wrapper.properties

      distributionBase=GRADLE_USER_HOME
      distributionPath=wrapper/dists
      distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
      zipStoreBase=GRADLE_USER_HOME
      zipStorePath=wrapper/dists
    

ffmpeg修改wav格式为pcm格式

  • 将wav转换为48kHz单声道pcm

     ffmpeg -y -i test.wav -acodec pcm_s16le -f s16le -ac 1 -ar 48000 test.pcm
    
  • 将wav转换为48kHz双声道pcm

      ffmpeg -y -i test.wav -acodec pcm_s16le -f s16le -ac 2 -ar 48000 test.pcm
    

何为pcm格式

解决问题

AndroidStudio版本

  • Android Studio Giraffe | 2022.3.1 Patch 2

解决ANDROID_SDK_HOME问题

  • 环境变量中将ANDROID_SDK_HOME改为ANDROID_HOME

解决NDK路径问题

  • local.properties修改如下:

      sdk.dir=C\:\\Users\\xxxx\\AppData\\Local\\Android\\Sdk
      ndk.dir=C\:\\Users\\xxxx\\AppData\\Local\\Android\\Sdk\\ndk\\21.4.7075529
    

参考连接

aaudiodemo's People

Contributors

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