简体   繁体   中英

Using AudioTrack to EQ a .WAV file?

I need to do some EQing and apply a digital effect for a .wav file. Is there any way of extracting individual PCM sample values from "buffer" below to carry out some EQ/processing? Is AudioTrack the right way to do this?

private void playSound() {


audioTrack.play();
double input = 0;
int bufferSize = 512;
byte[] buffer = new byte[bufferSize];
InputStream inputStream = getResources().openRawResource(R.raw.wave);

    try {
        while((input = inputStream.read(buffer)) != -1)
        audioTrack.write(buffer, 0, input);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

You can attach an Equalizer AudioEffect to the audio session of your AudioTrack starting with API level 9 (Gingerbread).

The other alternative would be to process the PCM data in your app before writing it to the audio track. This would probably be something you'd want to do in native code rather than Java for performance reasons.
The theory of implementing your own equalizer effect is a bit to broad a subject to be suitable for the Q&A format here at StackOverflow, so you'll have to search for information on that elsewhere if that's the route you want to take.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM