@@ -4,12 +4,9 @@ Channel::Channel(const size_t index, const double samplerate, const std::span<co
44{
55 const size_t dftsize = frequencies.size ();
66
7- // https://newt.phys.unsw.edu.au/jw/notes.html
8- const double hz = std::pow (2 , (double (index) - 69 ) / 12 ) * concertpitch;
9-
107 config.dftsize = dftsize;
118
12- config.freq = hz ;
9+ config.freq = midi_to_hertz (index, concertpitch) ;
1310 config.gain = 0 ;
1411
1512 config.samplerate = samplerate;
@@ -21,7 +18,7 @@ Channel::Channel(const size_t index, const double samplerate, const std::span<co
2118
2219 for (size_t i = 0 ; i < dftsize; ++i)
2320 {
24- config.chnfreqs [i] = hz * frequencies[i];
21+ config.chnfreqs [i] = config. freq * frequencies[i];
2522 }
2623}
2724
@@ -57,7 +54,7 @@ double Channel::synthesize(const std::span<std::complex<double>> dft,
5754{
5855 assert_true (dft.size () == config.dftsize , " Invalid DFT size!" );
5956
60- const double freq2phase = ( 2 * std::numbers::pi) / config.samplerate ;
57+ const double hz2rad = hertz_to_radian ( config.samplerate ) ;
6158
6259 const double gain = config.gain ;
6360 const auto & chnfreqs = config.chnfreqs ;
@@ -70,7 +67,7 @@ double Channel::synthesize(const std::span<std::complex<double>> dft,
7067 {
7168 const double newfreq = chnfreqs[i];
7269
73- phase[i] += newfreq * freq2phase ;
70+ phase[i] += newfreq * hz2rad ;
7471
7572 if (newfreq <= dftfreqs.front ())
7673 {
@@ -94,7 +91,7 @@ double Channel::synthesize(const std::span<std::complex<double>> dft,
9491 {
9592 const double newfreq = chnfreqs[i] * pvcfreqs[i];
9693
97- phase[i] += newfreq * freq2phase ;
94+ phase[i] += newfreq * hz2rad ;
9895
9996 if (newfreq <= dftfreqs.front ())
10097 {
0 commit comments