sinshu / meltysynth

A SoundFont MIDI synthesizer for .NET
Other
130 stars 15 forks source link

Weird "fade" artifacts - maximum polyphony? #47

Closed chipweinberger closed 2 weeks ago

chipweinberger commented 2 weeks ago

https://github.com/sinshu/meltysynth/assets/1863934/187e63cd-7b65-4b17-91bf-7cf15c8f91b9

Hey @sinshu , hello again :)

At 00:11 & 00:24 in the video, you can hear weird artifacts.I think it is due to maximum polyphony. But it still sounds not as expected.

I am playing the same note many times, and the first notes should note be loud anymore. Why is the artifact so large?

sinshu commented 2 weeks ago

Hi 😊

Let me confirm a few things.

chipweinberger commented 2 weeks ago

Yes. Dart port.

soundfont: akai_steinway.sf2 (https://musical-artifacts.com/artifacts/1876)

maximumPolyphony: 192

chipweinberger commented 2 weeks ago

midi file

jamcorder-0.mid.txt

chipweinberger commented 2 weeks ago

Thanks for your help @sinshu :)

chipweinberger commented 2 weeks ago

I counted the notes, and it is only about ~50 notes before artifact. So maybe not maximum polyphony.

But I noticed it happens when:

  1. sustain pedal is used for long time
  2. lots of repeated notes
sinshu commented 2 weeks ago

I haven't pinpointed the cause yet, but I remember dealing with a similar issue in the past. https://github.com/sinshu/meltysynth/issues/20

It seems that the commit for the C# version hasn't been brought into the Dart version. https://github.com/sinshu/meltysynth/commit/a8fcf2fc86b73da114b8acf106650ca047afccf3

It might help to port this commit to Dart. Could you please give it a try?

chipweinberger commented 2 weeks ago

yes this sounds like the exact same issue!

I will port it!!

chipweinberger commented 2 weeks ago

what should I do if "low" is null? for if (voice.voiceLength() > low.voiceLength()) {

Screenshot 2024-06-17 at 10 19 26 AM

I think it should be if (low == null || voice.voiceLength() > low.voiceLength()) {

chipweinberger commented 2 weeks ago

dart commit: https://github.com/chipweinberger/dart_melty_soundfont/commit/cf7792cfa8a53bc5336c614f06e82b3b4c7f3c04

I will test it later today.

thanks for your help so much.

chipweinberger commented 2 weeks ago

yes. this changed fixed it!

sinshu commented 2 weeks ago

@chipweinberger Glad to hear it got resolved 😁

Regarding the issue where low might become null:

Thus, low will never be null. In fact, there has never been a null pointer issue in this code path.