I am currently writing a program in which the user can play a simple virtual piano. I load a sample representing a middle C, and I change the pitch of that sound to get the other notes the user requests. However, I also want the player to be able to play notes of different lengths - quarter notes, half notes, etc.
Is there a way to dynamically alter the length of the sample? I've been mucking around in Audacity trying to change the sample length to have multiple samples (I only really want five - staccato, quarter, half, three-quarter and full), but doing so makes the sample sound very scratchy.
If there is no way to do this, does anybody know what other approaches I may try?