ROBOTC.net forumshttp://robotc.net/forums/ Music playing nxthttp://robotc.net/forums/viewtopic.php?f=15&t=4244 Page 1 of 1

 Author: Thekid986 [ Mon Feb 13, 2012 12:25 pm ] Post subject: Music playing nxt I am trying to use the sound function on the NXT to make it play the super marios theme song. Does anybody have any idea what the code would look like. I have programed a lot of other things but i have never really messed with sound. Thanks,Thekid986

Author:  sumasmreq [ Mon Feb 13, 2012 12:56 pm ]
Post subject:  Re: Music playing nxt

Here is a ROBOTC program I made a while ago to play the Mario theme on the VEX Cortex.
Also, here is a midi file and the resulting converted rmi file (used BricxCC) that both contain the Mario theme. The rmi file should play on the NXT (though I haven't tested it):
http://ge.tt/8Pl7MZD

 Author: Thekid986 [ Mon Feb 13, 2012 1:37 pm ] Post subject: Re: Music playing nxt Thanks a lot that helped out

Author:  magicode [ Mon Feb 13, 2012 3:36 pm ]
Post subject:  Re: Music playing nxt

If you don't want to write your own sound output function, like sumasmreq did, you can use ROBOTC's built in tone function:
 Code:void PlayTone(const int frequency, const int durationIn10MsecTicks)

Author:  Coder A [ Fri Jan 04, 2013 7:53 pm ]
Post subject:  Re: Music playing nxt

Just some music theory:

The lowest A on a piano has a frequency of 220. Every octave up, the frequency of a note doubles. Since there are 12 notes per octave, this means that to calculate the frequency of the nth note on a keyboard, you would use this:

 Code:short notefreq(short notenum){return round(pow(220,(notenum+12)/12));}

where the lowest A is notenum zero.

 Page 1 of 1 All times are UTC - 5 hours [ DST ] Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/