Update DUMB to revision 15b780d08f2ee6f50a9843dc7479349f4deee5a7

- Fixed most effects applying to background voices



SVN r4095 (trunk)
This commit is contained in:
Randy Heit 2013-02-08 00:43:08 +00:00
parent 25542b11bd
commit e1ec8df32d

View file

@ -1032,6 +1032,15 @@ static void update_retrig(DUMB_IT_SIGRENDERER *sigrenderer, IT_CHANNEL *channel)
} }
static void update_smooth_effects_playing(IT_PLAYING *playing)
{
playing->vibrato_time += playing->vibrato_n *
(playing->vibrato_speed << 2);
playing->tremolo_time += playing->tremolo_speed << 2;
playing->panbrello_time += playing->panbrello_speed;
if (playing->panbrello_waveform == 3)
playing->panbrello_random = (rand() % 129) - 64;
}
static void update_smooth_effects(DUMB_IT_SIGRENDERER *sigrenderer) static void update_smooth_effects(DUMB_IT_SIGRENDERER *sigrenderer)
{ {
@ -1042,12 +1051,15 @@ static void update_smooth_effects(DUMB_IT_SIGRENDERER *sigrenderer)
IT_PLAYING *playing = channel->playing; IT_PLAYING *playing = channel->playing;
if (playing) { if (playing) {
playing->vibrato_time += playing->vibrato_n * update_smooth_effects_playing(playing);
(playing->vibrato_speed << 2); }
playing->tremolo_time += playing->tremolo_speed << 2; }
playing->panbrello_time += playing->panbrello_speed;
if (playing->panbrello_waveform == 3) for (i = 0; i < DUMB_IT_N_NNA_CHANNELS; i++) {
playing->panbrello_random = (rand() % 129) - 64; IT_PLAYING *playing = sigrenderer->playing[i];
if (playing) {
update_smooth_effects_playing(playing);
} }
} }
} }
@ -1083,7 +1095,7 @@ static void update_invert_loop(IT_CHANNEL *channel, IT_SAMPLE *sample)
static void update_effects(DUMB_IT_SIGRENDERER *sigrenderer) static void update_effects(DUMB_IT_SIGRENDERER *sigrenderer)
{ {
int i; int i, j;
if (sigrenderer->globalvolslide) { if (sigrenderer->globalvolslide) {
sigrenderer->globalvolume += sigrenderer->globalvolslide; sigrenderer->globalvolume += sigrenderer->globalvolslide;
@ -1167,6 +1179,10 @@ static void update_effects(DUMB_IT_SIGRENDERER *sigrenderer)
} }
if (channel->playing) if (channel->playing)
channel->playing->channel_volume = channel->channelvolume; channel->playing->channel_volume = channel->channelvolume;
for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) {
if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel)
sigrenderer->playing[j]->channel_volume = channel->channelvolume;
}
} }
update_tremor(channel); update_tremor(channel);
@ -1177,80 +1193,127 @@ static void update_effects(DUMB_IT_SIGRENDERER *sigrenderer)
if (channel->inv_loop_speed) update_invert_loop(channel, playing ? playing->sample : NULL); if (channel->inv_loop_speed) update_invert_loop(channel, playing ? playing->sample : NULL);
if (playing) { for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) {
playing->slide += channel->portamento; if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel) break;
}
if (playing || j < DUMB_IT_N_NNA_CHANNELS) {
if (playing) playing->slide += channel->portamento;
for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) {
if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel)
sigrenderer->playing[j]->slide += channel->portamento;
}
if (channel->okt_toneslide) { if (channel->okt_toneslide) {
if (channel->okt_toneslide--) { if (channel->okt_toneslide--) {
playing->note += channel->toneslide; if (playing) {
if (playing->note >= 120) { playing->note += channel->toneslide;
if (channel->toneslide < 0) playing->note = 0; if (playing->note >= 120) {
else playing->note = 119; if (channel->toneslide < 0) playing->note = 0;
else playing->note = 119;
}
}
for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) {
if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel) {
IT_PLAYING *playing = sigrenderer->playing[j];
playing->note += channel->toneslide;
if (playing->note >= 120) {
if (channel->toneslide < 0) playing->note = 0;
else playing->note = 119;
}
}
} }
} }
} else if (channel->ptm_toneslide) { } else if (channel->ptm_toneslide) {
if (--channel->toneslide_tick == 0) { if (--channel->toneslide_tick == 0) {
channel->toneslide_tick = channel->ptm_toneslide; channel->toneslide_tick = channel->ptm_toneslide;
playing->note += channel->toneslide; if (playing) {
if (playing->note >= 120) { playing->note += channel->toneslide;
if (channel->toneslide < 0) playing->note = 0; if (playing->note >= 120) {
else playing->note = 119; if (channel->toneslide < 0) playing->note = 0;
} else playing->note = 119;
channel->note = channel->truenote = playing->note; }
if (channel->toneslide_retrig) { channel->note = channel->truenote = playing->note;
it_playing_reset_resamplers(playing, 0); if (channel->toneslide_retrig) {
it_playing_reset_resamplers(playing, 0);
#ifdef END_RAMPING #ifdef END_RAMPING
playing->declick_stage = 0; playing->declick_stage = 0;
playing->declick_volume = 1.f / 256.f; playing->declick_volume = 1.f / 256.f;
#endif #endif
}
}
for (j = 0; j < DUMB_IT_N_NNA_CHANNELS; j++) {
if (sigrenderer->playing[j] && sigrenderer->playing[j]->channel == channel) {
IT_PLAYING *playing = sigrenderer->playing[j];
playing->note += channel->toneslide;
if (playing->note >= 120) {
if (channel->toneslide < 0) playing->note = 0;
else playing->note = 119;
}
if (channel->toneslide_retrig) {
it_playing_reset_resamplers(playing, 0);
#ifdef END_RAMPING
playing->declick_stage = 0;
playing->declick_volume = 1.f / 256.f;
#endif
}
}
} }
} }
} }
if (sigrenderer->sigdata->flags & IT_LINEAR_SLIDES) { for (j = -1; j < DUMB_IT_N_NNA_CHANNELS; j++) {
if (channel->toneporta && channel->destnote < 120) { if (j >= 0) {
int currpitch = ((playing->note - 60) << 8) + playing->slide; playing = sigrenderer->playing[j];
int destpitch = (channel->destnote - 60) << 8; if (!playing || playing->channel != channel) continue;
if (currpitch > destpitch) {
currpitch -= channel->toneporta;
if (currpitch < destpitch) {
currpitch = destpitch;
channel->destnote = IT_NOTE_OFF;
}
} else if (currpitch < destpitch) {
currpitch += channel->toneporta;
if (currpitch > destpitch) {
currpitch = destpitch;
channel->destnote = IT_NOTE_OFF;
}
}
playing->slide = currpitch - ((playing->note - 60) << 8);
} }
} else { if (playing) {
if (channel->toneporta && channel->destnote < 120) { if (sigrenderer->sigdata->flags & IT_LINEAR_SLIDES) {
float amiga_multiplier = playing->sample->C5_speed * (1.0f / AMIGA_DIVISOR); if (channel->toneporta && channel->destnote < 120) {
int currpitch = ((playing->note - 60) << 8) + playing->slide;
float deltanote = (float)pow(DUMB_SEMITONE_BASE, 60 - playing->note); int destpitch = (channel->destnote - 60) << 8;
/* deltanote is 1.0 for C-5, 0.5 for C-6, etc. */ if (currpitch > destpitch) {
currpitch -= channel->toneporta;
float deltaslid = deltanote - playing->slide * amiga_multiplier; if (currpitch < destpitch) {
currpitch = destpitch;
float destdelta = (float)pow(DUMB_SEMITONE_BASE, 60 - channel->destnote); channel->destnote = IT_NOTE_OFF;
if (deltaslid < destdelta) { }
playing->slide -= channel->toneporta; } else if (currpitch < destpitch) {
deltaslid = deltanote - playing->slide * amiga_multiplier; currpitch += channel->toneporta;
if (deltaslid > destdelta) { if (currpitch > destpitch) {
playing->note = channel->destnote; currpitch = destpitch;
playing->slide = 0; channel->destnote = IT_NOTE_OFF;
channel->destnote = IT_NOTE_OFF; }
}
playing->slide = currpitch - ((playing->note - 60) << 8);
} }
} else { } else {
playing->slide += channel->toneporta; if (channel->toneporta && channel->destnote < 120) {
deltaslid = deltanote - playing->slide * amiga_multiplier; float amiga_multiplier = playing->sample->C5_speed * (1.0f / AMIGA_DIVISOR);
if (deltaslid < destdelta) {
playing->note = channel->destnote; float deltanote = (float)pow(DUMB_SEMITONE_BASE, 60 - playing->note);
playing->slide = 0; /* deltanote is 1.0 for C-5, 0.5 for C-6, etc. */
channel->destnote = IT_NOTE_OFF;
float deltaslid = deltanote - playing->slide * amiga_multiplier;
float destdelta = (float)pow(DUMB_SEMITONE_BASE, 60 - channel->destnote);
if (deltaslid < destdelta) {
playing->slide -= channel->toneporta;
deltaslid = deltanote - playing->slide * amiga_multiplier;
if (deltaslid > destdelta) {
playing->note = channel->destnote;
playing->slide = 0;
channel->destnote = IT_NOTE_OFF;
}
} else {
playing->slide += channel->toneporta;
deltaslid = deltanote - playing->slide * amiga_multiplier;
if (deltaslid < destdelta) {
playing->note = channel->destnote;
playing->slide = 0;
channel->destnote = IT_NOTE_OFF;
}
}
} }
} }
} }
@ -1985,6 +2048,8 @@ const char mod_convert_vibrato[] = {
static int process_effects(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *entry, int ignore_cxx) static int process_effects(DUMB_IT_SIGRENDERER *sigrenderer, IT_ENTRY *entry, int ignore_cxx)
{ {
DUMB_IT_SIGDATA *sigdata = sigrenderer->sigdata; DUMB_IT_SIGDATA *sigdata = sigrenderer->sigdata;
IT_PLAYING *playing;
int i;
IT_CHANNEL *channel = &sigrenderer->channel[(int)entry->channel]; IT_CHANNEL *channel = &sigrenderer->channel[(int)entry->channel];
@ -2041,10 +2106,17 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than
break; break;
case IT_VOLSLIDE_VIBRATO: case IT_VOLSLIDE_VIBRATO:
if (channel->playing) { for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) {
channel->playing->vibrato_speed = channel->lastHspeed; if (i < 0) playing = channel->playing;
channel->playing->vibrato_depth = channel->lastHdepth; else {
channel->playing->vibrato_n++; playing = sigrenderer->playing[i];
if (!playing || playing->channel != channel) continue;
}
if (playing) {
playing->vibrato_speed = channel->lastHspeed;
playing->vibrato_depth = channel->lastHdepth;
playing->vibrato_n++;
}
} }
/* Fall through and process volume slide. */ /* Fall through and process volume slide. */
case IT_VOLUME_SLIDE: case IT_VOLUME_SLIDE:
@ -2140,15 +2212,22 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than
v = channel->lastEF; v = channel->lastEF;
channel->lastEF = v; channel->lastEF = v;
} }
if (channel->playing) { for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) {
if ((v & 0xF0) == 0xF0) if (i < 0) playing = channel->playing;
channel->playing->slide -= (v & 15) << 4; else {
else if ((v & 0xF0) == 0xE0) playing = sigrenderer->playing[i];
channel->playing->slide -= (v & 15) << 2; if (!playing || playing->channel != channel) continue;
else if (sigdata->flags & IT_WAS_A_669) }
channel->portamento -= v << 3; if (playing) {
else if ((v & 0xF0) == 0xF0)
channel->portamento -= v << 4; playing->slide -= (v & 15) << 4;
else if ((v & 0xF0) == 0xE0)
playing->slide -= (v & 15) << 2;
else if (i < 0 && sigdata->flags & IT_WAS_A_669)
channel->portamento -= v << 3;
else if (i < 0)
channel->portamento -= v << 4;
}
} }
} }
break; break;
@ -2175,15 +2254,22 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than
v = channel->lastEF; v = channel->lastEF;
channel->lastEF = v; channel->lastEF = v;
} }
if (channel->playing) { for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) {
if ((v & 0xF0) == 0xF0) if (i < 0) playing = channel->playing;
channel->playing->slide += (v & 15) << 4; else {
else if ((v & 0xF0) == 0xE0) playing = sigrenderer->playing[i];
channel->playing->slide += (v & 15) << 2; if (!playing || playing->channel != channel) continue;
else if (sigdata->flags & IT_WAS_A_669) }
channel->portamento += v << 3; if (channel->playing) {
else if ((v & 0xF0) == 0xF0)
channel->portamento += v << 4; channel->playing->slide += (v & 15) << 4;
else if ((v & 0xF0) == 0xE0)
channel->playing->slide += (v & 15) << 2;
else if (i < 0 && sigdata->flags & IT_WAS_A_669)
channel->portamento += v << 3;
else if (i < 0)
channel->portamento += v << 4;
}
} }
} }
break; break;
@ -2232,10 +2318,17 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than
depth <<= 2; depth <<= 2;
channel->lastHdepth = depth; channel->lastHdepth = depth;
} }
if (channel->playing) { for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) {
channel->playing->vibrato_speed = speed; if (i < 0) playing = channel->playing;
channel->playing->vibrato_depth = depth; else {
channel->playing->vibrato_n++; playing = sigrenderer->playing[i];
if (!playing || playing->channel != channel) continue;
}
if (playing) {
playing->vibrato_speed = speed;
playing->vibrato_depth = depth;
playing->vibrato_n++;
}
} }
} }
} }
@ -2291,8 +2384,15 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than
else else
channel->channelvolume = 64; channel->channelvolume = 64;
#endif #endif
if (channel->playing) for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) {
channel->playing->channel_volume = channel->channelvolume; if (i < 0) playing = channel->playing;
else {
playing = sigrenderer->playing[i];
if (!playing || playing->channel != channel) continue;
}
if (playing)
playing->channel_volume = channel->channelvolume;
}
break; break;
case IT_CHANNEL_VOLUME_SLIDE: case IT_CHANNEL_VOLUME_SLIDE:
{ {
@ -2313,8 +2413,15 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than
if (channel->channelvolume > 64) channel->channelvolume = 0; if (channel->channelvolume > 64) channel->channelvolume = 0;
} else } else
break; break;
if (channel->playing) for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) {
channel->playing->channel_volume = channel->channelvolume; if (i < 0) playing = channel->playing;
else {
playing = sigrenderer->playing[i];
if (!playing || playing->channel != channel) continue;
}
if (playing)
playing->channel_volume = channel->channelvolume;
}
} }
} }
break; break;
@ -2467,9 +2574,16 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than
depth = channel->lastRdepth; depth = channel->lastRdepth;
channel->lastRdepth = depth; channel->lastRdepth = depth;
} }
if (channel->playing) { for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) {
channel->playing->tremolo_speed = speed; if (i < 0) playing = channel->playing;
channel->playing->tremolo_depth = depth; else {
playing = sigrenderer->playing[i];
if (!playing || playing->channel != channel) continue;
}
if (playing) {
playing->tremolo_speed = speed;
playing->tremolo_depth = depth;
}
} }
} }
break; break;
@ -2690,10 +2804,17 @@ Yxy This uses a table 4 times larger (hence 4 times slower) than
depth <<= 1; depth <<= 1;
channel->lastHdepth = depth; channel->lastHdepth = depth;
} }
if (channel->playing) { for (i = -1; i < DUMB_IT_N_NNA_CHANNELS; i++) {
channel->playing->vibrato_speed = speed; if (i < 0) playing = channel->playing;
channel->playing->vibrato_depth = depth; else {
channel->playing->vibrato_n++; playing = sigrenderer->playing[i];
if (!playing || playing->channel != channel) continue;
}
if (playing) {
playing->vibrato_speed = speed;
playing->vibrato_depth = depth;
playing->vibrato_n++;
}
} }
} }
break; break;
@ -3580,7 +3701,7 @@ static int it_envelope_end(IT_PLAYING *playing, IT_ENVELOPE *envelope, IT_PLAYIN
/* Returns 1 when fading should be initiated for a volume envelope. */ /* Returns 1 when fading should be initiated for a volume envelope. */
static int update_it_envelope(IT_PLAYING *playing, IT_ENVELOPE *envelope, IT_PLAYING_ENVELOPE *pe, int flags) static int update_it_envelope(IT_PLAYING *playing, IT_ENVELOPE *envelope, IT_PLAYING_ENVELOPE *pe, int flags)
{ {
if (!(playing->enabled_envelopes & flags)) if (!(playing->enabled_envelopes & flags) || !envelope->n_nodes)
return 0; return 0;
ASSERT(envelope->n_nodes > 0); ASSERT(envelope->n_nodes > 0);
@ -4323,7 +4444,7 @@ static float calculate_volume(DUMB_IT_SIGRENDERER *sigrenderer, IT_PLAYING *play
volume *= 1.0f / ((64 << 5) * 64.0f * 64.0f * 128.0f * 128.0f); volume *= 1.0f / ((64 << 5) * 64.0f * 64.0f * 128.0f * 128.0f);
if (volume && playing->instrument) { if (volume && playing->instrument) {
if (playing->enabled_envelopes & IT_ENV_VOLUME) { if (playing->enabled_envelopes & IT_ENV_VOLUME && playing->env_instrument->volume_envelope.n_nodes) {
volume *= envelope_get_y(&playing->env_instrument->volume_envelope, &playing->volume_envelope); volume *= envelope_get_y(&playing->env_instrument->volume_envelope, &playing->volume_envelope);
volume *= 1.0f / (64 << IT_ENVELOPE_SHIFT); volume *= 1.0f / (64 << IT_ENVELOPE_SHIFT);
} }