how do I use lejos.hardware.Sound.playSample?

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

Moderators: roger, gloomyandy, skoehler

how do I use lejos.hardware.Sound.playSample?

Postby GeekDude » Thu Nov 14, 2013 12:51 am

My code isn't working, all I hear is a slight static sound coming out of the speakers. No error code. Am I using it incorrectly?

Code: Select all
import java.io.File;
import static java.lang.System.out;
import lejos.hardware.Sound;

public class FirstEV3 {
   public static void main(String[] args) {
      File myFile = new File("nyan.wav");
      out.println(Sound.playSample(myFile));
   }
}


Edit: Also, how do you properly shut off your EV3 running lejos? From ssh I usually have to call "shutdown -h 0", but what if I turn it on by accident when it's not connected to a network?
GeekDude
New User
 
Posts: 9
Joined: Wed Nov 13, 2013 12:50 pm

Re: how do I use lejos.hardware.Sound.playSample?

Postby gloomyandy » Thu Nov 14, 2013 12:07 pm

How have you encoded your .wav file, it needs to be 8bit mono 8KHz. There are other threads on the forum about this...
viewtopic.php?f=18&t=4769&p=20298&hilit=ev3+sound#p20298

At the moment you need a network connection to shut things down, or simply remove a battery...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3640
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to EV3 Software

Who is online

Users browsing this forum: Baidu [Spider] and 0 guests

cron
more stuff