-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
No audio detected #35
Comments
is the no_mic version complete? (ok if it's not) I diffed it against master and I see that edit_alsa_conf() is commented out of install and edit_modules() was added. Looks like a loopback. Is some additional config needed to route properly? |
I followed this: |
Hey there, the no_mic version is complete, but you can consider it a version 1.0 since I still want to make it headless. The reason some things are commented out is because I'm trying to make the "mic" toggleable so that you can choose to use a mic or no mic during install or runtime. Once I have that done, I'll merge it into the master branch. If you run the edit_alsa_conf() function in the no_mic version, the lights won't work at all because the alsa config is edited to use a different audio device that is not the virtual device. I should have mention why it was commented out in the tutorial, but in my mind, it's temporary until I get the toggle working. The function also creates a backup of the alsa.conf file, you can restore it pretty easily. A couple of questions for @lucafossen:
Just want to make sure things were installed properly. Others reported similar issues and sometimes, reinstalling everything from scratch helped and other times, nothing worked. I reinstalled the no_mic version probably 8-10 times between my Pi 3 and Pi 4 and I can get it to run without issues every time. I usually follow my own videos to make sure I gave proper instructions. I'll keep trying to replicate and share a fix if I can get there. |
Ok thanks for that. I'm assuming the no_mic version allows one to feed the normal pi sound output (say HDMI) to the visualization. Is that correct? |
Yeah that's correct, except I can't get it to work with HDMI or the 3.5mm audio jack output. This only works with Bluetooth and USB Speakers. It might be possible to get this to run with HDMI output with some adjustments but the 3.5mm audio jack definitely won't work because there's some hardware/software limitation with the Pi (can't use that jack with a virtual mic). |
ok thanks, i'll look into it. If I find something working for HDMI i'll report back |
I seem to be having the same problem. Raspberry Pi 4B 2gb, full version of the OS, followed the install video step by step, but when I run it I get this:
I'm using a Soundcore 2 Bluetooth speaker, and accessing the pi through VNC Viewer. I've tried using VLC, mplayer, and the web browser. In all cases, the sound plays through the speaker, but the lights remain unlit. My LEDs are a strand of 50 WS2811s with a separate 10A power supply, and they function properly when I run strandtest.py More info:
I've tried everything I can think of, including starting from scratch with a fresh OS several times. I'm at a loss at this point. Any help would be greatly appreciated! |
Thanks for all the info @explorerswb! your setup looks exactly like mine (including the RPi 4 2gb). I blocked some time this coming weekend to go through my own video and redo everything and I'm hoping I can replicate it. Maybe something changed with Raspberry Pi OS since I did this in December because the frequency of reports like this has gone up. I'll record the set up as well and go through it from scratch. |
On a whim, I downloaded both the 2020-12-02 and 2020-08-20 versions of Raspberry Pi OS Full. I didn't update anything before running the install script, and the results were the same. So if this problem is the result of a software update, it would seem to be in one of the packages downloaded by the install script. I am also planning to try installing this on my RPi 3 B+ just to see if anything different happens, but that will have to wait for the weekend. |
Hey guys, just an update from my end - I'm trying to use this config: "Record audio from an application while also routing the audio to an output device" But it doesn't appear to work. I saw at least one error message in syslog which led me to update the Pi4's firmware (see here) but that didn't resolve the issue. I'm still an alsa newbie, so I'm going to keep digging in to see what other audio mixing mechanisms are available (and working) on raspberry pi. |
Hi @naztronaut , thanks for the reply.
I appreciate the time you take to help newbies like me! |
I have installed the full OS now, still getting the same issue.
|
@lucafossen sorry for hijacking your thread here, I considered opening a separate issue, but since it appears all of us here are cracking the same nut it made sense to keep posting on this thread. I hope you don't mind! I was able to get dancyPi working without a mic, i'm posting the details below so @naztronaut can work this into his installer on the weekend. First an important note about audio drivers on raspberry pi: As of Decemeber 2020 Raspberry Pi OS now uses PulseAudio as it's primary instead instead of Alsa. This is important because all my testing has been done on a Pi4 using Raspberry Pi OS Lite headless over ssh and as far as I can tell the lite version still retains Alsa as it's primary, but if you install the desktop versions they probably include PulseAudio. I'm going to experiment with that later but for now I highly recommend you start with lite and go headless. This is the best way to narrow down any issues your having. Also! Note that errors regarding jack server etc. are bogus and don't mean anything. They can be ignored.
Ok so here are the step-by-steps I used to get this working:
@naztronaut below is some code that might interest you. You might want to incoporate this into your installer, like maybe it could prompt them to choose? I used it to determine what input_device_index the pyaudio stream should listen to:
To test this code you can paste it into microphone.py underneath the line "p = pyaudio.PyAudio()" It will output something like this:
You will want to select the id corresponding to Loopback: PCM (hw:0,1) which is where the above config dumps out a copy of the default audio. To set the input_device_index, edit microphone.py like so:
With the above asound.conf and input_device_index you should be able to play sound through the default Alsa input, hear it on your output, and see it while running the visualizer against the loopback:
See the comments in the asound.conf for more test commands. If you want to use something like omxplayer, make sure you specify that it outputs to Alsa like so:
which demonstrates that any program you use must leverage the Alsa driver in order for this to work. |
Amazing work @VonHirsch! I'm going to try all of this out and make necessary updates to the project. It's interesting to read about Alsa and Pulseaudio. It's also funny how the update happened in Dec 2020. I think my installation is from the previous build so I never ran into this. And during reinstalls, the Pi Imager has just been installing a cached version of RPi OS. Good to know. Thanks! I'll let you know how my testing goes. Will try to do it this weekend but may need to move it to next weekend. I adopted a cat which is taking up a lot of my free time now :) |
@naztronaut thanks! Glad you like it. Oh yes don't worry about it, family and pets always come first! =) |
Hey @VonHirsch! Just wanted to let you know that I tried our your changes this weekend and unfortunately couldn't get it to work on headless mode. I can either play music through my speaker or have the lights dance, but not both at once. Everything is a fresh install and I followed your steps above. This is the issue I was having with the no_mic branch and why I required using the desktop/GUI. I'll keep playing around with it and see if I can figure it out. It's interesting that it works for you so I have hope that we can come up with a generic version of this app that works for everyone. |
Thanks for the update. On a similar note I've also found out that the configuration I put above is unreliable as the audio cuts out after a minute or so of running audio through the multi & loopback, and I can't seem to find any errors or messages in the logs. At first I thought it might have something to do with running the LED's, but I get the same cut-out behavior even if I don't launch any dancyPi code. I thought about running the alsa driver from source (which appears to be the only way to get debug output?) but that didn't seem like a simple proposition. The next thing I'm going to try is using pulseaudio to do the mixing. It's a more software / gui approach, but maybe if I can get it working in the gui I'll be able to extract the needed configs to run in headless mode. p.s. did you update your pi4's firmware? |
So I managed to get this working, reliably and reproducibly, but I'm honestly not entirely sure how. I was playing with setting up pulseaudio loopbacks via the pactl command, which seemed to work, but when I went back to reproduce it I accidentally tried testing the lights without those loopbacks and...it somehow still worked. So here are the steps to reproduce my (apparent) success. Hopefully someone with more experience with pulseaudio can explain why this works. Start with a fresh install of Pi OS Full. Set it up for VNC (or use KVM). At this point, the install script only installs dependencies. Run it. Edit config.py as necessary for your setup. Connect your speaker, and select it from the audio menu. I used a Soundcore 2 via Bluetooth. No, really. That's all I did, and it seems to be working like a charm. I tested it with VLC, aplay, pianobar, the web browser...it just works, and I have no idea why. |
@explorerswb I was able to reproduce your results! Good lookin' out. I guess we (or maybe just me!) were overthinking this situation :D I'm not sure why it works either because arecord -l shows no devices. I added the code to have pyaudio list out the devices it sees and I got this:
Then I set the input_device_index to each one and both worked, so i'm assuming "default" is just an alias to "pulse" ... at the moment I don't know much at all about pulseaudio, guess i'll have to read up about why pyaudio can read this stream so easily, but yea, it's good! On another note, before you posted I was also poking around with pulsesaudio. I started with the intermediate raspian image that comes with a desktop but not "recommended software." It didn't work out of the box (at least I don't think so) but I got the led's going by adding null sinks (a loopback basically?) and enabling simultaneous audio in paprefs as described here. After that dancypi worked with the default settings (I also commented out the replace_asound() and edit_alsa_conf() lines in install.py for these experiments) Next step for me is to see if I can get RetroPie and pulseaudio working together. I'm not sure if that will be challenging or not. |
Say what @explorerswb? This works without the long asound.conf file? I'll have to try it out this weekend. I wonder if the changes to alsa and pulseaudio in December did something because I tried this exact set up months ago and it wouldn't work without setting up the loopback device. Who knew, I should have just waited another month to update my tutorial, would have been way easier. Thanks for t he tip! Good luck with Retropie & pulseaudio @VonHirsch! Maybe it'll be easier than you think :) |
Hey guys, was hoping to try and get this to work for a show this upcoming weekend, but the audio input isn't working since the last time I tried this project- I get the same errors when I try to run visualizations as the ones written in the original post. I don't really need the LEDs to play off anything else and didn't need it to run in headless mode, but the old version of the tutorial did work with the mic and the new one doesn't is what I'm gathering? I tried doing both tutorials though and I was unable to solve anything. The mic functionality seems to have disappeared and it was all I really needed. |
Hi @D500844 - the mic function is still there. The Master branch hasn't been touched Are you getting any errors? The mic version requires you to specify the hardware in asound.conf: https://github.com/naztronaut/dancyPi-audio-reactive-led/blob/master/python/install/asound.conf So make sure you have the correct hw selected. You can confirm the number with this command:
|
I do have the same specifications in asound.conf as described in that link, the results of cat /proc/asound/cards is as follows; 0 [b1 ]: bcm2835_hdmi - bcm2835 HDMI 1 The error I get when I run the visuals is No audio input. Volume below threshold. Volume: 0.0 but the mic is plugged in. I've noticed it works if I run audio through the pi but it knocks the fps down to 21. The actual LED strip looks like its changing once every ~3 seconds. Barely running. Without the mic being the source of audio though I am out of shape. |
Is your mic installed correctly? It's not on the list. By default, the install script will use hardware 1 as the default input device, in your case it's the headphones which isn't an input device. Try plugging in your mic, restart your pi, then run that command again and see if your mic shows up. If it does appear and it's not listed as hardware 1, edit |
I'm using the Fifine USB K669, after plugging in and restarting same result; 0 [b1 ]: bcm2835_hdmi - bcm2835 HDMI 1 gonna reinstall OS. *New Edit: I Believe I have it working now, OS install issue- sorry for the trouble but thank you for the help! |
Awesome! Glad you got it working :) It's always something simple. Enjoy your project! |
btw @naztronaut, I ended up going with a hardware solution to drive led's for retropie. I use a USB Audio Dongle and headphone splitter to drive external speakers & a separate ESP32 circuit. The circuit and sketch are detailed in this repo. A software solution (running dancyPi & retropie at the same time) would have been super slick! but a hardware "plug & play" solution is proving easier manage. There's still setup on the pi / retropie side, I have to setup default pi and emulationstation audio to the usb card (aplay -l to find card #) and in one case I had to modify a shell script that uses omxplayer to use the correct card (omxplayer -o alsa:hw:2 ... or whatever your card # is) but it's manageable. Still lovin' this repo tho. The boilerplate effects are a lot of fun. I might have to ponder on some of that code for ESP32 ;) |
That's an awesome set up! Glad you have things working. Manageable is still better than not working at all :) Keep me posted on your progress, it looks awesome. I have a bunch of ESP8266s, I wonder if I can get it running there. I probably won't do anything significant like you but I like playing with new things :) I starred that repo. Will be back to it at some point. |
hello. i have a raspbery 4 8gb. ive tryed the video twice and i still get the no audio detected error. ive tryed several of the steps above but non of them fix it for me. |
Did you try @explorerswb's method as well? #35 (comment) You may have to start fresh, in case you were trying to override what you did before attempting that. I'm just gonna copy/paste some of my questions from earlier if that still doesn't work for you:
|
yes im running the full raspbery os. i ran the visialozation.py in the terminal where i typed all the comands in. i can hear the sound coming from the speakerand the outputs: pi@raspberrypi:~ $ cat /etc/modules /etc/modules: kernel modules to load at boot time.This file contains the names of kernel modules that should be loadedat boot time, one per line. Lines beginning with "#" are ignored.i2c-dev snd-alooppi@raspberrypi:~ $ arecord -l pi@raspberrypi:~ $ aplay -l |
The 'snd-aloop` line in your modules file means that you may not have done a fresh install. Can you reinstall Raspberry Pi OS and try what's posted here: #35 (comment) A few of us were able to replicate so it might work for you too. |
do i need to set it up for vnc? |
ok, it worked for me, but its only 25fps. is there a way to make it better? |
Great, glad you got it working! How many lights are you trying to run and how much power are you providing? Low FPS is typically a power issue. if you're powering your lights directly from the Pi, try powering the lights from an external power source. |
yea i have 300 leds ant they are powered from a 20 amp power suply. i get low fps before even pluging them in and i have 8gb of ram and my pi is overclocked so i dont know what else could be the issue |
Are you powering them through the Pi or are you using external power? If you're doing it through the pi, try powering them externally. The Pi can't pass too much current through its board (I don't know what the limit is). I typically use external power if I need to use more than 3A of current. If you still get low Fps, try setting the LED count to 100 or something and see if it helps. Just to rule out hardware. |
I am also struggling with this. 1st attempt was with the no_mic branch. Toggling the "audio output device" in VLC, I could either get the BT play sound OR the PCM Loopback device deliver the sound to visualization.py but not at the same time. 2nd attempt: Since my rpi was already all mixed up with various attempts and I found this topic, I tried to follow the master branch solution posted by @explorerswb and start from fresh Raspberry OS installation and exactly the given commands. It didn't work for me: trying to run the visualization.py results in pyaudio fault Curiously, I found that in my setup the devices listed by pyaudio are different with and without sudo. The error reproduces with message
When running without sudo, the snippet finds a default input device called Blaming the user stuff I tried the following:
Before I jump back to trying out the no_mic again, could you @explorerswb answer the following:
|
I haven't looked at this for a while, so it's possible updates to the OS have made the solution I posted obsolete. My Pi is currently in use on another project, so I sadly can't test it out myself right now. I do have the working setup on an SD card, so if I get a chance I'll try to hook it up and test it out this weekend.
|
@lassi-niemisto, I just had a thought, and I wanted to check with you before I started digging into this. I think I remember that error message. Are you connecting to the Pi via SSH? As far as I know, nobody has managed to get this working headless. You MUST connect either remotely via VNC Viewer or with a keyboard and monitor physically connected to the Pi, or else it will give you an error message that, if I'm remembering correctly, is very similar to that one. |
Thanks for your quick replies @explorerswb! Yeah I am running the stuff over VNC as instructed (tightvnc server to be precise, wouldnt believe the choice of VNC is meaningful here). |
@naztronaut - since it is clearly challenging to get the audio shared from output device to an input device, have you considered the following approach: Use pyaudio to write the audio file to output device directly and analyze the written samples for led control (no need to read them from audio device)? |
Tested my above idea of write instead of read with positive results. Also found a way to run the visualization without root user which makes accessing the bluetooth speaker much easier. For non root operation: Gonna post the direct-feed-audio version of However at least I can run this completely headless now 😎 |
nice, good job, looking forward to the PR! |
Sounds like you've made really nice progress. I'm very interested in seeing what you've come up with. I assume you don't need me to dig into my old configuration anymore (honestly, you've gone far deeper into the guts of this than I ever did), but if you do still need anything from me just let me know. |
Yeah no need for more investigation @explorerswb , thanks anyway! Pull request for direct audio player mode is here #48 |
Does the "Pull request for direct audio player mode #48" only allow for visualization of pre-recorded audio? |
@VonHirsch There is a config.py setting for enabling the "audio player mode" and passing the directory of .wav files. Otherwise it should work still with microphone also, but I haven't tested it. |
Ok, my misunderstanding then. When you said you were working on a solution I thought it was about addressing the "live mode" rather than adding on an "audio player mode" |
I was curious to try this as well because I've hit the same issues this thread is discussing -- but I can't get pyaudio to produce output either (tried all of the output device indexes). What was your config for the pyaudio stream? Edit: @lassi-niemisto I've reduced my situation to pulse audio not working under sudo. Struggling to figure out why this doesn't work and how to restart pulseaudio as --system (because I do believe we need sudo for neopixel) Edit2: Yup - okay, lassi's changes worked in #48 by basically giving the |
@raymondjacobson Great to hear my changes and the trick were helpful! I hit the same challenges with pulseaudio system mode, top bar broke etc. Maybe the best thing would be to split the led control to a system service and command it over e.g. localhost tcp from the application/pulseaudio code running as a regular user. |
Hi all. Great project here @naztronaut. I seem to be getting a similar result to others, the no audio detected issue. Cheers all. Jonno. Update: So i have managed to get it to work with the mic. I took a punt and installed an older version of raspian dated late last year. Then ran the install. It complained it was missing some updates, so i then did a complete update and upgrade and ran the install again. This seemed to get it up and running. I've saved an image of the sd card and now going to try the no mic version. |
Great thread and very useful tips.
|
Hi, I'm trying to run the no_mic version and I'm running into some issues. Here is the log:
It then just repeats the last line about volume being 0.0 forever, with 33-36 FPS logs in between.
Is something not installed?
Thanks for any help :)
The text was updated successfully, but these errors were encountered: