mirror of
https://github.com/mon/2dxTools.git
synced 2024-11-30 16:54:28 +01:00
Working preview trim
This commit is contained in:
parent
9ec75bd24f
commit
1ed9a80f26
16
2dxWav.c
16
2dxWav.c
@ -111,23 +111,23 @@ int convert_wav(char* inFile, char* outWav, int trimPreview) {
|
|||||||
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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user