View unanswered posts | View active topics It is currently Thu Apr 24, 2014 3:48 am

Reply to topic  [ 5 posts ] 
Music playing nxt 
Author Message

Joined: Wed Feb 08, 2012 8:28 pm
Posts: 13
Post 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,

Mon Feb 13, 2012 12:25 pm

Joined: Fri Jan 27, 2012 6:57 pm
Posts: 40
Post 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):

MarioSpeakerTest.c [9.7 KiB]
Downloaded 835 times
Mon Feb 13, 2012 12:56 pm

Joined: Wed Feb 08, 2012 8:28 pm
Posts: 13
Post Re: Music playing nxt
Thanks a lot that helped out

Mon Feb 13, 2012 1:37 pm
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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:
void PlayTone(const int frequency, const int durationIn10MsecTicks)

sudo rm -rf /

Mon Feb 13, 2012 3:36 pm

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 187
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post 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:

short notefreq(short notenum)
return round(pow(220,(notenum+12)/12));

where the lowest A is notenum zero.

I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot
Play chess for free!

Fri Jan 04, 2013 7:53 pm
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.