0

I want to build an android app that records a voice and play reversed version of that. I searched everywhere and there is these links:

  • First: that describes without any code that makes me confusing!

  • Second: with no answers until now!

  • Third: is a working code for swift

  • Forth: a working way in java. Not android!

  • Fifth: I'm not sure it is thr solution.

  • Sixth: I compiled it and changed it but it stops suddenly in recording.

  • Seventh: For swift there is AVFoundation.

  • Eighth: Not working.

Help me!!

Mahdi Moqadasi
  • 2,029
  • 4
  • 26
  • 52
  • It depends on what you mean by "reversed", since you haven't been clear on that. If you just mean playing all the samples in the opposite order from how they were recorded, then that seems trivial: just use an `AudioRecord` to record PCM data, then create a copy of the sample array where you place the original samples from last to first (taking into account of course the number of channels, etc). If you mean something like changing to _"one two three"_ into _"three two one"_ then that would be far more complex and not really suitable for a StackOverflow question. – Michael Feb 05 '19 at 09:13
  • I mean play all samples in opposite order. I recorded an audio but for 1 second it was 500kb and reversing it byte-by-byte takes about 6 minute and after that the sound was not playted at all. what format and configs must be used? is there any limitation in formats for changing bytes (like fixed header or sth)? can you give me some example codes? – Mahdi Moqadasi Feb 05 '19 at 09:20
  • 1
    _"reversing it byte-by-byte takes about 6 minute"_ Then you are doing something very wrong. You should edit your question and include the relevant parts of your code. – Michael Feb 05 '19 at 09:35

1 Answers1

1

You must record audio as raw with AudioRecord instead of MediaRecorder which uses encoder to compress and change the output. When you recorded PCM file, you can add 44Byte Header to it, to be converted to Wav format and be playable in devices. If you want reverse it, should use a loop to read Bytes of it (if use PCM16 must use 2Byte) and after that add header and play it. Good Luck.