7
7
import java .io .InputStream ;
8
8
import java .io .InputStreamReader ;
9
9
import java .text .DecimalFormat ;
10
+ import java .text .DecimalFormatSymbols ;
10
11
import java .util .ArrayList ;
11
12
import java .util .Arrays ;
12
13
import java .util .List ;
14
+ import java .util .Locale ;
13
15
14
16
import org .ffmpeg .android .BinaryInstaller ;
15
17
import org .ffmpeg .android .ShellUtils .ShellCallback ;
@@ -34,7 +36,7 @@ public SoxController(Context _context) throws FileNotFoundException, IOException
34
36
bi .installFromRaw ();
35
37
}
36
38
37
- soxBin = new File (fileBinDir ,"sox" ).getAbsolutePath ();
39
+ soxBin = new File (fileBinDir ,"sox" ).getCanonicalPath ();
38
40
39
41
}
40
42
@@ -112,11 +114,11 @@ public double getLength(String path) {
112
114
* @param length (optional)
113
115
* @return path to trimmed audio
114
116
*/
115
- public String trimAudio (String path , String start , String length ) {
117
+ public String trimAudio (String path , String start , String length ) throws IOException {
116
118
ArrayList <String > cmd = new ArrayList <String >();
117
119
118
120
File file = new File (path );
119
- String outFile = file .getAbsolutePath () + "_trimmed.wav" ;
121
+ String outFile = file .getCanonicalPath () + "_trimmed.wav" ;
120
122
cmd .add (soxBin );
121
123
cmd .add (path );
122
124
cmd .add ("-e" );
@@ -156,7 +158,7 @@ public String trimAudio(String path, String start, String length) {
156
158
* @param fadeOutLength (optional)
157
159
* @return
158
160
*/
159
- public String fadeAudio (String path , String type , String fadeInLength , String stopTime , String fadeOutLength ) {
161
+ public String fadeAudio (String path , String type , String fadeInLength , String stopTime , String fadeOutLength ) throws IOException {
160
162
161
163
final List <String > curves = Arrays .asList ( new String []{ "q" , "h" , "t" , "l" , "p" } );
162
164
@@ -166,7 +168,7 @@ public String fadeAudio(String path, String type, String fadeInLength, String st
166
168
}
167
169
168
170
File file = new File (path );
169
- String outFile = file .getAbsolutePath () + "_faded.wav" ;
171
+ String outFile = file .getCanonicalPath () + "_faded.wav" ;
170
172
171
173
ArrayList <String > cmd = new ArrayList <String >();
172
174
cmd .add (soxBin );
@@ -269,14 +271,16 @@ public String combine(List<String> files, String outFile) {
269
271
* @param seconds
270
272
*/
271
273
public String formatTimePeriod (double seconds ) {
272
- String seconds_frac = new DecimalFormat ("#.##" ).format (seconds );
273
- return String .format ("0:0:%s" , seconds_frac );
274
+ DecimalFormat df = new DecimalFormat ("#.##" );
275
+ df .setDecimalFormatSymbols (new DecimalFormatSymbols (Locale .US ));
276
+ String seconds_frac = df .format (seconds );
277
+ return String .format (Locale .US , "0:0:%s" , seconds_frac );
274
278
}
275
279
276
- private int execSox (List <String > cmd , ShellCallback sc ) throws IOException ,
280
+ public int execSox (List <String > cmd , ShellCallback sc ) throws IOException ,
277
281
InterruptedException {
278
282
279
- String soxBin = new File (fileBinDir , "sox" ).getAbsolutePath ();
283
+ String soxBin = new File (fileBinDir , "sox" ).getCanonicalPath ();
280
284
Runtime .getRuntime ().exec ("chmod 700 " + soxBin );
281
285
return execProcess (cmd , sc );
282
286
}
0 commit comments