Open mhamilt opened 3 years ago
After that, try and run it in a basic Command Line App
// dynamics filter loop
for (int n = 0; n < (N + 1); n++)
{
x0 = (1 - dynParam) * v[n] + (dynParam * x1);
y[n] = x0;
x1 = x0;
}
int yp1 = 0; // initializing previous output of allpas filter
int yp0; // initializing current output of allpass filter
// karplus-strong algorithm loop
for (int n = (N + 1); n < wtSize; n++)
{
yp0 = C * (y[(n - N)] - yp1) + y[(n - N - 1)];
y[n] = (rho * 0.5f) * (yp0 + yp1);
yp1 = yp0;
}
Your rho
calculation in MATLAB is
rho = exp(-1/(f0*tau))/(abs(cos(pi*f0/Fs)));
but you in your cpp class you use
Couple of problems since the last pull request
Should be
#include "PluckedNote.h"
main problem seems to stem from your variable type choices.
In general, if something is an index, make it an int
, don't cast a variable to an int
. If you want an index from a float, make a separate int
variable first then use it.
These should be float
type
When it comes to PBMMI based algorithms, if in doubt just print out your parameters
std::cout << "rho:\t" << rho << '\n';
std::cout << "wtSize:\t" << wtSize << '\n';
std::cout << "Nexact:\t" << Nexact << '\n';
std::cout << "N:\t\t" << N << '\n';
std::cout << "P:\t\t" << P << '\n';
std::cout << "C:\t\t" << C << '\n';
std::cout << "yp1:\t" << yp1 << '\n';
std::cout << "yp0:\t" << yp0 << '\n';
std::cout << "x1:\t\t" << x1 << '\n';
std::cout << "x0:\t\t" << x0 << '\n';
Should be fixed by https://github.com/Cameron1470/AudioProgrammingDrone/pull/3
Pretty fundamental issue, so let's start here.
https://github.com/Cameron1470/AudioProgrammingDrone/blob/55b52cde13aaadf4e67ba006504180ef3bf32d10/Source/PluckedNote.cpp#L48-L70
The wave table setup looks okay, there are perhaps more elegant solutions.
I'd recommend maybe changing this to just a standard array to start. You know the size
wtSize
, so instead ofhttps://github.com/Cameron1470/AudioProgrammingDrone/blob/55b52cde13aaadf4e67ba006504180ef3bf32d10/Source/PluckedNote.h#L53
use
instead of
https://github.com/Cameron1470/AudioProgrammingDrone/blob/55b52cde13aaadf4e67ba006504180ef3bf32d10/Source/PluckedNote.cpp#L48
or for a little more safety if run
generateNote()
more than once.for the process
https://github.com/Cameron1470/AudioProgrammingDrone/blob/55b52cde13aaadf4e67ba006504180ef3bf32d10/Source/PluckedNote.cpp#L75-L86
It should probably be something like
Instead of
https://github.com/Cameron1470/AudioProgrammingDrone/blob/55b52cde13aaadf4e67ba006504180ef3bf32d10/Source/PluckedNote.h#L51
and