adds the option to finish file B while mixing in

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@400 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent b93bc9d3fd
commit bea950eae9

@ -128,7 +128,7 @@ void AnnouncementDialog::startSession(){
throw string("AnnouncementDialog::onSessionStart: Cannot open file\n");
}
AmAudioMixIn* s = new AmAudioMixIn(&wav_file, f, 4, 0.0);
AmAudioMixIn* s = new AmAudioMixIn(&wav_file, f, 4, 0.1, true);
setOutput(s);
}

@ -17,7 +17,7 @@ class IvrDialog(IvrDialogBase):
self.beep.open(config['beep'], ivr.AUDIO_READ)
self.mixin = IvrAudioMixIn()
self.mixin.init(self.announcement, self.beep, 3, 0.6)
self.mixin.init(self.announcement, self.beep, 3, 0.6, True)
self.enqueue(self.mixin, None)
def onEmptyQueue(self):

@ -35,10 +35,11 @@ static PyObject* IvrAudioMixIn_init(IvrAudioMixIn* self, PyObject* args)
AmAudioFile* b = NULL;
int s;
double l;
int finish = 0;
PyObject *o_a, *o_b;
if(!PyArg_ParseTuple(args,"OOid", &o_a, &o_b, &s, &l))
if(!PyArg_ParseTuple(args,"OOid|i", &o_a, &o_b, &s, &l, &finish))
return NULL;
if (o_a == Py_None) {
@ -68,7 +69,7 @@ static PyObject* IvrAudioMixIn_init(IvrAudioMixIn* self, PyObject* args)
delete self->mix;
}
self->mix = new AmAudioMixIn(a, b, s, l);
self->mix = new AmAudioMixIn(a, b, s, l, finish);
Py_INCREF(Py_None);
return Py_None;

@ -29,8 +29,11 @@
#include "SampleArray.h"
AmAudioMixIn::AmAudioMixIn(AmAudio* A, AmAudioFile* B,
unsigned int s, double l)
: A(A),B(B), s(s), l(l), mixing(false), next_start_ts_i(false)
unsigned int s, double l,
bool finish_b_while_mixing)
: A(A),B(B), s(s), l(l),
mixing(false), next_start_ts_i(false),
finish_b_while_mixing(finish_b_while_mixing)
{
}
AmAudioMixIn::~AmAudioMixIn() { }
@ -68,7 +71,7 @@ int AmAudioMixIn::get(unsigned int user_ts, unsigned char* buffer,
// get audio from A
int len = A->get(user_ts, (unsigned char*)mix_buf, nb_samples);
if (len<0) { // A finished
if ((len<0) && !finish_b_while_mixing) { // A finished
return len;
}
for (int i=0;i<len;i++) {
@ -78,8 +81,13 @@ int AmAudioMixIn::get(unsigned int user_ts, unsigned char* buffer,
res = len;
// clear the rest
if (nb_samples<<1 != (unsigned int)len)
memset((void*)pdest[len], 0, nb_samples<<1 - (unsigned int)len);
unsigned int len_from_a = 0;
if (res>0)
len_from_a=(unsigned int)res;
if (nb_samples<<1 != len_from_a)
memset((void*)&pdest[len_from_a>>1], 0,
nb_samples<<1 - len_from_a);
// add audio from B
len = B->get(user_ts, (unsigned char*)mix_buf, nb_samples);

@ -50,6 +50,7 @@ class AmAudioMixIn : public AmAudio {
AmAudioFile* B;
unsigned int s;
double l;
bool finish_b_while_mixing;
bool mixing;
@ -58,9 +59,11 @@ class AmAudioMixIn : public AmAudio {
short mix_buf[MAX_BUF_SAMPLES]; // 240
public:
AmAudioMixIn(AmAudio* A, AmAudioFile* B,
unsigned int s, double l);
unsigned int s, double l,
bool finish_b_while_mixing = false);
~AmAudioMixIn();
protected:
// not used

Loading…
Cancel
Save