/* Get pitchbend from base note and period */ int period_to_bend(double p, int n, int limit, int gliss, int type) { int b; double d; if (!n) return 0; if (limit) { /* Force Amiga limits */ if (p > AMIGA_LIMIT_LOWER) p = AMIGA_LIMIT_LOWER; if (p < AMIGA_LIMIT_UPPER) p = AMIGA_LIMIT_UPPER; } if (type) { /* b = (100 * (((120 - n) << 4) - p)) >> 4 + f * 100 / 128; */ b = 100 * (8 * (((120 - n) << 4) - p)) / 128; /* Linear */ return gliss ? b / 100 * 100 : b; } if (p < MIN_PERIOD_A) p = MIN_PERIOD_A; d = note_to_period(n, 0, 0); b = 100.0 * ((1536.0 * log(d / p) / M_LN2)) / 128; return gliss ? b / 100 * 100 : b; /* Amiga */ }
static void check_arpeggio_okt5(xmp_context opaque, int note, int val, int spd) { struct xmp_frame_info info; int i; int a2 = val & 0x0f; int arp[20]; char error[60]; for (i = 0; i < 12; ) { arp[i++] = note_to_period(note + a2); arp[i++] = note_to_period(note + a2); arp[i++] = note_to_period(note); } for (i = 0; i < spd; i++) { xmp_play_frame(opaque); xmp_get_frame_info(opaque, &info); snprintf(error, 60, "Oktalyzer arp5 0x%02x error", val); fail_unless(PERIOD == arp[i], error); } }
static void do_toneporta(struct module_data *m, struct channel_data *xc, int note) { struct xmp_instrument *instrument = &m->mod.xxi[xc->ins]; int mapped = instrument->map[xc->key].ins; struct xmp_subinstrument *sub = &instrument->sub[mapped]; if (note >= 1 && note <= 0x80 && (uint32)xc->ins < m->mod.ins) { note--; xc->porta.target = note_to_period(note + sub->xpo + instrument->map[xc->key].xpo, xc->finetune, HAS_QUIRK(QUIRK_LINEAR), xc->per_adj); } xc->porta.dir = xc->period < xc->porta.target ? 1 : -1; }
static void set_effect_defaults(struct context_data *ctx, int note, struct xmp_subinstrument *sub, struct channel_data *xc, int is_toneporta) { struct module_data *m = &ctx->m; if (sub != NULL && note >= 0) { xc->pan.val = sub->pan; xc->finetune = sub->fin; xc->gvl = sub->gvl; if (sub->ifc & 0x80) { xc->filter.cutoff = (sub->ifc - 0x80) * 2; } else { xc->filter.cutoff = 0xff; } if (sub->ifr & 0x80) { xc->filter.resonance = (sub->ifr - 0x80) * 2; } else { xc->filter.resonance = 0; } set_lfo_depth(&xc->insvib.lfo, sub->vde); set_lfo_rate(&xc->insvib.lfo, sub->vra >> 2); set_lfo_waveform(&xc->insvib.lfo, sub->vwf); xc->insvib.sweep = sub->vsw; set_lfo_phase(&xc->vibrato, 0); set_lfo_phase(&xc->tremolo, 0); xc->porta.target = note_to_period(note, xc->finetune, HAS_QUIRK(QUIRK_LINEAR), xc->per_adj); if (xc->period < 1 || !is_toneporta) { xc->period = xc->porta.target; } }