src/common/operator/Dct.js
function getDctWeights(order, N, type = 'htk') {
  const weights = new Float32Array(N * order);
  const piOverN = PI / N;
  const scale0 = 1 / sqrt(2);
  const scale = sqrt(2 / N);

  for (let k = 0; k < order; k++) {
    const s = (k === 0) ? (scale0 * scale) : scale;
    // const s = scale; // rta doesn't apply k=0 scaling

    for (let n = 0; n < N; n++)
      weights[k * N + n] = s * cos(k * (n + 0.5) * piOverN);
  }

  return weights;
}
function getDctWeights(order, N, type = 'htk') {
  const weights = new Float32Array(N * order);
  const piOverN = PI / N;
  const scale0 = 1 / sqrt(2);
  const scale = sqrt(2 / N);

  for (let k = 0; k < order; k++) {
    const s = (k === 0) ? (scale0 * scale) : scale;
    // const s = scale; // rta doesn't apply k=0 scaling

    for (let n = 0; n < N; n++)
      weights[k * N + n] = s * cos(k * (n + 0.5) * piOverN);
  }

  return weights;
}
function getDctWeights ( order , N , type = 'htk' ) { const weights = new Float32Array ( N * order ) ; const piOverN = PI / N ; const scale0 = 1 / sqrt ( 2 ) ; const scale = sqrt ( 2 / N ) ; for ( let k = 0 ; k < order ; k ++ ) { const s = ( k === 0 ) ? ( scale0 * scale ) : scale ; // const s = scale; // rta doesn't apply k=0 scaling for ( let n = 0 ; n < N ; n ++ ) weights [ k * N + n ] = s * cos ( k * ( n + 0.5 ) * piOverN ) ; } return weights ; }
Dct Type 2 - orthogonal matrix scaling
Dct Type 2 - orthogonal matrix scaling