I am creating a program to create midi files and I have a problem with the sound of long notes. If I take short notes (for example, the duration of which is less than 480 ticks), then there is no problem, but if I want to take a longer note, then it fades faster than it should
I assumed it was done something like this:
midiTrack.insertEvent(new PitchBend((long) startTick, 0, 0, 64));
midiTrack.insertNote(0, pitch, 80, (long) startTick, duration);
midiTrack.insertEvent(new Controller(startTick + duration, 0, 0, 0));
but this did not bring results, although something similar happens in the ready-made examples. The pitchBend function accepts the following arguments PitchBend(tick, channel, lsb, msb) and the insertNote function accepts the following arguments insertNote(channel, pitch, velocity, tick, duration)
You're on the right way with this comment:
found out that most likely the maximum duration of the sound depends directly on the selected program
But I have a small correction: "depends on the synth you use to produce sound from MIDI". Program affects what sound you will get from the synth. MIDI is not Audio and you cannot get sound from MIDI without any device (synth) that produces sound. It's completely up to the synth how to process a note.
If you're on Windows, you use probably the default synth - Microsoft GS Wavetable Synth. But you can try another one and look how different will be the sound.