View unanswered posts | View active topics It is currently Fri Oct 31, 2014 1:16 pm






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

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,
Thekid986


Mon Feb 13, 2012 12:25 pm
Profile
Rookie

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):
http://ge.tt/8Pl7MZD


Attachments:
MarioSpeakerTest.c [9.7 KiB]
Downloaded 945 times
Mon Feb 13, 2012 12:56 pm
Profile
Rookie

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
Profile
Moderator
Moderator
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:
Code:
void PlayTone(const int frequency, const int durationIn10MsecTicks)

_________________
sudo rm -rf /


Mon Feb 13, 2012 3:36 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
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:

Code:
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


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

Who is online

Users browsing this forum: No registered users and 2 guests


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.