Quacksol / VSInstruments

3 stars 3 forks source link

Why do sustaining notes repeat and stutter when a new note is played? #2

Open elanhickler opened 2 years ago

elanhickler commented 2 years ago

Could you explain how the ABC interpreter is to work and/or recommend a midi to ABC converter?

Currently, it seems that my creations, whenever a note sustains, it is re-triggered when any new note begins rather than playing out and fading out as expected. For example, if I have a basic bassline plus a melody, every note of the melody will retrigger the bassline.

My ABC file in question: Ultima Online - Stones (Argi Game Remix).zip

Some ABC files played by the mod do not do this, so help me understand what is going on.

Quacksol commented 1 year ago

I use Starbound Composer, as it is what I used to make abc files from MIDI back when I played that game. It does require you have the game for the sound files, though. I'm not sure how I never noticed this, but other ABC players seem to use a fadeout time after a note has completed its duration. Mine cuts the sound off as soon as the duration is finished. I will look into fixing this.

c01dc0ffee commented 1 month ago

For reference, this is what Maestro does to handle that "fadeout time": https://github.com/digero/maestro/blob/db433464f5d7f5d821e0a1aac6f618b6a7c4c6b0/src/com/digero/common/abctomidi/AbcToMidi.java#L804

In summary: Add an extra 1.0 seconds for instruments which cannot sustain notes or 0.1 seconds for instruments which can. Convert the extra duration into microseconds and multiply by PULSES PER QUARTER NOTE divided by MICROSECONDS PER QUARTER NOTE. PPQN is derived from tempo or meter.

I created a fork that implements Sound.FadeOut and calls it during SoundManager.Update instead of stopping it.

public void FadeOut()
{
    sound.FadeOutAndStop(FadeDurationSeconds);
}

It still needs work. Many songs with simultaneous notes wind up sounding very discordant and I'm not sure what's causing that yet.