I am trying to add silence to begining and end of an audio wav file in a mac OS application(objective c). For that i am using sox library. i use prebuilt compiled framework from this repo. Dragged and dropped the libsox.a and sox.h files.
I am trying to use the 'pad' command. documentation of sox can be found here
Problem is that the pad command does not produce expected results when used in code. However, pad command works perfectly fine on terminal.
Lets take an example
Input file is like this
When i used pad command on terminal, it correctly adds silence to end and begining of file so i wrote on terminal
sox in.wav out.wav pad 0.5 0.5
added 0.5 seconds silence at start and end and my file. so output looked like this(perfect)
correct output from terminal
But when i use it in code, the output is wrong
unexpected output when used pad command from code
As you can see in the above image. silence is added at the start, but not added at end correctly, the file is being cut off from the end. audio is moved from the start, but length of file is not increased as expected.
I have been trying to make this work for several days but failed to do so. i saw other Questions and googled it but could not find a solution.
Code that i am using : https://www.codepile.net/pile/nL6xzjQ8
PS
File trimming(removing silence) works perfectly with sox with command "silence"
I am using audacity tool for viewing the output audio files
What i searched and found.
How to removed start and end silence from audio file
Any help would be much appreciated. Thanks