tessel / tessel-av

USB Camera, Microphone, MP3 Player and Text Speaker support for Tessel 2.
38 stars 9 forks source link

Error: spawn madplay ENOENT #3

Closed dudleyjosh closed 8 years ago

dudleyjosh commented 8 years ago

I get the following error when I try to play audio using the example provided. Also, the var path = require('path'); statement is missing from the sample code in the README.md file?

Error: spawn madplay ENOENT
    at exports._errnoException (util.js:874:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at doNTCallback2 (node.js:439:9)
    at process._tickCallback (node.js:353:17)
    at Function.Module.runMain (module.js:469:11)
    at startup (node.js:134:18)
    at node.js:961:3

See my code below. The error occurs at sound.play().

var tessel = require('tessel');
var av = require('tessel-av');
var path = require('path');

var mp3 = path.join(__dirname, 'major_malfunction.mp3');
var sound = new av.Speaker(mp3);

sound.play();

sound.on('timeupdate', function(seconds) {
    seconds = Math.round(seconds);

    if (seconds === 2) {
        this.pause();
    }

    if (seconds > 12) {
        this.stop().play();
    }
});

sound.on('pause', function() {
    setTimeout(() => this.play(10), 1000);
});
rwaldron commented 8 years ago

Ah, there is a chicken and egg problem at the moment. I released this update but madplay still needs to be added to the packages for openwrt and a new build needs to be released. Basically, I forgot to do that :\

If you want a head start, ssh to the board do this:

opkg update; opkg install madplay

Sorry about that!

dudleyjosh commented 8 years ago

I did the opkg update and opkg install madplay and that took care of the error, bur I still don't seem get any sound output?

rwaldron commented 8 years ago

Do you have a .tesselinclude file with major_malfunction.mp3 in it?

dudleyjosh commented 8 years ago

Yes, and I verified that it was getting loaded in /tmp/remote-script when I ssh'd into the T2.

I took a quick glance at speaker.js and I don't see/understand where it ever loads the mp3 file from the filesystem? The path gets passed in as a string, but how does it actually load the mp3 file to play it? Does it happen at line 111 state.process = cp.spawn('madplay', args); with the args parameter?

Is there anything related to controlling volume? If not, what volume level does it default to?

rwaldron commented 8 years ago

where it ever loads the mp3 file from the filesystem?

Because it doesn't ;)

Does it happen at line 111 state.process = cp.spawn('madplay', args); with the args parameter?

That's correct.

Is there anything related to controlling volume? If not, what volume level does it default to?

Possibly? I've used headphones, earbuds, desktop speakers and one of those fancy bluetooth things that had a 3.5mm jack on it. What do you have plugged in for outputs? Since you're familiar with ssh'ing now, you could go directly to /tmp/remote-script/ and run madplay major_malfunction.mp3. Also, could you put that mp3 on a dropbox (or similar), so I can give it a try as well? Thanks for being patient, we'll work through this :)

dudleyjosh commented 8 years ago

Well the good news is that it was just because I'm an idiot and I can't spell... I had the filename spelled 'major_malfuntion.mp3' and the reason it ended up in the /tmp/remote-script area was because I had used the --full option. So, it does work, but it might be handy if it would throw an error (and console.log) if the filename path was invalid.

Thanks for the help.

rwaldron commented 8 years ago

it might be handy if it would throw an error (and console.log) if the filename path was invalid.

Where was it misspelled? In the .tesselinclude? Unfortunately there is no way to determine if a glob expression in the .tesselinclude file is invalid. No matches doesn't mean invalid :|

dudleyjosh commented 8 years ago

The actual file itself was misspelled. I would think that if the path to the filename doesn't exist it could be detected when play() is called and error when the file doesn't exist.

rwaldron commented 8 years ago

The actual file itself was misspelled. I would think that if the path to the filename doesn't exist it could be detected when play() is called and error when the file doesn't exist.

I will see if I can make this useful :)