0

I'm very new to audio processing and the opensl es system. I'm currently developing an app that generates anti noise. My idea is to invert the values in the audio buffer queue, however, all the methods I've tried are not working. I'm using opensl es as my app requires low latency.

Configuration:

uint8_t *buffer; //buffer size is 384
engine.bitsPerSample_ = SL_PCMSAMPLEFORMAT_FIXED_16;
engine.sampleChannels_ = 1;

Methods tried:

  • Bitwise negation: e.g.
    bufffer[i] = ~buffer[i];
  • standard math: e.g. if buffer[i] is 200 then buffer[i] = 127 - 73(difference between 127 and 200);
  • Various other methods which were more or less trial and error

Aim:
All the values in the buffer are correctly inverted and when enqueued to SLAndroidSimpleBufferQueueItf the playback sound is the inverse of the source.


Does anyone know what the best way to solve this is?


Any and all help will be greatly appreciated :)

  • 1
    Could you please specify: "are not working". Does it not compile? Does the values not get inverted? – TobiSH Feb 10 '18 at 21:38
  • The code compiles and the values are successfully changed however the playback sound is not the inverted sound. I'm assuming it's because I'm inverting them wrong. – Ridoy Farhad Feb 11 '18 at 09:45
  • I answered your other post on OpenSL_ES manipulation, Now about this one won't make a complete answer, but what I would tell you is to consider that sound is not the same at your mic and your speakers unless they are really close and somehow don't produce feedback, you definitely need low latency, now days maybe a Samsung S8 (under 10ms with best OpenSL_ES config in terms of sample rate and buffer frames), Pixel, Nexux, Moto g3+ have it in that order. Still you would need to research on how to compensate delay and distance of mic and speakers. Usually 2 mics are used in hardware for this. – alexm Feb 15 '18 at 18:03
  • I think this reference involves every answer related to `Audio_Processing` whether it is *Pre-Processing* or *Post-Processing*: [Android_Audio_Processing_Using_WebRTC](https://github.com/mail2chromium/Android-Audio-Processing-Using-WebRTC), You can also visit this reference: https://stackoverflow.com/a/58546599/10413749 – Muhammad Usman Bashir Apr 07 '20 at 08:48

0 Answers0