Hi everybody!

What I'm trying to do is to manipulate a recorded audio file, in this
case to reverse it.
The temp file (.raw) I create during the recording works fine, but the
reversed one doesn't.
Pretty sure it's an easy task, I just can't find where the mistake
would be. Hope you can help..

Here's the code:

                byte data[] = new byte[bufferSize];
                byte rev_data[] = new byte[bufferSize];
                String filename = getTempFilename();
                String rev_filename= getTempRevFilename();
                FileOutputStream os = null;
                FileOutputStream os_rev = null;

                try {
                        os = new FileOutputStream(filename);
                } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

                try {
                        os_rev = new FileOutputStream(rev_filename);
                    } catch (FileNotFoundException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                    }

                int read = 0;

                if(null != os){
                        while(isRecording){
                                read = recorder.read(data, 0,
bufferSize);

 
if(AudioRecord.ERROR_INVALID_OPERATION != read){
                                        try {
                                                os.write(data);
                                        } catch (IOException e) {
                                                e.printStackTrace();
                                        }
                                }
                        }

                        for(int i=data.length-1, j=0;i>=0;i--,j++){
                                rev_data[j]=data[i];
                        }
                        try{
                                os_rev.write(rev_data);
                        } catch (IOException e) {
                                        e.printStackTrace();
                        }

Thank you in advance!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to