Sound Examples

Note frequencies from Physics of Music (http://www.phy.mtu.edu/~suits/notefreqs.html). Note and Beats functions by W. C. Carter (http://pruffle.mit.edu).

c  = 0;  d  = 1;  e = 2;  f = 3;  g = 4;  a = 5;  
    b = 6; 
freq[c]  = 261.63;
freq[d]   = 293.66;
freq[e]  = 329.63;
freq[f]  =  349.23;
freq[g]  = 392.00;
freq[a]  =  440.00;
freq[b]  =  493.88;

    
Note[note_]  :=  
        Sin[ 2 Pi freq[note] t];

Beats[list_,  duration_,  cadence_]  :=  
      Table[If[t ≥  (i - 1)* cadence  &&  
            t   ≤  (i - 1)*cadence  +  duration[[i]], 
          Evaluate[list[[i]]], 0], {i, 1, Length[list]}]

Twinkle, Twinkle, Little Star

LittleStarNotes =  
      Map[Note, {c,  c,  g,  g,  a,  a,  g,  g,  f,  f,  e,  e,  
          d,  d,  c,  c,   g,  g,  f,  f,  e,  e,  d,  d,  g,  
          g,  f,  f,  e,  e,  d,  d,  c,  c,  g,  g,  a,  a,  
          g,  g,  f,  f,  e,  e,  d,  d,  c,  c}]

Trick: notes with durations equal to the cadence play "legato", the effect being that notes seem to have different durations.

LittleStarTimes = {1, 1, 1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1}/2

Play[Evaluate[Beats[LittleStarNotes, LittleStarTimes, 0.55]], {t, 0, 30}]

Jingle Bells

JingleBellsNotes =  
      Map[Note, {e,  e,  e,  e,  e,  e,  e,  e,  e,  g,  c,  d,  
          e,  e,  e,  e,  f,  f,  f,  f,  f,  e,  e,  e,  e,  
          d,  d,  e,  d,  d,  d,  d,  e,  e,  e,  e,  e,  e,  
          e,  e,  e,  g,  c,  d,  e,  e,  e,  e,  f,  f,  f,  
          f,  f,  e,  e,  e,  g,  g,  f,  d,  c,  c,  c,  
          c}]

JingleBellsTimes = {1, 1, 1.1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1.1, 1.1, 1.1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1.1, 1.1, 1, 1, 1, 1.1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1.1, 1.1, 1.1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.1, 1.1, 1.1, 1}/4

Play[Evaluate[Beats[JingleBellsNotes, JingleBellsTimes, 0.275]], {t, 0, 18}]