Download presentation
Published byEdward Lewis Modified over 9 years ago
1
NXC: Making Music BricxCC has a built-in utility to convert .wav files into .rso files accessible via menu Tools, Sound conversion. Then you can store .rso sound files on NXT flash memory using another utility, the NXT memory browser (Tools, NXT explorer) and play them with the command: PlayFilesEx (filename, volume, loop?) Where volume is a number from 0 to 4 and loop is 1 (TRUE) or 0 (FALSE)
2
Music PlayToneEx(frequency, duration, volume, loop)
This command plays a note with the given frequency for the specified duration. The frequency is in Hz, so 440 is the pitch of the A above middle C on a piano. The duration is in thousandths of a second. You can only specify integer values for the frequency, so don't expect the pitches to be exactly in tune. No one expects your little robot to sound like Placido Domingo.
3
Middle C Goldennumber.net
5
As with the case of PlayFileEx, the NXT does not wait for the note to finish. So if you use multiple tones in a row then you will need to add (slightly longer) wait commands in between.
6
Example #define VOL 3 task main () { PlayToneEx(262, 400, VOL, FALSE); Wait(500); PlayToneEx(294, 400, VOL, FALSE); Wait(500); PlayToneEx(330, 400, VOL, FALSE); Wait(500); }
7
Loading Sound File to nxt
Find and Download Sound File to BricxCC Directory
9
Directory to which file is saved
10
Convert .wav to .rso Invoke sound conversion tool from BricxCC
11
Convert .wav to .rso (cont)
Select directory containing .wav file
12
Convert .wav to .rso (cont)
Press “Select Files…” Select the file Press “Open”
13
Convert .wav to .rso (cont)
Press “Convert”
14
Convert .wav to .rso (cont)
Select Linear Sample and reduce the value for “Rate” until file is converted with no error
15
Convert .wav to .rso (cont)
16
Convert .wav to .rso (cont)
Press “OK”
17
Load .rso File onto Brick
Invoke NXT Explorer
18
Load .rso File onto Brick (continued)
With Brick powered on, select desired .rso file and press “Download” Note: If a .rso file has previously been loaded onto the brick, it may be necessary to delete it.
19
Test Sound File on Brick
By highlighting the . rso file in the left panel, and clicking the green note the file can be played on the brick
20
Download Code Write, compile and download music file playing code to brick
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.