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

No moving bars for cava with alsa #534

Closed
reluekiss opened this issue Nov 18, 2023 · 9 comments
Closed

No moving bars for cava with alsa #534

reluekiss opened this issue Nov 18, 2023 · 9 comments

Comments

@reluekiss
Copy link

reluekiss commented Nov 18, 2023

No description provided.

@reluekiss
Copy link
Author

reluekiss commented Nov 18, 2023

I am running cava using alsa, I read through the readme for it and followed the instructions (the loopback suggestion inside the asound.conf is really good). In any case I try to run the program, the bars appear but do not move. I used the default cava config, after having built it from source using the following make flags

make --disable-input-pulse --disable-input-pipewire

My asound.conf is as follows:


pcm.loopback {
    type plug       
    slave.pcm {
        type multi
        slaves {
            a { channels 2 pcm "duplex" }
            b { channels 2 pcm "hw:2,1" }  
        }
        bindings {
            0 { slave a channel 0 }
            1 { slave a channel 1 }
            2 { slave b channel 0 }
            3 { slave b channel 1 }
        }
    }
    ttable [
        [ 1 0 1 0 ]   # left  -> a.left,  b.left
        [ 0 1 0 1 ]   # right -> a.right, b.right
    ]
}

pcm.dmixspeaker {
    type dmix
    ipc_key 1024
    ipc_key_add_uid 0
    slave {
        pcm "hw:1,0"
    }
        bindings {
        0 0
        1 1
    }
}

pcm.dsnooped {
    type dsnoop
    ipc_key 1025
    slave.pcm "hw:1,6"
}

pcm.duplex {
    type asym
    playback.pcm "dmixspeaker"
    capture.pcm "dsnooped"
}

# Instruct ALSA to use pcm.duplex as the default device
pcm.!default {
    type plug
    slave.pcm "duplex"
}
ctl.!default {
    type hw
    card 1
}

This is the output of aplay -l

card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 0: HDA Analog (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 3: HDMI1 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 4: HDMI2 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 5: HDMI3 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sofhdadsp [sof-hda-dsp], device 31: HDA Analog Deep Buffer (*) []
  Subdevices: 1/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

I use OS: VoidLinux x86_64, kernal version 6.5.11_1
It's doubly weird as I have confirmed that the loopback works due to being able to record my system audio and mic with ffmpeg. I even tried to change the config file to be specifically

; method alsa
; source = hw:2,1 #and also hw:2,1,0 for good measure

while commenting out all other audio capturing methods.

@reluekiss reluekiss changed the title I am running cava using alsa, I read through the readme for it and followed the instructions (the loopback suggestion inside the asound.conf is really good) No moving bars for cava Nov 18, 2023
@reluekiss reluekiss changed the title No moving bars for cava No moving bars for cava with alsa Nov 18, 2023
@karlstav
Copy link
Owner

hi @reluekiss,

if you are able to record your system audio through hw:2,1 then cava should also be able to use this.

in your example above of the cava config you still have the semi colons in front of the config options, you will have to remove them for the setting to take effect, like so:

method alsa
source = hw:2,1

(i have to check, a lot of people fall in to this trap)

@reluekiss
Copy link
Author

Thank you for your quick reply, @karlstav I removed the semicolons and later found the comment in the config file to do so regardless. However the bars still don't seem to move while playing. I thought more information couldn't hurt and I use st as my terminal emulator. And that when allowing pulseaudio it would work on this machine. (between these tries I installed and uninstalled pulseaudio as well so there wouldn't be conflicts)

@karlstav
Copy link
Owner

could you test some other source devices in the cava config? like your mic? or set some random device just to make sure it reads the config at all.

@reluekiss
Copy link
Author

it seems to read the config (i double checked and used the -p flag) but I did as you suggested and tried using my mic as input and it did indeed pick up on it with the bars moving. it just seems as if it doesn't pick up on the system audio. this is quite possibly an issue with the asound.conf setup? as i retested what i did with ffmpeg and i was actually using 'default' as the input method which would actually be taking the duplex as the input rather than the loopback. as i tried to specify it to use the loopback device, which then didn't work.

@karlstav
Copy link
Owner

Makes sense, but I am confused, if you already have a device that you can record system audio from with ffmpeg, why not also use this device with cava?

I remember playing around with dsnoop and dmix stuff when first making cava years ago, but I was never able to understand the inner workings of alsa configuration. There is a layer of abstraction there that I simply can't wrap my head around. The loopback/combined solution was just something I copied from stackoverflow

@reluekiss
Copy link
Author

ok, after some fiddeling it now works, it was just an issue with my alsa config, if anyone would like some inspiration, its here:

pcm.dmixed {
    type dmix
    ipc_key 1024
    ipc_key_add_uid 0
    slave {
        pcm "hw:1,0" #your hardware speaker device
        period_time 0
        period_size 1024
        buffer_size 4096
        channels  2
    }
        bindings {
        0 0
        1 1
    }
}

pcm.dsnooped {
    type dsnoop
    ipc_key 1025
    slave {
        pcm "hw:1,6" #your hardware input device (mic)
        period_time 0
        period_size 1024
        buffer_size 4096
        channels 2
    }
    bindings {
        0 0
        1 1
    }
}

pcm.dmixerloop {
    type dmix
    ipc_key 2048
    ipc_perm 0666 # allow other users
    slave.pcm "hw:Loopback,0,0"
    slave {
        period_time 0
        period_size 1024
        buffer_size 4096
        channels 2 # must match bindings
    }
    bindings {
        0 0
        1 1
    }
}

pcm.out {
    type plug
    route_policy "duplicate"
    slave.pcm {
        type multi
        slaves {
            a { channels 2 pcm "dmixed" }
            b { channels 2 pcm "dmixerloop" }
        }
        bindings {
            0 { slave a channel 0 }
            1 { slave a channel 1 }
            2 { slave b channel 0 }
            3 { slave b channel 1 }
        }
    }
    ttable [
        [ 1 0 1 0 ]
        [ 0 1 0 1 ]
    ]
}

pcm.looprec {
    type hw
    card "Loopback"
    device 1
    subdevice 0
}

pcm.!default {
    type asym
    playback.pcm "out"
    #capture.pcm "looprec"
    capture.pcm "dsnooped"
}

ctl.!default {
    type hw
    card 1
}

remember to activate using

sudo modprobe snd-aloop

if you wish to activate it on startup, create a file in /etc/modules-load.d/snd-aloop.conf with snd-aloop and to set this as your source with cava

method = alsa
source = hw:Loopback,1,0

Also, thank you @karlstav for your help. I will now be closing this issue.

@reluekiss
Copy link
Author

boop

@karlstav
Copy link
Owner

no problem, this is nice stuff. I'll add your config to the example files and also add a note about it in the readme

karlstav added a commit that referenced this issue Nov 24, 2023
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