Shop OBEX P1 Docs P2 Docs Learn Events
Star Wars Theme Song in Peizo — Parallax Forums

Star Wars Theme Song in Peizo

BoeBotBoeBot Posts: 37
edited 2010-06-19 07:45 in BASIC Stamp
Hello everyone,

I have recently created the Star Wars theme song for the Piezo speaker. I made it quickly so it may not be perfect.
Tell me what you think of it or how it should be improved.


I have the file attached.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Change is inevitable - except from a vending machine.

Robert C. Gallagher

Comments

  • IroneIrone Posts: 116
    edited 2010-06-17 06:27
    How Ya Doin'? I'm just an old newbie. You gotta see what Jessica Uelman posted last Christmas. She used look down and look up tables so she saved herself from copying much and a lot of program space. She also gives a great deal of musical know how and shortcuts to save you time. Go to Parallax's home page and fire up education. Then go to mini projects. Down close to the bottom·click Christmas Caroling Device with Light Display and be impressed. Chapter 8 in Whats a Microcontroller has even more information. It can not be that tough because I made a program with Good King Wenceslas for myself. Have fun!

    Casey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I fish, therefore I lie!
  • BoeBotBoeBot Posts: 37
    edited 2010-06-19 01:58
    Hello Irone, would you mind sharing your code for Good King Wenceslas?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Change is inevitable - except from a vending machine.

    Robert C. Gallagher
  • IroneIrone Posts: 116
    edited 2010-06-19 04:40
    How Ya Doin'? I am sorry but I have been running all day and right now I forget how to add an attachment. I am copying and pasting, I know it is wrong but here it is:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    'Good King Wenceslas
    Notes········ DATA··· "R", "D", "D", "D", "E", "D", "D", "A", "B", "A", "B", "d", "D", "D",
    ····················· "D", "D", "D", "E", "D", "D", "A", "B", "A", "B", "d", "D", "D",
    ····················· "A", "G", "g", "E", "g", "E", "D", "B", "A", "B", "d", "D", "D",
    ····················· "A", "A", "B", "d", "D", "D", "E", "A", "G", "g", "E", "D", "G", "D", "Q"
    Octaves······ DATA··· 0, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 7, 7, 7,
    ····················· 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 7, 7, 7,
    ····················· 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 7, 7, 7,
    ····················· 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
    Durations···· DATA··· 1000, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 2, 2,
    ····················· 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 2, 2,
    ····················· 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 2, 2,
    ····················· 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 2, 2, 1
    index········ VAR···· Byte
    offset······· VAR···· Nib
    noteLetter··· VAR···· Byte
    noteFreq····· VAR···· Word
    noteDuration· VAR···· Word
    noteOctave··· VAR···· Nib

    DO UNTIL noteLetter = "Q"
    · READ Notes + index, noteLetter
    ······· DEBUG"· ", noteletter

    · LOOKDOWN noteLetter, [noparse][[/noparse]· "C",· "d",· "D",· "e",· "E",
    ························· "F",· "g",· "G",· "a",· "A",
    ························· "b",· "B",· "R",· "Q"···· ], offset

    · LOOKUP offset,······· [noparse][[/noparse] 4186, 4435, 4699, 4978, 5274,
    ························· 5588, 5920, 6272, 6645, 7040,
    ························· 7459, 7902,··· 0,··· 0···· ], noteFreq
    ······· DEBUG "······ ", DEC4 noteFreq

    · READ Octaves + index, noteOctave
    · noteOctave = 8 - noteOctave
    · noteFreq = noteFreq / (DCD noteOctave)

    · READ Durations + index, noteDuration
    · noteDuration = 1000 / noteDuration

    · FREQOUT 8, noteDuration, noteFreq

    · index = index + 1
    LOOP
    END

    'R·= rest
    'and Q = quit
    'The other notes are regular and flats.

    If you notice the first thing that comes up in notes is a "R" which is a rest. When I first started it it played the song but ended up with an extra offkey note. I was confused for several days ( Drank Beer ) and then just put·a rest there and my final note went away. I have been going to ask if I did anything wrong but Christmas was six months ago. Maybe somebody will tell me now.

    If I make a dollar with this programer·it will be a dollar more than I have calculated. These things are really neat. I hope I keep my mind till I am at least 85 so I can keep having this much fun.

    Casey

    P.S. I haven't yet fired up my piezo speaker yet to hear your song, but I will.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I fish, therefore I lie!
  • IroneIrone Posts: 116
    edited 2010-06-19 07:45
    How Ya Doin'? Do you completly understand women? We ate late tonight and after we were done my wife took a shower. It was then when I replied to your message. I have drunk a couple of beers today but got confused about sending an attachment. She came out of the bathroom and gave me a quick cuff on the back of my neck. How did she know that I made a mistake? She said nothing but I started looking on my computer and found out what I did wrong. I am sure glad that I do not run around on that woman. Anyhow here is the attachment I said I would send. I used pin 8 as my freqout pin. This would be where you should connect your piezo buzzar. I looked on the web and found out about the Imperial music for Star wars and will try to apply it for the BS2 for you. But first I have to start my cucumbers because it is getting to the first day of summer and I gotta get them into the ground.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I fish, therefore I lie!
Sign In or Register to comment.