I implemented the synthesizer from scratch. Honestly I'm not super familair with digital synthesizer theory and for the implementation, mostly I referred to this article https://keithwhor.com/music/
The code of my implementation is at https://github.com/JNKKKK/pianochord.io/blob/master/src/libs...
I guess it't not a good choice to implement that part on my own, since there are many good libraries out there, like tone.js. I will probably deprecate my own synthesizer implementation and use tone.js.