Shop OBEX P1 Docs P2 Docs Learn Events
program (code) to generate full song of twinkle twinkle little star — Parallax Forums

program (code) to generate full song of twinkle twinkle little star

papupapu Posts: 5
edited 2007-04-13 15:28 in Learn with BlocklyProp
hello everyone

················ if anybody have a program (code) to generate full song of twinkle twinkle little star please provide me.

Post Edited By Moderator (Chris Savage (Parallax)) : 3/28/2007 12:14:55 AM GMT

Comments

  • crgwbrcrgwbr Posts: 614
    edited 2007-04-07 18:02
    A couple monthes ago (or maybe this month) in Servo magize there was an article about generating songs with a BS2. Basically, it just comes down to finding the sheet music for a song, then figureing out what freq each note is. One you have that data, you can figure out the timeing (quarter note = x mS eighth note = y mS).

    I'm sure you can take it from there,
    craig

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

    Microsoft: "You've got questions. We've got dancing paper clips."
  • ZootZoot Posts: 2,227
    edited 2007-04-07 19:53
    This won't give you "twinkle twinkle little star" per se, but the thread below has code for a music engine that lets you transcribe notes, octaves, durations from any musical score into DATA statements for playback.

    http://forums.parallax.com/showthread.php?p=619826

    Scroll to the bottom and look for _Music-player_REL.bsp and _Music-4kEEdata_REL.bsp. I use an external EEPROM for storing musical scores, but they can be put into DATA statements just as easily (you would need to change the I2CIN statements to READ statements).

    The only transcription I was able to find (in a quick google search) for TTLS is below.... you will need to transcribe this transcription into a format for the music engine referenced above, of course. Hopefully this will get you started.

    2/2    |  |  |_-_|  |  |  |_-_|  |  |  |_-_|  |  |  |_-_|
    0(C) CC|GG|AA|G  |FF|EE|DD|C  |GG|FF|EE|D  |GG|FF|EE|D  |
    2/2    |  |  |_-_|  |  |  |_-_||
    0    CC|GG|AA|G  |FF|EE|DD|C  ||
    
    



    Since the melody is almost all whole notes, it shouldn't be too tricky.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-04-12 00:23
    Somebody started a new Subject rather than Reply to this Subject, but here's what he had -- http://forums.parallax.com/showthread.php?p=644279
  • hitswarehitsware Posts: 156
    edited 2007-04-13 15:28
    n var byte
    t var nib
    x var byte
    a con 40
    c con 24
    d con 27
    e con 30
    f con 32
    g con 36
    q con 1
    h con 2
    for x=0 to 26
    lookup x,[noparse][[/noparse]c,c,g,g,a,a,g,f,f,e,e,d,d,c,g,g,f,e,e,d,g,g,f,f,e,e,d],n
    lookup x,[noparse][[/noparse]q,q,q,q,q,q,h,q,q,q,q,q,q,h,q,q,h,q,q,h,q,q,q,q,q,q,h],t
    freqout 0,t*300,n*11
    next
    for x=0 to 13
    lookup x,[noparse][[/noparse]c,c,g,g,a,a,g,f,f,e,e,d,d,c],n
    lookup x,[noparse][[/noparse]q,q,q,q,q,q,h,q,q,q,q,q,q,h],t
    freqout 0,t*300,n*11
    next
Sign In or Register to comment.