Author Topic: sound code in basic  (Read 2080 times)

0 Members and 1 Guest are viewing this topic.

Offline BANETopic starter

  • Supreme Robot
  • *****
  • Posts: 639
  • Helpful? 4
  • E=roboticsC^2
sound code in basic
« on: August 24, 2008, 08:05:58 AM »
Hello, I was trying to make my robot play the star wars theme song and it came out really crappy :D.  Does any one know of a web site that has cool sounds and music in basic?    ..........I give up on making my own :P

bane

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: sound code in basic
« Reply #1 on: August 24, 2008, 11:52:08 AM »
Look for some sheet music on the song of your choice. Store the 12 frequencies for one octave, than multiply accordingly (x2 for 1st, x4 for second, x8 for third, etc) to get any note in any octave. Make it as a function sound(note, octave). defines would be killer, such as Do = 0, Re = 2, Mi = 4, Fa = 5, etc..

Convert the sheet music in instructions for your theme.
Alternatively, you can get a midi and convert it. 
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline Carter05

  • Jr. Member
  • **
  • Posts: 19
  • Helpful? 0
Re: sound code in basic
« Reply #2 on: August 25, 2008, 11:18:43 AM »
Little thread hijaking here but same concept. I want to be able to play a multitude of sound effects from a small speaker, not little blips and beeps but sound effects. Is there something that is available that I can hook up an axon and be able to trigger different sound effects depending on what I input to it?

Offline BANETopic starter

  • Supreme Robot
  • *****
  • Posts: 639
  • Helpful? 4
  • E=roboticsC^2
Re: sound code in basic
« Reply #3 on: August 25, 2008, 04:43:50 PM »
So i would have to still convert whatever music piece that i wanted :P  I don't know any thing about music :D  Anti-bandy.. lol

Bane

Offline dsheller

  • Full Member
  • ***
  • Posts: 72
  • Helpful? 0
Re: sound code in basic
« Reply #4 on: September 01, 2008, 01:08:33 PM »
I did something similar to this a lonnng time ago when all I know was VB and a little C++... I have the notes and I'll have to dig a little for the note mappings to frequencies... but other than that here is the theme

D;250
D;250
D;250
G;1000
d;1000
c;250
B;250
A;250
g;1000
d;500
c;250
B;250
A;250
g;1000
d;500
c;250
B;250
c;250
A;1000
R;500
D;375
D;125
E;750
E;375
c;250
B;250
A;250
G;250
G;250
A;250
B;250
A;250
E;250
F#;500
D;375
D;125
E;750
E;250
c;250
B;250
A;250
G;250
d;500
A;1000
D;375
D;125
E;750
E;375
c;250
B;250
A;250
G;250
G;250
A;250
B;250
A;250
E;250
F#;500
d;375
d;125
g;375
F;125
d#;375
D;125
c;375
A#;125
A;375
G;125
D;1000
D;250
D;250
D;250
D;250
D;250
D;250
G;1000
d;1000
c;250
B;250
A;250
g;1000
d;500
c;250
B;250
A;250
g;1000
d;500
c;250
B;250
c;250
A;1000
D;375
D;125
G;1000
d;1000
c;250
B;250
A;250
g;1000
d;500
g;250
f;250
d#;250
a#;1000
a;500
g;500
G;250
G;250
G;250
G;1000

Offline dsheller

  • Full Member
  • ***
  • Posts: 72
  • Helpful? 0
Re: sound code in basic
« Reply #5 on: September 01, 2008, 01:10:07 PM »
Like you I had no idea about music, so I had a friend tell me what to put in for notes and I looked up the frequencies on the internet...

    strAllowed(0) = "A"
    strAllowed(1) = "B"
    strAllowed(2) = "C"
    strAllowed(3) = "D"
    strAllowed(4) = "E"
    strAllowed(5) = "F"
    strAllowed(6) = "G"
    strAllowed(7) = "a"
    strAllowed(8) = "b"
    strAllowed(9) = "c"
    strAllowed(10) = "d"
    strAllowed(11) = "e"
    strAllowed(12) = "f"
    strAllowed(13) = "g"
    strAllowed(14) = "A#"
    strAllowed(15) = "C#"
    strAllowed(16) = "D#"
    strAllowed(17) = "F#"
    strAllowed(18) = "G#"
    strAllowed(19) = "a#"
    strAllowed(20) = "c#"
    strAllowed(21) = "d#"
    strAllowed(22) = "f#"
    strAllowed(23) = "g#"
    strAllowed(24) = "R"
    strAllowed(25) = "bb"
    strAllowed(26) = "a#a"
    strAllowed(27) = "gg"
    strAllowed(28) = "aa"
   
    strFrequency(0) = "440"
    strFrequency(1) = "494"
    strFrequency(2) = "262"
    strFrequency(3) = "294"
    strFrequency(4) = "330"
    strFrequency(5) = "349"
    strFrequency(6) = "392"
    strFrequency(7) = "880"
    strFrequency(8) = "988"
    strFrequency(9) = "523"
    strFrequency(10) = "587"
    strFrequency(11) = "659"
    strFrequency(12) = "698"
    strFrequency(13) = "784"
    strFrequency(14) = "466"
    strFrequency(15) = "277"
    strFrequency(16) = "311"
    strFrequency(17) = "370"
    strFrequency(18) = "415"
    strFrequency(19) = "932"
    strFrequency(20) = "554"
    strFrequency(21) = "622"
    strFrequency(22) = "740"
    strFrequency(23) = "831"
    strFrequency(24) = "1"
    strFrequency(25) = "247"
    strFrequency(26) = "233"
    strFrequency(27) = "196"
    strFrequency(28) = "000"

So there you have the mappings.... donno why i have 28 as 000, was a long time ago I wrote this.

 


Get Your Ad Here