4

I'm confused as to how to set pitch natively on Android. I tried altering the native-sound sample from the NDK which uses OpenSL ES, but I get a SL_RESULT_FEATURE_UNSUPPORTED for pretty much anything related to pitch upon requesting the interface. Interfaces tried: SL_IID_PITCH, SL_IID_RATEPITCH, SL_3DDOPPLER

// create audio player
const SLInterfaceID ids[3] = { SL_IID_BUFFERQUEUE, SL_IID_PITCH, SL_IID_VOLUME};
const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &bqPlayerObject, &audioSrc, &audioSnk,
        3, ids, req);
assert(SL_RESULT_SUCCESS == result);

result is always SL_RESULT_UNSUPPORTED

My target is android-19. I tried many others as well to no avail. Am I doing something wrong? Is there an alternative that doesn't require using Java?

Thanks!

Kalen
  • 3,106
  • 8
  • 29
  • 42

2 Answers2

4

Android has a minimal implementation of OpenSL, and none of those interfaces are supported. You can find a description of what is supported (and what has been added) in the NDK docs, or here - the link is the exact same as the documentation from the NDK.

Unfortunately, there is no easy alternative besides writing your own algorithm to alter the PCM data.

Dave
  • 4,282
  • 2
  • 19
  • 24
0

The Synthesis ToolKit (STK) has a pitch shift effect that may work for you. https://ccrma.stanford.edu/software/stk/

As Dave pointed out, there is no native solution. At present, I would say Android is not the place to look for good native audio support.

HerrLip
  • 151
  • 3