1
0
mirror of https://github.com/mon/2dxTools.git synced 2024-11-27 15:30:49 +01:00

Working preview trim

This commit is contained in:
William Toohey 2017-03-23 22:46:35 +10:00
parent 9ec75bd24f
commit 1ed9a80f26
2 changed files with 15 additions and 11 deletions

View File

@ -110,24 +110,24 @@ int convert_wav(char* inFile, char* outWav, int trimPreview) {
assert(sox_add_effect(chain, e, &interm_signal, &out->signal) == SOX_SUCCESS); assert(sox_add_effect(chain, e, &interm_signal, &out->signal) == SOX_SUCCESS);
free(e); free(e);
} }
if (in->signal.channels != out->signal.channels) {
e = sox_create_effect(sox_find_effect("channels"));
assert(sox_effect_options(e, 0, NULL) == SOX_SUCCESS);
assert(sox_add_effect(chain, e, &interm_signal, &out->signal) == SOX_SUCCESS);
free(e);
}
// Only use 10 seconds of audio for previews // Only use 10 seconds of audio for previews
if(trimPreview) { if(trimPreview) {
e = sox_create_effect(sox_find_effect("trim")); e = sox_create_effect(sox_find_effect("trim"));
args[0] = "0"; args[0] = "0";
args[1] = "10"; args[1] = "10";
assert(sox_effect_options(e, 1, args) == SOX_SUCCESS); assert(sox_effect_options(e, 2, args) == SOX_SUCCESS);
assert(sox_add_effect(chain, e, &interm_signal, &in->signal) == SOX_SUCCESS); assert(sox_add_effect(chain, e, &interm_signal, &in->signal) == SOX_SUCCESS);
free(e); free(e);
} }
if (in->signal.channels != out->signal.channels) {
e = sox_create_effect(sox_find_effect("channels"));
assert(sox_effect_options(e, 0, NULL) == SOX_SUCCESS);
assert(sox_add_effect(chain, e, &interm_signal, &out->signal) == SOX_SUCCESS);
free(e);
}
e = sox_create_effect(sox_find_effect("output")); e = sox_create_effect(sox_find_effect("output"));
args[0] = (char *)out; args[0] = (char *)out;
assert(sox_effect_options(e, 1, args) == SOX_SUCCESS); assert(sox_effect_options(e, 1, args) == SOX_SUCCESS);

View File

@ -1,18 +1,22 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "shared.h" #include "shared.h"
#include "2dxWav.h" #include "2dxWav.h"
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
if(argc != 3) { if(argc != 3 && argc != 4) {
printf("2dxWavConvert infile outwav\n"); printf("2dxWavConvert infile outwav [preview]\n");
return 1; return 1;
} }
int preview = 0;
if(argc == 4 && !strcmp("preview", argv[3]))
preview = 1;
if(convert_wav(argv[1], argv[2], 0)) { if(convert_wav(argv[1], argv[2], preview)) {
printf("Conversion failed!\n"); printf("Conversion failed!\n");
return 1; return 1;
} }