vicwomg / pikaraoke

Youtube-based Karaoke machine for Raspberry Pi, OSX, Windows, and Linux
527 stars 136 forks source link

USB MIC not working #124

Open GST5555 opened 3 years ago

GST5555 commented 3 years ago

I conected an USB mic to the raspberry and the mic works fine on the raps, but with this application is useless, any idea how to mix the input of the mic with the karaoke ?

vicwomg commented 3 years ago

You'll need to somehow pipe your USB audio mic input into the output (HDMI or line out). See: https://stackoverflow.com/questions/54452020/raspberry-pi-redirect-usb-microphone-to-hdmi-audio

I don't personally recommend this setup due to latency. You'll get 0.3-1 sec delay in audio output, and you will notice it. That's just the nature of USB audio. Instead, I recommend getting a separate set of microphones and a mixer. There is a link in my readme for an all-in-one solution (2x wireless mics with mixer built into the receiver)

https://github.com/vicwomg/pikaraoke#where-do-i-plug-in-a-microphone

vicwomg commented 3 years ago

Piping audio input to HDMI output is possible with a USB microphone device, but my guess is that you're not going to find the latency usable

First find out the card/device number of your audio input, by running arecord -l

pi@pikaraoke:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 2: Device [USB PnP Audio Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

In this example, my USB microphone is Card 2 and Device 0. Therefore my device is "hw:2,0" which I plug into this arecord's -D parameter, and then pipe audio to playback.

arecord -D hw:2,0 -f CD -c 1 -- | aplay

You'll be able to hear your mic through your TV, but it will be delayed by almost 1s.

For now, this is why I do not recommend this sort of setup. Unless someone can figure out how to get the latency down. But it seems to me like a limitation of the pi.

vicwomg commented 3 years ago

fwiw, I did try tinyalsa as recommended in the above stackoverflow, and for hw device 2, the command was:

tinycap -- -D 2 -c 1 -r 48000 -b 16 | /usr/local/bin/tinyplay -

The latency was much better, but the playback sounded pitched up, like the chipmunks. No amount of messing with the sample rates seemed to fix it, but you may have better luck with your setup.