classpath and sound playback

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

Moderators: roger, gloomyandy, skoehler

classpath and sound playback

Postby JGeo » Fri Nov 08, 2013 6:42 am

I noticed that I have to put all libraries/jar files in the function call. Maybe I should add something to an environment variable to make it easier in the future. Took some time to find this out, as I am new to Java.

Code: Select all
jrun -cp /lejos/lib/ev3classes.jar:/lejos/libjna/usr/share/java/jna.jar:EV3FirstProgram.jar EV3FirstProgram


Now, I try to get playing a wav file working. Beeps do work, but I wanted something more.

Code: Select all
import java.io.File;
import lejos.nxt.Sound;
import lejos.util.Delay;

public class EV3FirstProgram
{
    /**
     * @param args
     */
    public static void main(String[] args)
    {
        System.out.println("playing wav...");
        final File soundFile = new File("intro.wav");
        Sound.playSample(soundFile, 100);
        System.out.println("still running...");
        Delay.msDelay(4000);
    }
}


I can see it starts, and after a couple of seconds, I see the program is still running, but I hear nothing. Still, this is quite literally the example found elsewhere. Should I configure something to be able to play wav files? I believe wav is always 8-bit, but does the sample rate matter? I put the intro.wav file in the same folder as from where I run the program on the EV3, /home/root.
Who would maybe have a suggestion how I solve this?
JGeo
New User
 
Posts: 3
Joined: Wed Oct 02, 2013 8:46 pm

Re: classpath and sound playback

Postby gloomyandy » Fri Nov 08, 2013 10:56 am

Hi,
I've split this post out as the original thread is not really very useful for others to find information in.

Check the return from the play method it will give an error code if there is a problem. What encoding have you used for the wav file, only 8bit, mono, 8KHz is supported by the EV3... Remember this is an alpha release so if you want to use it you will have to work a little harder. The source for the sound playback code is here:
https://sourceforge.net/p/lejos/ev3/ci/ ... Sound.java

You only need to add the jars that are not standard on the SD card to the classpath. Normally the jna and ev3classes.jar will be included already. Are you using as later version of these? If so why?

Also please read the posts I've made about the problems of using git master. If in doubt please use the same tag as the SD card you are using. If you do this you should not need to include anything other than your own jar files in the classpath.

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff