You could use a sequencer (like the one built in to Reaper, which is free) to sequence the notes you need using your sound card as the MIDI device.
You can then export your track as a WAV file and chop it up into individual notes using Audacity. You can then export each individual note as a separate MP3, and load them into your game.
Note that I’m using the word “soundcard” very loosely here: in many cases sound hardware is onboard nowadays. The point is your computer will have sounds you need built in.
You could also take one piano note sample and simply play it at different pitches, but the issue here is it will only sound good within a smallish range of notes - maybe an octave maximum.
Whereas your computer’s sound hardware is likely to have a piano as a wave table instrument that uses multiple or many samples or fragments of samples for each note and will sound better, though possibly still a bit synthetic.
> Note that I’m using the word “soundcard” very loosely here: in many cases sound hardware is onboard nowadays.
Mainstream computers haven't had "soundcards" or any kind of built-in hardware synthesis for many years. What you have for hardware is mostly just a digital to analog converter with some mixing features and possibly some basic DSP functions.
> The point is your computer will have sounds you need built in. > Whereas your computer’s sound hardware is likely to have a piano as a wave table instrument
They're going to be on the hard drive as files and synthesis is entirely in software, from which you have numerous options, including what comes with the OS.
Hardware wave table synthesis as a builtin is long obsolete.
A sound font or VST plug-in with appropriate licenses may be another route, but I can't speak to how difficult that would be to work with. It's on my to-do list.
I'm trying to find something to programatically make piano sounds (and record an mp3) based on 2 params midi note and velocity. I'm making a videogame and I need the mp3 piano notes.
I got a free piano sample library, but the sounds start not always at the same microsecond, so I think I need to produce the samples by myself.