Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Piano synthesis in Matlab Please HELP!

  1. Dec 18, 2011 #1

    I'm not sure if this is the right place to write this thread, but I have a question about attempting to synthesize a piano in MATLAB. I am very new to MATLAB and DSP in general and my project is trying to create a piano sound using whatever means (FM synthesis, additive synthesis, etc... whatever is simplest). My program asks the user for a note number (1-88) and should produce the tone with a piano timbre. Right now, I have a signal that is build on the fundamental plus 24 partials with an ADSR envelope for the entire signal. Here is some of the sample code:

    srate = 44100;

    ff = 27.5*2^((noteNumber-1)/12);

    t = (0:1/srate:2);

    for i = 1:25
    y = y + amp(i)*cos(2*pi*ff*i*t);

    The sound I am producing is more like that of a kazoo. I know that I need to add the percussive strike of the hammer on the piano strings and some inharmonicities as well but do not know how to go about that? Any help/code would be greatly appreciated. Thank you very much
  2. jcsd
  3. Dec 20, 2011 #2


    User Avatar
    Science Advisor

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook