sox-devel@lists.sourceforge.net unofficial mirror
 help / color / mirror / code / Atom feed
* libsox tempo API in C
@ 2018-12-03 20:53 CHIRAG JETHAVA
  0 siblings, 0 replies; only message in thread
From: CHIRAG JETHAVA @ 2018-12-03 20:53 UTC (permalink / raw)
  To: sox-devel


[-- Attachment #1.1: Type: text/plain, Size: 2515 bytes --]

I created below tempo change code using following link:
https://sourceforge.net/p/sox/code/ci/master/tree/src/example0.c

#include "sox.h"
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

int main(int argc, char * argv[])
{
static sox_format_t * in, * out; /* input and output files */
sox_effects_chain_t * chain;
sox_effect_t * e;
char * args[10];
assert(argc == 3);
/* All libSoX applications must start by initialising the SoX library */
assert(sox_init() == SOX_SUCCESS);
/* Open the input file (with default parameters) */
assert(in = sox_open_read(argv[1], NULL, NULL, NULL));
/* Open the output file; we must specify the output signal characteristics.
* Since we are using only simple effects, they are the same as the input
* file characteristics */
assert(out = sox_open_write(argv[2], &in->signal, NULL, NULL, NULL, NULL));
/* Create an effects chain; some effects need to know about the input
* or output file encoding so we provide that information here */
chain = sox_create_effects_chain(&in->encoding, &out->encoding);
/* The first effect in the effect chain must be something that can source
* samples; in this case, we use the built-in handler that inputs
* data from an audio file */
e = sox_create_effect(sox_find_effect("input"));
args[0] = (char *)in, assert(sox_effect_options(e, 1, args) == SOX_SUCCESS);
/* This becomes the first `effect' in the chain */
assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
free(e);

/*tempo effect*/
e = sox_create_effect(sox_find_effect("tempo"));
args[0] = "1.5", assert(sox_effect_options(e, 1, args) == SOX_SUCCESS);
assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
free(e);

/* The last effect in the effect chain must be something that only consumes
* samples; in this case, we use the built-in handler that outputs
* data to an audio file */
e = sox_create_effect(sox_find_effect("output"));
args[0] = (char *)out, assert(sox_effect_options(e, 1, args) == SOX_SUCCESS
);
assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
free(e);

/* Flow samples through the effects processing chain until EOF is reached */
sox_flow_effects(chain, NULL, NULL);
/* All done; tidy up: */
sox_delete_effects_chain(chain);
sox_close(out);
sox_close(in);
sox_quit();
return 0;
}

*For tempo value < 1 I am getting correct resulting output file but for
tempo value > 1 I am getting in proper  output file in  which  some of
voice samples are missing.How to solve this problem?*

thanks

[-- Attachment #1.2: Type: text/html, Size: 16391 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-03 20:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 20:53 libsox tempo API in C CHIRAG JETHAVA

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/sox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).