Skip to content

Commit

Permalink
Fix for initial instrument-without-note (should trigger C-0 note)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagamusix committed Mar 9, 2023
1 parent a663510 commit 73e9d60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions player/csndfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ static void set_current_pos_0(song_t *csf)
song_voice_t *v = csf->voices;
for (uint32_t i = 0; i < MAX_VOICES; i++, v++) {
memset(v, 0, sizeof(*v));
v->note = v->new_note = 1;
v->cutoff = 0x7F;
v->volume = 256;
if (i < MAX_CHANNELS) {
Expand All @@ -474,7 +475,8 @@ void csf_set_current_order(song_t *csf, uint32_t position)
song_voice_t *v = csf->voices + j;

v->frequency = 0;
v->note = v->new_note = v->new_instrument = 0;
v->note = v->new_note = 1;
v->new_instrument = 0;
v->portamento_target = 0;
v->n_command = 0;
v->cd_patloop = 0;
Expand Down Expand Up @@ -1206,7 +1208,8 @@ void csf_stop_sample(song_t *csf, song_sample_t *smp)
return;
for (int i = 0; i < MAX_VOICES; i++, v++) {
if (v->ptr_sample == smp || v->current_sample_data == smp->data) {
v->note = v->new_note = v->new_instrument = 0;
v->note = v->new_note = 1;
v->new_instrument = 0;
v->fadeout_volume = 0;
v->flags |= CHN_KEYOFF | CHN_NOTEFADE;
v->frequency = 0;
Expand Down
9 changes: 9 additions & 0 deletions player/effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,15 @@ void csf_process_effects(song_t *csf, int firsttick)
if (instr < MAX_SAMPLES)
chan->volume = csf->samples[instr].volume;
}

if (csf->flags & SONG_INSTRUMENTMODE) {
if (instr < MAX_INSTRUMENTS && (chan->ptr_instrument != csf->instruments[instr] || !chan->increment))
note = chan->note;
} else
{
if (instr < MAX_SAMPLES && (chan->ptr_sample != &csf->samples[instr] || !chan->increment))
note = chan->note;
}
}
// Invalid Instrument ?
if (instr >= MAX_INSTRUMENTS) instr = 0;
Expand Down

0 comments on commit 73e9d60

Please sign in to comment.