Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help needed to set it up :) #4

Closed
tociek opened this issue Dec 18, 2014 · 17 comments
Closed

Help needed to set it up :) #4

tociek opened this issue Dec 18, 2014 · 17 comments

Comments

@tociek
Copy link

tociek commented Dec 18, 2014

Ok, I did step by step instalation, but I guess I do not fully uderstand the part about .asoundrc configuration.

Here is what I get from aplay -l
jacwk@jacwk-HP-ENVY-17-Notebook-PC:~/hyperion-audio-effects$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: 92HD91BXX Analog [92HD91BXX Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 2: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 2: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7

How should my .asoundrc file look like?

when I start the app i get this output:
jacwk@jacwk-HP-ENVY-17-Notebook-PC:~/hyperion-audio-effects$ python main.py --gui
effect
(1L, 2L, 4L, 0L)
Using pipeline: autoaudiosrc ! level message=true interval=50000000 ! fakesink
Bus connected.
Pipeline STATE_PLAYING set.
Pipeline initialized.

But nothing happens, even in gui mode.

@RanzQ
Copy link
Owner

RanzQ commented Dec 19, 2014

The output seems fine, I have some debug prints left there. The necessary part in .asoundrc is the line i have commented: slaves.a.pcm "hw:0,0", it should match to your output device, which should be "hw:1,0" if you are using analog output (other devices u have are hw:0,3, hw:0,7, hw:0,8).

What the alsa config does, it creates a duplicating router (multi_dev) which shares your default sound output (alsa_sink) to hardware card (hw:1,0) and loopback card (hw:Loopback,0,0) which is then set as default recording device. This enables a software loopback.

Another option would be to use loopback recording (Stereo mix) from soundcard straightly, I tested it on Windows.

I still doubt if the loopback thing works with pulseaudio, KodiBuntu ships without pulse (better sound quality etc.) so I haven't tested it with it.

EDIT: Oh, and what I forgot from the instructions, you should reboot after modifying .asoundrc or at least reload alsa sudo alsa reload

@tociek
Copy link
Author

tociek commented Dec 19, 2014

None of the setting in .asoundrc worked :(

How can I debug further?

@RanzQ
Copy link
Owner

RanzQ commented Dec 20, 2014

You can test Gstreamer without python like this: gst-launch-1.0 audiotestsrc ! autoaudiosink. You should hear constant beep. Try the autoaudiosink first, then change it to alsasink device="hw:1,0".

If you hear beep, you can test the level plugin like this: gst-launch-1.0 audiotestsrc ! level ! autoaudiosink --messages. You should get messages printed to console.

If that works, try gst-launch-1.0 autoaudiosrc ! level ! fakesink --messages and play some music. It should print messages (I didn't see a difference if I play music or not, but that is the pipeline the python app uses).

What are you using for playback? I have tested with VLC, audacious and Spotify, all of them work.

You can also get detailed debug messages from Gstreamer by adding --gst-debug=*:5 to the command. But neither I did understand very much about them.

If those tests don't work, it might be a problem with pulseaudio, I should test myself how to setup pulseaudio with this. You can check if u have pulseaudio: pgrep pulseaudio. In that case you can test if you get any sound with gst-launch-1.0 audiotestsrc ! pulsesink.

@tociek
Copy link
Author

tociek commented Dec 20, 2014

jacwk@jacwk-HP-ENVY-17-Notebook-PC:~$ gst-launch-1.0 audiotestsrc ! alsasink device="hw:1,0"
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback. Device is being used by another application.
Additional debug info:
gstalsasink.c(846): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Device 'hw:1,0' is busy
Setting pipeline to NULL ...
Freeing pipeline ...

@RanzQ
Copy link
Owner

RanzQ commented Dec 20, 2014

Ok, I believe that pulseaudio takes control of your device. Check the last chapter I wrote.

@tociek
Copy link
Author

tociek commented Dec 20, 2014

jacwk@jacwk-HP-ENVY-17-Notebook-PC:$ pgrep pulseaudio
1755
jacwk@jacwk-HP-ENVY-17-Notebook-PC:
$ gst-launch-1.0 audiotestsrc ! pulsesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstPulseSinkClock
^Z
[2]+ Stopped gst-launch-1.0 audiotestsrc ! pulsesink

I got the "beep" sound.

@RanzQ
Copy link
Owner

RanzQ commented Dec 20, 2014

Ok, so you have pulseaudio. I need to investigate further if it's possible to make the loobback device work with it.

EDIT: Check also if your card has internal loopback, show the output of arecord -l

@tociek
Copy link
Author

tociek commented Dec 20, 2014

jacwk@jacwk-HP-ENVY-17-Notebook-PC:$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: PCH [HDA Intel PCH], device 0: 92HD91BXX Analog [92HD91BXX Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
jacwk@jacwk-HP-ENVY-17-Notebook-PC:
$

@RanzQ
Copy link
Owner

RanzQ commented Dec 20, 2014

Only one input device, so either the driver doesn't support loopback or it doesn't have one.

@tociek
Copy link
Author

tociek commented Dec 20, 2014

On Windows 8.1 I haven't got GUI drawn properly :( (endless "busy" circle as a mouse pointer and window is "not responding")

@RanzQ
Copy link
Owner

RanzQ commented Dec 21, 2014

There might be some issues with Tk (gui) on Windows. Also the PyGObject didn't run smoothly for me either. Even without the gui it was laggy.

I'm going to install pulseaudio back to my virtualbox machine to see if I get this running with it. It should have monitor device by default, according to these instructions:
http://manual.audacityteam.org/o/man/tutorial_recording_computer_playback_on_linux.html

I wanted to use alsa only at first cause my HTPC doesn't have pulseaudio.

@RanzQ
Copy link
Owner

RanzQ commented Dec 21, 2014

Ok, I was able to get it working on my virtualbox. Remove (or rename) the .asoundrc, it's not needed with pulse. Reload alsa sudo alsa force-reload, then launch pavucontrol, play some music and start the python application. Now the python application should appear as recording application:

pavucontrol

I selected "Monitor of Built-in Audio Analog Stereo" as input and now GUI draws bars. After quitting pavucontrol and restarting python it remembers the setting. Test if this works for you, I can then update the instructions.

@RanzQ
Copy link
Owner

RanzQ commented Dec 21, 2014

Using ALSA without pulseaudio is lighter though. People have also reported that sound quality is not so good with pulseaudio. Check these CPU usages (left is my virtualbox with pulse, right is my htpc):

pulse vs alsa

@tociek
Copy link
Author

tociek commented Dec 21, 2014

Yes, that works. There are still some values hardcoded in effects file, and those from main.py are ignored.
Effect already looks interesting, but I would like to modify it, to make it even more spectacular. Could you provide how-to for that?

That already looks very promising... :)

@RanzQ
Copy link
Owner

RanzQ commented Dec 21, 2014

I've created 3 effects, all of them are quite basic and need modifications to be cool. Effects are in folder effects/ copy one of them (spectrum_dump.py is not effect, it's used for manipulating the messages received from gstreamer). Then you can use your own effect like main.py --gui --effect=my_effect (default is vumeter).

Latest thing I tried is to map the spectrum levels to brightness of the leds.

The important parts of the effect file are these:

Here you init the spectrum dump (see spectrum_dump.py for explanation of those parameters):
spectrum = GstSpectrumDump(source='autoaudiosrc', vumeter=False, quiet=True, bands=effect.bands, interval=20, callback=effect.receive_magnitudes)

Basically it can give you 2 types of data, volume levels (vumeter=True) or frequency spectrum (vumeter=False).

And here you handle the magnitudes you receive:

def update_leds(self):
    ...

If it takes too much cpu, you can set longer sleep, time.sleep(0.01) (means "wait 10ms") or adjust the interval of messages.

Sorry for uncommented code... :)

@RanzQ
Copy link
Owner

RanzQ commented Dec 27, 2014

@tociek what about the lightberry? I'd like to make this compatible with pi too but I don't own one. ;)

@tociek
Copy link
Author

tociek commented Dec 27, 2014

@RanzQ drop me an email via Lightberry website

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants