コード例 #1
0
ファイル: Floor0.cs プロジェクト: perivar/FindSimilarCore
        override public int inverse2(Block vb, Object i, Object memo, float[] fout)
        {
            //System.err.println("Floor0.inverse "+i.getClass()+"]");
            LookFloor0 look = (LookFloor0)i;
            InfoFloor0 info = look.vi;

            if (memo != null)
            {
                float[] lsp = (float[])memo;
                float   amp = lsp[look.m];

                Lsp.lsp_to_curve(fout, look.linearmap, look.n, look.ln,
                                 lsp, look.m, amp, info.ampdB);
                return(1);
            }
            //  eop:
            //    memset(out,0,sizeof(float)*look->n);
            for (int j = 0; j < look.n; j++)
            {
                fout[j] = 0.0f;
            }
            return(0);
        }
コード例 #2
0
ファイル: Floor0.cs プロジェクト: perivar/FindSimilarCore
        int inverse(Block vb, Object i, float[] fout)
        {
            //System.err.println("Floor0.inverse "+i.getClass()+"]");
            LookFloor0 look   = (LookFloor0)i;
            InfoFloor0 info   = look.vi;
            int        ampraw = vb.opb.read(info.ampbits);

            if (ampraw > 0)
            {
                // also handles the -1 out of data case
                int   maxval  = (1 << info.ampbits) - 1;
                float amp     = (float)ampraw / maxval * info.ampdB;
                int   booknum = vb.opb.read(ilog(info.numbooks));

                if (booknum != -1 && booknum < info.numbooks)
                {
                    lock (this) {
                        if (lsp == null || lsp.Length < look.m)
                        {
                            lsp = new float[look.m];
                        }
                        else
                        {
                            for (int j = 0; j < look.m; j++)
                            {
                                lsp[j] = 0.0f;
                            }
                        }

                        CodeBook b    = vb.vd.fullbooks[info.books[booknum]];
                        float    last = 0.0f;

                        //memset(out,0,sizeof(float)*look->m);
                        for (int j = 0; j < look.m; j++)
                        {
                            fout[j] = 0.0f;
                        }

                        for (int j = 0; j < look.m; j += b.dim)
                        {
                            if (b.decodevs(lsp, j, vb.opb, 1, -1) == -1)
                            {
                                //goto eop;
                                // memset(out,0,sizeof(float)*look->n);
                                for (int k = 0; k < look.n; k++)
                                {
                                    fout[k] = 0.0f;
                                }
                                return(0);
                            }
                        }
                        for (int j = 0; j < look.m;)
                        {
                            for (int k = 0; k < b.dim; k++, j++)
                            {
                                lsp[j] += last;
                            }
                            last = lsp[j - 1];
                        }
                        // take the coefficients back to a spectral envelope curve

                        /*
                         * lsp_to_lpc(out,out,look.m);
                         * lpc_to_curve(out,out,amp,look,"",0);
                         * for(int j=0;j<look.n;j++){
                         * out[j]=fromdB(out[j]-info.ampdB);
                         * }
                         */
                        Lsp.lsp_to_curve(fout, look.linearmap, look.n, look.ln,
                                         lsp, look.m, amp, info.ampdB);

                        return(1);
                    }
                }
            }
            //  eop:
            //    memset(out,0,sizeof(float)*look->n);
            return(0);
        }