Question

I built sox for Android and I am using the generated binary files i.e. sox, rec, play and soxi generated directly in my app by installing them as binaries within my app.

I am able to invoke commands using sox directly however I have a problem in invoking rec command.

I used the following command, rec -r 8000 -c 2 output.wav But it fails saying that sox is not found or sox is expected but is not found.

The above rec command works perfectly in Ubuntu when I use it in command line

Please note that I am able to use operation related to sox binary successfully, but I am unable to use commands related to rec binary.

Initially I thought the problem may be because of permissions imposed by Android so I included these permissions in manifest.xml but to no avail.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>

I did some research and got this link, it says in section Using Sox to Play and Record that there might be some Linux systems which do not accept rec command directly.

I followed his suggestion and appended my commands with padsp etc, but it still doesn't work.

So my question is how do I invoke rec command successfully on Android system, has anyone tried this before?

Was it helpful?

Solution

rec, play, soxi are symbolic links to the sox binary. (Alternatively, on platforms that don’t support symbolic links, they are all identical copies of the same binary.) SoX has a different default behaviour depending on the name by which it is called.

It seems that something is wrong with the symlinks on your device. Perhaps they are pointing to the wrong path? Try if you can fix this.

Your other option is to use the sox binary for all tasks. rec -r 8000 -c 2 output.wav is actually the same as sox -d -r 8000 -c 2 output.wav (-d is the default audio device). For playback, similarly, play somefile is the same as sox somefile -d.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top