summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/wavtrim.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/wavtrim.c b/tools/wavtrim.c
index b82f270c8d..8517b4677e 100644
--- a/tools/wavtrim.c
+++ b/tools/wavtrim.c
@@ -167,7 +167,9 @@ int wavtrim(char * filename, int maxsilence ,char* errstring,int errsize)
167 /* clip the start */ 167 /* clip the start */
168 for (i=0; i<datalen; i+=2) 168 for (i=0; i<datalen; i+=2)
169 { 169 {
170 sample16 = *(short *)(databuf + i); 170 /* samples are little endian */
171 sample16 = (*(databuf + i + 1) << 8) | *(databuf + i);
172
171 if (abs(sample16) > max_silence) 173 if (abs(sample16) > max_silence)
172 break; 174 break;
173 } 175 }
@@ -178,7 +180,8 @@ int wavtrim(char * filename, int maxsilence ,char* errstring,int errsize)
178 /* clip the end */ 180 /* clip the end */
179 for (i=datalen-2; i>skip_head; i-=2) 181 for (i=datalen-2; i>skip_head; i-=2)
180 { 182 {
181 sample16 = *(short *)(databuf + i); 183 /* samples are little endian */
184 sample16 = (*(databuf + i + 1) << 8) | *(databuf + i);
182 if (abs(sample16) > max_silence) 185 if (abs(sample16) > max_silence)
183 break; 186 break;
184 } 187 }
@@ -231,7 +234,7 @@ int main (int argc, char** argv)
231 ret = wavtrim(argv[1],max_silence,errbuffer,255 ); 234 ret = wavtrim(argv[1],max_silence,errbuffer,255 );
232 if( ret< 0) 235 if( ret< 0)
233 { 236 {
234 printf(errbuffer); 237 printf("%s", errbuffer);
235 } 238 }
236 return ret; 239 return ret;
237} 240}