Yes I think you're right Jereon!  Well done - that's a subtle one and I 
had to drink 2 cups of coffee and mess about with pencil and paper to 
see the issue :-)

I've updated codec2.c and the C<->Octave unit tests with your fix.

Thanks,

David

On 16/01/17 00:07, Jeroen Vreeken wrote:
>
>
> On 01/15/2017 09:48 AM, David Rowe wrote:
>>
>> We need to call analyse_one_frame() every 10ms as that's the internal
>> frame rate of the core sinusoidal modeling inside Codec 2.  Note the ptr
>> into the input speech vector is offset by 80 samples (10ms) each time.
>> We need the input speech sample driver to supply us with a 320 sample
>> (40ms) input vector. Various states need to be updated even though we
>> toss the output model parameters away for 3/4 of the frames in 700C.
>>
>> Just transmitting the model parameters 1 in every 4 frames is like
>> "decimation in time" of any sampled sequence.  At the decoder, to
>> reconstruct the missing frames (say 2,3,4) we interpolate between need
>> frames 1 and 5.
>>
>> So we could send a sequence of frames 1,5,9 or 2,6,10 ... either way you
>> get a 40ms latency.
>
> The 40ms I get, but to me the current code looks like it is introducing
> yet another 30ms latency by not taking the updated model into account
> untill the next call to the function. I can even see it in the energy
> output of the different frames, it is almost a whole frame delayed
> compared to the other modes.
> Wouldn't the following change remove the 30ms without changing the reset
> of the interpolation?
>
> --- src/codec2.c    (revision 2964)
> +++ src/codec2.c    (working copy)
> @@ -1797,8 +1797,11 @@
>
>      memset(bits, '\0',  ((codec2_bits_per_frame(c2) + 7) / 8));
>
> -    analyse_one_frame(c2, &model, speech);
> +    for(i=0; i<M; i++) {
> +        analyse_one_frame(c2, &model, &speech[i*N_SAMP]);
> +    }
>
> +
>      int K = 20;
>      float rate_K_vec[K], mean;
>      float rate_K_vec_no_mean[K], rate_K_vec_no_mean_[K];
> @@ -1812,10 +1815,6 @@
>                               rate_K_vec_no_mean,
>                               rate_K_vec_no_mean_);
>
> -    for(i=1; i<M; i++) {
> -        analyse_one_frame(c2, &model, &speech[i*N_SAMP]);
> -    }
> -
>      pack_natural_or_gray(bits, &nbit, indexes[0], 9, 0);
>      pack_natural_or_gray(bits, &nbit, indexes[1], 9, 0);
>      pack_natural_or_gray(bits, &nbit, indexes[2], 4, 0);
>
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> Freetel-codec2 mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freetel-codec2
>

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Freetel-codec2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freetel-codec2

Reply via email to