diff --git a/dereverbrate/dereveb_c/FFTImplementationCallback.cpp b/dereverbrate/dereveb_c/FFTImplementationCallback.cpp index c8eed23..def8499 100644 --- a/dereverbrate/dereveb_c/FFTImplementationCallback.cpp +++ b/dereverbrate/dereveb_c/FFTImplementationCallback.cpp @@ -1,968 +1,968 @@ // // File: FFTImplementationCallback.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "FFTImplementationCallback.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : const ::coder::array &x // int xoffInit // ::coder::array &y // int nrowsx // int nRows // int nfft // const ::coder::array &wwc // const ::coder::array &costab // const ::coder::array &sintab // const ::coder::array &costabinv // const ::coder::array &sintabinv // Return Type : void // namespace coder { namespace internal { void FFTImplementationCallback::doHalfLengthBluestein( const ::coder::array &x, int xoffInit, ::coder::array &y, int nrowsx, int nRows, int nfft, const ::coder::array &wwc, const ::coder::array &costab, const ::coder::array &sintab, const ::coder::array &costabinv, const ::coder::array &sintabinv) { array fv; array fy; array reconVar1; array reconVar2; array ytmp; array b_costab; array b_sintab; array costab1q; array hcostabinv; array hsintab; array hsintabinv; array wrapIndex; double b_temp_re_tmp; double re_tmp; double temp_im; double temp_re; double twid_im; double twid_re; double z_tmp; int hnRows; int i; int iDelta2; int ihi; int istart; int j; int ju; int k; int nRowsD2; int nd2; int temp_re_tmp; boolean_T tst; hnRows = nRows / 2; ytmp.set_size(hnRows); if (hnRows > nrowsx) { ytmp.set_size(hnRows); for (iDelta2 = 0; iDelta2 < hnRows; iDelta2++) { ytmp[iDelta2].re = 0.0; ytmp[iDelta2].im = 0.0; } } if ((x.size(0) & 1) == 0) { tst = true; ihi = x.size(0); } else if (x.size(0) >= nRows) { tst = true; ihi = nRows; } else { tst = false; ihi = x.size(0) - 1; } if (ihi > nRows) { ihi = nRows; } nd2 = nRows << 1; temp_im = 6.2831853071795862 / static_cast(nd2); j = nd2 / 2 / 2; costab1q.set_size(1, j + 1); costab1q[0] = 1.0; nd2 = j / 2 - 1; for (k = 0; k <= nd2; k++) { costab1q[k + 1] = std::cos(temp_im * (static_cast(k) + 1.0)); } iDelta2 = nd2 + 2; nd2 = j - 1; for (k = iDelta2; k <= nd2; k++) { costab1q[k] = std::sin(temp_im * static_cast(j - k)); } costab1q[j] = 0.0; j = costab1q.size(1) - 1; nd2 = (costab1q.size(1) - 1) << 1; b_costab.set_size(1, nd2 + 1); b_sintab.set_size(1, nd2 + 1); b_costab[0] = 1.0; b_sintab[0] = 0.0; for (k = 0; k < j; k++) { b_costab[k + 1] = costab1q[k + 1]; b_sintab[k + 1] = -costab1q[(j - k) - 1]; } iDelta2 = costab1q.size(1); for (k = iDelta2; k <= nd2; k++) { b_costab[k] = -costab1q[nd2 - k]; b_sintab[k] = -costab1q[k - j]; } nd2 = costab.size(1) / 2; costab1q.set_size(1, nd2); hsintab.set_size(1, nd2); hcostabinv.set_size(1, nd2); hsintabinv.set_size(1, nd2); for (i = 0; i < nd2; i++) { iDelta2 = ((i + 1) << 1) - 2; costab1q[i] = costab[iDelta2]; hsintab[i] = sintab[iDelta2]; hcostabinv[i] = costabinv[iDelta2]; hsintabinv[i] = sintabinv[iDelta2]; } reconVar1.set_size(hnRows); reconVar2.set_size(hnRows); wrapIndex.set_size(1, hnRows); for (i = 0; i < hnRows; i++) { iDelta2 = i << 1; temp_im = b_sintab[iDelta2]; temp_re = b_costab[iDelta2]; reconVar1[i].re = temp_im + 1.0; reconVar1[i].im = -temp_re; reconVar2[i].re = 1.0 - temp_im; reconVar2[i].im = temp_re; if (i + 1 != 1) { wrapIndex[i] = (hnRows - i) + 1; } else { wrapIndex[0] = 1; } } z_tmp = static_cast(ihi) / 2.0; iDelta2 = static_cast(z_tmp); for (ju = 0; ju < iDelta2; ju++) { temp_re_tmp = (hnRows + ju) - 1; temp_re = wwc[temp_re_tmp].re; temp_im = wwc[temp_re_tmp].im; nd2 = xoffInit + (ju << 1); twid_re = x[nd2]; twid_im = x[nd2 + 1]; ytmp[ju].re = temp_re * twid_re + temp_im * twid_im; ytmp[ju].im = temp_re * twid_im - temp_im * twid_re; } if (!tst) { temp_re_tmp = (hnRows + static_cast(z_tmp)) - 1; temp_re = wwc[temp_re_tmp].re; temp_im = wwc[temp_re_tmp].im; twid_re = x[xoffInit + (static_cast(z_tmp) << 1)]; ytmp[static_cast(z_tmp)].re = temp_re * twid_re + temp_im * 0.0; ytmp[static_cast(z_tmp)].im = temp_re * 0.0 - temp_im * twid_re; if (static_cast(z_tmp) + 2 <= hnRows) { iDelta2 = static_cast(static_cast(ihi) / 2.0) + 2; for (i = iDelta2; i <= hnRows; i++) { ytmp[i - 1].re = 0.0; ytmp[i - 1].im = 0.0; } } } else if (static_cast(z_tmp) + 1 <= hnRows) { iDelta2 = static_cast(static_cast(ihi) / 2.0) + 1; for (i = iDelta2; i <= hnRows; i++) { ytmp[i - 1].re = 0.0; ytmp[i - 1].im = 0.0; } } z_tmp = static_cast(nfft) / 2.0; nd2 = static_cast(z_tmp); fy.set_size(nd2); if (static_cast(z_tmp) > ytmp.size(0)) { fy.set_size(nd2); for (iDelta2 = 0; iDelta2 < nd2; iDelta2++) { fy[iDelta2].re = 0.0; fy[iDelta2].im = 0.0; } } ihi = ytmp.size(0); istart = static_cast(z_tmp); if (ihi <= istart) { istart = ihi; } iDelta2 = static_cast(z_tmp) - 2; nRowsD2 = static_cast(z_tmp) / 2; k = nRowsD2 / 2; nd2 = 0; ju = 0; for (i = 0; i <= istart - 2; i++) { fy[nd2] = ytmp[i]; j = static_cast(z_tmp); tst = true; while (tst) { j >>= 1; ju ^= j; tst = ((ju & j) == 0); } nd2 = ju; } fy[nd2] = ytmp[istart - 1]; if (static_cast(z_tmp) > 1) { for (i = 0; i <= iDelta2; i += 2) { b_temp_re_tmp = fy[i + 1].re; temp_re = fy[i + 1].im; re_tmp = fy[i].re; twid_re = fy[i].im; fy[i + 1].re = re_tmp - b_temp_re_tmp; fy[i + 1].im = twid_re - temp_re; fy[i].re = re_tmp + b_temp_re_tmp; fy[i].im = twid_re + temp_re; } } nd2 = 2; iDelta2 = 4; ju = ((k - 1) << 2) + 1; while (k > 0) { for (i = 0; i < ju; i += iDelta2) { temp_re_tmp = i + nd2; temp_re = fy[temp_re_tmp].re; temp_im = fy[temp_re_tmp].im; fy[temp_re_tmp].re = fy[i].re - temp_re; fy[temp_re_tmp].im = fy[i].im - temp_im; fy[i].re = fy[i].re + temp_re; fy[i].im = fy[i].im + temp_im; } istart = 1; for (j = k; j < nRowsD2; j += k) { twid_re = costab1q[j]; twid_im = hsintab[j]; i = istart; ihi = istart + ju; while (i < ihi) { temp_re_tmp = i + nd2; b_temp_re_tmp = fy[temp_re_tmp].im; temp_im = fy[temp_re_tmp].re; temp_re = twid_re * temp_im - twid_im * b_temp_re_tmp; temp_im = twid_re * b_temp_re_tmp + twid_im * temp_im; fy[temp_re_tmp].re = fy[i].re - temp_re; fy[temp_re_tmp].im = fy[i].im - temp_im; fy[i].re = fy[i].re + temp_re; fy[i].im = fy[i].im + temp_im; i += iDelta2; } istart++; } k /= 2; nd2 = iDelta2; iDelta2 += iDelta2; ju -= nd2; } FFTImplementationCallback::r2br_r2dit_trig_impl(wwc, static_cast(z_tmp), costab1q, hsintab, fv); nd2 = fy.size(0); for (iDelta2 = 0; iDelta2 < nd2; iDelta2++) { re_tmp = fy[iDelta2].re; twid_im = fv[iDelta2].im; temp_im = fy[iDelta2].im; temp_re = fv[iDelta2].re; fy[iDelta2].re = re_tmp * temp_re - temp_im * twid_im; fy[iDelta2].im = re_tmp * twid_im + temp_im * temp_re; } FFTImplementationCallback::r2br_r2dit_trig_impl(fy, static_cast(z_tmp), hcostabinv, hsintabinv, fv); if (fv.size(0) > 1) { temp_im = 1.0 / static_cast(fv.size(0)); nd2 = fv.size(0); for (iDelta2 = 0; iDelta2 < nd2; iDelta2++) { fv[iDelta2].re = temp_im * fv[iDelta2].re; fv[iDelta2].im = temp_im * fv[iDelta2].im; } } iDelta2 = wwc.size(0); for (k = hnRows; k <= iDelta2; k++) { temp_im = wwc[k - 1].re; temp_re = fv[k - 1].im; twid_re = wwc[k - 1].im; twid_im = fv[k - 1].re; nd2 = k - hnRows; ytmp[nd2].re = temp_im * twid_im + twid_re * temp_re; ytmp[nd2].im = temp_im * temp_re - twid_re * twid_im; } for (i = 0; i < hnRows; i++) { double ytmp_re_tmp; iDelta2 = wrapIndex[i]; temp_im = ytmp[i].re; temp_re = reconVar1[i].im; twid_re = ytmp[i].im; twid_im = reconVar1[i].re; re_tmp = ytmp[iDelta2 - 1].re; b_temp_re_tmp = -ytmp[iDelta2 - 1].im; z_tmp = reconVar2[i].im; ytmp_re_tmp = reconVar2[i].re; y[i].re = 0.5 * ((temp_im * twid_im - twid_re * temp_re) + (re_tmp * ytmp_re_tmp - b_temp_re_tmp * z_tmp)); y[i].im = 0.5 * ((temp_im * temp_re + twid_re * twid_im) + (re_tmp * z_tmp + b_temp_re_tmp * ytmp_re_tmp)); iDelta2 = hnRows + i; y[iDelta2].re = 0.5 * ((temp_im * ytmp_re_tmp - twid_re * z_tmp) + (re_tmp * twid_im - b_temp_re_tmp * temp_re)); y[iDelta2].im = 0.5 * ((temp_im * z_tmp + twid_re * ytmp_re_tmp) + (re_tmp * temp_re + b_temp_re_tmp * twid_im)); } } // // Arguments : const ::coder::array &x // int xoffInit // ::coder::array &y // int unsigned_nRows // const ::coder::array &costab // const ::coder::array &sintab // Return Type : void // void FFTImplementationCallback::doHalfLengthRadix2( const ::coder::array &x, int xoffInit, ::coder::array &y, int unsigned_nRows, const ::coder::array &costab, const ::coder::array &sintab) { array reconVar1; array reconVar2; array hcostab; array hsintab; array wrapIndex; array bitrevIndex; double b_y_re_tmp; double c_y_re_tmp; double d_y_re_tmp; double temp2_im; double temp2_re; double temp_im; double temp_im_tmp; double temp_re; double temp_re_tmp; double y_re_tmp; double z_tmp; int hszCostab; int i; int istart; int iy; int j; int ju; int k; int nRows; int nRowsD2; int nRowsM2; boolean_T tst; nRows = unsigned_nRows / 2; j = y.size(0); if (j > nRows) { j = nRows; } nRowsM2 = nRows - 2; nRowsD2 = nRows / 2; k = nRowsD2 / 2; hszCostab = costab.size(1) / 2; hcostab.set_size(1, hszCostab); hsintab.set_size(1, hszCostab); for (i = 0; i < hszCostab; i++) { iy = ((i + 1) << 1) - 2; hcostab[i] = costab[iy]; hsintab[i] = sintab[iy]; } reconVar1.set_size(nRows); reconVar2.set_size(nRows); wrapIndex.set_size(1, nRows); for (i = 0; i < nRows; i++) { temp_re = sintab[i]; temp2_re = costab[i]; reconVar1[i].re = temp_re + 1.0; reconVar1[i].im = -temp2_re; reconVar2[i].re = 1.0 - temp_re; reconVar2[i].im = temp2_re; if (i + 1 != 1) { wrapIndex[i] = (nRows - i) + 1; } else { wrapIndex[0] = 1; } } z_tmp = static_cast(unsigned_nRows) / 2.0; ju = 0; iy = 1; hszCostab = static_cast(z_tmp); bitrevIndex.set_size(hszCostab); for (istart = 0; istart < hszCostab; istart++) { bitrevIndex[istart] = 0; } for (istart = 0; istart <= j - 2; istart++) { bitrevIndex[istart] = iy; hszCostab = static_cast(z_tmp); tst = true; while (tst) { hszCostab >>= 1; ju ^= hszCostab; tst = ((ju & hszCostab) == 0); } iy = ju + 1; } bitrevIndex[j - 1] = iy; if ((x.size(0) & 1) == 0) { tst = true; j = x.size(0); } else if (x.size(0) >= unsigned_nRows) { tst = true; j = unsigned_nRows; } else { tst = false; j = x.size(0) - 1; } if (j > unsigned_nRows) { j = unsigned_nRows; } temp_re = static_cast(j) / 2.0; istart = static_cast(temp_re); for (i = 0; i < istart; i++) { iy = xoffInit + (i << 1); y[bitrevIndex[i] - 1].re = x[iy]; y[bitrevIndex[i] - 1].im = x[iy + 1]; } if (!tst) { istart = bitrevIndex[static_cast(temp_re)] - 1; y[istart].re = x[xoffInit + (static_cast(temp_re) << 1)]; y[istart].im = 0.0; } if (nRows > 1) { for (i = 0; i <= nRowsM2; i += 2) { temp_re_tmp = y[i + 1].re; temp_im_tmp = y[i + 1].im; y[i + 1].re = y[i].re - temp_re_tmp; y[i + 1].im = y[i].im - y[i + 1].im; y[i].re = y[i].re + temp_re_tmp; y[i].im = y[i].im + temp_im_tmp; } } hszCostab = 2; iy = 4; ju = ((k - 1) << 2) + 1; while (k > 0) { for (i = 0; i < ju; i += iy) { nRowsM2 = i + hszCostab; temp_re = y[nRowsM2].re; temp_im = y[nRowsM2].im; y[nRowsM2].re = y[i].re - temp_re; y[nRowsM2].im = y[i].im - temp_im; y[i].re = y[i].re + temp_re; y[i].im = y[i].im + temp_im; } istart = 1; for (j = k; j < nRowsD2; j += k) { temp2_re = hcostab[j]; temp2_im = hsintab[j]; i = istart; nRows = istart + ju; while (i < nRows) { nRowsM2 = i + hszCostab; temp_re_tmp = y[nRowsM2].im; y_re_tmp = y[nRowsM2].re; temp_re = temp2_re * y_re_tmp - temp2_im * temp_re_tmp; temp_im = temp2_re * temp_re_tmp + temp2_im * y_re_tmp; y[nRowsM2].re = y[i].re - temp_re; y[nRowsM2].im = y[i].im - temp_im; y[i].re = y[i].re + temp_re; y[i].im = y[i].im + temp_im; i += iy; } istart++; } k /= 2; hszCostab = iy; iy += iy; ju -= hszCostab; } hszCostab = static_cast(z_tmp) / 2; temp_re_tmp = y[0].re; temp_im_tmp = y[0].im; y[0].re = 0.5 * ((temp_re_tmp * reconVar1[0].re - temp_im_tmp * reconVar1[0].im) + (temp_re_tmp * reconVar2[0].re - -temp_im_tmp * reconVar2[0].im)); y[0].im = 0.5 * ((temp_re_tmp * reconVar1[0].im + temp_im_tmp * reconVar1[0].re) + (temp_re_tmp * reconVar2[0].im + -temp_im_tmp * reconVar2[0].re)); y[static_cast(z_tmp)].re = 0.5 * ((temp_re_tmp * reconVar2[0].re - temp_im_tmp * reconVar2[0].im) + (temp_re_tmp * reconVar1[0].re - -temp_im_tmp * reconVar1[0].im)); y[static_cast(z_tmp)].im = 0.5 * ((temp_re_tmp * reconVar2[0].im + temp_im_tmp * reconVar2[0].re) + (temp_re_tmp * reconVar1[0].im + -temp_im_tmp * reconVar1[0].re)); for (i = 2; i <= hszCostab; i++) { double temp2_im_tmp; temp_re_tmp = y[i - 1].re; temp_im_tmp = y[i - 1].im; istart = wrapIndex[i - 1]; temp2_im = y[istart - 1].re; temp2_im_tmp = y[istart - 1].im; y_re_tmp = reconVar1[i - 1].im; b_y_re_tmp = reconVar1[i - 1].re; c_y_re_tmp = reconVar2[i - 1].im; d_y_re_tmp = reconVar2[i - 1].re; y[i - 1].re = 0.5 * ((temp_re_tmp * b_y_re_tmp - temp_im_tmp * y_re_tmp) + (temp2_im * d_y_re_tmp - -temp2_im_tmp * c_y_re_tmp)); y[i - 1].im = 0.5 * ((temp_re_tmp * y_re_tmp + temp_im_tmp * b_y_re_tmp) + (temp2_im * c_y_re_tmp + -temp2_im_tmp * d_y_re_tmp)); iy = (static_cast(z_tmp) + i) - 1; y[iy].re = 0.5 * ((temp_re_tmp * d_y_re_tmp - temp_im_tmp * c_y_re_tmp) + (temp2_im * b_y_re_tmp - -temp2_im_tmp * y_re_tmp)); y[iy].im = 0.5 * ((temp_re_tmp * c_y_re_tmp + temp_im_tmp * d_y_re_tmp) + (temp2_im * y_re_tmp + -temp2_im_tmp * b_y_re_tmp)); temp_im = reconVar1[istart - 1].im; temp_re = reconVar1[istart - 1].re; y_re_tmp = reconVar2[istart - 1].im; temp2_re = reconVar2[istart - 1].re; y[istart - 1].re = 0.5 * ((temp2_im * temp_re - temp2_im_tmp * temp_im) + (temp_re_tmp * temp2_re - -temp_im_tmp * y_re_tmp)); y[istart - 1].im = 0.5 * ((temp2_im * temp_im + temp2_im_tmp * temp_re) + (temp_re_tmp * y_re_tmp + -temp_im_tmp * temp2_re)); istart = (istart + static_cast(z_tmp)) - 1; y[istart].re = 0.5 * ((temp2_im * temp2_re - temp2_im_tmp * y_re_tmp) + (temp_re_tmp * temp_re - -temp_im_tmp * temp_im)); y[istart].im = 0.5 * ((temp2_im * y_re_tmp + temp2_im_tmp * temp2_re) + (temp_re_tmp * temp_im + -temp_im_tmp * temp_re)); } temp_re_tmp = y[hszCostab].re; temp_im_tmp = y[hszCostab].im; y_re_tmp = reconVar1[hszCostab].im; b_y_re_tmp = reconVar1[hszCostab].re; c_y_re_tmp = reconVar2[hszCostab].im; d_y_re_tmp = reconVar2[hszCostab].re; temp_re = temp_re_tmp * d_y_re_tmp; temp2_re = temp_re_tmp * b_y_re_tmp; y[hszCostab].re = 0.5 * ((temp2_re - temp_im_tmp * y_re_tmp) + (temp_re - -temp_im_tmp * c_y_re_tmp)); temp2_im = temp_re_tmp * c_y_re_tmp; temp_im = temp_re_tmp * y_re_tmp; y[hszCostab].im = 0.5 * ((temp_im + temp_im_tmp * b_y_re_tmp) + (temp2_im + -temp_im_tmp * d_y_re_tmp)); istart = static_cast(z_tmp) + hszCostab; y[istart].re = 0.5 * ((temp_re - temp_im_tmp * c_y_re_tmp) + (temp2_re - -temp_im_tmp * y_re_tmp)); y[istart].im = 0.5 * ((temp2_im + temp_im_tmp * d_y_re_tmp) + (temp_im + -temp_im_tmp * b_y_re_tmp)); } // // Arguments : const ::coder::array &x // int n2blue // int nfft // const ::coder::array &costab // const ::coder::array &sintab // const ::coder::array &sintabinv // ::coder::array &y // Return Type : void // void FFTImplementationCallback::dobluesteinfft( const ::coder::array &x, int n2blue, int nfft, const ::coder::array &costab, const ::coder::array &sintab, const ::coder::array &sintabinv, ::coder::array &y) { array b_fv; array fv; array r; array wwc; double b_re_tmp; double c_re_tmp; double d_re_tmp; double re_tmp; int b_k; int b_y; int i; int i1; int minNrowsNx; int nInt2m1; int u0; int xoff; if ((nfft & 1) == 0) { int k; int nInt2; int nRows; int rt; nRows = nfft / 2; nInt2m1 = (nRows + nRows) - 1; wwc.set_size(nInt2m1); rt = 0; wwc[nRows - 1].re = 1.0; wwc[nRows - 1].im = 0.0; nInt2 = nRows << 1; for (k = 0; k <= nRows - 2; k++) { double nt_im; double nt_re; b_y = ((k + 1) << 1) - 1; if (nInt2 - rt <= b_y) { rt += b_y - nInt2; } else { rt += b_y; } nt_im = -3.1415926535897931 * static_cast(rt) / static_cast(nRows); if (nt_im == 0.0) { nt_re = 1.0; nt_im = 0.0; } else { nt_re = std::cos(nt_im); nt_im = std::sin(nt_im); } i = (nRows - k) - 2; wwc[i].re = nt_re; wwc[i].im = -nt_im; } i = nInt2m1 - 1; for (k = i; k >= nRows; k--) { wwc[k] = wwc[(nInt2m1 - k) - 1]; } } else { int k; int nInt2; int rt; nInt2m1 = (nfft + nfft) - 1; wwc.set_size(nInt2m1); rt = 0; wwc[nfft - 1].re = 1.0; wwc[nfft - 1].im = 0.0; nInt2 = nfft << 1; for (k = 0; k <= nfft - 2; k++) { double nt_im; double nt_re; b_y = ((k + 1) << 1) - 1; if (nInt2 - rt <= b_y) { rt += b_y - nInt2; } else { rt += b_y; } nt_im = -3.1415926535897931 * static_cast(rt) / static_cast(nfft); if (nt_im == 0.0) { nt_re = 1.0; nt_im = 0.0; } else { nt_re = std::cos(nt_im); nt_im = std::sin(nt_im); } i = (nfft - k) - 2; wwc[i].re = nt_re; wwc[i].im = -nt_im; } i = nInt2m1 - 1; for (k = i; k >= nfft; k--) { wwc[k] = wwc[(nInt2m1 - k) - 1]; } } nInt2m1 = x.size(0); y.set_size(nfft, x.size(1)); if (nfft > x.size(0)) { y.set_size(nfft, x.size(1)); b_y = nfft * x.size(1); for (i = 0; i < b_y; i++) { y[i].re = 0.0; y[i].im = 0.0; } } b_y = x.size(1) - 1; #pragma omp parallel for num_threads(omp_get_max_threads()) private( \ fv, b_fv, r, xoff, i1, minNrowsNx, u0, b_k, re_tmp, b_re_tmp, c_re_tmp, \ d_re_tmp) for (int chan = 0; chan <= b_y; chan++) { xoff = chan * nInt2m1; r.set_size(nfft); if (nfft > x.size(0)) { r.set_size(nfft); for (i1 = 0; i1 < nfft; i1++) { r[i1].re = 0.0; r[i1].im = 0.0; } } if ((n2blue != 1) && ((nfft & 1) == 0)) { FFTImplementationCallback::doHalfLengthBluestein( x, xoff, r, x.size(0), nfft, n2blue, wwc, costab, sintab, costab, sintabinv); } else { minNrowsNx = x.size(0); if (nfft <= minNrowsNx) { minNrowsNx = nfft; } for (b_k = 0; b_k < minNrowsNx; b_k++) { u0 = (nfft + b_k) - 1; i1 = xoff + b_k; r[b_k].re = wwc[u0].re * x[i1]; r[b_k].im = wwc[u0].im * -x[i1]; } i1 = minNrowsNx + 1; for (b_k = i1; b_k <= nfft; b_k++) { r[b_k - 1].re = 0.0; r[b_k - 1].im = 0.0; } FFTImplementationCallback::r2br_r2dit_trig_impl(r, n2blue, costab, sintab, b_fv); FFTImplementationCallback::r2br_r2dit_trig_impl(wwc, n2blue, costab, sintab, fv); fv.set_size(b_fv.size(0)); u0 = b_fv.size(0); for (i1 = 0; i1 < u0; i1++) { re_tmp = b_fv[i1].re; b_re_tmp = fv[i1].im; c_re_tmp = b_fv[i1].im; d_re_tmp = fv[i1].re; fv[i1].re = re_tmp * d_re_tmp - c_re_tmp * b_re_tmp; fv[i1].im = re_tmp * b_re_tmp + c_re_tmp * d_re_tmp; } FFTImplementationCallback::r2br_r2dit_trig_impl(fv, n2blue, costab, sintabinv, b_fv); if (b_fv.size(0) > 1) { re_tmp = 1.0 / static_cast(b_fv.size(0)); u0 = b_fv.size(0); for (i1 = 0; i1 < u0; i1++) { b_fv[i1].re = re_tmp * b_fv[i1].re; b_fv[i1].im = re_tmp * b_fv[i1].im; } } i1 = wwc.size(0); for (b_k = nfft; b_k <= i1; b_k++) { re_tmp = wwc[b_k - 1].re; b_re_tmp = b_fv[b_k - 1].im; c_re_tmp = wwc[b_k - 1].im; d_re_tmp = b_fv[b_k - 1].re; u0 = b_k - nfft; r[u0].re = re_tmp * d_re_tmp + c_re_tmp * b_re_tmp; r[u0].im = re_tmp * b_re_tmp - c_re_tmp * d_re_tmp; } } u0 = r.size(0); for (i1 = 0; i1 < u0; i1++) { y[i1 + y.size(0) * chan] = r[i1]; } } } // // Arguments : int nfft // boolean_T useRadix2 // int *n2blue // int *nRows // Return Type : void // void FFTImplementationCallback::get_algo_sizes(int nfft, boolean_T useRadix2, int *n2blue, int *nRows) { *n2blue = 1; if (useRadix2) { *nRows = nfft; } else { if (nfft > 0) { int n; int pmax; n = (nfft + nfft) - 1; pmax = 31; if (n <= 1) { pmax = 0; } else { int pmin; boolean_T exitg1; pmin = 0; exitg1 = false; while ((!exitg1) && (pmax - pmin > 1)) { int k; int pow2p; k = (pmin + pmax) >> 1; pow2p = 1 << k; if (pow2p == n) { pmax = k; exitg1 = true; } else if (pow2p > n) { pmax = k; } else { pmin = k; } } } *n2blue = 1 << pmax; } *nRows = *n2blue; } } // // Arguments : const ::coder::array &x // int n1_unsigned // const ::coder::array &costab // const ::coder::array &sintab // ::coder::array &y // Return Type : void // void FFTImplementationCallback::r2br_r2dit_trig( const ::coder::array &x, int n1_unsigned, const ::coder::array &costab, const ::coder::array &sintab, ::coder::array &y) { array r; int i1; int loop_ub; int nrows; int xoff; nrows = x.size(0); y.set_size(n1_unsigned, x.size(1)); if (n1_unsigned > x.size(0)) { y.set_size(n1_unsigned, x.size(1)); loop_ub = n1_unsigned * x.size(1); for (int i{0}; i < loop_ub; i++) { y[i].re = 0.0; y[i].im = 0.0; } } loop_ub = x.size(1) - 1; #pragma omp parallel for num_threads(omp_get_max_threads()) private(r, xoff, i1) for (int chan = 0; chan <= loop_ub; chan++) { xoff = chan * nrows; r.set_size(n1_unsigned); if (n1_unsigned > x.size(0)) { r.set_size(n1_unsigned); for (i1 = 0; i1 < n1_unsigned; i1++) { r[i1].re = 0.0; r[i1].im = 0.0; } } FFTImplementationCallback::doHalfLengthRadix2(x, xoff, r, n1_unsigned, costab, sintab); xoff = r.size(0); for (i1 = 0; i1 < xoff; i1++) { y[i1 + y.size(0) * chan] = r[i1]; } } } // // Arguments : const ::coder::array &x // int unsigned_nRows // const ::coder::array &costab // const ::coder::array &sintab // ::coder::array &y // Return Type : void // void FFTImplementationCallback::r2br_r2dit_trig_impl( const ::coder::array &x, int unsigned_nRows, const ::coder::array &costab, const ::coder::array &sintab, ::coder::array &y) { double temp_im; double temp_re; double temp_re_tmp; double twid_re; int i; int iDelta2; int iheight; int iy; int ju; int k; int nRowsD2; y.set_size(unsigned_nRows); if (unsigned_nRows > x.size(0)) { y.set_size(unsigned_nRows); for (iy = 0; iy < unsigned_nRows; iy++) { y[iy].re = 0.0; y[iy].im = 0.0; } } iDelta2 = x.size(0); if (iDelta2 > unsigned_nRows) { iDelta2 = unsigned_nRows; } iheight = unsigned_nRows - 2; nRowsD2 = unsigned_nRows / 2; k = nRowsD2 / 2; iy = 0; ju = 0; for (i = 0; i <= iDelta2 - 2; i++) { boolean_T tst; y[iy] = x[i]; iy = unsigned_nRows; tst = true; while (tst) { iy >>= 1; ju ^= iy; tst = ((ju & iy) == 0); } iy = ju; } y[iy] = x[iDelta2 - 1]; if (unsigned_nRows > 1) { for (i = 0; i <= iheight; i += 2) { temp_re_tmp = y[i + 1].re; temp_im = y[i + 1].im; temp_re = y[i].re; twid_re = y[i].im; y[i + 1].re = temp_re - temp_re_tmp; y[i + 1].im = twid_re - temp_im; y[i].re = temp_re + temp_re_tmp; y[i].im = twid_re + temp_im; } } iy = 2; iDelta2 = 4; iheight = ((k - 1) << 2) + 1; while (k > 0) { int b_temp_re_tmp; for (i = 0; i < iheight; i += iDelta2) { b_temp_re_tmp = i + iy; temp_re = y[b_temp_re_tmp].re; temp_im = y[b_temp_re_tmp].im; y[b_temp_re_tmp].re = y[i].re - temp_re; y[b_temp_re_tmp].im = y[i].im - temp_im; y[i].re = y[i].re + temp_re; y[i].im = y[i].im + temp_im; } ju = 1; for (int j{k}; j < nRowsD2; j += k) { double twid_im; int ihi; twid_re = costab[j]; twid_im = sintab[j]; i = ju; ihi = ju + iheight; while (i < ihi) { b_temp_re_tmp = i + iy; temp_re_tmp = y[b_temp_re_tmp].im; temp_im = y[b_temp_re_tmp].re; temp_re = twid_re * temp_im - twid_im * temp_re_tmp; temp_im = twid_re * temp_re_tmp + twid_im * temp_im; y[b_temp_re_tmp].re = y[i].re - temp_re; y[b_temp_re_tmp].im = y[i].im - temp_im; y[i].re = y[i].re + temp_re; y[i].im = y[i].im + temp_im; i += iDelta2; } ju++; } k /= 2; iy = iDelta2; iDelta2 += iDelta2; iheight -= iy; } } } // namespace internal } // namespace coder // // File trailer for FFTImplementationCallback.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/FFTImplementationCallback.h b/dereverbrate/dereveb_c/FFTImplementationCallback.h index 57e16b2..2abb496 100644 --- a/dereverbrate/dereveb_c/FFTImplementationCallback.h +++ b/dereverbrate/dereveb_c/FFTImplementationCallback.h @@ -1,65 +1,65 @@ // // File: FFTImplementationCallback.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef FFTIMPLEMENTATIONCALLBACK_H #define FFTIMPLEMENTATIONCALLBACK_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Type Definitions namespace coder { namespace internal { class FFTImplementationCallback { public: static void get_algo_sizes(int nfft, boolean_T useRadix2, int *n2blue, int *nRows); static void r2br_r2dit_trig(const ::coder::array &x, int n1_unsigned, const ::coder::array &costab, const ::coder::array &sintab, ::coder::array &y); static void dobluesteinfft(const ::coder::array &x, int n2blue, int nfft, const ::coder::array &costab, const ::coder::array &sintab, const ::coder::array &sintabinv, ::coder::array &y); static void r2br_r2dit_trig_impl(const ::coder::array &x, int unsigned_nRows, const ::coder::array &costab, const ::coder::array &sintab, ::coder::array &y); protected: static void doHalfLengthRadix2(const ::coder::array &x, int xoffInit, ::coder::array &y, int unsigned_nRows, const ::coder::array &costab, const ::coder::array &sintab); static void doHalfLengthBluestein(const ::coder::array &x, int xoffInit, ::coder::array &y, int nrowsx, int nRows, int nfft, const ::coder::array &wwc, const ::coder::array &costab, const ::coder::array &sintab, const ::coder::array &costabinv, const ::coder::array &sintabinv); }; } // namespace internal } // namespace coder #endif // // File trailer for FFTImplementationCallback.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/cat.cpp b/dereverbrate/dereveb_c/cat.cpp deleted file mode 100644 index 5adeaff..0000000 --- a/dereverbrate/dereveb_c/cat.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -// File: cat.cpp -// -// MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 -// - -// Include Files -#include "cat.h" -#include "rt_nonfinite.h" -#include "coder_array.h" - -// Function Definitions -// -// Arguments : coder::array &x -// const coder::array &r1 -// const coder::array &inputFramePower -// const coder::array &M -// Return Type : void -// -void binary_expand_op(coder::array &x, - const coder::array &r1, - const coder::array &inputFramePower, - const coder::array &M) -{ - coder::array r; - int i; - int loop_ub; - int stride_0_0; - int stride_1_0; - if (inputFramePower.size(0) == 1) { - i = r1.size(0); - } else { - i = inputFramePower.size(0); - } - r.set_size(i); - stride_0_0 = (r1.size(0) != 1); - stride_1_0 = (inputFramePower.size(0) != 1); - if (inputFramePower.size(0) == 1) { - loop_ub = r1.size(0); - } else { - loop_ub = inputFramePower.size(0); - } - for (i = 0; i < loop_ub; i++) { - r[i] = 1.0 - r1[i * stride_0_0] / inputFramePower[i * stride_1_0]; - } - x.set_size(r.size(0), 2); - loop_ub = r.size(0); - for (i = 0; i < loop_ub; i++) { - x[i] = r[i]; - } - loop_ub = M.size(0); - for (i = 0; i < loop_ub; i++) { - x[i + x.size(0)] = 0.0; - } -} - -// -// File trailer for cat.cpp -// -// [EOF] -// diff --git a/dereverbrate/dereveb_c/cat.h b/dereverbrate/dereveb_c/cat.h deleted file mode 100644 index c86f21e..0000000 --- a/dereverbrate/dereveb_c/cat.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// File: cat.h -// -// MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 -// - -#ifndef CAT_H -#define CAT_H - -// Include Files -#include "rtwtypes.h" -#include "coder_array.h" -#include "omp.h" -#include -#include - -// Function Declarations -void binary_expand_op(coder::array &x, - const coder::array &r1, - const coder::array &inputFramePower, - const coder::array &M); - -#endif -// -// File trailer for cat.h -// -// [EOF] -// diff --git a/dereverbrate/dereveb_c/codedescriptor.dmr b/dereverbrate/dereveb_c/codedescriptor.dmr index ca55916..137b03a 100644 Binary files a/dereverbrate/dereveb_c/codedescriptor.dmr and b/dereverbrate/dereveb_c/codedescriptor.dmr differ diff --git a/dereverbrate/dereveb_c/computeDFT.cpp b/dereverbrate/dereveb_c/computeDFT.cpp index 0b17232..3cb20de 100644 --- a/dereverbrate/dereveb_c/computeDFT.cpp +++ b/dereverbrate/dereveb_c/computeDFT.cpp @@ -1,252 +1,252 @@ // // File: computeDFT.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "computeDFT.h" #include "FFTImplementationCallback.h" #include "dereveb_c_rtwutil.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Declarations static int div_s32(int numerator, int denominator); // Function Definitions // // Arguments : int numerator // int denominator // Return Type : int // static int div_s32(int numerator, int denominator) { int quotient; if (denominator == 0) { if (numerator >= 0) { quotient = MAX_int32_T; } else { quotient = MIN_int32_T; } } else { unsigned int b_denominator; unsigned int b_numerator; if (numerator < 0) { b_numerator = ~static_cast(numerator) + 1U; } else { b_numerator = static_cast(numerator); } if (denominator < 0) { b_denominator = ~static_cast(denominator) + 1U; } else { b_denominator = static_cast(denominator); } b_numerator /= b_denominator; if ((numerator < 0) != (denominator < 0)) { quotient = -static_cast(b_numerator); } else { quotient = static_cast(b_numerator); } } return quotient; } // // Arguments : const ::coder::array &xin // double nfft // ::coder::array &Xx // ::coder::array &f // Return Type : void // namespace coder { void computeDFT(const ::coder::array &xin, double nfft, ::coder::array &Xx, ::coder::array &f) { array costab; array costab1q; array sintab; array sintabinv; array wrappedData; array xw; double freq_res; double half_res; int b_remainder; int i; int i1; int k; int loop_ub_tmp; int nFullPasses; int offset; loop_ub_tmp = static_cast(nfft); xw.set_size(loop_ub_tmp, xin.size(1)); offset = static_cast(nfft) * xin.size(1); for (i = 0; i < offset; i++) { xw[i] = 0.0; } if (xin.size(0) > nfft) { i = xin.size(1); for (int j{0}; j < i; j++) { if (xin.size(0) == 1) { wrappedData.set_size(1, loop_ub_tmp); for (i1 = 0; i1 < loop_ub_tmp; i1++) { wrappedData[i1] = 0.0; } } else { wrappedData.set_size(loop_ub_tmp, 1); for (i1 = 0; i1 < loop_ub_tmp; i1++) { wrappedData[i1] = 0.0; } } nFullPasses = div_s32(xin.size(0), static_cast(nfft)); offset = nFullPasses * static_cast(nfft); b_remainder = (xin.size(0) - offset) - 1; for (k = 0; k <= b_remainder; k++) { wrappedData[k] = xin[(offset + k) + xin.size(0) * j]; } i1 = b_remainder + 2; for (k = i1; k <= loop_ub_tmp; k++) { wrappedData[k - 1] = 0.0; } for (b_remainder = 0; b_remainder < nFullPasses; b_remainder++) { offset = b_remainder * static_cast(nfft); for (k = 0; k < loop_ub_tmp; k++) { wrappedData[k] = wrappedData[k] + xin[(offset + k) + xin.size(0) * j]; } } offset = wrappedData.size(0) * wrappedData.size(1); for (i1 = 0; i1 < offset; i1++) { xw[i1 + xw.size(0) * j] = wrappedData[i1]; } } } else { xw.set_size(xin.size(0), xin.size(1)); offset = xin.size(0) * xin.size(1); for (i = 0; i < offset; i++) { xw[i] = xin[i]; } } if ((xw.size(0) == 0) || (xw.size(1) == 0)) { Xx.set_size(loop_ub_tmp, xw.size(1)); offset = static_cast(nfft) * xw.size(1); for (i = 0; i < offset; i++) { Xx[i].re = 0.0; Xx[i].im = 0.0; } } else { boolean_T useRadix2; useRadix2 = ((static_cast(nfft) > 0) && ((static_cast(nfft) & (static_cast(nfft) - 1)) == 0)); internal::FFTImplementationCallback::get_algo_sizes( static_cast(nfft), useRadix2, &nFullPasses, &offset); freq_res = 6.2831853071795862 / static_cast(offset); b_remainder = offset / 2 / 2; costab1q.set_size(1, b_remainder + 1); costab1q[0] = 1.0; offset = b_remainder / 2 - 1; for (k = 0; k <= offset; k++) { costab1q[k + 1] = std::cos(freq_res * (static_cast(k) + 1.0)); } i = offset + 2; i1 = b_remainder - 1; for (k = i; k <= i1; k++) { costab1q[k] = std::sin(freq_res * static_cast(b_remainder - k)); } costab1q[b_remainder] = 0.0; if (!useRadix2) { b_remainder = costab1q.size(1) - 1; offset = (costab1q.size(1) - 1) << 1; costab.set_size(1, offset + 1); sintab.set_size(1, offset + 1); costab[0] = 1.0; sintab[0] = 0.0; sintabinv.set_size(1, offset + 1); for (k = 0; k < b_remainder; k++) { sintabinv[k + 1] = costab1q[(b_remainder - k) - 1]; } i = costab1q.size(1); for (k = i; k <= offset; k++) { sintabinv[k] = costab1q[k - b_remainder]; } for (k = 0; k < b_remainder; k++) { costab[k + 1] = costab1q[k + 1]; sintab[k + 1] = -costab1q[(b_remainder - k) - 1]; } i = costab1q.size(1); for (k = i; k <= offset; k++) { costab[k] = -costab1q[offset - k]; sintab[k] = -costab1q[k - b_remainder]; } } else { b_remainder = costab1q.size(1) - 1; offset = (costab1q.size(1) - 1) << 1; costab.set_size(1, offset + 1); sintab.set_size(1, offset + 1); costab[0] = 1.0; sintab[0] = 0.0; for (k = 0; k < b_remainder; k++) { costab[k + 1] = costab1q[k + 1]; sintab[k + 1] = -costab1q[(b_remainder - k) - 1]; } i = costab1q.size(1); for (k = i; k <= offset; k++) { costab[k] = -costab1q[offset - k]; sintab[k] = -costab1q[k - b_remainder]; } sintabinv.set_size(1, 0); } if (useRadix2) { internal::FFTImplementationCallback::r2br_r2dit_trig( xw, static_cast(nfft), costab, sintab, Xx); } else { internal::FFTImplementationCallback::dobluesteinfft( xw, nFullPasses, static_cast(nfft), costab, sintab, sintabinv, Xx); } } freq_res = 6.2831853071795862 / nfft; if (nfft - 1.0 < 0.0) { costab1q.set_size(costab1q.size(0), 0); } else if (std::isinf(nfft - 1.0) && (0.0 == nfft - 1.0)) { costab1q.set_size(1, 1); costab1q[0] = rtNaN; } else { offset = static_cast(std::floor(nfft - 1.0)); costab1q.set_size(1, offset + 1); for (i = 0; i <= offset; i++) { costab1q[i] = i; } } costab1q.set_size(1, costab1q.size(1)); offset = costab1q.size(1) - 1; for (i = 0; i <= offset; i++) { costab1q[i] = freq_res * costab1q[i]; } half_res = freq_res / 2.0; if (rt_remd_snf(nfft, 2.0) != 0.0) { double halfNPTS; halfNPTS = (nfft + 1.0) / 2.0; costab1q[static_cast(halfNPTS) - 1] = 3.1415926535897931 - half_res; costab1q[static_cast(static_cast(halfNPTS))] = half_res + 3.1415926535897931; } else { costab1q[static_cast(nfft / 2.0 + 1.0) - 1] = 3.1415926535897931; } costab1q[static_cast(nfft) - 1] = 6.2831853071795862 - freq_res; f.set_size(costab1q.size(1)); offset = costab1q.size(1); for (i = 0; i < offset; i++) { f[i] = costab1q[i]; } } } // namespace coder // // File trailer for computeDFT.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/computeDFT.h b/dereverbrate/dereveb_c/computeDFT.h index 18b52b4..f0bf894 100644 --- a/dereverbrate/dereveb_c/computeDFT.h +++ b/dereverbrate/dereveb_c/computeDFT.h @@ -1,30 +1,30 @@ // // File: computeDFT.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef COMPUTEDFT_H #define COMPUTEDFT_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { void computeDFT(const ::coder::array &xin, double nfft, ::coder::array &Xx, ::coder::array &f); } #endif // // File trailer for computeDFT.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c.cpp b/dereverbrate/dereveb_c/dereveb_c.cpp index 6991522..b4ad4bb 100644 --- a/dereverbrate/dereveb_c/dereveb_c.cpp +++ b/dereverbrate/dereveb_c/dereveb_c.cpp @@ -1,1802 +1,1598 @@ // // File: dereveb_c.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "dereveb_c.h" -#include "cat.h" -#include "combineVectorElements.h" #include "dereveb_c_data.h" #include "dereveb_c_initialize.h" #include "div.h" #include "hann.h" #include "ifft.h" #include "ixfun.h" +#include "minOrMax.h" #include "ref.h" #include "rt_nonfinite.h" #include "spectrogram.h" #include "sum.h" +#include "unsafeSxfun.h" #include "coder_array.h" #include #include // Function Declarations static void b_binary_expand_op(coder::array &unchanged, const coder::array &newEstimates, const coder::array &H_pow, int blockIndex); static void binary_expand_op(coder::array &H_pow, int blockIndex, const coder::array &M, const coder::array &C); -static void binary_expand_op(coder::array &G_R, - const coder::captured_var frequencyCount, - const coder::array &G_S); - -static void binary_expand_op(coder::array &allBlocks, - int inputFrameIndex, - const coder::array &G_S, - const coder::array &M); - -static void binary_expand_op(coder::array &vocal_effect, +static void binary_expand_op(coder::array &vocal_reverb, const coder::array &G_R, const coder::array &M, int inputFrameIndex); static void binary_expand_op(coder::array &H_pow_sm, const coder::array &H_pow); static void -binary_expand_op(coder::array &r, +binary_expand_op(coder::array &newEstimates, const coder::array &previousSFramesPower_vc, const coder::array &H_pow_sm); -static void binary_expand_op(coder::array &G_R_vc, +static void binary_expand_op(coder::array &G_Rxx, + const coder::captured_var frequencyCount, + const coder::array &G_Sxx); + +static void binary_expand_op(coder::array &bk_revertant, + const coder::array &G_Rxx, const coder::array &M, - const coder::array &r1, - const coder::array &vocal_effect_sm, - const coder::array &vocal_effect, - const coder::array &inputFramePower); + int inputFrameIndex, + const coder::array &r); static void binary_expand_op(double output[220500], const coder::array &r, const coder::array &sampleRange, const coder::array &window, const coder::array &r1); -static void c_binary_expand_op(coder::array &unchanged, - const coder::array &newEstimates, - const coder::array &inputFramePower); - -static void d_binary_expand_op(coder::array &G_S, +static void c_binary_expand_op(coder::array &G_Sxx, const coder::captured_var frequencyCount, - const coder::array &newEstimates); - -static void gt(coder::array &unchanged, - const coder::array &newEstimates, - const coder::array &inputFramePower); + const coder::array &r1); static void reconstruct(coder::captured_var *stftWindowSize, coder::captured_var *frequencyCount, coder::captured_var *frameCount, const coder::array &spectrumx, const coder::array &window, double overlapSamples, double output[220500]); static double rt_hypotd_snf(double u0, double u1); // Function Definitions // // Arguments : coder::array &unchanged // const coder::array &newEstimates // const coder::array &H_pow // int blockIndex // Return Type : void // static void b_binary_expand_op(coder::array &unchanged, const coder::array &newEstimates, const coder::array &H_pow, int blockIndex) { int i; int loop_ub; int stride_0_0; int stride_1_0; i = H_pow.size(0); if (i == 1) { stride_0_0 = newEstimates.size(0); } else { stride_0_0 = i; } unchanged.set_size(stride_0_0); stride_0_0 = (newEstimates.size(0) != 1); stride_1_0 = (i != 1); if (i == 1) { loop_ub = newEstimates.size(0); } else { loop_ub = i; } for (i = 0; i < loop_ub; i++) { unchanged[i] = (newEstimates[i * stride_0_0] >= H_pow[i * stride_1_0 + H_pow.size(0) * blockIndex]); } } // // Arguments : coder::array &H_pow // int blockIndex // const coder::array &M // const coder::array &C // Return Type : void // static void binary_expand_op(coder::array &H_pow, int blockIndex, const coder::array &M, const coder::array &C) { coder::array r; int b_H_pow; int i; int i1; int i2; int i3; int stride_1_0; int stride_3_0; b_H_pow = H_pow.size(0) - 1; i = M.size(0); i1 = M.size(0); i2 = C.size(0); if (i2 == 1) { i3 = i1; } else { i3 = i2; } if (i3 == 1) { if (b_H_pow + 1 == 1) { i3 = i; } else { i3 = b_H_pow + 1; } } else if (i2 == 1) { i3 = i1; } else { i3 = i2; } r.set_size(i3); stride_1_0 = (b_H_pow + 1 != 1); stride_3_0 = (i2 != 1); if (i2 == 1) { i3 = i1; } else { i3 = i2; } if (i3 == 1) { if (b_H_pow + 1 == 1) { b_H_pow = i; } else { b_H_pow++; } } else if (i2 == 1) { b_H_pow = i1; } else { b_H_pow = i2; } for (i = 0; i < b_H_pow; i++) { r[i] = 0.2 * H_pow[i * stride_1_0 + H_pow.size(0) * blockIndex] + 0.8 * C[i * stride_3_0 + C.size(0) * blockIndex]; } b_H_pow = r.size(0); for (i = 0; i < b_H_pow; i++) { H_pow[i + H_pow.size(0) * blockIndex] = r[i]; } } // -// Arguments : coder::array &G_R -// const coder::captured_var frequencyCount -// const coder::array &G_S -// Return Type : void -// -static void binary_expand_op(coder::array &G_R, - const coder::captured_var frequencyCount, - const coder::array &G_S) -{ - coder::array r; - int i; - int loop_ub; - int stride_1_0; - int stride_3_0; - if (G_S.size(0) == 1) { - i = static_cast(frequencyCount.contents); - } else { - i = G_S.size(0); - } - if (i == 1) { - if (G_R.size(0) == 1) { - i = static_cast(frequencyCount.contents); - } else { - i = G_R.size(0); - } - } else if (G_S.size(0) == 1) { - i = static_cast(frequencyCount.contents); - } else { - i = G_S.size(0); - } - r.set_size(i); - stride_1_0 = (G_R.size(0) != 1); - stride_3_0 = (G_S.size(0) != 1); - if (G_S.size(0) == 1) { - i = static_cast(frequencyCount.contents); - } else { - i = G_S.size(0); - } - if (i == 1) { - if (G_R.size(0) == 1) { - loop_ub = static_cast(frequencyCount.contents); - } else { - loop_ub = G_R.size(0); - } - } else if (G_S.size(0) == 1) { - loop_ub = static_cast(frequencyCount.contents); - } else { - loop_ub = G_S.size(0); - } - for (i = 0; i < loop_ub; i++) { - r[i] = 0.7 * G_R[i * stride_1_0] + 0.3 * (1.0 - G_S[i * stride_3_0]); - } - G_R.set_size(r.size(0)); - loop_ub = r.size(0); - for (i = 0; i < loop_ub; i++) { - G_R[i] = r[i]; - } -} - -// -// Arguments : coder::array &allBlocks -// int inputFrameIndex -// const coder::array &G_S -// const coder::array &M -// Return Type : void -// -static void binary_expand_op(coder::array &allBlocks, - int inputFrameIndex, - const coder::array &G_S, - const coder::array &M) -{ - int i; - int loop_ub; - int stride_0_0; - int stride_1_0; - i = M.size(0); - stride_0_0 = (G_S.size(0) != 1); - stride_1_0 = (i != 1); - if (i == 1) { - loop_ub = G_S.size(0); - } else { - loop_ub = i; - } - for (i = 0; i < loop_ub; i++) { - double d; - int i1; - i1 = i * stride_1_0; - d = G_S[i * stride_0_0]; - allBlocks[i + allBlocks.size(0) * inputFrameIndex].re = - d * M[i1 + M.size(0) * inputFrameIndex].re; - allBlocks[i + allBlocks.size(0) * inputFrameIndex].im = - d * M[i1 + M.size(0) * inputFrameIndex].im; - } -} - -// -// Arguments : coder::array &vocal_effect +// Arguments : coder::array &vocal_reverb // const coder::array &G_R // const coder::array &M // int inputFrameIndex // Return Type : void // -static void binary_expand_op(coder::array &vocal_effect, +static void binary_expand_op(coder::array &vocal_reverb, const coder::array &G_R, const coder::array &M, int inputFrameIndex) { int i; int i1; int loop_ub; int stride_0_0; int stride_1_0; i = M.size(0); if (i == 1) { i1 = G_R.size(0); } else { i1 = i; } - vocal_effect.set_size(i1); + vocal_reverb.set_size(i1); stride_0_0 = (G_R.size(0) != 1); stride_1_0 = (i != 1); if (i == 1) { loop_ub = G_R.size(0); } else { loop_ub = i; } for (i = 0; i < loop_ub; i++) { double d; i1 = i * stride_1_0; d = G_R[i * stride_0_0]; - vocal_effect[i].re = d * M[i1 + M.size(0) * inputFrameIndex].re; - vocal_effect[i].im = d * M[i1 + M.size(0) * inputFrameIndex].im; + vocal_reverb[i].re = d * M[i1 + M.size(0) * inputFrameIndex].re; + vocal_reverb[i].im = d * M[i1 + M.size(0) * inputFrameIndex].im; } } // // Arguments : coder::array &H_pow_sm // const coder::array &H_pow // Return Type : void // static void binary_expand_op(coder::array &H_pow_sm, const coder::array &H_pow) { coder::array r; int i; int i1; int loop_ub; int stride_0_0; int stride_1_0; if (H_pow.size(0) == 1) { i = H_pow_sm.size(0); } else { i = H_pow.size(0); } r.set_size(i, 400); stride_0_0 = (H_pow_sm.size(0) != 1); stride_1_0 = (H_pow.size(0) != 1); if (H_pow.size(0) == 1) { loop_ub = H_pow_sm.size(0); } else { loop_ub = H_pow.size(0); } for (i = 0; i < 400; i++) { for (i1 = 0; i1 < loop_ub; i1++) { r[i1 + r.size(0) * i] = - 0.98 * H_pow_sm[i1 * stride_0_0 + H_pow_sm.size(0) * i] + - 0.02 * H_pow[i1 * stride_1_0 + H_pow.size(0) * i]; + 0.95 * H_pow_sm[i1 * stride_0_0 + H_pow_sm.size(0) * i] + + 0.05 * H_pow[i1 * stride_1_0 + H_pow.size(0) * i]; } } H_pow_sm.set_size(r.size(0), 400); loop_ub = r.size(0); for (i = 0; i < 400; i++) { for (i1 = 0; i1 < loop_ub; i1++) { H_pow_sm[i1 + H_pow_sm.size(0) * i] = r[i1 + r.size(0) * i]; } } } // -// Arguments : coder::array &r +// Arguments : coder::array &newEstimates // const coder::array &previousSFramesPower_vc // const coder::array &H_pow_sm // Return Type : void // static void -binary_expand_op(coder::array &r, +binary_expand_op(coder::array &newEstimates, const coder::array &previousSFramesPower_vc, const coder::array &H_pow_sm) { coder::array b_previousSFramesPower_vc; int i; int loop_ub; int stride_0_0; int stride_1_0; if (H_pow_sm.size(0) == 1) { i = previousSFramesPower_vc.size(0); } else { i = H_pow_sm.size(0); } b_previousSFramesPower_vc.set_size(i, 400); stride_0_0 = (previousSFramesPower_vc.size(0) != 1); stride_1_0 = (H_pow_sm.size(0) != 1); if (H_pow_sm.size(0) == 1) { loop_ub = previousSFramesPower_vc.size(0); } else { loop_ub = H_pow_sm.size(0); } for (i = 0; i < 400; i++) { for (int i1{0}; i1 < loop_ub; i1++) { b_previousSFramesPower_vc[i1 + b_previousSFramesPower_vc.size(0) * i] = previousSFramesPower_vc[i1 * stride_0_0 + previousSFramesPower_vc.size(0) * i] * H_pow_sm[i1 * stride_1_0 + H_pow_sm.size(0) * i]; } } - coder::sum(b_previousSFramesPower_vc, r); + coder::sum(b_previousSFramesPower_vc, newEstimates); } // -// Arguments : coder::array &G_R_vc -// const coder::array &M -// const coder::array &r1 -// const coder::array &vocal_effect_sm -// const coder::array &vocal_effect -// const coder::array &inputFramePower +// Arguments : coder::array &G_Rxx +// const coder::captured_var frequencyCount +// const coder::array &G_Sxx // Return Type : void // -static void binary_expand_op(coder::array &G_R_vc, - const coder::array &M, - const coder::array &r1, - const coder::array &vocal_effect_sm, - const coder::array &vocal_effect, - const coder::array &inputFramePower) +static void binary_expand_op(coder::array &G_Rxx, + const coder::captured_var frequencyCount, + const coder::array &G_Sxx) { - coder::array r; - int M_idx_0; - int b_M_idx_0; + coder::array r; int i; + int loop_ub; int stride_1_0; int stride_3_0; - int stride_4_0; - int stride_5_0; - int stride_6_0; - M_idx_0 = M.size(0); - b_M_idx_0 = M.size(0); - if (inputFramePower.size(0) == 1) { - i = vocal_effect.size(0); + if (G_Sxx.size(0) == 1) { + i = static_cast(frequencyCount.contents); } else { - i = inputFramePower.size(0); + i = G_Sxx.size(0); } if (i == 1) { - i = vocal_effect_sm.size(0); - } else if (inputFramePower.size(0) == 1) { - i = vocal_effect.size(0); - } else { - i = inputFramePower.size(0); - } - if (r1.size(0) == 1) { - stride_1_0 = b_M_idx_0; + if (G_Rxx.size(0) == 1) { + i = static_cast(frequencyCount.contents); + } else { + i = G_Rxx.size(0); + } + } else if (G_Sxx.size(0) == 1) { + i = static_cast(frequencyCount.contents); } else { - stride_1_0 = r1.size(0); + i = G_Sxx.size(0); } - if (inputFramePower.size(0) == 1) { - stride_3_0 = vocal_effect.size(0); + r.set_size(i); + stride_1_0 = (G_Rxx.size(0) != 1); + stride_3_0 = (G_Sxx.size(0) != 1); + if (G_Sxx.size(0) == 1) { + i = static_cast(frequencyCount.contents); } else { - stride_3_0 = inputFramePower.size(0); + i = G_Sxx.size(0); } if (i == 1) { - if (stride_1_0 == 1) { - if (G_R_vc.size(0) == 1) { - i = M_idx_0; - } else { - i = G_R_vc.size(0); - } - } else if (r1.size(0) == 1) { - i = b_M_idx_0; + if (G_Rxx.size(0) == 1) { + loop_ub = static_cast(frequencyCount.contents); } else { - i = r1.size(0); + loop_ub = G_Rxx.size(0); } - } else if (stride_3_0 == 1) { - i = vocal_effect_sm.size(0); - } else if (inputFramePower.size(0) == 1) { - i = vocal_effect.size(0); + } else if (G_Sxx.size(0) == 1) { + loop_ub = static_cast(frequencyCount.contents); } else { - i = inputFramePower.size(0); + loop_ub = G_Sxx.size(0); } - r.set_size(i); - stride_1_0 = (G_R_vc.size(0) != 1); - stride_3_0 = (r1.size(0) != 1); - stride_4_0 = (vocal_effect_sm.size(0) != 1); - stride_5_0 = (vocal_effect.size(0) != 1); - stride_6_0 = (inputFramePower.size(0) != 1); - if (inputFramePower.size(0) == 1) { - i = vocal_effect.size(0); - } else { - i = inputFramePower.size(0); + for (i = 0; i < loop_ub; i++) { + r[i] = 0.7 * G_Rxx[i * stride_1_0] + 0.3 * (1.0 - G_Sxx[i * stride_3_0]); } - if (i == 1) { - i = vocal_effect_sm.size(0); - } else if (inputFramePower.size(0) == 1) { - i = vocal_effect.size(0); - } else { - i = inputFramePower.size(0); + G_Rxx.set_size(r.size(0)); + loop_ub = r.size(0); + for (i = 0; i < loop_ub; i++) { + G_Rxx[i] = r[i]; } - if (i == 1) { - if (r1.size(0) == 1) { - i = b_M_idx_0; - } else { - i = r1.size(0); - } +} + +// +// Arguments : coder::array &bk_revertant +// const coder::array &G_Rxx +// const coder::array &M +// int inputFrameIndex +// const coder::array &r +// Return Type : void +// +static void binary_expand_op(coder::array &bk_revertant, + const coder::array &G_Rxx, + const coder::array &M, + int inputFrameIndex, + const coder::array &r) +{ + int i; + int loop_ub; + int stride_0_0; + int stride_1_0; + int stride_2_0; + i = M.size(0); + if (r.size(0) == 1) { if (i == 1) { - if (G_R_vc.size(0) == 1) { - b_M_idx_0 = M_idx_0; - } else { - b_M_idx_0 = G_R_vc.size(0); - } - } else if (r1.size(0) != 1) { - b_M_idx_0 = r1.size(0); - } - } else { - if (inputFramePower.size(0) == 1) { - i = vocal_effect.size(0); + stride_0_0 = G_Rxx.size(0); } else { - i = inputFramePower.size(0); + stride_0_0 = i; } + } else { + stride_0_0 = r.size(0); + } + bk_revertant.set_size(stride_0_0); + stride_0_0 = (G_Rxx.size(0) != 1); + stride_1_0 = (i != 1); + stride_2_0 = (r.size(0) != 1); + if (r.size(0) == 1) { if (i == 1) { - b_M_idx_0 = vocal_effect_sm.size(0); - } else if (inputFramePower.size(0) == 1) { - b_M_idx_0 = vocal_effect.size(0); + loop_ub = G_Rxx.size(0); } else { - b_M_idx_0 = inputFramePower.size(0); - } - } - for (i = 0; i < b_M_idx_0; i++) { - double ai; - double br; - double vocal_effect_im; - double vocal_effect_re; - M_idx_0 = i * stride_5_0; - vocal_effect_im = vocal_effect[M_idx_0].re; - ai = vocal_effect[M_idx_0].im; - br = inputFramePower[i * stride_6_0] + 1.0E-5; - if (ai == 0.0) { - vocal_effect_re = vocal_effect_im / br; - vocal_effect_im = 0.0; - } else if (vocal_effect_im == 0.0) { - vocal_effect_re = 0.0; - vocal_effect_im = ai / br; - } else { - vocal_effect_re = vocal_effect_im / br; - vocal_effect_im = ai / br; + loop_ub = i; } - M_idx_0 = i * stride_1_0; - ai = vocal_effect_sm[i * stride_4_0]; - r[i].re = (0.7 * G_R_vc[M_idx_0].re + 0.3 * r1[i * stride_3_0]) + - ai * vocal_effect_re; - r[i].im = 0.7 * G_R_vc[M_idx_0].im + ai * vocal_effect_im; + } else { + loop_ub = r.size(0); } - G_R_vc.set_size(r.size(0)); - b_M_idx_0 = r.size(0); - for (i = 0; i < b_M_idx_0; i++) { - G_R_vc[i] = r[i]; + for (i = 0; i < loop_ub; i++) { + double b_G_Rxx_re_tmp; + double d; + int G_Rxx_re_tmp; + G_Rxx_re_tmp = i * stride_1_0; + b_G_Rxx_re_tmp = G_Rxx[i * stride_0_0]; + d = r[i * stride_2_0]; + bk_revertant[i].re = + d * (b_G_Rxx_re_tmp * M[G_Rxx_re_tmp + M.size(0) * inputFrameIndex].re); + bk_revertant[i].im = + d * (b_G_Rxx_re_tmp * M[G_Rxx_re_tmp + M.size(0) * inputFrameIndex].im); } } // // Arguments : double output[220500] // const coder::array &r // const coder::array &sampleRange // const coder::array &window // const coder::array &r1 // Return Type : void // static void binary_expand_op(double output[220500], const coder::array &r, const coder::array &sampleRange, const coder::array &window, const coder::array &r1) { coder::array b_output; int i; int loop_ub; int stride_0_1; int stride_1_1; int stride_2_1; b_output.set_size(1, r.size(1)); stride_0_1 = (sampleRange.size(1) != 1); stride_1_1 = (window.size(0) != 1); stride_2_1 = (r1.size(0) != 1); loop_ub = r.size(1); for (i = 0; i < loop_ub; i++) { b_output[i] = output[static_cast(sampleRange[i * stride_0_1]) - 1] + window[i * stride_1_1] * r1[i * stride_2_1]; } loop_ub = b_output.size(1); for (i = 0; i < loop_ub; i++) { output[r[i] - 1] = b_output[i]; } } // -// Arguments : coder::array &unchanged -// const coder::array &newEstimates -// const coder::array &inputFramePower -// Return Type : void -// -static void c_binary_expand_op(coder::array &unchanged, - const coder::array &newEstimates, - const coder::array &inputFramePower) -{ - int i; - int loop_ub; - int stride_0_0; - int stride_1_0; - if (inputFramePower.size(0) == 1) { - i = newEstimates.size(0); - } else { - i = inputFramePower.size(0); - } - unchanged.set_size(i); - stride_0_0 = (newEstimates.size(0) != 1); - stride_1_0 = (inputFramePower.size(0) != 1); - if (inputFramePower.size(0) == 1) { - loop_ub = newEstimates.size(0); - } else { - loop_ub = inputFramePower.size(0); - } - for (i = 0; i < loop_ub; i++) { - unchanged[i] = - (newEstimates[i * stride_0_0] < 0.2 * inputFramePower[i * stride_1_0]); - } -} - -// -// Arguments : coder::array &G_S +// Arguments : coder::array &G_Sxx // const coder::captured_var frequencyCount -// const coder::array &newEstimates +// const coder::array &r1 // Return Type : void // -static void d_binary_expand_op(coder::array &G_S, +static void c_binary_expand_op(coder::array &G_Sxx, const coder::captured_var frequencyCount, - const coder::array &newEstimates) + const coder::array &r1) { coder::array r; int i; int loop_ub; int stride_1_0; int stride_3_0; - if (newEstimates.size(0) == 1) { + if (r1.size(0) == 1) { i = static_cast(frequencyCount.contents); } else { - i = newEstimates.size(0); + i = r1.size(0); } if (i == 1) { - if (G_S.size(0) == 1) { + if (G_Sxx.size(0) == 1) { i = static_cast(frequencyCount.contents); } else { - i = G_S.size(0); + i = G_Sxx.size(0); } - } else if (newEstimates.size(0) == 1) { + } else if (r1.size(0) == 1) { i = static_cast(frequencyCount.contents); } else { - i = newEstimates.size(0); + i = r1.size(0); } r.set_size(i); - stride_1_0 = (G_S.size(0) != 1); - stride_3_0 = (newEstimates.size(0) != 1); - if (newEstimates.size(0) == 1) { + stride_1_0 = (G_Sxx.size(0) != 1); + stride_3_0 = (r1.size(0) != 1); + if (r1.size(0) == 1) { i = static_cast(frequencyCount.contents); } else { - i = newEstimates.size(0); + i = r1.size(0); } if (i == 1) { - if (G_S.size(0) == 1) { + if (G_Sxx.size(0) == 1) { loop_ub = static_cast(frequencyCount.contents); } else { - loop_ub = G_S.size(0); + loop_ub = G_Sxx.size(0); } - } else if (newEstimates.size(0) == 1) { + } else if (r1.size(0) == 1) { loop_ub = static_cast(frequencyCount.contents); } else { - loop_ub = newEstimates.size(0); + loop_ub = r1.size(0); } for (i = 0; i < loop_ub; i++) { - r[i] = 0.7 * G_S[i * stride_1_0] + 0.3 * newEstimates[i * stride_3_0]; + r[i] = 0.7 * G_Sxx[i * stride_1_0] + 0.3 * r1[i * stride_3_0]; } - G_S.set_size(r.size(0)); + G_Sxx.set_size(r.size(0)); loop_ub = r.size(0); for (i = 0; i < loop_ub; i++) { - G_S[i] = r[i]; - } -} - -// -// Arguments : coder::array &unchanged -// const coder::array &newEstimates -// const coder::array &inputFramePower -// Return Type : void -// -static void gt(coder::array &unchanged, - const coder::array &newEstimates, - const coder::array &inputFramePower) -{ - int i; - int loop_ub; - int stride_0_0; - int stride_1_0; - if (inputFramePower.size(0) == 1) { - i = newEstimates.size(0); - } else { - i = inputFramePower.size(0); - } - unchanged.set_size(i); - stride_0_0 = (newEstimates.size(0) != 1); - stride_1_0 = (inputFramePower.size(0) != 1); - if (inputFramePower.size(0) == 1) { - loop_ub = newEstimates.size(0); - } else { - loop_ub = inputFramePower.size(0); - } - for (i = 0; i < loop_ub; i++) { - unchanged[i] = - (newEstimates[i * stride_0_0] > inputFramePower[i * stride_1_0]); + G_Sxx[i] = r[i]; } } // // Arguments : coder::captured_var *stftWindowSize // coder::captured_var *frequencyCount // coder::captured_var *frameCount // const coder::array &spectrumx // const coder::array &window // double overlapSamples // double output[220500] // Return Type : void // static void reconstruct(coder::captured_var *stftWindowSize, coder::captured_var *frequencyCount, coder::captured_var *frameCount, const coder::array &spectrumx, const coder::array &window, double overlapSamples, double output[220500]) { coder::array r; coder::array spectrum; coder::array b_spectrum; coder::array r1; coder::array b_output; coder::array sampleRange; coder::array r2; coder::array r3; double xtmp_im; double xtmp_re; int b_i; int i; int i1; int loop_ub; int m; int md2; int n; boolean_T exitg1; + // scalex = sum(abs(dry_vc))/(sum(abs(reverberated_vc))+ 1e-4); + // scalex = min(1,scalex); + // reverberated_vc = scalex*reverberated_vc; + // reverberated_vc = OverflowLimit(reverberated_vc); // Helper functions stftWindowSize->contents = window.size(0); frameCount->contents = spectrumx.size(1); frequencyCount->contents = spectrumx.size(0); i = static_cast(stftWindowSize->contents); loop_ub = static_cast(frameCount->contents); spectrum.set_size(i, loop_ub); md2 = i * loop_ub; for (i = 0; i < md2; i++) { spectrum[i].re = 0.0; spectrum[i].im = 1.0E-5; } // spectrum(frequencyCount+1:stftWindowSize, :) = // conj(flipud(spectrum(1:frequencyCount-2, :))); xtmp_re = frequencyCount->contents; if (2.0 > xtmp_re) { i = 0; i1 = -1; } else { i = 1; i1 = static_cast(xtmp_re) - 1; } md2 = spectrumx.size(1); for (n = 0; n < md2; n++) { m = spectrumx.size(0); for (b_i = 0; b_i < m; b_i++) { spectrum[b_i + spectrum.size(0) * n] = spectrumx[b_i + spectrumx.size(0) * n]; } } sampleRange.set_size(1, loop_ub); for (n = 0; n < loop_ub; n++) { sampleRange[n] = 0.0; } loop_ub = sampleRange.size(1); for (n = 0; n < loop_ub; n++) { spectrum[spectrum.size(0) * n].re = 0.0; spectrum[spectrum.size(0) * n].im = 0.0; } i1 -= i; if (1 > i1) { loop_ub = -1; } else { loop_ub = i1 - 1; } xtmp_re = frequencyCount->contents + 1.0; if (xtmp_re > stftWindowSize->contents) { i1 = 1; } else { i1 = static_cast(xtmp_re); } md2 = spectrumx.size(1) - 1; r.set_size(loop_ub + 1, spectrumx.size(1)); for (n = 0; n <= md2; n++) { for (b_i = 0; b_i <= loop_ub; b_i++) { m = i + b_i; r[b_i + r.size(0) * n].re = spectrumx[m + spectrumx.size(0) * n].re; r[b_i + r.size(0) * n].im = -spectrumx[m + spectrumx.size(0) * n].im; } } m = r.size(0) - 1; n = r.size(1); md2 = r.size(0) >> 1; for (loop_ub = 0; loop_ub < n; loop_ub++) { for (b_i = 0; b_i < md2; b_i++) { xtmp_re = r[b_i + r.size(0) * loop_ub].re; xtmp_im = r[b_i + r.size(0) * loop_ub].im; i = m - b_i; r[b_i + r.size(0) * loop_ub] = r[i + r.size(0) * loop_ub]; r[i + r.size(0) * loop_ub].re = xtmp_re; r[i + r.size(0) * loop_ub].im = xtmp_im; } } loop_ub = r.size(1); for (i = 0; i < loop_ub; i++) { md2 = r.size(0); for (n = 0; n < md2; n++) { spectrum[((i1 + n) + spectrum.size(0) * i) - 1] = r[n + r.size(0) * i]; } } std::memset(&output[0], 0, 220500U * sizeof(double)); xtmp_im = stftWindowSize->contents - overlapSamples; xtmp_re = frameCount->contents; md2 = 0; exitg1 = false; while ((!exitg1) && (md2 <= static_cast(xtmp_re) - 1)) { double b; double frameStart; frameStart = ((static_cast(md2) + 1.0) - 1.0) * xtmp_im; b = frameStart + stftWindowSize->contents; if (b > 220500.0) { exitg1 = true; } else { if (std::isnan(frameStart + 1.0) || std::isnan(b)) { sampleRange.set_size(1, 1); sampleRange[0] = rtNaN; } else if (b < frameStart + 1.0) { sampleRange.set_size(1, 0); } else if ((std::isinf(frameStart + 1.0) || std::isinf(b)) && (frameStart + 1.0 == b)) { sampleRange.set_size(1, 1); sampleRange[0] = rtNaN; } else if (std::floor(frameStart + 1.0) == frameStart + 1.0) { loop_ub = static_cast(std::floor(b - (frameStart + 1.0))); sampleRange.set_size(1, loop_ub + 1); for (i = 0; i <= loop_ub; i++) { sampleRange[i] = (frameStart + 1.0) + static_cast(i); } } else { double apnd; double cdiff; double ndbl; ndbl = std::floor((b - (frameStart + 1.0)) + 0.5); apnd = (frameStart + 1.0) + ndbl; cdiff = apnd - b; if (std::abs(cdiff) < 4.4408920985006262E-16 * std::fmax(std::abs(frameStart + 1.0), std::abs(b))) { ndbl++; apnd = b; } else if (cdiff > 0.0) { apnd = (frameStart + 1.0) + (ndbl - 1.0); } else { ndbl++; } if (ndbl >= 0.0) { n = static_cast(ndbl); } else { n = 0; } sampleRange.set_size(1, n); if (n > 0) { sampleRange[0] = frameStart + 1.0; if (n > 1) { sampleRange[n - 1] = apnd; m = (n - 1) / 2; for (loop_ub = 0; loop_ub <= m - 2; loop_ub++) { sampleRange[loop_ub + 1] = (frameStart + 1.0) + (static_cast(loop_ub) + 1.0); sampleRange[(n - loop_ub) - 2] = apnd - (static_cast(loop_ub) + 1.0); } if (m << 1 == n - 1) { sampleRange[m] = ((frameStart + 1.0) + apnd) / 2.0; } else { sampleRange[m] = (frameStart + 1.0) + static_cast(m); sampleRange[m + 1] = apnd - static_cast(m); } } } } // reconstructedFrame(:) = window .* ifft(spectrum(:, frameIndex), // 'symmetric'); // v = spectrum(:, frameIndex); // v_conj= conj(v([1,end:-1:2])); loop_ub = spectrum.size(0); b_spectrum.set_size(spectrum.size(0)); for (i = 0; i < loop_ub; i++) { b_spectrum[i] = spectrum[i + spectrum.size(0) * md2]; } coder::ifft(b_spectrum, r1); r2.set_size(r1.size(0)); loop_ub = r1.size(0); for (i = 0; i < loop_ub; i++) { r2[i] = r1[i].re; } r3.set_size(1, sampleRange.size(1)); loop_ub = sampleRange.size(1); for (i = 0; i < loop_ub; i++) { r3[i] = static_cast(sampleRange[i]); } if (window.size(0) == 1) { i = r2.size(0); } else { i = window.size(0); } if ((window.size(0) == r2.size(0)) && (sampleRange.size(1) == i)) { b_output.set_size(1, r3.size(1)); loop_ub = r3.size(1); for (i = 0; i < loop_ub; i++) { b_output[i] = output[static_cast(sampleRange[i]) - 1] + window[i] * r2[i]; } loop_ub = b_output.size(1); for (i = 0; i < loop_ub; i++) { output[r3[i] - 1] = b_output[i]; } } else { binary_expand_op(output, r3, sampleRange, window, r2); } md2++; } } } // // Arguments : double u0 // double u1 // Return Type : double // static double rt_hypotd_snf(double u0, double u1) { double a; double y; a = std::abs(u0); y = std::abs(u1); if (a < y) { a /= y; y *= std::sqrt(a * a + 1.0); } else if (a > y) { y /= a; y = a * std::sqrt(y * y + 1.0); } else if (!std::isnan(y)) { y = a * 1.4142135623730951; } return y; } // // % inputFilename = 'audio/EchoSample.mp3'; // inputFilename = // '/Volumes/T7_2/starmaker_files/音效提取算法/effect_files/2/vocal_left_16k.wav'; // inputFilename = // '/Volumes/T7_2/starmaker_files/音效提取算法/effect_files/1/vocla_left.wav'; // // % inputFilename = 'audio/stalbans_omni_sing.mp3'; // % inputFilename = 'audio/mozart_reverb_short.mp3'; // [signal, fs] = audioread(inputFilename); // signal= signal(1:fs*30); // % Take only the left channel from the stereo recording // signal = signal(:, 1); // // Arguments : const double b_signal[220500] // const double signal_vc[220500] // double fs // const double impulseResponse[264600] // double reverberated_vc[220500] // Return Type : void // void dereveb_c(const double b_signal[220500], const double signal_vc[220500], double fs, const double impulseResponse[264600], double reverberated_vc[220500]) { coder::captured_var frameCount; coder::captured_var frequencyCount; coder::captured_var stftWindowSize; coder::array M; coder::array M_vc; coder::array R_vc; coder::array S_vc; coder::array allBlocks; coder::array x; - coder::array G_R_vc; - coder::array vocal_effect; + coder::array bk_revertant; + coder::array vocal_dry; + coder::array vocal_reverb; coder::array C; coder::array H_pow; coder::array H_pow_sm; coder::array b_previousSFramesPower; - coder::array b_x; coder::array c_previousSFramesPower; coder::array previousMFramesPower; coder::array previousSFramesPower; coder::array previousSFramesPower_vc; + coder::array r1; coder::array y; coder::array G_R; + coder::array G_Rxx; coder::array G_S; + coder::array G_Sxx; coder::array b_y; coder::array inputFramePower; coder::array newEstimates; - coder::array vocal_effect_sm; + coder::array r; coder::array window; - coder::array r; - coder::array r1; coder::array r2; coder::array unchanged; double overlapSamples; double scale_cl; - int en; int i; int i1; int i2; + int k; int loop_ub; int nx; if (!isInitialized_dereveb_c) { dereveb_c_initialize(); } // Dereverberation // inputFilename_vc = // '/Volumes/T7_2/starmaker_files/音效提取算法/effect_files/2/611752105030248995_8162774327817435_dv_44100_16k.wav'; // inputFilename_vc = // '/Volumes/T7_2/starmaker_files/音效提取算法/effect_files/1/611752105030249000_8162774329368194_dv_44100.wav'; // [signal_vc, fs] = audioread(inputFilename_vc); // signal_vc= signal_vc(1:fs*30); // % Take only the left channel from the stereo recording // signal_vc = signal_vc(:, 1); // Compute the signal's STFT stftWindowSize.contents = 1024.0 * std::floor(fs / 16000.0); // In the paper he used 0.5 (50% overlap). overlapSamples = std::floor(0.75 * stftWindowSize.contents); // TODO: zero padding? coder::hann(stftWindowSize.contents, window); // Specify empty Fs so that t is returned in samples and w in rad/sample. // figure; // [M,~,~] = spectrogram(signal, window, overlapSamples, [], []); coder::spectrogram(b_signal, window, overlapSamples, M); // M ('microphone') - input signal (reverberated) frequency-domain vectors. // Rows - frequencies, Columns - time frames (middle time- // point) frequencyCount.contents = M.size(0); // [M_vc,~,~] = spectrogram(signal_vc, window, overlapSamples, [], []); coder::spectrogram(signal_vc, window, overlapSamples, M_vc); // M ('microphone') - input signal (reverberated) frequency-domain vectors. // Rows - frequencies, Columns - time frames (middle time-point) frameCount.contents = std::fmin(static_cast(M.size(1)), static_cast(M_vc.size(1))); // Constants // Impulse response block length - has to be 'sufficiently small' // TODO: experiment with value. Is this really the same as the window size? // Number of impulse response blocks. TODO: experiment. // Minimum gain per frequency. TODO: Experiment. // Maximum magnitude estimate per impulse response block and frequency. // Should 'reflect real world systems'. (Page 11 - MaxValue.) // maxHEstimate(:) = readImpulseResponse('audio/stalbans_a_mono.wav', B, // window, overlapSamples); // impulseResponse = audioread(irFilename); // assert(irFs == fs); // function image = spectrogramPlot(spectrum, t, w) // figure; // image = imagesc(t, w, 10*log10(abs(spectrum)+eps)); // image.Parent.YDir = 'normal'; // colorbar(); // end coder::b_spectrogram(impulseResponse, window, overlapSamples, allBlocks); // pow = @(x) abs(x).^2; loop_ub = allBlocks.size(0); x.set_size(allBlocks.size(0), 400); for (i = 0; i < 400; i++) { for (i1 = 0; i1 < loop_ub; i1++) { x[i1 + x.size(0) * i] = allBlocks[i1 + allBlocks.size(0) * i]; } } nx = allBlocks.size(0) * 400; y.set_size(allBlocks.size(0), 400); - for (en = 0; en < nx; en++) { - y[en] = rt_hypotd_snf(x[en].re, x[en].im); + for (k = 0; k < nx; k++) { + y[k] = rt_hypotd_snf(x[k].re, x[k].im); } loop_ub = y.size(0) * 400; y.set_size(y.size(0), 400); for (i = 0; i < loop_ub; i++) { scale_cl = y[i]; y[i] = scale_cl * scale_cl; } // maxHEstimate(:) = 0.9; // Bias used to keep the magnitude estimate from getting stuck on a wrong // minimum. // TODO: Experiment // From the paper - gamma (Page 10). Lower means more smoothing between // gains vectors of consecutive frames. Value 0-1 (1 = no smoothing). // From the paper - alpha (Page 11). Lower means less smoothing between // magnitude response block estimates on consecutive frames. // Value 0-1 (0 = no smoothing). // Algorithm implementation: block-wise signal dereverberation. allBlocks.set_size(M.size(0), M.size(1)); loop_ub = M.size(0) * M.size(1); for (i = 0; i < loop_ub; i++) { allBlocks[i].re = 0.0; allBlocks[i].im = 1.0E-5; } // Dry signal frequency-domain vectors. // Reverberated components frequency-domain vectors. S_vc.set_size(M.size(0), M.size(1)); loop_ub = M.size(0) * M.size(1); for (i = 0; i < loop_ub; i++) { S_vc[i].re = 0.0; S_vc[i].im = 1.0E-5; } R_vc.set_size(M.size(0), M.size(1)); loop_ub = M.size(0) * M.size(1); for (i = 0; i < loop_ub; i++) { R_vc[i].re = 0.0; R_vc[i].im = 1.0E-5; } // Reverberant system frequency response estimate blocks - power. // H_pow = zeros(frequencyCount, B); // Set initial estimates to half of the maximum. H_pow.set_size(y.size(0), 400); loop_ub = y.size(0) * 400; for (i = 0; i < loop_ub; i++) { H_pow[i] = y[i] / 2.0; } // pow = @(x) abs(x).^2; previousSFramesPower.set_size(M.size(0), 400); loop_ub = M.size(0) * 400; for (i = 0; i < loop_ub; i++) { previousSFramesPower[i] = 0.0; } // Most recent previous frame is first. previousMFramesPower.set_size(M.size(0), 400); loop_ub = M.size(0) * 400; for (i = 0; i < loop_ub; i++) { previousMFramesPower[i] = 1.0; } // Most recent previous frame is first. // Reverberant system frequency response power estimate blocks - temporary. C.set_size(H_pow.size(0), 400); loop_ub = H_pow.size(0) * 400; for (i = 0; i < loop_ub; i++) { C[i] = 0.0; } // Matrix to keep all estimates over time (not needed by algorithm - just // for visualization purposes). // H_pow_all = zeros([HisCount size(H_pow)]); // Initially, all components are estimated to belong to the dry signal. G_S.set_size(M.size(0)); loop_ub = M.size(0); for (i = 0; i < loop_ub; i++) { G_S[i] = 1.0; } G_R.set_size(M.size(0)); loop_ub = M.size(0); for (i = 0; i < loop_ub; i++) { G_R[i] = 0.0; } + G_Sxx.set_size(M.size(0)); + loop_ub = M.size(0); + for (i = 0; i < loop_ub; i++) { + G_Sxx[i] = 1.0; + } + G_Rxx.set_size(M.size(0)); + loop_ub = M.size(0); + for (i = 0; i < loop_ub; i++) { + G_Rxx[i] = 0.0; + } previousSFramesPower_vc.set_size(M.size(0), 400); loop_ub = M.size(0) * 400; for (i = 0; i < loop_ub; i++) { previousSFramesPower_vc[i] = 0.0; } // Most recent previous frame is first. // Most recent previous frame is first. - G_R_vc.set_size(M.size(0)); - loop_ub = M.size(0); - for (i = 0; i < loop_ub; i++) { - G_R_vc[i].re = 0.0; - G_R_vc[i].im = 1.0E-5; - } H_pow_sm.set_size(H_pow.size(0), 400); loop_ub = H_pow.size(0) * 400; for (i = 0; i < loop_ub; i++) { H_pow_sm[i] = H_pow[i]; } i = static_cast(frameCount.contents); if (0.0 <= i - 1) { i2 = y.size(0); } for (int inputFrameIndex{0}; inputFrameIndex < i; inputFrameIndex++) { - double ai; double varargin_2; int b_i; - int blockIndex; - int i3; // X = sprintf('frameidx: %d / %d \r',inputFrameIndex,frameCount); // disp(X) loop_ub = M.size(0); - vocal_effect_sm.set_size(M.size(0)); - for (en = 0; en < loop_ub; en++) { - vocal_effect_sm[en] = - rt_hypotd_snf(M[en + M.size(0) * inputFrameIndex].re, - M[en + M.size(0) * inputFrameIndex].im); - } - inputFramePower.set_size(vocal_effect_sm.size(0)); - loop_ub = vocal_effect_sm.size(0); + newEstimates.set_size(M.size(0)); + for (k = 0; k < loop_ub; k++) { + newEstimates[k] = rt_hypotd_snf(M[k + M.size(0) * inputFrameIndex].re, + M[k + M.size(0) * inputFrameIndex].im); + } + inputFramePower.set_size(newEstimates.size(0)); + loop_ub = newEstimates.size(0); for (i1 = 0; i1 < loop_ub; i1++) { - scale_cl = vocal_effect_sm[i1]; + scale_cl = newEstimates[i1]; inputFramePower[i1] = scale_cl * scale_cl; } // Update system frequency response estimates. loop_ub = inputFramePower.size(0); - for (blockIndex = 0; blockIndex < 400; blockIndex++) { + for (int blockIndex{0}; blockIndex < 400; blockIndex++) { if (inputFramePower.size(0) == previousMFramesPower.size(0)) { newEstimates.set_size(inputFramePower.size(0)); for (i1 = 0; i1 < loop_ub; i1++) { newEstimates[i1] = inputFramePower[i1] / previousMFramesPower[i1 + previousMFramesPower.size(0) * blockIndex]; } } else { binary_expand_op(newEstimates, inputFramePower, previousMFramesPower, blockIndex); } if (newEstimates.size(0) == H_pow.size(0)) { unchanged.set_size(newEstimates.size(0)); nx = newEstimates.size(0); for (i1 = 0; i1 < nx; i1++) { unchanged[i1] = (newEstimates[i1] >= H_pow[i1 + H_pow.size(0) * blockIndex]); } } else { b_binary_expand_op(unchanged, newEstimates, H_pow, blockIndex); } - en = unchanged.size(0) - 1; + k = unchanged.size(0) - 1; nx = 0; - for (b_i = 0; b_i <= en; b_i++) { + for (b_i = 0; b_i <= k; b_i++) { if (unchanged[b_i]) { nx++; } } - r.set_size(nx); + r2.set_size(nx); nx = 0; - for (b_i = 0; b_i <= en; b_i++) { + for (b_i = 0; b_i <= k; b_i++) { if (unchanged[b_i]) { - r[nx] = b_i + 1; + r2[nx] = b_i + 1; nx++; } } - nx = r.size(0); - b_y.set_size(r.size(0)); + nx = r2.size(0); + r.set_size(r2.size(0)); for (i1 = 0; i1 < nx; i1++) { - b_y[i1] = H_pow[(r[i1] + H_pow.size(0) * blockIndex) - 1] * 1.01; + r[i1] = H_pow[(r2[i1] + H_pow.size(0) * blockIndex) - 1] * 1.01; } - en = unchanged.size(0); + k = unchanged.size(0); nx = 0; - for (b_i = 0; b_i < en; b_i++) { + for (b_i = 0; b_i < k; b_i++) { if (unchanged[b_i]) { - newEstimates[b_i] = b_y[nx] + 2.2204460492503131E-16; + newEstimates[b_i] = r[nx] + 2.2204460492503131E-16; nx++; } } if (newEstimates.size(0) == i2) { nx = newEstimates.size(0); for (i1 = 0; i1 < nx; i1++) { scale_cl = newEstimates[i1]; varargin_2 = y[i1 + y.size(0) * blockIndex]; C[i1 + C.size(0) * blockIndex] = std::fmin(scale_cl, varargin_2); } } else { nx = y.size(0); b_y.set_size(y.size(0)); for (i1 = 0; i1 < nx; i1++) { b_y[i1] = y[i1 + y.size(0) * blockIndex]; } - coder::internal::expand_min(newEstimates, b_y, vocal_effect_sm); - nx = vocal_effect_sm.size(0); + coder::internal::expand_min(newEstimates, b_y, r); + nx = r.size(0); for (i1 = 0; i1 < nx; i1++) { - C[i1 + C.size(0) * blockIndex] = vocal_effect_sm[i1]; + C[i1 + C.size(0) * blockIndex] = r[i1]; } } nx = M.size(0); if (M.size(0) == 1) { i1 = H_pow.size(0); } else { i1 = M.size(0); } if (M.size(0) == 1) { - i3 = C.size(0); + k = C.size(0); } else { - i3 = M.size(0); + k = M.size(0); } if ((M.size(0) == H_pow.size(0)) && (M.size(0) == C.size(0)) && - (i1 == i3)) { - vocal_effect_sm.set_size(M.size(0)); + (i1 == k)) { + r.set_size(M.size(0)); for (i1 = 0; i1 < nx; i1++) { - vocal_effect_sm[i1] = 0.2 * H_pow[i1 + H_pow.size(0) * blockIndex] + - 0.8 * C[i1 + C.size(0) * blockIndex]; + r[i1] = 0.2 * H_pow[i1 + H_pow.size(0) * blockIndex] + + 0.8 * C[i1 + C.size(0) * blockIndex]; } - nx = vocal_effect_sm.size(0); + nx = r.size(0); for (i1 = 0; i1 < nx; i1++) { - H_pow[i1 + H_pow.size(0) * blockIndex] = vocal_effect_sm[i1]; + H_pow[i1 + H_pow.size(0) * blockIndex] = r[i1]; } } else { binary_expand_op(H_pow, blockIndex, M, C); } } // % H_pow_all(inputFrameIndex, :, :) = H_pow; // H_pow_all(2:end,:,:) = H_pow_all( 1:end-1,:,:); // H_pow_all(1,:, :) = H_pow; %%放在最开始位置 // TODO: ?? G_S = sqrt(G_S); // Enforce a minimum gain for each frequency. if (previousSFramesPower.size(0) == H_pow.size(0)) { b_previousSFramesPower.set_size(previousSFramesPower.size(0), 400); loop_ub = previousSFramesPower.size(0) * 400; for (i1 = 0; i1 < loop_ub; i1++) { b_previousSFramesPower[i1] = previousSFramesPower[i1] * H_pow[i1]; } - coder::sum(b_previousSFramesPower, b_y); + coder::sum(b_previousSFramesPower, r); } else { - binary_expand_op(b_y, previousSFramesPower, H_pow); + binary_expand_op(r, previousSFramesPower, H_pow); } - if (b_y.size(0) == inputFramePower.size(0)) { - b_x.set_size(b_y.size(0), 2); - loop_ub = b_y.size(0); + if (r.size(0) == inputFramePower.size(0)) { + r1.set_size(r.size(0), 2); + loop_ub = r.size(0); for (i1 = 0; i1 < loop_ub; i1++) { - b_x[i1] = 1.0 - b_y[i1] / inputFramePower[i1]; + r1[i1] = 1.0 - r[i1] / inputFramePower[i1]; } loop_ub = M.size(0); for (i1 = 0; i1 < loop_ub; i1++) { - b_x[i1 + b_x.size(0)] = 0.0; + r1[i1 + r1.size(0)] = 0.0; } + coder::internal::maximum(r1, r); } else { - binary_expand_op(b_x, b_y, inputFramePower, M); - } - nx = b_x.size(0) - 1; - newEstimates.set_size(b_x.size(0)); - if (b_x.size(0) >= 1) { - for (b_i = 0; b_i <= nx; b_i++) { - newEstimates[b_i] = b_x[b_i]; - } - for (b_i = 0; b_i <= nx; b_i++) { - boolean_T p; - scale_cl = b_x[b_i + b_x.size(0)]; - if (std::isnan(scale_cl)) { - p = false; - } else if (std::isnan(newEstimates[b_i])) { - p = true; - } else { - p = (newEstimates[b_i] < scale_cl); - } - if (p) { - newEstimates[b_i] = scale_cl; - } - } + c_binary_expand_op(r, inputFramePower, M); } loop_ub = G_S.size(0); i1 = static_cast(frequencyCount.contents); if (frequencyCount.contents == 1.0) { - en = G_S.size(0); + k = G_S.size(0); } else { - en = static_cast(frequencyCount.contents); + k = static_cast(frequencyCount.contents); } if (frequencyCount.contents == 1.0) { - b_i = newEstimates.size(0); + nx = r.size(0); } else { - b_i = static_cast(frequencyCount.contents); + nx = static_cast(frequencyCount.contents); } - if ((i1 == G_S.size(0)) && (i1 == newEstimates.size(0)) && (en == b_i)) { - for (blockIndex = 0; blockIndex < loop_ub; blockIndex++) { - G_S[blockIndex] = - 0.7 * G_S[blockIndex] + 0.3 * newEstimates[blockIndex]; + if ((i1 == G_S.size(0)) && (i1 == r.size(0)) && (k == nx)) { + for (b_i = 0; b_i < loop_ub; b_i++) { + G_S[b_i] = 0.7 * G_S[b_i] + 0.3 * r[b_i]; } } else { - d_binary_expand_op(G_S, frequencyCount, newEstimates); + c_binary_expand_op(G_S, frequencyCount, r); } loop_ub = G_R.size(0); if (frequencyCount.contents == 1.0) { - en = G_R.size(0); + k = G_R.size(0); } else { - en = static_cast(frequencyCount.contents); + k = static_cast(frequencyCount.contents); } if (frequencyCount.contents == 1.0) { - b_i = G_S.size(0); + nx = G_S.size(0); } else { - b_i = static_cast(frequencyCount.contents); + nx = static_cast(frequencyCount.contents); } - if ((i1 == G_R.size(0)) && (i1 == G_S.size(0)) && (en == b_i)) { - for (i1 = 0; i1 < loop_ub; i1++) { - G_R[i1] = 0.7 * G_R[i1] + 0.3 * (1.0 - G_S[i1]); + if ((i1 == G_R.size(0)) && (i1 == G_S.size(0)) && (k == nx)) { + for (b_i = 0; b_i < loop_ub; b_i++) { + G_R[b_i] = 0.7 * G_R[b_i] + 0.3 * (1.0 - G_S[b_i]); } } else { binary_expand_op(G_R, frequencyCount, G_S); } loop_ub = G_S.size(0); if (G_S.size(0) == M.size(0)) { - for (i1 = 0; i1 < loop_ub; i1++) { - allBlocks[i1 + allBlocks.size(0) * inputFrameIndex].re = - G_S[i1] * M[i1 + M.size(0) * inputFrameIndex].re; - allBlocks[i1 + allBlocks.size(0) * inputFrameIndex].im = - G_S[i1] * M[i1 + M.size(0) * inputFrameIndex].im; + vocal_dry.set_size(G_S.size(0)); + for (b_i = 0; b_i < loop_ub; b_i++) { + vocal_dry[b_i].re = G_S[b_i] * M[b_i + M.size(0) * inputFrameIndex].re; + vocal_dry[b_i].im = G_S[b_i] * M[b_i + M.size(0) * inputFrameIndex].im; } } else { - binary_expand_op(allBlocks, inputFrameIndex, G_S, M); + binary_expand_op(vocal_dry, G_S, M, inputFrameIndex); + } + loop_ub = vocal_dry.size(0); + for (b_i = 0; b_i < loop_ub; b_i++) { + allBlocks[b_i + allBlocks.size(0) * inputFrameIndex] = vocal_dry[b_i]; } // G_S .* real(inputFrame) + 1j*G_S .* imag(inputFrame); % %%干声 loop_ub = G_R.size(0); if (G_R.size(0) == M.size(0)) { - vocal_effect.set_size(G_R.size(0)); - for (i1 = 0; i1 < loop_ub; i1++) { - vocal_effect[i1].re = G_R[i1] * M[i1 + M.size(0) * inputFrameIndex].re; - vocal_effect[i1].im = G_R[i1] * M[i1 + M.size(0) * inputFrameIndex].im; + vocal_reverb.set_size(G_R.size(0)); + for (b_i = 0; b_i < loop_ub; b_i++) { + vocal_reverb[b_i].re = + G_R[b_i] * M[b_i + M.size(0) * inputFrameIndex].re; + vocal_reverb[b_i].im = + G_R[b_i] * M[b_i + M.size(0) * inputFrameIndex].im; } } else { - binary_expand_op(vocal_effect, G_R, M, inputFrameIndex); + binary_expand_op(vocal_reverb, G_R, M, inputFrameIndex); } // G_R .* real(inputFrame) + 1j*G_R .* imag(inputFrame); % %%混响 // Shift all previous frames one column to the right, and insert the // current frame at the beginning. nx = previousSFramesPower.size(0) - 1; c_previousSFramesPower.set_size(previousSFramesPower.size(0), 399); - for (i1 = 0; i1 < 399; i1++) { - for (blockIndex = 0; blockIndex <= nx; blockIndex++) { - c_previousSFramesPower[blockIndex + - c_previousSFramesPower.size(0) * i1] = - previousSFramesPower[blockIndex + - previousSFramesPower.size(0) * i1]; + for (b_i = 0; b_i < 399; b_i++) { + for (k = 0; k <= nx; k++) { + c_previousSFramesPower[k + c_previousSFramesPower.size(0) * b_i] = + previousSFramesPower[k + previousSFramesPower.size(0) * b_i]; } } loop_ub = c_previousSFramesPower.size(0); - for (i1 = 0; i1 < 399; i1++) { - for (blockIndex = 0; blockIndex < loop_ub; blockIndex++) { - previousSFramesPower[blockIndex + - previousSFramesPower.size(0) * (i1 + 1)] = - c_previousSFramesPower[blockIndex + - c_previousSFramesPower.size(0) * i1]; + for (b_i = 0; b_i < 399; b_i++) { + for (k = 0; k < loop_ub; k++) { + previousSFramesPower[k + previousSFramesPower.size(0) * (b_i + 1)] = + c_previousSFramesPower[k + c_previousSFramesPower.size(0) * b_i]; } } loop_ub = allBlocks.size(0); - vocal_effect_sm.set_size(allBlocks.size(0)); - for (en = 0; en < loop_ub; en++) { - vocal_effect_sm[en] = - rt_hypotd_snf(allBlocks[en + allBlocks.size(0) * inputFrameIndex].re, - allBlocks[en + allBlocks.size(0) * inputFrameIndex].im); + newEstimates.set_size(allBlocks.size(0)); + for (k = 0; k < loop_ub; k++) { + newEstimates[k] = + rt_hypotd_snf(allBlocks[k + allBlocks.size(0) * inputFrameIndex].re, + allBlocks[k + allBlocks.size(0) * inputFrameIndex].im); } - loop_ub = vocal_effect_sm.size(0); - for (i1 = 0; i1 < loop_ub; i1++) { - scale_cl = vocal_effect_sm[i1]; - previousSFramesPower[i1] = scale_cl * scale_cl; + loop_ub = newEstimates.size(0); + for (b_i = 0; b_i < loop_ub; b_i++) { + scale_cl = newEstimates[b_i]; + previousSFramesPower[b_i] = scale_cl * scale_cl; } nx = previousMFramesPower.size(0) - 1; c_previousSFramesPower.set_size(previousMFramesPower.size(0), 399); - for (i1 = 0; i1 < 399; i1++) { - for (blockIndex = 0; blockIndex <= nx; blockIndex++) { - c_previousSFramesPower[blockIndex + - c_previousSFramesPower.size(0) * i1] = - previousMFramesPower[blockIndex + - previousMFramesPower.size(0) * i1]; + for (b_i = 0; b_i < 399; b_i++) { + for (k = 0; k <= nx; k++) { + c_previousSFramesPower[k + c_previousSFramesPower.size(0) * b_i] = + previousMFramesPower[k + previousMFramesPower.size(0) * b_i]; } } loop_ub = c_previousSFramesPower.size(0); - for (i1 = 0; i1 < 399; i1++) { - for (blockIndex = 0; blockIndex < loop_ub; blockIndex++) { - previousMFramesPower[blockIndex + - previousMFramesPower.size(0) * (i1 + 1)] = - c_previousSFramesPower[blockIndex + - c_previousSFramesPower.size(0) * i1]; + for (b_i = 0; b_i < 399; b_i++) { + for (k = 0; k < loop_ub; k++) { + previousMFramesPower[k + previousMFramesPower.size(0) * (b_i + 1)] = + c_previousSFramesPower[k + c_previousSFramesPower.size(0) * b_i]; } } loop_ub = inputFramePower.size(0); - for (i1 = 0; i1 < loop_ub; i1++) { - previousMFramesPower[i1] = inputFramePower[i1]; + for (b_i = 0; b_i < loop_ub; b_i++) { + previousMFramesPower[b_i] = inputFramePower[b_i]; } // %%%%%%%%%%%添加新的部分%%%%%%%%%%%%%% - // %%%方法5: - // 直接使用vc文件,不计算增益,直接相加,rir做平滑,增加下限(rir平滑没问题) + loop_ub = M_vc.size(0); + bk_revertant.set_size(M_vc.size(0)); + inputFramePower.set_size(M_vc.size(0)); + for (k = 0; k < loop_ub; k++) { + bk_revertant[k] = M_vc[k + M_vc.size(0) * inputFrameIndex]; + inputFramePower[k] = + rt_hypotd_snf(M_vc[k + M_vc.size(0) * inputFrameIndex].re, + M_vc[k + M_vc.size(0) * inputFrameIndex].im); + } + // %%%% 方法4,借鉴aec的方法; + // CNT = 50;%10;% + // H_pow_sm = (1- 1/CNT)*H_pow_sm + (1/CNT)*H_pow; + // newG_R_vc = (sum(previousSFramesPower_vc .* H_pow_sm, 2)) ; + // yfk = newG_R_vc; %sum(YFb,2);%%将YFb按行求和,得到65*1的矩阵 + // N = stftWindowSize/2; + // tmp = [yfk ; flipud(conj(yfk(2:N)))]; + // ykt = real(ifft(tmp)); + // ykfb = ykt(end-N+1:end);%%得到回声信号时域,为64*1矩阵 + // + // % ---------------------- Error estimation + // ekfb = dk + ykfb;%%时域误差信号 + // + // + // scale_cl = sum(abs(bk_revertant)) / (sum(abs(inputFrame_vc)) + + // 1e-10); scale_cl = min(1,scale_cl); S_vc(:, inputFrameIndex) = + // (1-scale_cl) * real(inputFrame_vc) + 1j * (1-scale_cl) * + // imag(inputFrame_vc); %%vc 干声 R_vc(:, inputFrameIndex) = + // bk_revertant; %%混响 + // %%方法5: + // 直接使用vc文件,不计算增益,直接相加,rir做平滑,增加下限(rir平滑没问题) // CNT = 50;%10;% // % st = max(1,inputFrameIndex-CNT); // % en = inputFrameIndex; // % H_pow = squeeze(mean(H_pow_all(st:en, :, :),1)); // % newG_R_vc = (sum(previousSFramesPower_vc .* H_pow, 2)) ; // H_pow_sm = (1- 1/CNT)*H_pow_sm + (1/CNT)*H_pow; // newG_R_vc = (sum(previousSFramesPower_vc .* H_pow_sm, 2)) ; // G_R_vc = (1-gainSmoothingFactor_vc).*G_R_vc + // gainSmoothingFactor_vc.*newG_R_vc; // // % vocal_effect = G_R .* inputFrame; // % % bk_revertant = min(G_R_vc,vocal_effect); // % % bk_revertant = max(bk_revertant,0.2*vocal_effect); // % G_R_vc_abs = abs(G_R_vc); // % vocal_effect_abs = abs(vocal_effect); // % idx_change = G_R_vc_abs > vocal_effect_abs; // % G_R_vc(idx_change,:)= vocal_effect(idx_change,:); // % idx_change = G_R_vc_abs < 0.2*vocal_effect_abs; // % G_R_vc(idx_change,:)= vocal_effect(idx_change,:); // bk_revertant = G_R_vc; // // // % S_vc(:, inputFrameIndex) = inputFrame_vc; %%vc 干声 // % R_vc(:, inputFrameIndex) = bk_revertant; %%混响 - // 方法6:rir做平滑,背景混响(平滑)和当前混响直接相加 - // %%%%%当前混响 + // 方法6:rir做平滑,背景混响(平滑)和当前混响直接相加 (第一版本c的算法) + // %%%%%当前混响 + // CNT = 50;%10;% + // H_pow_sm = (1- 1/CNT)*H_pow_sm + (1/CNT)*H_pow; + // newG_R_vc = (sum(previousSFramesPower_vc .* H_pow_sm, 2)) ; + // G_R_vc = (1-gainSmoothingFactor).*G_R_vc + + // gainSmoothingFactor.*newG_R_vc; + // %%%%%得到backgroud混响 + // vocal_effect = G_R .* inputFrame; + // vocal_effect_abs = abs(vocal_effect); + // vocal_effect_sm = vocal_effect_abs; + // N1 = 10; + // for ii = 1:length(vocal_effect_abs) + // st = max(ii-N1,1); + // en = min(ii+N1,length(vocal_effect_abs)); + // vocal_effect_sm(ii) = mean(vocal_effect_abs(st:en)); + // end + // vocal_effect_sm_final = vocal_effect_sm .*(vocal_effect ./ + // (vocal_effect_abs+1e-5)); %混响相加,并做限制 + // %%复数谱直接相加,效果不错 + // G_R_vc = G_R_vc + vocal_effect_sm_final; + // + // G_R_vc_abs = abs(G_R_vc); + // vocal_effect_abs = abs(vocal_effect); + // idx_change = G_R_vc_abs > vocal_effect_abs; + // G_R_vc(idx_change,:)= vocal_effect(idx_change,:); + // idx_change = G_R_vc_abs < 0.2*vocal_effect_abs; + // G_R_vc(idx_change,:)= vocal_effect(idx_change,:); + // bk_revertant = G_R_vc; + // + // scale_cl = sum(abs(bk_revertant)) / (sum(abs(inputFrame_vc)) + + // 1e-10); scale_cl = min(1,scale_cl); S_vc(:, inputFrameIndex) = + // (1-scale_cl) * real(inputFrame_vc) + 1j * (1-scale_cl) * + // imag(inputFrame_vc); %%vc 干声 R_vc(:, inputFrameIndex) = + // bk_revertant; %%混响 + // + // %%% 第二版本c的算法 + // CNT = 50;%10;% + // H_pow_sm = (1- 1/CNT)*H_pow_sm + (1/CNT)*H_pow; + // % newG_R_vc = (sum(previousSFramesPower_vc .* H_pow_sm, 2)) ; + // tmp_reverb =(sum(previousSFramesPower_vc .* H_pow_sm, 2)); + // newG_Sxx = 1 - tmp_reverb./ (inputFramePower_vc + tmp_reverb); + // newG_Sxx = max([newG_Sxx minGain], [], 2); + // G_Sxx = (1-gainSmoothingFactor).*G_Sxx + + // gainSmoothingFactor.*newG_Sxx; newG_Rxx = 1 - G_Sxx; G_Rxx = + // (1-gainSmoothingFactor).*G_Rxx + gainSmoothingFactor.*newG_Rxx; + // G_R_vc = G_Rxx .* inputFrame; + // + // %%%%%平滑后作为基础混响 + // G_R_vc = G_Rxx .* (inputFrame_vc + G_R_vc); %%%gain*混响 + // N1 = 3; + // G_R_vc_abs = abs(G_R_vc); + // G_R_vc_sm = G_R_vc_abs; + // for ii = 1:length(G_R_vc_abs) + // st = max(ii-N1,1); + // en = min(ii+N1,length(G_R_vc_abs)); + // G_R_vc_sm(ii) = mean(G_R_vc_abs(st:en)); + // end + // G_R_vc = G_R_vc_sm .*(G_R_vc ./ (G_R_vc_abs+1e-5)); + // G_R_vc = G_Rxx.*inputFrame_vc + G_R_vc; + // bk_revertant = G_R_vc; + // + // scale_cl = sum(abs(bk_revertant)) / (sum(abs(inputFrame_vc)) + + // 1e-10); scale_cl = min(1,scale_cl); S_vc(:, inputFrameIndex) = + // (1-scale_cl) * real(inputFrame_vc) + 1j * (1-scale_cl) * + // imag(inputFrame_vc); %%vc 干声 R_vc(:, inputFrameIndex) = + // bk_revertant; %%混响 + // %%%方法8:在方法8的基础上,使用vc计算混响比例,然后在乘以原始比例,加个限制min(1.0,scale) + // %%%%%% ==》 (能听到环绕声,有拖尾) // 10;% - // st = 1; - // en = CNT; - // H_pow_sm_tmp = mean(H_pow_all(st:en, :, :),1); - // H_pow_sm(:,:) = H_pow_sm_tmp(1,:,:); if (H_pow_sm.size(0) == H_pow.size(0)) { loop_ub = H_pow_sm.size(0) * 400; H_pow_sm.set_size(H_pow_sm.size(0), 400); - for (i1 = 0; i1 < loop_ub; i1++) { - H_pow_sm[i1] = 0.98 * H_pow_sm[i1] + 0.02 * H_pow[i1]; + for (b_i = 0; b_i < loop_ub; b_i++) { + H_pow_sm[b_i] = 0.95 * H_pow_sm[b_i] + 0.05 * H_pow[b_i]; } } else { binary_expand_op(H_pow_sm, H_pow); } - // %%%%%得到backgroud混响 - nx = vocal_effect.size(0); - inputFramePower.set_size(vocal_effect.size(0)); - for (en = 0; en < nx; en++) { - inputFramePower[en] = - rt_hypotd_snf(vocal_effect[en].re, vocal_effect[en].im); - } - vocal_effect_sm.set_size(inputFramePower.size(0)); - loop_ub = inputFramePower.size(0); - for (i1 = 0; i1 < loop_ub; i1++) { - vocal_effect_sm[i1] = inputFramePower[i1]; - } - i1 = inputFramePower.size(0); - for (b_i = 0; b_i < i1; b_i++) { - nx = static_cast( - std::fmax((static_cast(b_i) + 1.0) - 10.0, 1.0)); - en = static_cast( - std::fmin((static_cast(b_i) + 1.0) + 10.0, - static_cast(inputFramePower.size(0)))); - if (nx > en) { - blockIndex = -1; - nx = -1; - } else { - blockIndex = nx - 2; - nx = en - 1; - } - loop_ub = nx - blockIndex; - b_y.set_size(loop_ub); - for (nx = 0; nx < loop_ub; nx++) { - b_y[nx] = inputFramePower[(blockIndex + nx) + 1]; - } - vocal_effect_sm[b_i] = - coder::combineVectorElements(b_y) / static_cast(loop_ub); - } - // 混响相加,并做限制 - // %%使用比值幅度相加,相位不变 - // bli_h = bli_h*0.8 + 0.2*sum(vocal_effect_abs)/(sum(abs(G_R_vc)) + - // 1e-6); sum_spec = mixFactor .* vocal_effect_sm + (1 - mixFactor) .* - // abs(G_R_vc)*bli_h; G_R_vc = G_R_vc .* (sum_spec ./ - // (abs(G_R_vc)+1e-10)); - // - // %%复数谱直接相加,效果不错 if (previousSFramesPower_vc.size(0) == H_pow_sm.size(0)) { b_previousSFramesPower.set_size(previousSFramesPower_vc.size(0), 400); loop_ub = previousSFramesPower_vc.size(0) * 400; - for (i1 = 0; i1 < loop_ub; i1++) { - b_previousSFramesPower[i1] = previousSFramesPower_vc[i1] * H_pow_sm[i1]; + for (b_i = 0; b_i < loop_ub; b_i++) { + b_previousSFramesPower[b_i] = + previousSFramesPower_vc[b_i] * H_pow_sm[b_i]; } - coder::sum(b_previousSFramesPower, b_y); + coder::sum(b_previousSFramesPower, newEstimates); } else { - binary_expand_op(b_y, previousSFramesPower_vc, H_pow_sm); + binary_expand_op(newEstimates, previousSFramesPower_vc, H_pow_sm); + } + r.set_size(inputFramePower.size(0)); + loop_ub = inputFramePower.size(0); + for (b_i = 0; b_i < loop_ub; b_i++) { + scale_cl = inputFramePower[b_i]; + r[b_i] = scale_cl * scale_cl; } - loop_ub = G_R_vc.size(0); - if (M.size(0) == 1) { - i1 = G_R_vc.size(0); + if (r.size(0) == 1) { + k = newEstimates.size(0); } else { - i1 = M.size(0); + k = r.size(0); } - if (M.size(0) == 1) { - i3 = b_y.size(0); + if ((r.size(0) == newEstimates.size(0)) && (newEstimates.size(0) == k)) { + r1.set_size(newEstimates.size(0), 2); + loop_ub = newEstimates.size(0); + for (b_i = 0; b_i < loop_ub; b_i++) { + r1[b_i] = 1.0 - newEstimates[b_i] / (r[b_i] + newEstimates[b_i]); + } + loop_ub = M.size(0); + for (b_i = 0; b_i < loop_ub; b_i++) { + r1[b_i + r1.size(0)] = 0.0; + } + coder::internal::maximum(r1, r); } else { - i3 = M.size(0); + binary_expand_op(r, newEstimates, M); } - if (vocal_effect.size(0) == 1) { - en = inputFramePower.size(0); + loop_ub = G_Sxx.size(0); + if (frequencyCount.contents == 1.0) { + k = G_Sxx.size(0); } else { - en = vocal_effect.size(0); + k = static_cast(frequencyCount.contents); } - if (M.size(0) == 1) { - b_i = G_R_vc.size(0); + if (frequencyCount.contents == 1.0) { + nx = r.size(0); } else { - b_i = M.size(0); + nx = static_cast(frequencyCount.contents); } - if (b_i == 1) { - if (M.size(0) == 1) { - b_i = b_y.size(0); - } else { - b_i = M.size(0); + if ((i1 == G_Sxx.size(0)) && (i1 == r.size(0)) && (k == nx)) { + for (b_i = 0; b_i < loop_ub; b_i++) { + G_Sxx[b_i] = 0.7 * G_Sxx[b_i] + 0.3 * r[b_i]; } - } else if (M.size(0) == 1) { - b_i = G_R_vc.size(0); } else { - b_i = M.size(0); + c_binary_expand_op(G_Sxx, frequencyCount, r); } - if (vocal_effect_sm.size(0) == 1) { - if (vocal_effect.size(0) == 1) { - nx = inputFramePower.size(0); - } else { - nx = vocal_effect.size(0); - } + loop_ub = G_Rxx.size(0); + if (frequencyCount.contents == 1.0) { + k = G_Rxx.size(0); } else { - nx = vocal_effect_sm.size(0); + k = static_cast(frequencyCount.contents); } - if ((M.size(0) == G_R_vc.size(0)) && (M.size(0) == b_y.size(0)) && - (i1 == i3) && (vocal_effect.size(0) == inputFramePower.size(0)) && - (vocal_effect_sm.size(0) == en) && (b_i == nx)) { - for (i1 = 0; i1 < loop_ub; i1++) { - double br; - scale_cl = vocal_effect[i1].re; - ai = vocal_effect[i1].im; - br = inputFramePower[i1] + 1.0E-5; - if (ai == 0.0) { - varargin_2 = scale_cl / br; - scale_cl = 0.0; - } else if (scale_cl == 0.0) { - varargin_2 = 0.0; - scale_cl = ai / br; - } else { - varargin_2 = scale_cl / br; - scale_cl = ai / br; - } - G_R_vc[i1].re = (0.7 * G_R_vc[i1].re + 0.3 * b_y[i1]) + - vocal_effect_sm[i1] * varargin_2; - G_R_vc[i1].im = 0.7 * G_R_vc[i1].im + vocal_effect_sm[i1] * scale_cl; - } + if (frequencyCount.contents == 1.0) { + nx = G_Sxx.size(0); } else { - binary_expand_op(G_R_vc, M, b_y, vocal_effect_sm, vocal_effect, - inputFramePower); - } - // bk_revertant = min(G_R_vc,vocal_effect); - // bk_revertant = max(bk_revertant,0.2*vocal_effect); - i1 = G_R_vc.size(0); - newEstimates.set_size(G_R_vc.size(0)); - for (en = 0; en < i1; en++) { - newEstimates[en] = rt_hypotd_snf(G_R_vc[en].re, G_R_vc[en].im); - } - if (newEstimates.size(0) == inputFramePower.size(0)) { - unchanged.set_size(newEstimates.size(0)); - loop_ub = newEstimates.size(0); + nx = static_cast(frequencyCount.contents); + } + if ((i1 == G_Rxx.size(0)) && (i1 == G_Sxx.size(0)) && (k == nx)) { for (i1 = 0; i1 < loop_ub; i1++) { - unchanged[i1] = (newEstimates[i1] > inputFramePower[i1]); + G_Rxx[i1] = 0.7 * G_Rxx[i1] + 0.3 * (1.0 - G_Sxx[i1]); } } else { - gt(unchanged, newEstimates, inputFramePower); + binary_expand_op(G_Rxx, frequencyCount, G_Sxx); } - en = unchanged.size(0) - 1; - nx = 0; - for (b_i = 0; b_i <= en; b_i++) { - if (unchanged[b_i]) { - nx++; - } + // 修正了能量以后copy的vocal混响 + // G_R_vc =G_Rxx .* (inputFrame_vc + G_R_vc); + // 混响 + // 干声 + // vocal_dry_sm = (1 - dryMagnitudeSmoothingFactor) .* vocal_dry_sm + + // dryMagnitudeSmoothingFactor.* abs(vocal_dry ); vc_dray_sm = (1 - + // dryMagnitudeSmoothingFactor) .* vc_dray_sm + + // dryMagnitudeSmoothingFactor.* abs(inputFrame_vc ); + nx = vocal_reverb.size(0); + r.set_size(vocal_reverb.size(0)); + for (k = 0; k < nx; k++) { + r[k] = rt_hypotd_snf(vocal_reverb[k].re, vocal_reverb[k].im); + } + nx = vocal_dry.size(0); + newEstimates.set_size(vocal_dry.size(0)); + for (k = 0; k < nx; k++) { + newEstimates[k] = rt_hypotd_snf(vocal_dry[k].re, vocal_dry[k].im); } - r1.set_size(nx); - nx = 0; - for (b_i = 0; b_i <= en; b_i++) { - if (unchanged[b_i]) { - r1[nx] = b_i + 1; - nx++; - } + if (inputFramePower.size(0) == 1) { + i1 = r.size(0); + } else { + i1 = inputFramePower.size(0); } - loop_ub = r1.size(0); - for (i1 = 0; i1 < loop_ub; i1++) { - G_R_vc[r1[i1] - 1] = vocal_effect[r1[i1] - 1]; + if (newEstimates.size(0) == 1) { + k = r.size(0); + } else { + k = newEstimates.size(0); } - if (newEstimates.size(0) == inputFramePower.size(0)) { - unchanged.set_size(newEstimates.size(0)); - loop_ub = newEstimates.size(0); + if ((inputFramePower.size(0) == r.size(0)) && + (newEstimates.size(0) == r.size(0)) && (i1 == k)) { + r.set_size(inputFramePower.size(0)); + loop_ub = inputFramePower.size(0); for (i1 = 0; i1 < loop_ub; i1++) { - unchanged[i1] = (newEstimates[i1] < 0.2 * inputFramePower[i1]); + varargin_2 = (inputFramePower[i1] + r[i1]) / + ((newEstimates[i1] + r[i1]) + 1.0E-8); + r[i1] = std::fmin(1.0, varargin_2); } } else { - c_binary_expand_op(unchanged, newEstimates, inputFramePower); + binary_expand_op(r, inputFramePower, newEstimates); } - en = unchanged.size(0) - 1; - nx = 0; - for (b_i = 0; b_i <= en; b_i++) { - if (unchanged[b_i]) { - nx++; - } + loop_ub = G_Rxx.size(0); + if (G_Rxx.size(0) == 1) { + i1 = M.size(0); + } else { + i1 = G_Rxx.size(0); } - r2.set_size(nx); - nx = 0; - for (b_i = 0; b_i <= en; b_i++) { - if (unchanged[b_i]) { - r2[nx] = b_i + 1; - nx++; + if ((G_Rxx.size(0) == M.size(0)) && (i1 == r.size(0))) { + bk_revertant.set_size(G_Rxx.size(0)); + for (i1 = 0; i1 < loop_ub; i1++) { + bk_revertant[i1].re = + r[i1] * (G_Rxx[i1] * M[i1 + M.size(0) * inputFrameIndex].re); + bk_revertant[i1].im = + r[i1] * (G_Rxx[i1] * M[i1 + M.size(0) * inputFrameIndex].im); } + } else { + binary_expand_op(bk_revertant, G_Rxx, M, inputFrameIndex, r); } - loop_ub = r2.size(0); - for (i1 = 0; i1 < loop_ub; i1++) { - G_R_vc[r2[i1] - 1] = vocal_effect[r2[i1] - 1]; - } - // % %%%% - // % scale_cl = sum(abs(inputFrame_vc)) / (sum(abs(inputFrame_vc)) + - // sum(abs(bk_revertant)) + 1e-10); % scale_cl = min(1,scale_cl); % - // S_vc(:, inputFrameIndex) = scale_cl * inputFrame_vc; %%vc 干声 % - // R_vc(:, inputFrameIndex) = (1-scale_cl) * bk_revertant; %%混响 - // %%% - i1 = G_R_vc.size(0); - vocal_effect_sm.set_size(G_R_vc.size(0)); - for (en = 0; en < i1; en++) { - vocal_effect_sm[en] = rt_hypotd_snf(G_R_vc[en].re, G_R_vc[en].im); + nx = bk_revertant.size(0); + newEstimates.set_size(bk_revertant.size(0)); + for (k = 0; k < nx; k++) { + newEstimates[k] = rt_hypotd_snf(bk_revertant[k].re, bk_revertant[k].im); } - loop_ub = M_vc.size(0); - newEstimates.set_size(M_vc.size(0)); - for (en = 0; en < loop_ub; en++) { - newEstimates[en] = - rt_hypotd_snf(M_vc[en + M_vc.size(0) * inputFrameIndex].re, - M_vc[en + M_vc.size(0) * inputFrameIndex].im); - } - scale_cl = std::fmin( - 1.0, coder::combineVectorElements(vocal_effect_sm) / - (coder::combineVectorElements(newEstimates) + 1.0E-10)); + scale_cl = std::fmin(1.0, coder::sum(newEstimates) / + (coder::sum(inputFramePower) + 1.0E-10)); varargin_2 = (1.0 - scale_cl) * 0.0; loop_ub = M_vc.size(0); for (i1 = 0; i1 < loop_ub; i1++) { - ai = M_vc[i1 + M_vc.size(0) * inputFrameIndex].im; + double d; + d = M_vc[i1 + M_vc.size(0) * inputFrameIndex].im; S_vc[i1 + S_vc.size(0) * inputFrameIndex].re = (1.0 - scale_cl) * M_vc[i1 + M_vc.size(0) * inputFrameIndex].re + - varargin_2 * ai; - S_vc[i1 + S_vc.size(0) * inputFrameIndex].im = (1.0 - scale_cl) * ai; + varargin_2 * d; + S_vc[i1 + S_vc.size(0) * inputFrameIndex].im = (1.0 - scale_cl) * d; } // vc 干声 - loop_ub = G_R_vc.size(0); + loop_ub = bk_revertant.size(0); for (i1 = 0; i1 < loop_ub; i1++) { - R_vc[i1 + R_vc.size(0) * inputFrameIndex] = G_R_vc[i1]; + R_vc[i1 + R_vc.size(0) * inputFrameIndex] = bk_revertant[i1]; } // 混响 // Shift all previous frames one column to the right, and insert the // current frame at the beginning. nx = previousSFramesPower_vc.size(0) - 1; c_previousSFramesPower.set_size(previousSFramesPower_vc.size(0), 399); for (i1 = 0; i1 < 399; i1++) { - for (blockIndex = 0; blockIndex <= nx; blockIndex++) { - c_previousSFramesPower[blockIndex + - c_previousSFramesPower.size(0) * i1] = - previousSFramesPower_vc[blockIndex + - previousSFramesPower_vc.size(0) * i1]; + for (b_i = 0; b_i <= nx; b_i++) { + c_previousSFramesPower[b_i + c_previousSFramesPower.size(0) * i1] = + previousSFramesPower_vc[b_i + previousSFramesPower_vc.size(0) * i1]; } } loop_ub = c_previousSFramesPower.size(0); for (i1 = 0; i1 < 399; i1++) { - for (blockIndex = 0; blockIndex < loop_ub; blockIndex++) { - previousSFramesPower_vc[blockIndex + + for (b_i = 0; b_i < loop_ub; b_i++) { + previousSFramesPower_vc[b_i + previousSFramesPower_vc.size(0) * (i1 + 1)] = - c_previousSFramesPower[blockIndex + - c_previousSFramesPower.size(0) * i1]; + c_previousSFramesPower[b_i + c_previousSFramesPower.size(0) * i1]; } } loop_ub = S_vc.size(0); - vocal_effect_sm.set_size(S_vc.size(0)); - for (en = 0; en < loop_ub; en++) { - vocal_effect_sm[en] = - rt_hypotd_snf(S_vc[en + S_vc.size(0) * inputFrameIndex].re, - S_vc[en + S_vc.size(0) * inputFrameIndex].im); + newEstimates.set_size(S_vc.size(0)); + for (k = 0; k < loop_ub; k++) { + newEstimates[k] = + rt_hypotd_snf(S_vc[k + S_vc.size(0) * inputFrameIndex].re, + S_vc[k + S_vc.size(0) * inputFrameIndex].im); } - loop_ub = vocal_effect_sm.size(0); + loop_ub = newEstimates.size(0); for (i1 = 0; i1 < loop_ub; i1++) { - scale_cl = vocal_effect_sm[i1]; + scale_cl = newEstimates[i1]; previousSFramesPower_vc[i1] = scale_cl * scale_cl; } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } // Reconstruct and play dry signal // dry_vc = zeros(inputLength_vc,1); // dry_vc(:) = reconstruct(S_vc, window, overlapSamples, inputLength_vc); // Reconstruct and play reverberant components reconstruct(&stftWindowSize, &frequencyCount, &frameCount, R_vc, window, overlapSamples, reverberated_vc); // Reconstruct and play original reverberant signal using both components // reverbConstant = 5; for (i = 0; i < 220500; i++) { reverberated_vc[i] += signal_vc[i]; } } // // File trailer for dereveb_c.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c.h b/dereverbrate/dereveb_c/dereveb_c.h index e86e4e0..8da900e 100644 --- a/dereverbrate/dereveb_c/dereveb_c.h +++ b/dereverbrate/dereveb_c/dereveb_c.h @@ -1,28 +1,28 @@ // // File: dereveb_c.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef DEREVEB_C_H #define DEREVEB_C_H // Include Files #include "rtwtypes.h" #include "omp.h" #include #include // Function Declarations extern void dereveb_c(const double b_signal[220500], const double signal_vc[220500], double fs, const double impulseResponse[264600], double reverberated_vc[220500]); #endif // // File trailer for dereveb_c.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_data.cpp b/dereverbrate/dereveb_c/dereveb_c_data.cpp index c705869..26aef6e 100644 --- a/dereverbrate/dereveb_c/dereveb_c_data.cpp +++ b/dereverbrate/dereveb_c/dereveb_c_data.cpp @@ -1,21 +1,21 @@ // // File: dereveb_c_data.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "dereveb_c_data.h" #include "rt_nonfinite.h" // Variable Definitions omp_nest_lock_t dereveb_c_nestLockGlobal; boolean_T isInitialized_dereveb_c{false}; // // File trailer for dereveb_c_data.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_data.h b/dereverbrate/dereveb_c/dereveb_c_data.h index 20a41f0..b59bf85 100644 --- a/dereverbrate/dereveb_c/dereveb_c_data.h +++ b/dereverbrate/dereveb_c/dereveb_c_data.h @@ -1,26 +1,26 @@ // // File: dereveb_c_data.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef DEREVEB_C_DATA_H #define DEREVEB_C_DATA_H // Include Files #include "rtwtypes.h" #include "omp.h" #include #include // Variable Declarations extern omp_nest_lock_t dereveb_c_nestLockGlobal; extern boolean_T isInitialized_dereveb_c; #endif // // File trailer for dereveb_c_data.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_initialize.cpp b/dereverbrate/dereveb_c/dereveb_c_initialize.cpp index f579cdc..7aa56d2 100644 --- a/dereverbrate/dereveb_c/dereveb_c_initialize.cpp +++ b/dereverbrate/dereveb_c/dereveb_c_initialize.cpp @@ -1,28 +1,28 @@ // // File: dereveb_c_initialize.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "dereveb_c_initialize.h" #include "dereveb_c_data.h" #include "rt_nonfinite.h" // Function Definitions // // Arguments : void // Return Type : void // void dereveb_c_initialize() { omp_init_nest_lock(&dereveb_c_nestLockGlobal); isInitialized_dereveb_c = true; } // // File trailer for dereveb_c_initialize.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_initialize.h b/dereverbrate/dereveb_c/dereveb_c_initialize.h index 6311fe9..29c2c40 100644 --- a/dereverbrate/dereveb_c/dereveb_c_initialize.h +++ b/dereverbrate/dereveb_c/dereveb_c_initialize.h @@ -1,25 +1,25 @@ // // File: dereveb_c_initialize.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef DEREVEB_C_INITIALIZE_H #define DEREVEB_C_INITIALIZE_H // Include Files #include "rtwtypes.h" #include "omp.h" #include #include // Function Declarations extern void dereveb_c_initialize(); #endif // // File trailer for dereveb_c_initialize.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_rtw.mk b/dereverbrate/dereveb_c/dereveb_c_rtw.mk index 0b4597b..32c41f0 100644 --- a/dereverbrate/dereveb_c/dereveb_c_rtw.mk +++ b/dereverbrate/dereveb_c/dereveb_c_rtw.mk @@ -1,475 +1,475 @@ ########################################################################### ## Makefile generated for component 'dereveb_c'. ## ## Makefile : dereveb_c_rtw.mk -## Generated on : Wed Mar 22 17:38:06 2023 +## Generated on : Tue Mar 28 21:20:32 2023 ## Final product: ./dereveb_c.a ## Product type : static-library ## ########################################################################### ########################################################################### ## MACROS ########################################################################### # Macro Descriptions: # PRODUCT_NAME Name of the system to build # MAKEFILE Name of this makefile # MODELLIB Static library target PRODUCT_NAME = dereveb_c MAKEFILE = dereveb_c_rtw.mk MATLAB_ROOT = /Applications/MATLAB_R2021b.app MATLAB_BIN = /Applications/MATLAB_R2021b.app/bin MATLAB_ARCH_BIN = $(MATLAB_BIN)/maci64 START_DIR = /Volumes/T7_2/starmaker_files/音效提取算法/dereverberate TGT_FCN_LIB = ISO_C++11 SOLVER_OBJ = CLASSIC_INTERFACE = 0 MODEL_HAS_DYNAMICALLY_LOADED_SFCNS = RELATIVE_PATH_TO_ANCHOR = ../../.. C_STANDARD_OPTS = -fno-common -fexceptions CPP_STANDARD_OPTS = -std=c++14 -fno-common -fexceptions MODELLIB = dereveb_c.a ########################################################################### ## TOOLCHAIN SPECIFICATIONS ########################################################################### # Toolchain Name: Clang v3.1 | gmake (64-bit Mac) # Supported Version(s): 3.1 # ToolchainInfo Version: 2021b # Specification Revision: 1.0 # #------------------------------------------- # Macros assumed to be defined elsewhere #------------------------------------------- # C_STANDARD_OPTS # CPP_STANDARD_OPTS #----------- # MACROS #----------- ARCHS = x86_64 XCODE_SDK_VER = $(shell perl $(MATLAB_ROOT)/rtw/c/tools/macsdkver.pl) XCODE_SDK = MacOSX$(XCODE_SDK_VER).sdk XCODE_DEVEL_DIR = $(shell xcode-select -print-path) XCODE_SDK_ROOT = $(XCODE_DEVEL_DIR)/Platforms/MacOSX.platform/Developer/SDKs/$(XCODE_SDK) TOOLCHAIN_SRCS = TOOLCHAIN_INCS = TOOLCHAIN_LIBS = #------------------------ # BUILD TOOL COMMANDS #------------------------ # C Compiler: Clang C Compiler CC = xcrun clang # Linker: Clang Linker LD = xcrun clang++ # C++ Compiler: Clang C++ Compiler CPP = xcrun clang++ # C++ Linker: Clang C++ Linker CPP_LD = xcrun clang++ # Archiver: Clang Archiver AR = xcrun ar # MEX Tool: MEX Tool MEX_PATH = $(MATLAB_ARCH_BIN) MEX = "$(MEX_PATH)/mex" # Download: Download DOWNLOAD = # Execute: Execute EXECUTE = $(PRODUCT) # Builder: GMAKE Utility MAKE_PATH = %MATLAB%/bin/maci64 MAKE = "$(MAKE_PATH)/gmake" #------------------------- # Directives/Utilities #------------------------- CDEBUG = -g C_OUTPUT_FLAG = -o LDDEBUG = -g OUTPUT_FLAG = -o CPPDEBUG = -g CPP_OUTPUT_FLAG = -o CPPLDDEBUG = -g OUTPUT_FLAG = -o ARDEBUG = STATICLIB_OUTPUT_FLAG = MEX_DEBUG = -g RM = @rm -f ECHO = @echo MV = @mv RUN = #-------------------------------------- # "Faster Runs" Build Configuration #-------------------------------------- ARFLAGS = ruvs CFLAGS = -c -isysroot $(XCODE_SDK_ROOT) -arch $(ARCHS) $(C_STANDARD_OPTS) -mmacosx-version-min=10.15 \ -O3 CPPFLAGS = -c -isysroot $(XCODE_SDK_ROOT) -arch $(ARCHS) $(CPP_STANDARD_OPTS) -mmacosx-version-min=10.15 \ -O3 CPP_LDFLAGS = -arch $(ARCHS) -isysroot $(XCODE_SDK_ROOT) -Wl,-rpath,@executable_path -Wl,-rpath,@executable_path/$(RELATIVE_PATH_TO_ANCHOR) CPP_SHAREDLIB_LDFLAGS = -dynamiclib -install_name @rpath/$(notdir $(PRODUCT)) -isysroot $(XCODE_SDK_ROOT) \ -Wl,$(LD_NAMESPACE) $(LD_UNDEFS) DOWNLOAD_FLAGS = EXECUTE_FLAGS = LDFLAGS = -arch $(ARCHS) -isysroot $(XCODE_SDK_ROOT) -Wl,-rpath,@executable_path -Wl,-rpath,@executable_path/$(RELATIVE_PATH_TO_ANCHOR) MEX_CPPFLAGS = MEX_CPPLDFLAGS = MEX_CFLAGS = MEX_LDFLAGS = MAKE_FLAGS = -f $(MAKEFILE) SHAREDLIB_LDFLAGS = -dynamiclib -install_name @rpath/$(notdir $(PRODUCT)) -isysroot $(XCODE_SDK_ROOT) \ -Wl,$(LD_NAMESPACE) $(LD_UNDEFS) ########################################################################### ## OUTPUT INFO ########################################################################### PRODUCT = ./dereveb_c.a PRODUCT_TYPE = "static-library" BUILD_TYPE = "Static Library" ########################################################################### ## INCLUDE PATHS ########################################################################### INCLUDES_BUILDINFO = -I$(START_DIR)/codegen/lib/dereveb_c -I$(START_DIR) -I$(MATLAB_ROOT)/extern/include INCLUDES = $(INCLUDES_BUILDINFO) ########################################################################### ## DEFINES ########################################################################### DEFINES_CUSTOM = DEFINES_STANDARD = -DMODEL=dereveb_c DEFINES = $(DEFINES_CUSTOM) $(DEFINES_STANDARD) ########################################################################### ## SOURCE FILES ########################################################################### -SRCS = $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_data.cpp $(START_DIR)/codegen/lib/dereveb_c/rt_nonfinite.cpp $(START_DIR)/codegen/lib/dereveb_c/rtGetNaN.cpp $(START_DIR)/codegen/lib/dereveb_c/rtGetInf.cpp $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_initialize.cpp $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_terminate.cpp $(START_DIR)/codegen/lib/dereveb_c/dereveb_c.cpp $(START_DIR)/codegen/lib/dereveb_c/hann.cpp $(START_DIR)/codegen/lib/dereveb_c/iseven.cpp $(START_DIR)/codegen/lib/dereveb_c/gencoswin.cpp $(START_DIR)/codegen/lib/dereveb_c/spectrogram.cpp $(START_DIR)/codegen/lib/dereveb_c/hamming.cpp $(START_DIR)/codegen/lib/dereveb_c/ixfun.cpp $(START_DIR)/codegen/lib/dereveb_c/sum.cpp $(START_DIR)/codegen/lib/dereveb_c/combineVectorElements.cpp $(START_DIR)/codegen/lib/dereveb_c/ifft.cpp $(START_DIR)/codegen/lib/dereveb_c/computeDFT.cpp $(START_DIR)/codegen/lib/dereveb_c/welchparse.cpp $(START_DIR)/codegen/lib/dereveb_c/pspectrogram.cpp $(START_DIR)/codegen/lib/dereveb_c/div.cpp $(START_DIR)/codegen/lib/dereveb_c/cat.cpp $(START_DIR)/codegen/lib/dereveb_c/FFTImplementationCallback.cpp $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_rtwutil.cpp +SRCS = $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_data.cpp $(START_DIR)/codegen/lib/dereveb_c/rt_nonfinite.cpp $(START_DIR)/codegen/lib/dereveb_c/rtGetNaN.cpp $(START_DIR)/codegen/lib/dereveb_c/rtGetInf.cpp $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_initialize.cpp $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_terminate.cpp $(START_DIR)/codegen/lib/dereveb_c/dereveb_c.cpp $(START_DIR)/codegen/lib/dereveb_c/hann.cpp $(START_DIR)/codegen/lib/dereveb_c/iseven.cpp $(START_DIR)/codegen/lib/dereveb_c/gencoswin.cpp $(START_DIR)/codegen/lib/dereveb_c/spectrogram.cpp $(START_DIR)/codegen/lib/dereveb_c/hamming.cpp $(START_DIR)/codegen/lib/dereveb_c/ixfun.cpp $(START_DIR)/codegen/lib/dereveb_c/sum.cpp $(START_DIR)/codegen/lib/dereveb_c/minOrMax.cpp $(START_DIR)/codegen/lib/dereveb_c/ifft.cpp $(START_DIR)/codegen/lib/dereveb_c/computeDFT.cpp $(START_DIR)/codegen/lib/dereveb_c/welchparse.cpp $(START_DIR)/codegen/lib/dereveb_c/pspectrogram.cpp $(START_DIR)/codegen/lib/dereveb_c/div.cpp $(START_DIR)/codegen/lib/dereveb_c/unsafeSxfun.cpp $(START_DIR)/codegen/lib/dereveb_c/FFTImplementationCallback.cpp $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_rtwutil.cpp ALL_SRCS = $(SRCS) ########################################################################### ## OBJECTS ########################################################################### -OBJS = dereveb_c_data.o rt_nonfinite.o rtGetNaN.o rtGetInf.o dereveb_c_initialize.o dereveb_c_terminate.o dereveb_c.o hann.o iseven.o gencoswin.o spectrogram.o hamming.o ixfun.o sum.o combineVectorElements.o ifft.o computeDFT.o welchparse.o pspectrogram.o div.o cat.o FFTImplementationCallback.o dereveb_c_rtwutil.o +OBJS = dereveb_c_data.o rt_nonfinite.o rtGetNaN.o rtGetInf.o dereveb_c_initialize.o dereveb_c_terminate.o dereveb_c.o hann.o iseven.o gencoswin.o spectrogram.o hamming.o ixfun.o sum.o minOrMax.o ifft.o computeDFT.o welchparse.o pspectrogram.o div.o unsafeSxfun.o FFTImplementationCallback.o dereveb_c_rtwutil.o ALL_OBJS = $(OBJS) ########################################################################### ## PREBUILT OBJECT FILES ########################################################################### PREBUILT_OBJS = ########################################################################### ## LIBRARIES ########################################################################### LIBS = ########################################################################### ## SYSTEM LIBRARIES ########################################################################### SYSTEM_LIBS = -L"$(MATLAB_ROOT)/sys/os/maci64" -lm -lstdc++ -liomp5 ########################################################################### ## ADDITIONAL TOOLCHAIN FLAGS ########################################################################### #--------------- # C Compiler #--------------- CFLAGS_OPTS = -Xpreprocessor -fopenmp -I/Applications/MATLAB_R2021b.app/toolbox/eml/externalDependency/omp/maci64/include -DOpenMP_omp_LIBRARY=/Applications/MATLAB_R2021b.app/sys/os/maci64/libiomp5.dylib CFLAGS_BASIC = $(DEFINES) $(INCLUDES) CFLAGS += $(CFLAGS_OPTS) $(CFLAGS_BASIC) #----------------- # C++ Compiler #----------------- CPPFLAGS_OPTS = -Xpreprocessor -fopenmp -I/Applications/MATLAB_R2021b.app/toolbox/eml/externalDependency/omp/maci64/include -DOpenMP_omp_LIBRARY=/Applications/MATLAB_R2021b.app/sys/os/maci64/libiomp5.dylib CPPFLAGS_BASIC = $(DEFINES) $(INCLUDES) CPPFLAGS += $(CPPFLAGS_OPTS) $(CPPFLAGS_BASIC) #--------------- # C++ Linker #--------------- CPP_LDFLAGS_ = -Wl,-rpath,$(MATLAB_ROOT)/sys/os/$(ARCH)/ CPP_LDFLAGS += $(CPP_LDFLAGS_) #------------------------------ # C++ Shared Library Linker #------------------------------ CPP_SHAREDLIB_LDFLAGS_ = -Wl,-rpath,$(MATLAB_ROOT)/sys/os/$(ARCH)/ CPP_SHAREDLIB_LDFLAGS += $(CPP_SHAREDLIB_LDFLAGS_) #----------- # Linker #----------- LDFLAGS_ = -Wl,-rpath,$(MATLAB_ROOT)/sys/os/$(ARCH)/ LDFLAGS += $(LDFLAGS_) #-------------------------- # Shared Library Linker #-------------------------- SHAREDLIB_LDFLAGS_ = -Wl,-rpath,$(MATLAB_ROOT)/sys/os/$(ARCH)/ SHAREDLIB_LDFLAGS += $(SHAREDLIB_LDFLAGS_) ########################################################################### ## INLINED COMMANDS ########################################################################### ########################################################################### ## PHONY TARGETS ########################################################################### .PHONY : all build clean info prebuild download execute all : build @echo "### Successfully generated all binary outputs." build : prebuild $(PRODUCT) prebuild : download : $(PRODUCT) execute : download ########################################################################### ## FINAL TARGET ########################################################################### #--------------------------------- # Create a static library #--------------------------------- $(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) @echo "### Creating static library "$(PRODUCT)" ..." $(AR) $(ARFLAGS) $(PRODUCT) $(OBJS) @echo "### Created: $(PRODUCT)" ########################################################################### ## INTERMEDIATE TARGETS ########################################################################### #--------------------- # SOURCE-TO-OBJECT #--------------------- %.o : %.c $(CC) $(CFLAGS) -o "$@" "$<" %.o : %.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" %.o : $(RELATIVE_PATH_TO_ANCHOR)/%.c $(CC) $(CFLAGS) -o "$@" "$<" %.o : $(RELATIVE_PATH_TO_ANCHOR)/%.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" %.o : $(START_DIR)/codegen/lib/dereveb_c/%.c $(CC) $(CFLAGS) -o "$@" "$<" %.o : $(START_DIR)/codegen/lib/dereveb_c/%.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" %.o : $(START_DIR)/%.c $(CC) $(CFLAGS) -o "$@" "$<" %.o : $(START_DIR)/%.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" dereveb_c_data.o : $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_data.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" rt_nonfinite.o : $(START_DIR)/codegen/lib/dereveb_c/rt_nonfinite.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" rtGetNaN.o : $(START_DIR)/codegen/lib/dereveb_c/rtGetNaN.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" rtGetInf.o : $(START_DIR)/codegen/lib/dereveb_c/rtGetInf.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" dereveb_c_initialize.o : $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_initialize.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" dereveb_c_terminate.o : $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_terminate.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" dereveb_c.o : $(START_DIR)/codegen/lib/dereveb_c/dereveb_c.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" hann.o : $(START_DIR)/codegen/lib/dereveb_c/hann.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" iseven.o : $(START_DIR)/codegen/lib/dereveb_c/iseven.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" gencoswin.o : $(START_DIR)/codegen/lib/dereveb_c/gencoswin.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" spectrogram.o : $(START_DIR)/codegen/lib/dereveb_c/spectrogram.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" hamming.o : $(START_DIR)/codegen/lib/dereveb_c/hamming.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" ixfun.o : $(START_DIR)/codegen/lib/dereveb_c/ixfun.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" sum.o : $(START_DIR)/codegen/lib/dereveb_c/sum.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" -combineVectorElements.o : $(START_DIR)/codegen/lib/dereveb_c/combineVectorElements.cpp +minOrMax.o : $(START_DIR)/codegen/lib/dereveb_c/minOrMax.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" ifft.o : $(START_DIR)/codegen/lib/dereveb_c/ifft.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" computeDFT.o : $(START_DIR)/codegen/lib/dereveb_c/computeDFT.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" welchparse.o : $(START_DIR)/codegen/lib/dereveb_c/welchparse.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" pspectrogram.o : $(START_DIR)/codegen/lib/dereveb_c/pspectrogram.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" div.o : $(START_DIR)/codegen/lib/dereveb_c/div.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" -cat.o : $(START_DIR)/codegen/lib/dereveb_c/cat.cpp +unsafeSxfun.o : $(START_DIR)/codegen/lib/dereveb_c/unsafeSxfun.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" FFTImplementationCallback.o : $(START_DIR)/codegen/lib/dereveb_c/FFTImplementationCallback.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" dereveb_c_rtwutil.o : $(START_DIR)/codegen/lib/dereveb_c/dereveb_c_rtwutil.cpp $(CPP) $(CPPFLAGS) -o "$@" "$<" ########################################################################### ## DEPENDENCIES ########################################################################### $(ALL_OBJS) : rtw_proj.tmw $(MAKEFILE) ########################################################################### ## MISCELLANEOUS TARGETS ########################################################################### info : @echo "### PRODUCT = $(PRODUCT)" @echo "### PRODUCT_TYPE = $(PRODUCT_TYPE)" @echo "### BUILD_TYPE = $(BUILD_TYPE)" @echo "### INCLUDES = $(INCLUDES)" @echo "### DEFINES = $(DEFINES)" @echo "### ALL_SRCS = $(ALL_SRCS)" @echo "### ALL_OBJS = $(ALL_OBJS)" @echo "### LIBS = $(LIBS)" @echo "### MODELREF_LIBS = $(MODELREF_LIBS)" @echo "### SYSTEM_LIBS = $(SYSTEM_LIBS)" @echo "### TOOLCHAIN_LIBS = $(TOOLCHAIN_LIBS)" @echo "### CFLAGS = $(CFLAGS)" @echo "### LDFLAGS = $(LDFLAGS)" @echo "### SHAREDLIB_LDFLAGS = $(SHAREDLIB_LDFLAGS)" @echo "### CPPFLAGS = $(CPPFLAGS)" @echo "### CPP_LDFLAGS = $(CPP_LDFLAGS)" @echo "### CPP_SHAREDLIB_LDFLAGS = $(CPP_SHAREDLIB_LDFLAGS)" @echo "### ARFLAGS = $(ARFLAGS)" @echo "### MEX_CFLAGS = $(MEX_CFLAGS)" @echo "### MEX_CPPFLAGS = $(MEX_CPPFLAGS)" @echo "### MEX_LDFLAGS = $(MEX_LDFLAGS)" @echo "### MEX_CPPLDFLAGS = $(MEX_CPPLDFLAGS)" @echo "### DOWNLOAD_FLAGS = $(DOWNLOAD_FLAGS)" @echo "### EXECUTE_FLAGS = $(EXECUTE_FLAGS)" @echo "### MAKE_FLAGS = $(MAKE_FLAGS)" clean : $(ECHO) "### Deleting all derived files..." $(RM) $(PRODUCT) $(RM) $(ALL_OBJS) $(ECHO) "### Deleted all derived files." diff --git a/dereverbrate/dereveb_c/dereveb_c_rtwutil.cpp b/dereverbrate/dereveb_c/dereveb_c_rtwutil.cpp index 90d095b..86fe70d 100644 --- a/dereverbrate/dereveb_c/dereveb_c_rtwutil.cpp +++ b/dereverbrate/dereveb_c/dereveb_c_rtwutil.cpp @@ -1,89 +1,89 @@ // // File: dereveb_c_rtwutil.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "dereveb_c_rtwutil.h" #include "rt_nonfinite.h" #include #include // Function Definitions // // Arguments : int numerator // int denominator // Return Type : int // int div_s32_floor(int numerator, int denominator) { int quotient; if (denominator == 0) { if (numerator >= 0) { quotient = MAX_int32_T; } else { quotient = MIN_int32_T; } } else { unsigned int absDenominator; unsigned int absNumerator; unsigned int tempAbsQuotient; boolean_T quotientNeedsNegation; if (numerator < 0) { absNumerator = ~static_cast(numerator) + 1U; } else { absNumerator = static_cast(numerator); } if (denominator < 0) { absDenominator = ~static_cast(denominator) + 1U; } else { absDenominator = static_cast(denominator); } quotientNeedsNegation = ((numerator < 0) != (denominator < 0)); tempAbsQuotient = absNumerator / absDenominator; if (quotientNeedsNegation) { absNumerator %= absDenominator; if (absNumerator > 0U) { tempAbsQuotient++; } quotient = -static_cast(tempAbsQuotient); } else { quotient = static_cast(tempAbsQuotient); } } return quotient; } // // Arguments : double u0 // double u1 // Return Type : double // double rt_remd_snf(double u0, double u1) { double y; if (std::isnan(u0) || std::isnan(u1) || std::isinf(u0)) { y = rtNaN; } else if (std::isinf(u1)) { y = u0; } else if ((u1 != 0.0) && (u1 != std::trunc(u1))) { double q; q = std::abs(u0 / u1); if (!(std::abs(q - std::floor(q + 0.5)) > DBL_EPSILON * q)) { y = 0.0 * u0; } else { y = std::fmod(u0, u1); } } else { y = std::fmod(u0, u1); } return y; } // // File trailer for dereveb_c_rtwutil.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_rtwutil.h b/dereverbrate/dereveb_c/dereveb_c_rtwutil.h index 73cfa2b..9de1959 100644 --- a/dereverbrate/dereveb_c/dereveb_c_rtwutil.h +++ b/dereverbrate/dereveb_c/dereveb_c_rtwutil.h @@ -1,27 +1,27 @@ // // File: dereveb_c_rtwutil.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef DEREVEB_C_RTWUTIL_H #define DEREVEB_C_RTWUTIL_H // Include Files #include "rtwtypes.h" #include "omp.h" #include #include // Function Declarations extern int div_s32_floor(int numerator, int denominator); extern double rt_remd_snf(double u0, double u1); #endif // // File trailer for dereveb_c_rtwutil.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_terminate.cpp b/dereverbrate/dereveb_c/dereveb_c_terminate.cpp index 103d774..317b83f 100644 --- a/dereverbrate/dereveb_c/dereveb_c_terminate.cpp +++ b/dereverbrate/dereveb_c/dereveb_c_terminate.cpp @@ -1,28 +1,28 @@ // // File: dereveb_c_terminate.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "dereveb_c_terminate.h" #include "dereveb_c_data.h" #include "rt_nonfinite.h" // Function Definitions // // Arguments : void // Return Type : void // void dereveb_c_terminate() { omp_destroy_nest_lock(&dereveb_c_nestLockGlobal); isInitialized_dereveb_c = false; } // // File trailer for dereveb_c_terminate.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_terminate.h b/dereverbrate/dereveb_c/dereveb_c_terminate.h index c5d610b..898ed28 100644 --- a/dereverbrate/dereveb_c/dereveb_c_terminate.h +++ b/dereverbrate/dereveb_c/dereveb_c_terminate.h @@ -1,25 +1,25 @@ // // File: dereveb_c_terminate.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef DEREVEB_C_TERMINATE_H #define DEREVEB_C_TERMINATE_H // Include Files #include "rtwtypes.h" #include "omp.h" #include #include // Function Declarations extern void dereveb_c_terminate(); #endif // // File trailer for dereveb_c_terminate.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/dereveb_c_types.h b/dereverbrate/dereveb_c/dereveb_c_types.h index a6b3b1b..535ed01 100644 --- a/dereverbrate/dereveb_c/dereveb_c_types.h +++ b/dereverbrate/dereveb_c/dereveb_c_types.h @@ -1,20 +1,20 @@ // // File: dereveb_c_types.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef DEREVEB_C_TYPES_H #define DEREVEB_C_TYPES_H // Include Files #include "rtwtypes.h" #define MAX_THREADS omp_get_max_threads() #endif // // File trailer for dereveb_c_types.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/div.cpp b/dereverbrate/dereveb_c/div.cpp index e51a8d6..329b7db 100644 --- a/dereverbrate/dereveb_c/div.cpp +++ b/dereverbrate/dereveb_c/div.cpp @@ -1,56 +1,56 @@ // // File: div.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "div.h" #include "rt_nonfinite.h" #include "coder_array.h" // Function Definitions // // Arguments : coder::array &newEstimates // const coder::array &inputFramePower // const coder::array &previousMFramesPower // int blockIndex // Return Type : void // void binary_expand_op(coder::array &newEstimates, const coder::array &inputFramePower, const coder::array &previousMFramesPower, int blockIndex) { int i; int loop_ub; int stride_0_0; int stride_1_0; i = previousMFramesPower.size(0); if (i == 1) { stride_0_0 = inputFramePower.size(0); } else { stride_0_0 = i; } newEstimates.set_size(stride_0_0); stride_0_0 = (inputFramePower.size(0) != 1); stride_1_0 = (i != 1); if (i == 1) { loop_ub = inputFramePower.size(0); } else { loop_ub = i; } for (i = 0; i < loop_ub; i++) { newEstimates[i] = inputFramePower[i * stride_0_0] / previousMFramesPower[i * stride_1_0 + previousMFramesPower.size(0) * blockIndex]; } } // // File trailer for div.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/div.h b/dereverbrate/dereveb_c/div.h index cf91ae0..da1b9c2 100644 --- a/dereverbrate/dereveb_c/div.h +++ b/dereverbrate/dereveb_c/div.h @@ -1,29 +1,29 @@ // // File: div.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef DIV_H #define DIV_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations void binary_expand_op(coder::array &newEstimates, const coder::array &inputFramePower, const coder::array &previousMFramesPower, int blockIndex); #endif // // File trailer for div.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/gencoswin.cpp b/dereverbrate/dereveb_c/gencoswin.cpp index 2f28e01..bd5fe8c 100644 --- a/dereverbrate/dereveb_c/gencoswin.cpp +++ b/dereverbrate/dereveb_c/gencoswin.cpp @@ -1,104 +1,104 @@ // // File: gencoswin.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "gencoswin.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : double m // double n // ::coder::array &w // Return Type : void // namespace coder { void b_calc_window(double m, double n, ::coder::array &w) { array y; int k; int nx; if (std::isnan(m - 1.0)) { y.set_size(1, 1); y[0] = rtNaN; } else if (m - 1.0 < 0.0) { y.set_size(1, 0); } else if (std::isinf(m - 1.0) && (0.0 == m - 1.0)) { y.set_size(1, 1); y[0] = rtNaN; } else { nx = static_cast(std::floor(m - 1.0)); y.set_size(1, nx + 1); for (k = 0; k <= nx; k++) { y[k] = k; } } w.set_size(y.size(1)); nx = y.size(1); for (k = 0; k < nx; k++) { w[k] = 6.2831853071795862 * (y[k] / (n - 1.0)); } nx = w.size(0); for (k = 0; k < nx; k++) { w[k] = std::cos(w[k]); } nx = w.size(0); for (k = 0; k < nx; k++) { w[k] = 0.54 - 0.46 * w[k]; } } // // Arguments : double m // double n // ::coder::array &w // Return Type : void // void calc_window(double m, double n, ::coder::array &w) { array y; int k; int nx; if (std::isnan(m - 1.0)) { y.set_size(1, 1); y[0] = rtNaN; } else if (m - 1.0 < 0.0) { y.set_size(1, 0); } else if (std::isinf(m - 1.0) && (0.0 == m - 1.0)) { y.set_size(1, 1); y[0] = rtNaN; } else { nx = static_cast(std::floor(m - 1.0)); y.set_size(1, nx + 1); for (k = 0; k <= nx; k++) { y[k] = k; } } w.set_size(y.size(1)); nx = y.size(1); for (k = 0; k < nx; k++) { w[k] = 6.2831853071795862 * (y[k] / (n - 1.0)); } nx = w.size(0); for (k = 0; k < nx; k++) { w[k] = std::cos(w[k]); } nx = w.size(0); for (k = 0; k < nx; k++) { w[k] = 0.5 - 0.5 * w[k]; } } } // namespace coder // // File trailer for gencoswin.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/gencoswin.h b/dereverbrate/dereveb_c/gencoswin.h index 596f7e8..0671c6b 100644 --- a/dereverbrate/dereveb_c/gencoswin.h +++ b/dereverbrate/dereveb_c/gencoswin.h @@ -1,31 +1,31 @@ // // File: gencoswin.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef GENCOSWIN_H #define GENCOSWIN_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { void b_calc_window(double m, double n, ::coder::array &w); void calc_window(double m, double n, ::coder::array &w); } // namespace coder #endif // // File trailer for gencoswin.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/hamming.cpp b/dereverbrate/dereveb_c/hamming.cpp index 3cf7c8a..f637f06 100644 --- a/dereverbrate/dereveb_c/hamming.cpp +++ b/dereverbrate/dereveb_c/hamming.cpp @@ -1,116 +1,116 @@ // // File: hamming.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "hamming.h" #include "dereveb_c_rtwutil.h" #include "gencoswin.h" #include "iseven.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : double varargin_1 // ::coder::array &w // Return Type : void // namespace coder { void hamming(double varargin_1, ::coder::array &w) { array b_w; double L; int i; int trivialwin; int w_size; signed char w_data; w_size = 1; w_data = 0; trivialwin = 0; if (varargin_1 == std::floor(varargin_1)) { L = varargin_1; } else { L = std::round(varargin_1); } if (L == 0.0) { w_size = 0; trivialwin = 1; } else if (L == 1.0) { w_data = 1; trivialwin = 1; } w.set_size(w_size); for (i = 0; i < w_size; i++) { w[0] = w_data; } if (trivialwin == 0) { if (iseven(L)) { int i1; int loop_ub; b_calc_window(L / 2.0, L, w); if (1 > w.size(0)) { i = 0; w_size = 1; i1 = -1; } else { i = w.size(0) - 1; w_size = -1; i1 = 0; } trivialwin = div_s32_floor(i1 - i, w_size); b_w.set_size((w.size(0) + trivialwin) + 1); loop_ub = w.size(0); for (i1 = 0; i1 < loop_ub; i1++) { b_w[i1] = w[i1]; } for (i1 = 0; i1 <= trivialwin; i1++) { b_w[i1 + w.size(0)] = w[i + w_size * i1]; } w.set_size(b_w.size(0)); trivialwin = b_w.size(0); for (i = 0; i < trivialwin; i++) { w[i] = b_w[i]; } } else { int i1; int loop_ub; b_calc_window((L + 1.0) / 2.0, L, w); if (1 > w.size(0) - 1) { i = 0; w_size = 1; i1 = -1; } else { i = w.size(0) - 2; w_size = -1; i1 = 0; } trivialwin = div_s32_floor(i1 - i, w_size); b_w.set_size((w.size(0) + trivialwin) + 1); loop_ub = w.size(0); for (i1 = 0; i1 < loop_ub; i1++) { b_w[i1] = w[i1]; } for (i1 = 0; i1 <= trivialwin; i1++) { b_w[i1 + w.size(0)] = w[i + w_size * i1]; } w.set_size(b_w.size(0)); trivialwin = b_w.size(0); for (i = 0; i < trivialwin; i++) { w[i] = b_w[i]; } } } } } // namespace coder // // File trailer for hamming.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/hamming.h b/dereverbrate/dereveb_c/hamming.h index 4ebd72d..44c49e3 100644 --- a/dereverbrate/dereveb_c/hamming.h +++ b/dereverbrate/dereveb_c/hamming.h @@ -1,29 +1,29 @@ // // File: hamming.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef HAMMING_H #define HAMMING_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { void hamming(double varargin_1, ::coder::array &w); } #endif // // File trailer for hamming.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/hann.cpp b/dereverbrate/dereveb_c/hann.cpp index 5dfe724..21f76f4 100644 --- a/dereverbrate/dereveb_c/hann.cpp +++ b/dereverbrate/dereveb_c/hann.cpp @@ -1,116 +1,116 @@ // // File: hann.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "hann.h" #include "dereveb_c_rtwutil.h" #include "gencoswin.h" #include "iseven.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : double varargin_1 // ::coder::array &w // Return Type : void // namespace coder { void hann(double varargin_1, ::coder::array &w) { array b_w; double L; int i; int trivialwin; int w_size; signed char w_data; w_size = 1; w_data = 0; trivialwin = 0; if (varargin_1 == std::floor(varargin_1)) { L = varargin_1; } else { L = std::round(varargin_1); } if (L == 0.0) { w_size = 0; trivialwin = 1; } else if (L == 1.0) { w_data = 1; trivialwin = 1; } w.set_size(w_size); for (i = 0; i < w_size; i++) { w[0] = w_data; } if (trivialwin == 0) { if (iseven(L + 1.0)) { int i1; int loop_ub; calc_window((L + 1.0) / 2.0, L + 1.0, w); if (2 > w.size(0)) { i = 0; w_size = 1; i1 = -1; } else { i = w.size(0) - 1; w_size = -1; i1 = 1; } trivialwin = div_s32_floor(i1 - i, w_size); b_w.set_size((w.size(0) + trivialwin) + 1); loop_ub = w.size(0); for (i1 = 0; i1 < loop_ub; i1++) { b_w[i1] = w[i1]; } for (i1 = 0; i1 <= trivialwin; i1++) { b_w[i1 + w.size(0)] = w[i + w_size * i1]; } w.set_size(b_w.size(0)); trivialwin = b_w.size(0); for (i = 0; i < trivialwin; i++) { w[i] = b_w[i]; } } else { int i1; int loop_ub; calc_window(((L + 1.0) + 1.0) / 2.0, L + 1.0, w); if (2 > w.size(0) - 1) { i = 0; w_size = 1; i1 = -1; } else { i = w.size(0) - 2; w_size = -1; i1 = 1; } trivialwin = div_s32_floor(i1 - i, w_size); b_w.set_size((w.size(0) + trivialwin) + 1); loop_ub = w.size(0); for (i1 = 0; i1 < loop_ub; i1++) { b_w[i1] = w[i1]; } for (i1 = 0; i1 <= trivialwin; i1++) { b_w[i1 + w.size(0)] = w[i + w_size * i1]; } w.set_size(b_w.size(0)); trivialwin = b_w.size(0); for (i = 0; i < trivialwin; i++) { w[i] = b_w[i]; } } } } } // namespace coder // // File trailer for hann.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/hann.h b/dereverbrate/dereveb_c/hann.h index ca7fd9d..e2cfbee 100644 --- a/dereverbrate/dereveb_c/hann.h +++ b/dereverbrate/dereveb_c/hann.h @@ -1,29 +1,29 @@ // // File: hann.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef HANN_H #define HANN_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { void hann(double varargin_1, ::coder::array &w); } #endif // // File trailer for hann.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/ifft.cpp b/dereverbrate/dereveb_c/ifft.cpp index 872b9c5..bda3ff5 100644 --- a/dereverbrate/dereveb_c/ifft.cpp +++ b/dereverbrate/dereveb_c/ifft.cpp @@ -1,225 +1,224 @@ // // File: ifft.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "ifft.h" #include "FFTImplementationCallback.h" -#include "dereveb_c_data.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : const ::coder::array &x // ::coder::array &y // Return Type : void // namespace coder { void ifft(const ::coder::array &x, ::coder::array &y) { array b_fv; array fv; array wwc; array costab; array costab1q; array sintab; array sintabinv; int N2blue; int nd2; int nfft; nfft = x.size(0); if (x.size(0) == 0) { y.set_size(0); } else { double nt_im; int i; int k; int nInt2; int rt; boolean_T useRadix2; useRadix2 = ((x.size(0) & (x.size(0) - 1)) == 0); internal::FFTImplementationCallback::get_algo_sizes(x.size(0), useRadix2, &N2blue, &nd2); nt_im = 6.2831853071795862 / static_cast(nd2); nInt2 = nd2 / 2 / 2; costab1q.set_size(1, nInt2 + 1); costab1q[0] = 1.0; nd2 = nInt2 / 2 - 1; for (k = 0; k <= nd2; k++) { costab1q[k + 1] = std::cos(nt_im * (static_cast(k) + 1.0)); } i = nd2 + 2; rt = nInt2 - 1; for (k = i; k <= rt; k++) { costab1q[k] = std::sin(nt_im * static_cast(nInt2 - k)); } costab1q[nInt2] = 0.0; if (!useRadix2) { nInt2 = costab1q.size(1) - 1; nd2 = (costab1q.size(1) - 1) << 1; costab.set_size(1, nd2 + 1); sintab.set_size(1, nd2 + 1); costab[0] = 1.0; sintab[0] = 0.0; sintabinv.set_size(1, nd2 + 1); for (k = 0; k < nInt2; k++) { sintabinv[k + 1] = costab1q[(nInt2 - k) - 1]; } i = costab1q.size(1); for (k = i; k <= nd2; k++) { sintabinv[k] = costab1q[k - nInt2]; } for (k = 0; k < nInt2; k++) { costab[k + 1] = costab1q[k + 1]; sintab[k + 1] = -costab1q[(nInt2 - k) - 1]; } i = costab1q.size(1); for (k = i; k <= nd2; k++) { costab[k] = -costab1q[nd2 - k]; sintab[k] = -costab1q[k - nInt2]; } } else { nInt2 = costab1q.size(1) - 1; nd2 = (costab1q.size(1) - 1) << 1; costab.set_size(1, nd2 + 1); sintab.set_size(1, nd2 + 1); costab[0] = 1.0; sintab[0] = 0.0; for (k = 0; k < nInt2; k++) { costab[k + 1] = costab1q[k + 1]; sintab[k + 1] = costab1q[(nInt2 - k) - 1]; } i = costab1q.size(1); for (k = i; k <= nd2; k++) { costab[k] = -costab1q[nd2 - k]; sintab[k] = costab1q[k - nInt2]; } sintabinv.set_size(1, 0); } if (useRadix2) { internal::FFTImplementationCallback::r2br_r2dit_trig_impl( x, x.size(0), costab, sintab, y); if (y.size(0) > 1) { nt_im = 1.0 / static_cast(y.size(0)); nd2 = y.size(0); for (i = 0; i < nd2; i++) { y[i].re = nt_im * y[i].re; y[i].im = nt_im * y[i].im; } } } else { double b_re_tmp; double c_re_tmp; double nt_re; double re_tmp; nd2 = (x.size(0) + x.size(0)) - 1; wwc.set_size(nd2); rt = 0; wwc[x.size(0) - 1].re = 1.0; wwc[x.size(0) - 1].im = 0.0; nInt2 = x.size(0) << 1; i = x.size(0); for (k = 0; k <= i - 2; k++) { int b_y; b_y = ((k + 1) << 1) - 1; if (nInt2 - rt <= b_y) { rt += b_y - nInt2; } else { rt += b_y; } nt_im = 3.1415926535897931 * static_cast(rt) / static_cast(nfft); if (nt_im == 0.0) { nt_re = 1.0; nt_im = 0.0; } else { nt_re = std::cos(nt_im); nt_im = std::sin(nt_im); } wwc[(x.size(0) - k) - 2].re = nt_re; wwc[(x.size(0) - k) - 2].im = -nt_im; } i = nd2 - 1; for (k = i; k >= nfft; k--) { wwc[k] = wwc[(nd2 - k) - 1]; } y.set_size(x.size(0)); nd2 = x.size(0); for (k = 0; k < nd2; k++) { nt_re = wwc[(nfft + k) - 1].re; nt_im = wwc[(nfft + k) - 1].im; re_tmp = x[k].im; b_re_tmp = x[k].re; y[k].re = nt_re * b_re_tmp + nt_im * re_tmp; y[k].im = nt_re * re_tmp - nt_im * b_re_tmp; } i = x.size(0) + 1; for (k = i; k <= nfft; k++) { y[k - 1].re = 0.0; y[k - 1].im = 0.0; } internal::FFTImplementationCallback::r2br_r2dit_trig_impl( y, N2blue, costab, sintab, fv); internal::FFTImplementationCallback::r2br_r2dit_trig_impl( wwc, N2blue, costab, sintab, b_fv); b_fv.set_size(fv.size(0)); nd2 = fv.size(0); for (i = 0; i < nd2; i++) { nt_im = fv[i].re; re_tmp = b_fv[i].im; b_re_tmp = fv[i].im; c_re_tmp = b_fv[i].re; b_fv[i].re = nt_im * c_re_tmp - b_re_tmp * re_tmp; b_fv[i].im = nt_im * re_tmp + b_re_tmp * c_re_tmp; } internal::FFTImplementationCallback::r2br_r2dit_trig_impl( b_fv, N2blue, costab, sintabinv, fv); if (fv.size(0) > 1) { nt_im = 1.0 / static_cast(fv.size(0)); nd2 = fv.size(0); for (i = 0; i < nd2; i++) { fv[i].re = nt_im * fv[i].re; fv[i].im = nt_im * fv[i].im; } } nt_re = x.size(0); i = x.size(0); rt = wwc.size(0); for (k = i; k <= rt; k++) { double ar; nt_im = wwc[k - 1].re; re_tmp = fv[k - 1].im; b_re_tmp = wwc[k - 1].im; c_re_tmp = fv[k - 1].re; ar = nt_im * c_re_tmp + b_re_tmp * re_tmp; nt_im = nt_im * re_tmp - b_re_tmp * c_re_tmp; if (nt_im == 0.0) { nd2 = k - i; y[nd2].re = ar / nt_re; y[nd2].im = 0.0; } else if (ar == 0.0) { nd2 = k - i; y[nd2].re = 0.0; y[nd2].im = nt_im / nt_re; } else { nd2 = k - i; y[nd2].re = ar / nt_re; y[nd2].im = nt_im / nt_re; } } } } } } // namespace coder // // File trailer for ifft.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/ifft.h b/dereverbrate/dereveb_c/ifft.h index b7a7d2c..3dc9488 100644 --- a/dereverbrate/dereveb_c/ifft.h +++ b/dereverbrate/dereveb_c/ifft.h @@ -1,29 +1,29 @@ // // File: ifft.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef IFFT_H #define IFFT_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { void ifft(const ::coder::array &x, ::coder::array &y); } #endif // // File trailer for ifft.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/interface/_coder_dereveb_c_api.cpp b/dereverbrate/dereveb_c/interface/_coder_dereveb_c_api.cpp index 90f9123..dd07bf2 100644 --- a/dereverbrate/dereveb_c/interface/_coder_dereveb_c_api.cpp +++ b/dereverbrate/dereveb_c/interface/_coder_dereveb_c_api.cpp @@ -1,324 +1,324 @@ // // File: _coder_dereveb_c_api.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "_coder_dereveb_c_api.h" #include "_coder_dereveb_c_mex.h" // Variable Definitions emlrtCTX emlrtRootTLSGlobal{nullptr}; emlrtContext emlrtContextGlobal{ true, // bFirstTime false, // bInitialized 131611U, // fVersionInfo nullptr, // fErrorFunction "dereveb_c", // fFunctionName nullptr, // fRTCallStack false, // bDebugMode {2045744189U, 2170104910U, 2743257031U, 4284093946U}, // fSigWrd nullptr // fSigMem }; // Function Declarations static real_T b_emlrt_marshallIn(const emlrtStack *sp, const mxArray *fs, const char_T *identifier); static real_T b_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const emlrtMsgIdentifier *parentId); static real_T (*c_emlrt_marshallIn(const emlrtStack *sp, const mxArray *impulseResponse, const char_T *identifier))[264600]; static real_T (*c_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const emlrtMsgIdentifier *parentId))[264600]; static real_T (*d_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const emlrtMsgIdentifier *msgId))[220500]; static real_T e_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const emlrtMsgIdentifier *msgId); static real_T (*emlrt_marshallIn(const emlrtStack *sp, const mxArray *b_signal, const char_T *identifier))[220500]; static real_T (*emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const emlrtMsgIdentifier *parentId))[220500]; static const mxArray *emlrt_marshallOut(const real_T u[220500]); static real_T (*f_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const emlrtMsgIdentifier *msgId))[264600]; // Function Definitions // // Arguments : const emlrtStack *sp // const mxArray *fs // const char_T *identifier // Return Type : real_T // static real_T b_emlrt_marshallIn(const emlrtStack *sp, const mxArray *fs, const char_T *identifier) { emlrtMsgIdentifier thisId; real_T y; thisId.fIdentifier = const_cast(identifier); thisId.fParent = nullptr; thisId.bParentIsCell = false; y = b_emlrt_marshallIn(sp, emlrtAlias(fs), &thisId); emlrtDestroyArray(&fs); return y; } // // Arguments : const emlrtStack *sp // const mxArray *u // const emlrtMsgIdentifier *parentId // Return Type : real_T // static real_T b_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const emlrtMsgIdentifier *parentId) { real_T y; y = e_emlrt_marshallIn(sp, emlrtAlias(u), parentId); emlrtDestroyArray(&u); return y; } // // Arguments : const emlrtStack *sp // const mxArray *impulseResponse // const char_T *identifier // Return Type : real_T (*)[264600] // static real_T (*c_emlrt_marshallIn(const emlrtStack *sp, const mxArray *impulseResponse, const char_T *identifier))[264600] { emlrtMsgIdentifier thisId; real_T(*y)[264600]; thisId.fIdentifier = const_cast(identifier); thisId.fParent = nullptr; thisId.bParentIsCell = false; y = c_emlrt_marshallIn(sp, emlrtAlias(impulseResponse), &thisId); emlrtDestroyArray(&impulseResponse); return y; } // // Arguments : const emlrtStack *sp // const mxArray *u // const emlrtMsgIdentifier *parentId // Return Type : real_T (*)[264600] // static real_T (*c_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const emlrtMsgIdentifier *parentId))[264600] { real_T(*y)[264600]; y = f_emlrt_marshallIn(sp, emlrtAlias(u), parentId); emlrtDestroyArray(&u); return y; } // // Arguments : const emlrtStack *sp // const mxArray *src // const emlrtMsgIdentifier *msgId // Return Type : real_T (*)[220500] // static real_T (*d_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const emlrtMsgIdentifier *msgId))[220500] { static const int32_T dims{220500}; real_T(*ret)[220500]; emlrtCheckBuiltInR2012b((emlrtCTX)sp, msgId, src, (const char_T *)"double", false, 1U, (void *)&dims); ret = (real_T(*)[220500])emlrtMxGetData(src); emlrtDestroyArray(&src); return ret; } // // Arguments : const emlrtStack *sp // const mxArray *src // const emlrtMsgIdentifier *msgId // Return Type : real_T // static real_T e_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const emlrtMsgIdentifier *msgId) { static const int32_T dims{0}; real_T ret; emlrtCheckBuiltInR2012b((emlrtCTX)sp, msgId, src, (const char_T *)"double", false, 0U, (void *)&dims); ret = *(real_T *)emlrtMxGetData(src); emlrtDestroyArray(&src); return ret; } // // Arguments : const emlrtStack *sp // const mxArray *b_signal // const char_T *identifier // Return Type : real_T (*)[220500] // static real_T (*emlrt_marshallIn(const emlrtStack *sp, const mxArray *b_signal, const char_T *identifier))[220500] { emlrtMsgIdentifier thisId; real_T(*y)[220500]; thisId.fIdentifier = const_cast(identifier); thisId.fParent = nullptr; thisId.bParentIsCell = false; y = emlrt_marshallIn(sp, emlrtAlias(b_signal), &thisId); emlrtDestroyArray(&b_signal); return y; } // // Arguments : const emlrtStack *sp // const mxArray *u // const emlrtMsgIdentifier *parentId // Return Type : real_T (*)[220500] // static real_T (*emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const emlrtMsgIdentifier *parentId))[220500] { real_T(*y)[220500]; y = d_emlrt_marshallIn(sp, emlrtAlias(u), parentId); emlrtDestroyArray(&u); return y; } // // Arguments : const real_T u[220500] // Return Type : const mxArray * // static const mxArray *emlrt_marshallOut(const real_T u[220500]) { static const int32_T i{0}; static const int32_T i1{220500}; const mxArray *m; const mxArray *y; y = nullptr; m = emlrtCreateNumericArray(1, (const void *)&i, mxDOUBLE_CLASS, mxREAL); emlrtMxSetData((mxArray *)m, (void *)&u[0]); emlrtSetDimensions((mxArray *)m, &i1, 1); emlrtAssign(&y, m); return y; } // // Arguments : const emlrtStack *sp // const mxArray *src // const emlrtMsgIdentifier *msgId // Return Type : real_T (*)[264600] // static real_T (*f_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const emlrtMsgIdentifier *msgId))[264600] { static const int32_T dims{264600}; real_T(*ret)[264600]; emlrtCheckBuiltInR2012b((emlrtCTX)sp, msgId, src, (const char_T *)"double", false, 1U, (void *)&dims); ret = (real_T(*)[264600])emlrtMxGetData(src); emlrtDestroyArray(&src); return ret; } // // Arguments : const mxArray * const prhs[4] // const mxArray **plhs // Return Type : void // void dereveb_c_api(const mxArray *const prhs[4], const mxArray **plhs) { emlrtStack st{ nullptr, // site nullptr, // tls nullptr // prev }; real_T(*impulseResponse)[264600]; real_T(*b_signal)[220500]; real_T(*reverberated_vc)[220500]; real_T(*signal_vc)[220500]; real_T fs; st.tls = emlrtRootTLSGlobal; reverberated_vc = (real_T(*)[220500])mxMalloc(sizeof(real_T[220500])); // Marshall function inputs b_signal = emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "signal"); signal_vc = emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "signal_vc"); fs = b_emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "fs"); impulseResponse = c_emlrt_marshallIn(&st, emlrtAlias(prhs[3]), "impulseResponse"); // Invoke the target function dereveb_c(*b_signal, *signal_vc, fs, *impulseResponse, *reverberated_vc); // Marshall function outputs *plhs = emlrt_marshallOut(*reverberated_vc); } // // Arguments : void // Return Type : void // void dereveb_c_atexit() { emlrtStack st{ nullptr, // site nullptr, // tls nullptr // prev }; mexFunctionCreateRootTLS(); st.tls = emlrtRootTLSGlobal; emlrtEnterRtStackR2012b(&st); emlrtLeaveRtStackR2012b(&st); emlrtDestroyRootTLS(&emlrtRootTLSGlobal); dereveb_c_xil_terminate(); dereveb_c_xil_shutdown(); emlrtExitTimeCleanup(&emlrtContextGlobal); } // // Arguments : void // Return Type : void // void dereveb_c_initialize() { emlrtStack st{ nullptr, // site nullptr, // tls nullptr // prev }; mexFunctionCreateRootTLS(); st.tls = emlrtRootTLSGlobal; emlrtClearAllocCountR2012b(&st, false, 0U, nullptr); emlrtEnterRtStackR2012b(&st); emlrtFirstTimeR2012b(emlrtRootTLSGlobal); } // // Arguments : void // Return Type : void // void dereveb_c_terminate() { emlrtStack st{ nullptr, // site nullptr, // tls nullptr // prev }; st.tls = emlrtRootTLSGlobal; emlrtLeaveRtStackR2012b(&st); emlrtDestroyRootTLS(&emlrtRootTLSGlobal); } // // File trailer for _coder_dereveb_c_api.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/interface/_coder_dereveb_c_api.h b/dereverbrate/dereveb_c/interface/_coder_dereveb_c_api.h index 8ae1d6e..e5b6ace 100644 --- a/dereverbrate/dereveb_c/interface/_coder_dereveb_c_api.h +++ b/dereverbrate/dereveb_c/interface/_coder_dereveb_c_api.h @@ -1,42 +1,42 @@ // // File: _coder_dereveb_c_api.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef _CODER_DEREVEB_C_API_H #define _CODER_DEREVEB_C_API_H // Include Files #include "emlrt.h" #include "tmwtypes.h" #include #include // Variable Declarations extern emlrtCTX emlrtRootTLSGlobal; extern emlrtContext emlrtContextGlobal; // Function Declarations void dereveb_c(real_T b_signal[220500], real_T signal_vc[220500], real_T fs, real_T impulseResponse[264600], real_T reverberated_vc[220500]); void dereveb_c_api(const mxArray *const prhs[4], const mxArray **plhs); void dereveb_c_atexit(); void dereveb_c_initialize(); void dereveb_c_terminate(); void dereveb_c_xil_shutdown(); void dereveb_c_xil_terminate(); #endif // // File trailer for _coder_dereveb_c_api.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/interface/_coder_dereveb_c_mex.cpp b/dereverbrate/dereveb_c/interface/_coder_dereveb_c_mex.cpp index 987cf0c..171ceea 100644 --- a/dereverbrate/dereveb_c/interface/_coder_dereveb_c_mex.cpp +++ b/dereverbrate/dereveb_c/interface/_coder_dereveb_c_mex.cpp @@ -1,85 +1,85 @@ // // File: _coder_dereveb_c_mex.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "_coder_dereveb_c_mex.h" #include "_coder_dereveb_c_api.h" // Function Definitions // // Arguments : int32_T nlhs // mxArray *plhs[] // int32_T nrhs // const mxArray *prhs[] // Return Type : void // void mexFunction(int32_T nlhs, mxArray *plhs[], int32_T nrhs, const mxArray *prhs[]) { mexAtExit(&dereveb_c_atexit); // Module initialization. dereveb_c_initialize(); try { emlrtShouldCleanupOnError((emlrtCTX *)emlrtRootTLSGlobal, false); // Dispatch the entry-point. unsafe_dereveb_c_mexFunction(nlhs, plhs, nrhs, prhs); // Module termination. dereveb_c_terminate(); } catch (...) { emlrtCleanupOnException((emlrtCTX *)emlrtRootTLSGlobal); throw; } } // // Arguments : void // Return Type : emlrtCTX // emlrtCTX mexFunctionCreateRootTLS() { emlrtCreateRootTLSR2021a(&emlrtRootTLSGlobal, &emlrtContextGlobal, nullptr, 1, nullptr); return emlrtRootTLSGlobal; } // // Arguments : int32_T nlhs // mxArray *plhs[1] // int32_T nrhs // const mxArray *prhs[4] // Return Type : void // void unsafe_dereveb_c_mexFunction(int32_T nlhs, mxArray *plhs[1], int32_T nrhs, const mxArray *prhs[4]) { emlrtStack st{ nullptr, // site nullptr, // tls nullptr // prev }; const mxArray *outputs; st.tls = emlrtRootTLSGlobal; // Check for proper number of arguments. if (nrhs != 4) { emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:WrongNumberOfInputs", 5, 12, 4, 4, 9, "dereveb_c"); } if (nlhs > 1) { emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:TooManyOutputArguments", 3, 4, 9, "dereveb_c"); } // Call the function. dereveb_c_api(prhs, &outputs); // Copy over outputs to the caller. emlrtReturnArrays(1, &plhs[0], &outputs); } // // File trailer for _coder_dereveb_c_mex.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/interface/_coder_dereveb_c_mex.h b/dereverbrate/dereveb_c/interface/_coder_dereveb_c_mex.h index 86aa734..38924b5 100644 --- a/dereverbrate/dereveb_c/interface/_coder_dereveb_c_mex.h +++ b/dereverbrate/dereveb_c/interface/_coder_dereveb_c_mex.h @@ -1,30 +1,30 @@ // // File: _coder_dereveb_c_mex.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef _CODER_DEREVEB_C_MEX_H #define _CODER_DEREVEB_C_MEX_H // Include Files #include "emlrt.h" #include "mex.h" #include "tmwtypes.h" // Function Declarations MEXFUNCTION_LINKAGE void mexFunction(int32_T nlhs, mxArray *plhs[], int32_T nrhs, const mxArray *prhs[]); emlrtCTX mexFunctionCreateRootTLS(); void unsafe_dereveb_c_mexFunction(int32_T nlhs, mxArray *plhs[1], int32_T nrhs, const mxArray *prhs[4]); #endif // // File trailer for _coder_dereveb_c_mex.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/iseven.cpp b/dereverbrate/dereveb_c/iseven.cpp index 1d3193d..3e3c32b 100644 --- a/dereverbrate/dereveb_c/iseven.cpp +++ b/dereverbrate/dereveb_c/iseven.cpp @@ -1,43 +1,43 @@ // // File: iseven.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "iseven.h" #include "rt_nonfinite.h" #include // Function Definitions // // Arguments : double x // Return Type : boolean_T // namespace coder { boolean_T iseven(double x) { double r; if (std::isnan(x) || std::isinf(x)) { r = rtNaN; } else if (x == 0.0) { r = 0.0; } else { r = std::fmod(x, 2.0); if (r == 0.0) { r = 0.0; } else if (x < 0.0) { r += 2.0; } } return r == 0.0; } } // namespace coder // // File trailer for iseven.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/iseven.h b/dereverbrate/dereveb_c/iseven.h index b8c5c0c..61c629f 100644 --- a/dereverbrate/dereveb_c/iseven.h +++ b/dereverbrate/dereveb_c/iseven.h @@ -1,28 +1,28 @@ // // File: iseven.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef ISEVEN_H #define ISEVEN_H // Include Files #include "rtwtypes.h" #include "omp.h" #include #include // Function Declarations namespace coder { boolean_T iseven(double x); } #endif // // File trailer for iseven.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/ixfun.cpp b/dereverbrate/dereveb_c/ixfun.cpp index a1b025c..2dd7da6 100644 --- a/dereverbrate/dereveb_c/ixfun.cpp +++ b/dereverbrate/dereveb_c/ixfun.cpp @@ -1,65 +1,65 @@ // // File: ixfun.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "ixfun.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : const ::coder::array &a // const ::coder::array &b // ::coder::array &c // Return Type : void // namespace coder { namespace internal { void expand_min(const ::coder::array &a, const ::coder::array &b, ::coder::array &c) { int acoef; int csz_idx_0; int u0; u0 = a.size(0); acoef = b.size(0); if (u0 <= acoef) { acoef = u0; } if (a.size(0) == 1) { csz_idx_0 = b.size(0); } else { csz_idx_0 = acoef; } u0 = a.size(0); acoef = b.size(0); if (u0 <= acoef) { acoef = u0; } if (a.size(0) == 1) { acoef = b.size(0); } c.set_size(acoef); if (csz_idx_0 != 0) { acoef = (a.size(0) != 1); u0 = csz_idx_0 - 1; for (csz_idx_0 = 0; csz_idx_0 <= u0; csz_idx_0++) { c[csz_idx_0] = std::fmin(a[acoef * csz_idx_0], b[csz_idx_0]); } } } } // namespace internal } // namespace coder // // File trailer for ixfun.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/ixfun.h b/dereverbrate/dereveb_c/ixfun.h index 805c525..8bc6ce5 100644 --- a/dereverbrate/dereveb_c/ixfun.h +++ b/dereverbrate/dereveb_c/ixfun.h @@ -1,33 +1,33 @@ // // File: ixfun.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef IXFUN_H #define IXFUN_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { namespace internal { void expand_min(const ::coder::array &a, const ::coder::array &b, ::coder::array &c); } } // namespace coder #endif // // File trailer for ixfun.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/minOrMax.cpp b/dereverbrate/dereveb_c/minOrMax.cpp new file mode 100644 index 0000000..6e0bda8 --- /dev/null +++ b/dereverbrate/dereveb_c/minOrMax.cpp @@ -0,0 +1,163 @@ +// +// File: minOrMax.cpp +// +// MATLAB Coder version : 5.3 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 +// + +// Include Files +#include "minOrMax.h" +#include "rt_nonfinite.h" +#include "coder_array.h" +#include + +// Function Definitions +// +// Arguments : coder::array &r2 +// const coder::array &newEstimates +// const coder::array &M +// Return Type : void +// +void binary_expand_op(coder::array &r2, + const coder::array &newEstimates, + const coder::array &M) +{ + coder::array r1; + coder::array r; + int i; + int loop_ub; + int stride_0_0; + int stride_1_0; + int stride_2_0; + if (newEstimates.size(0) == 1) { + i = r2.size(0); + } else { + i = newEstimates.size(0); + } + if (i == 1) { + i = newEstimates.size(0); + } else if (newEstimates.size(0) == 1) { + i = r2.size(0); + } else { + i = newEstimates.size(0); + } + r.set_size(i); + stride_0_0 = (newEstimates.size(0) != 1); + stride_1_0 = (r2.size(0) != 1); + stride_2_0 = (newEstimates.size(0) != 1); + if (newEstimates.size(0) == 1) { + i = r2.size(0); + } else { + i = newEstimates.size(0); + } + if (i == 1) { + loop_ub = newEstimates.size(0); + } else if (newEstimates.size(0) == 1) { + loop_ub = r2.size(0); + } else { + loop_ub = newEstimates.size(0); + } + for (i = 0; i < loop_ub; i++) { + r[i] = 1.0 - newEstimates[i * stride_0_0] / + (r2[i * stride_1_0] + newEstimates[i * stride_2_0]); + } + r1.set_size(r.size(0), 2); + loop_ub = r.size(0); + for (i = 0; i < loop_ub; i++) { + r1[i] = r[i]; + } + loop_ub = M.size(0); + for (i = 0; i < loop_ub; i++) { + r1[i + r1.size(0)] = 0.0; + } + coder::internal::maximum(r1, r2); +} + +// +// Arguments : coder::array &r2 +// const coder::array &inputFramePower +// const coder::array &M +// Return Type : void +// +void c_binary_expand_op(coder::array &r2, + const coder::array &inputFramePower, + const coder::array &M) +{ + coder::array r1; + coder::array r; + int i; + int loop_ub; + int stride_0_0; + int stride_1_0; + if (inputFramePower.size(0) == 1) { + i = r2.size(0); + } else { + i = inputFramePower.size(0); + } + r.set_size(i); + stride_0_0 = (r2.size(0) != 1); + stride_1_0 = (inputFramePower.size(0) != 1); + if (inputFramePower.size(0) == 1) { + loop_ub = r2.size(0); + } else { + loop_ub = inputFramePower.size(0); + } + for (i = 0; i < loop_ub; i++) { + r[i] = 1.0 - r2[i * stride_0_0] / inputFramePower[i * stride_1_0]; + } + r1.set_size(r.size(0), 2); + loop_ub = r.size(0); + for (i = 0; i < loop_ub; i++) { + r1[i] = r[i]; + } + loop_ub = M.size(0); + for (i = 0; i < loop_ub; i++) { + r1[i + r1.size(0)] = 0.0; + } + coder::internal::maximum(r1, r2); +} + +// +// Arguments : const ::coder::array &x +// ::coder::array &ex +// Return Type : void +// +namespace coder { +namespace internal { +void maximum(const ::coder::array &x, + ::coder::array &ex) +{ + int m; + m = x.size(0) - 1; + ex.set_size(x.size(0)); + if (x.size(0) >= 1) { + int i; + for (i = 0; i <= m; i++) { + ex[i] = x[i]; + } + for (i = 0; i <= m; i++) { + double b; + boolean_T p; + b = x[i + x.size(0)]; + if (std::isnan(b)) { + p = false; + } else if (std::isnan(ex[i])) { + p = true; + } else { + p = (ex[i] < b); + } + if (p) { + ex[i] = b; + } + } + } +} + +} // namespace internal +} // namespace coder + +// +// File trailer for minOrMax.cpp +// +// [EOF] +// diff --git a/dereverbrate/dereveb_c/minOrMax.h b/dereverbrate/dereveb_c/minOrMax.h new file mode 100644 index 0000000..1b04bd0 --- /dev/null +++ b/dereverbrate/dereveb_c/minOrMax.h @@ -0,0 +1,40 @@ +// +// File: minOrMax.h +// +// MATLAB Coder version : 5.3 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 +// + +#ifndef MINORMAX_H +#define MINORMAX_H + +// Include Files +#include "rtwtypes.h" +#include "coder_array.h" +#include "omp.h" +#include +#include + +// Function Declarations +void binary_expand_op(coder::array &r2, + const coder::array &newEstimates, + const coder::array &M); + +void c_binary_expand_op(coder::array &r2, + const coder::array &inputFramePower, + const coder::array &M); + +namespace coder { +namespace internal { +void maximum(const ::coder::array &x, + ::coder::array &ex); + +} +} // namespace coder + +#endif +// +// File trailer for minOrMax.h +// +// [EOF] +// diff --git a/dereverbrate/dereveb_c/pspectrogram.cpp b/dereverbrate/dereveb_c/pspectrogram.cpp index 68b511a..de5b733 100644 --- a/dereverbrate/dereveb_c/pspectrogram.cpp +++ b/dereverbrate/dereveb_c/pspectrogram.cpp @@ -1,124 +1,124 @@ // // File: pspectrogram.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "pspectrogram.h" #include "dereveb_c_rtwutil.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : ::coder::array &y // ::coder::array &f // double nfft // const char options_range[8] // Return Type : void // namespace coder { void formatSpectrogram(::coder::array &y, ::coder::array &f, double nfft, const char options_range[8]) { static const char cv[128]{ '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', ' ', '!', '\"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '\x7f'}; static const char cv1[8]{'o', 'n', 'e', 's', 'i', 'd', 'e', 'd'}; array w1; int kstr; boolean_T b_bool; b_bool = false; kstr = 0; int exitg1; do { exitg1 = 0; if (kstr < 8) { if (cv[static_cast(options_range[kstr])] != cv[static_cast(cv1[kstr])]) { exitg1 = 1; } else { kstr++; } } else { b_bool = true; exitg1 = 1; } } while (exitg1 == 0); if (b_bool) { double freq_res; double halfNPTS; double half_res; int b_y; int i; freq_res = 6.2831853071795862 / nfft; if (std::isnan(nfft - 1.0)) { w1.set_size(1, 1); w1[0] = rtNaN; } else if (nfft - 1.0 < 0.0) { w1.set_size(w1.size(0), 0); } else if (std::isinf(nfft - 1.0) && (0.0 == nfft - 1.0)) { w1.set_size(1, 1); w1[0] = rtNaN; } else { kstr = static_cast(std::floor(nfft - 1.0)); w1.set_size(1, kstr + 1); for (i = 0; i <= kstr; i++) { w1[i] = i; } } w1.set_size(1, w1.size(1)); kstr = w1.size(1) - 1; for (i = 0; i <= kstr; i++) { w1[i] = freq_res * w1[i]; } half_res = freq_res / 2.0; if (rt_remd_snf(nfft, 2.0) != 0.0) { halfNPTS = (nfft + 1.0) / 2.0; w1[static_cast(halfNPTS) - 1] = 3.1415926535897931 - half_res; w1[static_cast(static_cast(halfNPTS))] = half_res + 3.1415926535897931; } else { halfNPTS = nfft / 2.0 + 1.0; w1[static_cast(halfNPTS) - 1] = 3.1415926535897931; } w1[static_cast(nfft) - 1] = 6.2831853071795862 - freq_res; kstr = static_cast(halfNPTS); f.set_size(kstr); for (i = 0; i < kstr; i++) { f[i] = w1[i]; } b_y = y.size(1) - 1; for (i = 0; i <= b_y; i++) { for (int i1{0}; i1 < kstr; i1++) { y[i1 + static_cast(halfNPTS) * i] = y[i1 + y.size(0) * i]; } } y.set_size(kstr, b_y + 1); } } } // namespace coder // // File trailer for pspectrogram.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/pspectrogram.h b/dereverbrate/dereveb_c/pspectrogram.h index b2a1657..7a8de2e 100644 --- a/dereverbrate/dereveb_c/pspectrogram.h +++ b/dereverbrate/dereveb_c/pspectrogram.h @@ -1,31 +1,31 @@ // // File: pspectrogram.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef PSPECTROGRAM_H #define PSPECTROGRAM_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { void formatSpectrogram(::coder::array &y, ::coder::array &f, double nfft, const char options_range[8]); } #endif // // File trailer for pspectrogram.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/ref.h b/dereverbrate/dereveb_c/ref.h index 24b4170..bae6e04 100644 --- a/dereverbrate/dereveb_c/ref.h +++ b/dereverbrate/dereveb_c/ref.h @@ -1,31 +1,31 @@ // // File: ref.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef REF_H #define REF_H // Include Files #include "rtwtypes.h" #include "omp.h" #include #include // Type Definitions namespace coder { class captured_var { public: double contents; }; } // namespace coder #endif // // File trailer for ref.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/rtGetInf.cpp b/dereverbrate/dereveb_c/rtGetInf.cpp index 53a5de9..c28bd31 100644 --- a/dereverbrate/dereveb_c/rtGetInf.cpp +++ b/dereverbrate/dereveb_c/rtGetInf.cpp @@ -1,55 +1,55 @@ // // File: rtGetInf.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Abstract: // MATLAB for code generation function to initialize non-finite, Inf and // MinusInf // Include Files #include "rtGetInf.h" #include "rt_nonfinite.h" // Function: rtGetInf // ================================================================== // Abstract: // Initialize rtInf needed by the generated code. real_T rtGetInf(void) { return rtInf; } // Function: rtGetInfF // ================================================================= // Abstract: // Initialize rtInfF needed by the generated code. real32_T rtGetInfF(void) { return rtInfF; } // Function: rtGetMinusInf // ============================================================= // Abstract: // Initialize rtMinusInf needed by the generated code. real_T rtGetMinusInf(void) { return rtMinusInf; } // Function: rtGetMinusInfF // ============================================================ // Abstract: // Initialize rtMinusInfF needed by the generated code. real32_T rtGetMinusInfF(void) { return rtMinusInfF; } // // File trailer for rtGetInf.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/rtGetInf.h b/dereverbrate/dereveb_c/rtGetInf.h index fac518d..fece781 100644 --- a/dereverbrate/dereveb_c/rtGetInf.h +++ b/dereverbrate/dereveb_c/rtGetInf.h @@ -1,31 +1,31 @@ // // File: rtGetInf.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef RTGETINF_H #define RTGETINF_H // Include Files #include "rtwtypes.h" #ifdef __cplusplus extern "C" { #endif extern real_T rtGetInf(void); extern real32_T rtGetInfF(void); extern real_T rtGetMinusInf(void); extern real32_T rtGetMinusInfF(void); #ifdef __cplusplus } #endif #endif // // File trailer for rtGetInf.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/rtGetNaN.cpp b/dereverbrate/dereveb_c/rtGetNaN.cpp index b88f72f..fc2a00b 100644 --- a/dereverbrate/dereveb_c/rtGetNaN.cpp +++ b/dereverbrate/dereveb_c/rtGetNaN.cpp @@ -1,38 +1,38 @@ // // File: rtGetNaN.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Abstract: // MATLAB for code generation function to initialize non-finite, NaN // Include Files #include "rtGetNaN.h" #include "rt_nonfinite.h" // Function: rtGetNaN // ====================================================================== // Abstract: // Initialize rtNaN needed by the generated code. // NaN is initialized as non-signaling. Assumes IEEE. real_T rtGetNaN(void) { return rtNaN; } // Function: rtGetNaNF // ===================================================================== // Abstract: // Initialize rtNaNF needed by the generated code. // NaN is initialized as non-signaling. Assumes IEEE real32_T rtGetNaNF(void) { return rtNaNF; } // // File trailer for rtGetNaN.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/rtGetNaN.h b/dereverbrate/dereveb_c/rtGetNaN.h index 32af9ff..e20bb6d 100644 --- a/dereverbrate/dereveb_c/rtGetNaN.h +++ b/dereverbrate/dereveb_c/rtGetNaN.h @@ -1,29 +1,29 @@ // // File: rtGetNaN.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef RTGETNAN_H #define RTGETNAN_H // Include Files #include "rtwtypes.h" #ifdef __cplusplus extern "C" { #endif extern real_T rtGetNaN(void); extern real32_T rtGetNaNF(void); #ifdef __cplusplus } #endif #endif // // File trailer for rtGetNaN.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/rt_nonfinite.cpp b/dereverbrate/dereveb_c/rt_nonfinite.cpp index 4dc1a6f..bcc3bc1 100644 --- a/dereverbrate/dereveb_c/rt_nonfinite.cpp +++ b/dereverbrate/dereveb_c/rt_nonfinite.cpp @@ -1,27 +1,27 @@ // // File: rt_nonfinite.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Abstract: // MATLAB for code generation function to initialize non-finites, // (Inf, NaN and -Inf). // Include Files #include "rt_nonfinite.h" #include #include real_T rtNaN{std::numeric_limits::quiet_NaN()}; real_T rtInf{std::numeric_limits::infinity()}; real_T rtMinusInf{-std::numeric_limits::infinity()}; real32_T rtNaNF{std::numeric_limits::quiet_NaN()}; real32_T rtInfF{std::numeric_limits::infinity()}; real32_T rtMinusInfF{-std::numeric_limits::infinity()}; // // File trailer for rt_nonfinite.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/rt_nonfinite.h b/dereverbrate/dereveb_c/rt_nonfinite.h index 2549c97..0392c04 100644 --- a/dereverbrate/dereveb_c/rt_nonfinite.h +++ b/dereverbrate/dereveb_c/rt_nonfinite.h @@ -1,33 +1,33 @@ // // File: rt_nonfinite.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef RT_NONFINITE_H #define RT_NONFINITE_H // Include Files #include "rtwtypes.h" #ifdef __cplusplus extern "C" { #endif extern real_T rtInf; extern real_T rtMinusInf; extern real_T rtNaN; extern real32_T rtInfF; extern real32_T rtMinusInfF; extern real32_T rtNaNF; #ifdef __cplusplus } #endif #endif // // File trailer for rt_nonfinite.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/rtwtypes.h b/dereverbrate/dereveb_c/rtwtypes.h index c42628e..523ca9d 100644 --- a/dereverbrate/dereveb_c/rtwtypes.h +++ b/dereverbrate/dereveb_c/rtwtypes.h @@ -1,45 +1,45 @@ // // File: rtwtypes.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef RTWTYPES_H #define RTWTYPES_H /*=======================================================================* * Fixed width word size data types: * * int64_T - signed 64 bit integers * * uint64_T - unsigned 64 bit integers * *=======================================================================*/ #if defined(__APPLE__) #ifndef INT64_T #define INT64_T long #define FMT64 "l" #if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) #define INT_TYPE_64_IS_LONG #endif #endif #endif #if defined(__APPLE__) #ifndef UINT64_T #define UINT64_T unsigned long #define FMT64 "l" #if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) #define INT_TYPE_64_IS_LONG #endif #endif #endif // Include Files #include "tmwtypes.h" #endif // // File trailer for rtwtypes.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/spectrogram.cpp b/dereverbrate/dereveb_c/spectrogram.cpp index 388e90b..5e61750 100644 --- a/dereverbrate/dereveb_c/spectrogram.cpp +++ b/dereverbrate/dereveb_c/spectrogram.cpp @@ -1,270 +1,270 @@ // // File: spectrogram.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "spectrogram.h" #include "computeDFT.h" #include "hamming.h" #include "pspectrogram.h" #include "rt_nonfinite.h" #include "welchparse.h" #include "coder_array.h" #include #include // Type Definitions struct cell_wrap_6 { double f1[220500]; }; struct cell_wrap_22 { double f1[264600]; }; // Function Definitions // // Arguments : const double x[264600] // const ::coder::array &varargin_1 // double varargin_2 // ::coder::array &varargout_1 // Return Type : void // namespace coder { void b_spectrogram(const double x[264600], const ::coder::array &varargin_1, double varargin_2, ::coder::array &varargout_1) { static cell_wrap_22 r; array r1; array xin; array win; double b_expl_temp; double expl_temp; double hopSize; double options_nfft; int acoef; int bcoef; int i; int i1; int iCol; char options_range[8]; boolean_T c_expl_temp; boolean_T d_expl_temp; boolean_T e_expl_temp; boolean_T f_expl_temp; boolean_T g_expl_temp; boolean_T h_expl_temp; std::copy(&x[0], &x[264600], &r.f1[0]); if (varargin_1.size(0) == 0) { hopSize = std::trunc((7.0 * varargin_2 + 264600.0) / 8.0); hamming(hopSize, win); } else if (varargin_1.size(0) > 1) { hopSize = varargin_1.size(0); win.set_size(varargin_1.size(0)); bcoef = varargin_1.size(0); for (i = 0; i < bcoef; i++) { win[i] = varargin_1[i]; } } else { hamming(varargin_1[0], win); hopSize = win.size(0); } signal::internal::spectral::welch_options( hopSize, &options_nfft, &expl_temp, &b_expl_temp, &c_expl_temp, &d_expl_temp, &e_expl_temp, &f_expl_temp, &g_expl_temp, &h_expl_temp, options_range); hopSize = static_cast(win.size(0)) - varargin_2; i = static_cast(std::trunc((264600.0 - varargin_2) / hopSize)); xin.set_size(win.size(0), i); bcoef = win.size(0) * static_cast(std::trunc((264600.0 - varargin_2) / hopSize)); for (i1 = 0; i1 < bcoef; i1++) { xin[i1] = 0.0; } for (iCol = 0; iCol < i; iCol++) { expl_temp = hopSize * ((static_cast(iCol) + 1.0) - 1.0); b_expl_temp = static_cast(win.size(0)) + expl_temp; if (expl_temp + 1.0 > b_expl_temp) { i1 = 0; acoef = 0; } else { i1 = static_cast(expl_temp + 1.0) - 1; acoef = static_cast(b_expl_temp); } bcoef = acoef - i1; for (acoef = 0; acoef < bcoef; acoef++) { xin[acoef + xin.size(0) * iCol] = r.f1[i1 + acoef]; } } bcoef = xin.size(0); iCol = win.size(0); if (bcoef <= iCol) { iCol = bcoef; } if (xin.size(0) == 1) { iCol = win.size(0); } else if (win.size(0) == 1) { iCol = xin.size(0); } else if (win.size(0) == xin.size(0)) { iCol = win.size(0); } r1.set_size(iCol, xin.size(1)); bcoef = xin.size(0); iCol = win.size(0); if (bcoef <= iCol) { iCol = bcoef; } if (xin.size(0) == 1) { iCol = win.size(0); } else if (win.size(0) == 1) { iCol = xin.size(0); } else if (win.size(0) == xin.size(0)) { iCol = win.size(0); } if ((iCol != 0) && (xin.size(1) != 0)) { bcoef = (xin.size(1) != 1); i = xin.size(1) - 1; for (int k{0}; k <= i; k++) { int b_bcoef; iCol = bcoef * k; acoef = (win.size(0) != 1); b_bcoef = (xin.size(0) != 1); i1 = r1.size(0) - 1; for (int b_k{0}; b_k <= i1; b_k++) { r1[b_k + r1.size(0) * k] = win[acoef * b_k] * xin[b_bcoef * b_k + xin.size(0) * iCol]; } } } computeDFT(r1, options_nfft, varargout_1, win); formatSpectrogram(varargout_1, win, options_nfft, options_range); } // // Arguments : const double x[220500] // const ::coder::array &varargin_1 // double varargin_2 // ::coder::array &varargout_1 // Return Type : void // void spectrogram(const double x[220500], const ::coder::array &varargin_1, double varargin_2, ::coder::array &varargout_1) { static cell_wrap_6 r; array r1; array xin; array win; double b_expl_temp; double expl_temp; double hopSize; double options_nfft; int acoef; int bcoef; int i; int i1; int iCol; char options_range[8]; boolean_T c_expl_temp; boolean_T d_expl_temp; boolean_T e_expl_temp; boolean_T f_expl_temp; boolean_T g_expl_temp; boolean_T h_expl_temp; std::copy(&x[0], &x[220500], &r.f1[0]); if (varargin_1.size(0) == 0) { hopSize = std::trunc((7.0 * varargin_2 + 220500.0) / 8.0); hamming(hopSize, win); } else if (varargin_1.size(0) > 1) { hopSize = varargin_1.size(0); win.set_size(varargin_1.size(0)); bcoef = varargin_1.size(0); for (i = 0; i < bcoef; i++) { win[i] = varargin_1[i]; } } else { hamming(varargin_1[0], win); hopSize = win.size(0); } signal::internal::spectral::welch_options( hopSize, &options_nfft, &expl_temp, &b_expl_temp, &c_expl_temp, &d_expl_temp, &e_expl_temp, &f_expl_temp, &g_expl_temp, &h_expl_temp, options_range); hopSize = static_cast(win.size(0)) - varargin_2; i = static_cast(std::trunc((220500.0 - varargin_2) / hopSize)); xin.set_size(win.size(0), i); bcoef = win.size(0) * static_cast(std::trunc((220500.0 - varargin_2) / hopSize)); for (i1 = 0; i1 < bcoef; i1++) { xin[i1] = 0.0; } for (iCol = 0; iCol < i; iCol++) { expl_temp = hopSize * ((static_cast(iCol) + 1.0) - 1.0); b_expl_temp = static_cast(win.size(0)) + expl_temp; if (expl_temp + 1.0 > b_expl_temp) { i1 = 0; acoef = 0; } else { i1 = static_cast(expl_temp + 1.0) - 1; acoef = static_cast(b_expl_temp); } bcoef = acoef - i1; for (acoef = 0; acoef < bcoef; acoef++) { xin[acoef + xin.size(0) * iCol] = r.f1[i1 + acoef]; } } bcoef = xin.size(0); iCol = win.size(0); if (bcoef <= iCol) { iCol = bcoef; } if (xin.size(0) == 1) { iCol = win.size(0); } else if (win.size(0) == 1) { iCol = xin.size(0); } else if (win.size(0) == xin.size(0)) { iCol = win.size(0); } r1.set_size(iCol, xin.size(1)); bcoef = xin.size(0); iCol = win.size(0); if (bcoef <= iCol) { iCol = bcoef; } if (xin.size(0) == 1) { iCol = win.size(0); } else if (win.size(0) == 1) { iCol = xin.size(0); } else if (win.size(0) == xin.size(0)) { iCol = win.size(0); } if ((iCol != 0) && (xin.size(1) != 0)) { bcoef = (xin.size(1) != 1); i = xin.size(1) - 1; for (int k{0}; k <= i; k++) { int b_bcoef; iCol = bcoef * k; acoef = (win.size(0) != 1); b_bcoef = (xin.size(0) != 1); i1 = r1.size(0) - 1; for (int b_k{0}; b_k <= i1; b_k++) { r1[b_k + r1.size(0) * k] = win[acoef * b_k] * xin[b_bcoef * b_k + xin.size(0) * iCol]; } } } computeDFT(r1, options_nfft, varargout_1, win); formatSpectrogram(varargout_1, win, options_nfft, options_range); } } // namespace coder // // File trailer for spectrogram.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/spectrogram.h b/dereverbrate/dereveb_c/spectrogram.h index 83404a5..b483cb0 100644 --- a/dereverbrate/dereveb_c/spectrogram.h +++ b/dereverbrate/dereveb_c/spectrogram.h @@ -1,35 +1,35 @@ // // File: spectrogram.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef SPECTROGRAM_H #define SPECTROGRAM_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { void b_spectrogram(const double x[264600], const ::coder::array &varargin_1, double varargin_2, ::coder::array &varargout_1); void spectrogram(const double x[220500], const ::coder::array &varargin_1, double varargin_2, ::coder::array &varargout_1); } // namespace coder #endif // // File trailer for spectrogram.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/sum.cpp b/dereverbrate/dereveb_c/sum.cpp index bf07a8d..2a37a03 100644 --- a/dereverbrate/dereveb_c/sum.cpp +++ b/dereverbrate/dereveb_c/sum.cpp @@ -1,48 +1,99 @@ // // File: sum.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "sum.h" #include "rt_nonfinite.h" #include "coder_array.h" // Function Definitions // // Arguments : const ::coder::array &x // ::coder::array &y // Return Type : void // namespace coder { void sum(const ::coder::array &x, ::coder::array &y) { if (x.size(0) == 0) { y.set_size(0); } else { int vstride; int xj; vstride = x.size(0); y.set_size(x.size(0)); for (xj = 0; xj < vstride; xj++) { y[xj] = x[xj]; } for (int k{0}; k < 399; k++) { int xoffset; xoffset = (k + 1) * vstride; for (xj = 0; xj < vstride; xj++) { y[xj] = y[xj] + x[xoffset + xj]; } } } } +// +// Arguments : const ::coder::array &x +// Return Type : double +// +double sum(const ::coder::array &x) +{ + double y; + if (x.size(0) == 0) { + y = 0.0; + } else { + int firstBlockLength; + int k; + int lastBlockLength; + int nblocks; + if (x.size(0) <= 1024) { + firstBlockLength = x.size(0); + lastBlockLength = 0; + nblocks = 1; + } else { + firstBlockLength = 1024; + nblocks = x.size(0) / 1024; + lastBlockLength = x.size(0) - (nblocks << 10); + if (lastBlockLength > 0) { + nblocks++; + } else { + lastBlockLength = 1024; + } + } + y = x[0]; + for (k = 2; k <= firstBlockLength; k++) { + y += x[k - 1]; + } + for (int ib{2}; ib <= nblocks; ib++) { + double bsum; + int hi; + firstBlockLength = (ib - 1) << 10; + bsum = x[firstBlockLength]; + if (ib == nblocks) { + hi = lastBlockLength; + } else { + hi = 1024; + } + for (k = 2; k <= hi; k++) { + bsum += x[(firstBlockLength + k) - 1]; + } + y += bsum; + } + } + return y; +} + } // namespace coder // // File trailer for sum.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/sum.h b/dereverbrate/dereveb_c/sum.h index c54aad0..2173cdd 100644 --- a/dereverbrate/dereveb_c/sum.h +++ b/dereverbrate/dereveb_c/sum.h @@ -1,29 +1,31 @@ // // File: sum.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef SUM_H #define SUM_H // Include Files #include "rtwtypes.h" #include "coder_array.h" #include "omp.h" #include #include // Function Declarations namespace coder { void sum(const ::coder::array &x, ::coder::array &y); -} +double sum(const ::coder::array &x); + +} // namespace coder #endif // // File trailer for sum.h // // [EOF] // diff --git a/dereverbrate/dereveb_c/unsafeSxfun.cpp b/dereverbrate/dereveb_c/unsafeSxfun.cpp new file mode 100644 index 0000000..b0cc1a5 --- /dev/null +++ b/dereverbrate/dereveb_c/unsafeSxfun.cpp @@ -0,0 +1,87 @@ +// +// File: unsafeSxfun.cpp +// +// MATLAB Coder version : 5.3 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 +// + +// Include Files +#include "unsafeSxfun.h" +#include "rt_nonfinite.h" +#include "coder_array.h" +#include + +// Function Definitions +// +// Arguments : coder::array &r +// const coder::array &inputFramePower +// const coder::array &newEstimates +// Return Type : void +// +void binary_expand_op(coder::array &r, + const coder::array &inputFramePower, + const coder::array &newEstimates) +{ + coder::array b_inputFramePower; + int i; + int loop_ub; + int stride_0_0; + int stride_1_0; + int stride_2_0; + int stride_3_0; + if (r.size(0) == 1) { + i = newEstimates.size(0); + } else { + i = r.size(0); + } + if (i == 1) { + if (r.size(0) == 1) { + i = inputFramePower.size(0); + } else { + i = r.size(0); + } + } else if (r.size(0) == 1) { + i = newEstimates.size(0); + } else { + i = r.size(0); + } + b_inputFramePower.set_size(i); + stride_0_0 = (inputFramePower.size(0) != 1); + stride_1_0 = (r.size(0) != 1); + stride_2_0 = (newEstimates.size(0) != 1); + stride_3_0 = (r.size(0) != 1); + if (r.size(0) == 1) { + i = newEstimates.size(0); + } else { + i = r.size(0); + } + if (i == 1) { + if (r.size(0) == 1) { + loop_ub = inputFramePower.size(0); + } else { + loop_ub = r.size(0); + } + } else if (r.size(0) == 1) { + loop_ub = newEstimates.size(0); + } else { + loop_ub = r.size(0); + } + for (i = 0; i < loop_ub; i++) { + b_inputFramePower[i] = + (inputFramePower[i * stride_0_0] + r[i * stride_1_0]) / + ((newEstimates[i * stride_2_0] + r[i * stride_3_0]) + 1.0E-8); + } + r.set_size(b_inputFramePower.size(0)); + loop_ub = b_inputFramePower.size(0); + for (i = 0; i < loop_ub; i++) { + double varargin_2; + varargin_2 = b_inputFramePower[i]; + r[i] = std::fmin(1.0, varargin_2); + } +} + +// +// File trailer for unsafeSxfun.cpp +// +// [EOF] +// diff --git a/dereverbrate/dereveb_c/unsafeSxfun.h b/dereverbrate/dereveb_c/unsafeSxfun.h new file mode 100644 index 0000000..f16ea61 --- /dev/null +++ b/dereverbrate/dereveb_c/unsafeSxfun.h @@ -0,0 +1,28 @@ +// +// File: unsafeSxfun.h +// +// MATLAB Coder version : 5.3 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 +// + +#ifndef UNSAFESXFUN_H +#define UNSAFESXFUN_H + +// Include Files +#include "rtwtypes.h" +#include "coder_array.h" +#include "omp.h" +#include +#include + +// Function Declarations +void binary_expand_op(coder::array &r, + const coder::array &inputFramePower, + const coder::array &newEstimates); + +#endif +// +// File trailer for unsafeSxfun.h +// +// [EOF] +// diff --git a/dereverbrate/dereveb_c/welchparse.cpp b/dereverbrate/dereveb_c/welchparse.cpp index 4b93fd7..48b890b 100644 --- a/dereverbrate/dereveb_c/welchparse.cpp +++ b/dereverbrate/dereveb_c/welchparse.cpp @@ -1,127 +1,127 @@ // // File: welchparse.cpp // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // // Include Files #include "welchparse.h" #include "rt_nonfinite.h" #include #include // Function Declarations static double rt_powd_snf(double u0, double u1); // Function Definitions // // Arguments : double u0 // double u1 // Return Type : double // static double rt_powd_snf(double u0, double u1) { double y; if (std::isnan(u0) || std::isnan(u1)) { y = rtNaN; } else { double d; double d1; d = std::abs(u0); d1 = std::abs(u1); if (std::isinf(u1)) { if (d == 1.0) { y = 1.0; } else if (d > 1.0) { if (u1 > 0.0) { y = rtInf; } else { y = 0.0; } } else if (u1 > 0.0) { y = 0.0; } else { y = rtInf; } } else if (d1 == 0.0) { y = 1.0; } else if (d1 == 1.0) { if (u1 > 0.0) { y = u0; } else { y = 1.0 / u0; } } else if (u1 == 2.0) { y = u0 * u0; } else if ((u1 == 0.5) && (u0 >= 0.0)) { y = std::sqrt(u0); } else if ((u0 < 0.0) && (u1 > std::floor(u1))) { y = rtNaN; } else { y = std::pow(u0, u1); } } return y; } // // Arguments : double N // double *options1_nfft // double *options1_Fs // double *options1_conflevel // boolean_T *options1_average // boolean_T *options1_maxhold // boolean_T *options1_minhold // boolean_T *options1_MIMO // boolean_T *options1_isNFFTSingle // boolean_T *options1_centerdc // char options1_range[8] // Return Type : void // namespace coder { namespace signal { namespace internal { namespace spectral { void welch_options(double N, double *options1_nfft, double *options1_Fs, double *options1_conflevel, boolean_T *options1_average, boolean_T *options1_maxhold, boolean_T *options1_minhold, boolean_T *options1_MIMO, boolean_T *options1_isNFFTSingle, boolean_T *options1_centerdc, char options1_range[8]) { static const char cv[8]{'o', 'n', 'e', 's', 'i', 'd', 'e', 'd'}; double absn; int eint; for (int i{0}; i < 8; i++) { options1_range[i] = cv[i]; } absn = std::abs(N); if ((!std::isinf(absn)) && (!std::isnan(absn))) { double f; f = frexp(absn, &eint); absn = eint; if (f == 0.5) { absn = static_cast(eint) - 1.0; } } *options1_nfft = std::fmax(256.0, rt_powd_snf(2.0, absn)); *options1_Fs = rtNaN; *options1_average = true; *options1_maxhold = false; *options1_minhold = false; *options1_MIMO = false; *options1_conflevel = rtNaN; *options1_isNFFTSingle = false; *options1_centerdc = false; } } // namespace spectral } // namespace internal } // namespace signal } // namespace coder // // File trailer for welchparse.cpp // // [EOF] // diff --git a/dereverbrate/dereveb_c/welchparse.h b/dereverbrate/dereveb_c/welchparse.h index 97d4421..07d1a8f 100644 --- a/dereverbrate/dereveb_c/welchparse.h +++ b/dereverbrate/dereveb_c/welchparse.h @@ -1,38 +1,38 @@ // // File: welchparse.h // // MATLAB Coder version : 5.3 -// C/C++ source code generated on : 22-Mar-2023 20:50:16 +// C/C++ source code generated on : 29-Mar-2023 11:20:55 // #ifndef WELCHPARSE_H #define WELCHPARSE_H // Include Files #include "rtwtypes.h" #include "omp.h" #include #include // Function Declarations namespace coder { namespace signal { namespace internal { namespace spectral { void welch_options(double N, double *options1_nfft, double *options1_Fs, double *options1_conflevel, boolean_T *options1_average, boolean_T *options1_maxhold, boolean_T *options1_minhold, boolean_T *options1_MIMO, boolean_T *options1_isNFFTSingle, boolean_T *options1_centerdc, char options1_range[8]); } } // namespace internal } // namespace signal } // namespace coder #endif // // File trailer for welchparse.h // // [EOF] //