ofxPiMapper icon indicating copy to clipboard operation
ofxPiMapper copied to clipboard

Audio Playback

Open magdesign opened this issue 9 years ago • 18 comments

Is there any chance to enable audio playback to the minjack?

This would be amazing! Or is it already available and I miss something?

magdesign avatar Aug 03 '16 16:08 magdesign

I think this is what you have to do: https://gist.github.com/jvcleave/4972661

kr15h avatar Aug 03 '16 17:08 kr15h

And VideoSource::enableAudio = true;

kr15h avatar Aug 03 '16 17:08 kr15h

Thanks for the hint. I changed in: example/src/ofApp.cpp line 8: ofx::piMapper::VideoSource::enableAudio = true;

and in: src/Sources/VideoSource.cpp line 6:bool VideoSource::enableAudio = true;

Audio now plays back thru HDMi but sounds very glitchy... Maybe the change in src/Sources/VideoSource.cpp is not necessary. Will figure out how to change to mini jack (the modprobe solution does not have any effect) and will post results later. Compiling just always takes soooo long :-) Also tried with compiling ofxOMXplayer basic example, no glitch there....

Maybe there are some other tricks as well.....anyone?

magdesign avatar Aug 04 '16 14:08 magdesign

It might be also audio encoding problem. Have you tried to play back the video from commandline using omxplayer?

kr15h avatar Aug 04 '16 18:08 kr15h

The compiling is a bit of a mystery to me as it seems that it did compile faster on the older Raspberry Pi's . Maybe there is something that has been changed in oF. Might be interesting to dig into that. But crosscompiling setup is soo needed for me now. Have to work on that. Make a kind of a network-boot development platform.

kr15h avatar Aug 04 '16 18:08 kr15h

Yea, audio is smooth with omxplayer, jack and hdmi. We compile omxplayer with cross-compiling... sd cardreader on centoOS computer.. its very fast, will check if this would also work with ofx. Maybe there is an option to allocate all 4 cores before compiling on the pi.... its just such a pain to wait soo long after changing an option :-)

magdesign avatar Aug 04 '16 19:08 magdesign

After messing with raspi-config, conf.txt, .asoundrc, amixer cset and alsa stuff, I figured out that there is a line in: src/Sources/VideoSource.cpp on line 28 which must be changed to: settings.useHDMIForAudio = false;

I'm not on the newest PiMapper version, so it might be that you don't have this line, then change it in: src/Sources/OMXPlayerCache.cpp on line 21

compile and after that, audio is working on jack.

The Audio quality is not the best, but for my purpose it works so far....

magdesign avatar Aug 07 '16 12:08 magdesign

ok, maybe adding a config variable for this one would be a good idea..

kr15h avatar Aug 07 '16 13:08 kr15h

jap, that would be amazing!!

magdesign avatar Aug 07 '16 13:08 magdesign

So I added a simple flag that should be set before running piMapper.setup(). Use VideoSource::useHDMIForAudio = true; to enable HDMI audio output.

kr15h avatar Aug 12 '16 09:08 kr15h

Is there a chance to output audio to an ALSA device ?

For example: VideoSource::usealsa:hw:1,0 = true

magdesign avatar Dec 20 '16 21:12 magdesign

Good question. I think that due the changes in the ofxOMXPlayer API this is not working anymore.

kr15h avatar Dec 20 '16 22:12 kr15h

Opened an issue on ofxOMXPlayer concerning ALSA support. Hopefully jvcleave will update his fork of omxplayer. https://github.com/jvcleave/ofxOMXPlayer/issues/101

magdesign avatar Jan 12 '17 14:01 magdesign

Just figured out that you made a lot of changes in the code. Seems to me that you dont use ofxOmxplayer anymore, its not listed in the dependencies anymore. Does this mean its now possible to have ALSA support? What videoplayer do you use now instead?

magdesign avatar Mar 18 '17 20:03 magdesign

It is still there in the stable branch. I am developing the master branch to be compatible with the openFrameworks master branch now. The removal of ofxOMXPlayer has to be tested still. Will do this the following week. I removed the ofxIO and am removing the ofxOMXPlayer dependencies because most of the configuration problems from users are related to these addons.

kr15h avatar Mar 18 '17 20:03 kr15h

And in the stable branch there are steps how to make the sound work. I mean. I tested it last week with alsamixer and omxplayer - it was working without problems. The trick might be that you should set the volume to 90 - 100% in alsamixer

kr15h avatar Mar 18 '17 20:03 kr15h

Cool, thanks! will test this, great effort.

magdesign avatar Mar 18 '17 20:03 magdesign

Is it currently possible to output to a USB sound device ? I have a USB soundcard which is set to default in Raspbian but sound still plays from the built-in jack

natcl avatar Sep 07 '17 15:09 natcl