paulrosen / abcjs

javascript for rendering abc music notation
Other
1.9k stars 282 forks source link

Click on fadeout in a half note #882

Open computermusicneix opened 1 year ago

computermusicneix commented 1 year ago

When I wrote a half note on lower times (<60 BPM) I hear a click before the end of stave.

For example: Q: 20 M: 4/4 d4

I tried with the option: fadeLength but without results.

Any idea?

paulrosen commented 1 year ago

Using your example I don't hear a click, but the note definitely stops early. Are you using a different voice besides piano?

It stops early because, to save space, each note is only a maximum length, figuring most music doesn't have notes that long. To fix that you would have to use your own soundfont. I was thinking about doing some processing to change the length of the sound on the fly but that would be expensive and I'm not sure how realistic that would sound. Probably for some instruments it would sound just fine.

Anyway, fadeLength will cause the note to fade only if it hasn't finished playing, so it would have an effect on shorter notes.

I would like to investigate the click you are reporting if I could duplicate it. I pasted your exact example into https://editor.drawthedots.com/ for my test. Do you hear the click when doing that?

computermusicneix commented 1 year ago

I pasted this code on https://editor.drawthedots.com/

X:1 T: Click??? C: M N: for u L: 1/4 M: 4/4 Q: 34 V: Voice4 name='piano1' K: C treble %%MIDI program 0 z4 | V: Voice3 name='piano1' K: C bass %%MIDI program 0 !pp![d,,,4 e,,4] |!mp![d,,, f,,] !pp![f,,, f,,] !p![f,,, e,,] z | V: Voice2 name='celesta1' K: C treble %%MIDI program 2 z4 | V: Voice1 name='celesta1' K: C bass %%MIDI program 2 z4 |

and I don't really hear the click, just an abrupt ending (Can you control that fade out?) I definitely think it is a problem with my soundfont. I had chosen especially long samples so this wouldn't happen to me, but it looks like I need to work on it more.

Excuse me for asking before doing all the checking.

paulrosen commented 1 year ago

It would be possible for someone who knew how to stretch the sample if the length was longer than the sample. I don't have time to research it, but I'd love a pull request!

I think there are some complications - some instruments have an onset and stop that is different from the held note that shouldn't be part of the stretch. Some instruments can't be stretched (what would it mean to stretch a wood block?). Some instruments are strong for the entire length (violin) and some will fade (piano). And some soundfonts might behave differently from others even with the same instruments.