static void rhythm_model(t_rhythm *x, t_floatarg f) { if(f == 1) { x->x_model = 1; /* Toiviainen model */ rhythm_reset(x); post("rhythm: using \"Toiviainen\" adaptation model"); } else { x->x_model = 0; /* Large and Kolen model */ rhythm_reset(x); post("rhythm: using \"Large and Kolen\" adaptation model"); } }
/** * Reset * @param[in] opna The instance * @param[in] cCaps */ void opna_reset(POPNA opna, REG8 cCaps) { memset(&opna->s, 0, sizeof(opna->s)); opna->s.adpcmmask = ~(0x1c); opna->s.cCaps = cCaps; opna->s.irq = 0xff; opna->s.reg[0x07] = 0xbf; opna->s.reg[0x0e] = 0xff; opna->s.reg[0x0f] = 0xff; opna->s.reg[0xff] = (cCaps & OPNA_HAS_RHYTHM) ? 0x01 : 0x00; for (UINT i = 0; i < 2; i++) { memset(opna->s.reg + (i * 0x100) + 0x30, 0xff, 0x60); memset(opna->s.reg + (i * 0x100) + 0xb4, 0xc0, 0x04); } for (UINT i = 0; i < 7; i++) { opna->s.keyreg[i] = i & 7; } opngen_reset(&opna->opngen); psggen_reset(&opna->psg); rhythm_reset(&opna->rhythm); adpcm_reset(&opna->adpcm); if (cCaps == 0) { CExternalOpna* pExt = reinterpret_cast<CExternalOpna*>(opna->userdata); if (pExt) { CExternalChipManager::GetInstance()->Release(pExt); opna->userdata = reinterpret_cast<INTPTR>(NULL); } } }
static void *rhythm_new(t_floatarg f) { t_rhythm *x = (t_rhythm *)pd_new(rhythm_class); inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("ft1")); x->x_out_bpm = outlet_new(&x->x_ob, gensym("float")); x->x_out_period = outlet_new(&x->x_ob, gensym("float")); x->x_out_pulse = outlet_new(&x->x_ob, gensym("bang")); x->x_tick = clock_new(x, (t_method)rhythm_tick); rhythm_reset(x); if(f == 1) { x->x_model = 1; /* Toiviainen model */ post("rhythm: using \"Toiviainen\" adaptation model"); } else { x->x_model = 0; /* Large and Kolen model */ post("rhythm: using \"Large and Kolen\" adaptation model"); } return (void *)x; }