我是 libsox 编程的新手,我想从名为“a.wav”的立体声音频中减少一个通道,然后使用以下代码生成一个单声道音频“b.wav”:
sox_format_t * in, * out;
sox_effects_chain_t * chain;
sox_effect_t * e;
char * args[10];
sox_init();
in = sox_open_read("E:\\a.wav", NULL, NULL, NULL);
out = sox_open_write("E:\\b.wav", &in->signal, NULL, NULL, NULL, NULL);
out->signal.channels = 1;
chain = sox_create_effects_chain(&in->encoding, &out->encoding);
e = sox_create_effect(sox_find_effect("input"));
sox_add_effect(chain, e, &in->signal, &in->signal);
e = sox_create_effect(sox_find_effect("channels"));
sox_add_effect(chain, e, &in->signal, &out->signal);
e = sox_create_effect(sox_find_effect("output"));
sox_add_effect(chain, e, &in->signal, &out->signal);
sox_flow_effects(chain, NULL, NULL);
sox_delete_effects_chain(chain);
sox_close(out);
sox_close(in);
sox_format_quit();
运行应用程序后,生成了单声道音频“b.wav”,但声音的持续时间是 a.wav 的一半。我的代码有问题吗?
任何回复将不胜感激!