Shop OBEX P1 Docs P2 Docs Learn Events
twinkle twinkle little star — Parallax Forums

twinkle twinkle little star

hitswarehitsware Posts: 156
edited 2007-04-13 15:27 in BASIC Stamp
cx data 8,6,9,6:nx data 2,4,3,4
c var nib (4):n var nib(4):x var nib:y var nib
for x=0 to 3:read cx+x,c(x):read nx+x,n(x):next
play:for x=0 to 3:for y=0 to 3
freqout 0,400,c(x)*n(y)*8,c(x)*n(y)*16
next[noparse]:next:[/noparse]goto play

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-04-11 04:12
    hitsware,

    Is there a question or information in your post? The code you posted is incomplete, unformatted and there is no statement or question to assist us in identifying what your post is to convey.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • hitswarehitsware Posts: 156
    edited 2007-04-11 06:25
    >Is there a question or information in your post?

    Evedently not

    >The code you posted is incomplete,

    It runs with stamp2.exe
    and a BS2

    >unformatted and there is no statement or question
    >to assist us in identifying what your post is to convey.

    If you hook your sterero (via Y plug to (p0 (of your stamp)to both channels))
    (and run the code) you will hear what I mean.

    Just trying to show the musical abilities of a BS ........
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-04-11 14:03
    My apologies…Because of the code formatting I missed the first line of code which contains the data I was missing. I would recommend adding some formatting to code you post so that it is easier for new users of the BASIC Stamp to follow. You can see some examples by looking at code we have posted. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • hitswarehitsware Posts: 156
    edited 2007-04-11 14:59
    cx data 8,6,9,6 ' This is in response to a post below (which seems
    nx data 2,4,3,4 'to have disappeared(or I can't find)) asking for a
    c var nib (4) ' pic version of "twinkle twinkle little star".
    n var nib(4) 'This is not that tune, but demonstrates one
    x var nib 'method of generating music with a stamp2
    y var nib 'cx = chord
    for x=0 to 3 'nx=note
    read cx+x,c(x) 'for instance for the notes in
    read nx+x,n(x) '(major chords have a 3,4,5 frequency ratio)
    next 'Cmaj:
    play '6*3=18=G,6*4=24=C,6*5=30=E
    for x=0 to 3 '6,8,9 gives the ratios of the 3 major chords
    for y=0 to 3 'in a key (say C,F,G)
    freqout 0,400,c(x)*n(y)*8,c(x)*n(y)*16 '
    next
    next
    goto play
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-04-12 00:22
    I guess, hitsware, that you meant (??) to Reply to this Subject -- http://forums.parallax.com/showthread.php?p=641113
  • hitswarehitsware Posts: 156
    edited 2007-04-13 15:27
    n var byte ' Yea. Thanks. Finally got it.
    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.