complex_t BiquadBase::response (double normalizedFrequency) const { const double a0 = getA0 (); const double a1 = getA1 (); const double a2 = getA2 (); const double b0 = getB0 (); const double b1 = getB1 (); const double b2 = getB2 (); const double w = 2 * doublePi * normalizedFrequency; const complex_t czn1 = std::polar (1., -w); const complex_t czn2 = std::polar (1., -2 * w); complex_t ch (1); complex_t cbot (1); complex_t ct (b0/a0); complex_t cb (1); ct = addmul (ct, b1/a0, czn1); ct = addmul (ct, b2/a0, czn2); cb = addmul (cb, a1/a0, czn1); cb = addmul (cb, a2/a0, czn2); ch *= ct; cbot *= cb; return ch / cbot; }
void send(uint32_t data) { if (!G_midiStatus) return; msg[0] = getB1(data); msg[1] = getB2(data); msg[2] = getB3(data); midiOut->sendMessage(&msg); printf("[KM] send msg=0x%X\n", data); }
float Cylinder::nhs(const Cylinder &c) const { int hamming = 0; const float P = 30; if (abs(dFi(getrT(),c.getrT())) > 0.785398163397 || dss(c.getX(), c.getY()) > DELTAXY*DELTAXY) return 0; for(unsigned int i = 0; i < NUMCELLS; ++i) if (getB1(i) != c.getB1(i)) hamming++; return pow(1.0-((float)hamming)/NUMCELLS, P); }
float Cylinder::similarity(const Cylinder & c) const { unsigned int count = 0; float norma_b = 0, normb_a = 0, norm_diff = 0; float ca_b, cb_a; if (abs(dFi(getrT(),c.getrT())) > DELTAZETA) return 0; if (bit == false) { for (unsigned int i=0; i<NUMCELLS; i++) { ca_b = cmVector[i]; cb_a = c.getCM(i); if (ca_b>=0 && cb_a>=0) { count++; norma_b += ca_b*ca_b; normb_a += cb_a*cb_a; norm_diff += ca_b*cb_a; } } //Check if two cylinders are matchable if(count >= MINCELLS) { norm_diff = sqrt(norma_b + normb_a - 2.0*norm_diff); return 1.0 - (norm_diff/(sqrt(norma_b)+sqrt(normb_a))); } else return 0; } else { int counta_b = 0, countb_a = 0, count_diff = 0; for (unsigned int i=0; i<cmBit1.size(); ++i) if (getB2(i) && c.getB2(i)) { count++; if (getB1(i)) { counta_b++; if(!c.getB1(i)) count_diff++; } if (c.getB1(i)) { countb_a++; if(!getB1(i)) count_diff++; } } //Check if two cylinders are matchable if (count >= MINCELLS) return (1 - (sqrt(count_diff)/(sqrt(counta_b)+sqrt(countb_a)))); else return 0; } }