How to add echo effect to wav file in android?

For some time I struggled on how to modify the wav file, adding an echo effect to it; My application does screening, speed and volume, but I can not add effects. I am an absolute audio engineer or something like that.

My main goal is to find an algorithm and make a function that takes byte [] patterns and modifies it.

I'm using this current code right now:



sonic = new Sonic(44100, 1);
            byte samples[] = new byte[4096];
            byte modifiedSamples[] = new byte[2048];
            int bytesRead;

            if (soundFile != null) {
                sonic.setSpeed(params[0]);
                sonic.setVolume(params[1]);
                sonic.setPitch(params[2]);
                do {
                    try {
                        bytesRead = soundFile.read(samples, 0, samples.length);
                    } catch (IOException e) {
                        e.printStackTrace();
                        return null;
                    }

                    if (bytesRead > 0) {
                        sonic.putBytes(samples, bytesRead);
                    } else {
                        sonic.flush();
                    }

                    int available = sonic.availableBytes();

                    if (available > 0) {
                        if (modifiedSamples.length < available) {
                            modifiedSamples = new byte[available * 2];
                        }

                        sonic.receiveBytes(modifiedSamples, available);
                        if (thread.getTrack() != null && thread.getTrack().getState() != AudioTrack.STATE_UNINITIALIZED)

                            thread.WriteTrack(modifiedSamples, available);
                    }

                } while (bytesRead > 0);

, sonic ndk , byte [] "modifiedSamples", , "modifiedSamples", , , , , . , , , .

+4
1

- , wav .

//Clone original Bytes
byte[] temp = bytesTemp.clone();
RandomAccessFile randomAccessFile = new RandomAccessFile(fileRecording, "rw");
//seek to skip 44 bytes
randomAccessFile.seek(44);
//Echo
int N = sampleRate / 8;
for (int n = N + 1; n < bytesTemp.length; n++) {
   bytesTemp[n] = (byte) (temp[n] + .5 * temp[n - N]);
}
randomAccessFile.write(bytesTemp);

.

+3

All Articles