hi,
i want to write a fundemental audio file operation library, so i tried to 
seperate some functions from Sox command, such as: concatenating, mixing and 
trimming. According example from source package,  i write a trimming program :

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

/* 
* usage: trim source output start length
*/

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 == 5);

  assert(sox_init() == SOX_SUCCESS);

  assert(in = sox_open_read(argv[1], NULL, NULL, NULL));

  assert(out = sox_open_write(argv[2], &in->signal, &in->encoding, NULL, NULL, 
NULL));

  chain = sox_create_effects_chain(&in->encoding, &out->encoding);

  e = sox_create_effect(sox_find_effect("trim"));
  args[0] = (char*)argv[3];
  args[1] = (char*)argv[4];
  assert(sox_effect_options(e, 2, args) == SOX_SUCCESS);
  assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
  sox_trim_get_start(e);

  sox_flow_effects(chain, NULL, NULL);

  sox_delete_effects_chain(chain);
  sox_close(out);
  sox_close(in);
  sox_quit();
  return 0;
}

but it did not work. So, any suggestion will be appreciated. Thanks.

leiyonghua
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

Reply via email to