how can i play a wav file?

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

how can i play a wav file?

Postby treeface99 » Thu Feb 02, 2012 1:21 pm

Hi all,

I have created a blackjack playing robot and i would like to learn how to play wav files from the PC. I have found a few examples of code that run ok but they are really long and complex and i cant get my head around it.

Can anyone show/write me very basic code for playing a wav file. Simplest code possible. Or know of any good tutorials?

The sound i want to play is in my project directory and is called - sound.wav

Many Thanks!
treeface99
Novice
 
Posts: 30
Joined: Thu Nov 24, 2011 10:07 am

Re: how can i play a wav file?

Postby Xfel » Thu Feb 02, 2012 5:59 pm

It is as easy as
Code: Select all
lejos.nxt.Sound.playSample(sound.wav);

however, you will have to upload the sound file to the nxt. I would recommend using the nxjbrowse command for uploading. see here: http://lejos.sourceforge.net/nxt/nxj/tutorial/PC_GUI/PCGUITools.htm#1
Xfel
New User
 
Posts: 11
Joined: Mon Jan 30, 2012 3:29 pm

Re: how can i play a wav file?

Postby treeface99 » Mon Feb 06, 2012 8:51 pm

Thanks for that. Sorry i dont think i have made my aims very clear. I am planning on outputting the wav file on the PC through the PC speakers.
treeface99
Novice
 
Posts: 30
Joined: Thu Nov 24, 2011 10:07 am

Re: how can i play a wav file?

Postby Rickz2020 » Mon Feb 06, 2012 9:19 pm

Hi,

Does that mean that you still need help? The memory on the NXT is small (tiny!) and so I guess you want to send a command to the PC requesting the PC play a song stored on the HDD, correct?
Rickz2020
Active User
 
Posts: 121
Joined: Thu Feb 10, 2011 5:47 pm
Location: London, Earth.


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

cron
more stuff