Pisound and Darkice / Icecast

Hello, i try to setup an internet radio.
Everything is fine with pisound-config, driver is ok : hw:1,0
But when i stream an audio to IN, nothing happens.
With darkice, message i clear :
Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:1,0
Using POSIX real-time scheduling, priority 4
0 bytes transferred to the encoders
So, 0 bytes : nothing is entering into pisound.

arecord -D hw:pisound -c 2 -r 48000 -f S16_LE | tee recording.wav | aplay -D hw:pisound -

gives me… nothing at all : a file is recorded with no sound, and there is no sound in my headphone…
I think i 'm missing something, but what ?
I’ve got an undervoltage with dmesg : is it possible pisound works, with red leds, buttons ok, but can’t proceed with sound because low voltage ?

Thanks a lot for helping me.

Hey, if the power supply is underpowerd, audio input may not work. What is the power supply you are using? We recommend 5V, 2.5A one, like this: https://www.raspberrypi.org/products/raspberry-pi-universal-power-supply/

I was using an Iphone 5c power supply (yes, i know, it’s not right). I ordered official Rpi’s power supply. I let you know if it’s working fine with the right power supply or not. I hope so.

So, i’ve got my Rpi official power supply. dmesg says nothing bad about voltage. When i plug In pisound (mix table), there’s a red light on Pisound. If have 0 sound, no more red light : Pisound gets the sound, so ?
But if i plug phones headers to the Out on pisound : nothing, no sound. And my darkice sends 0 bytes, because it can’t get sound, i think :
Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:1,0
Using POSIX real-time scheduling, priority 4
0 bytes transferred to the encoders

dmesg :
pisound: Searching for spi device…
[ 8.051905] pisound: Found!
[ 8.127381] pisound: Detected Pisound card:
[ 8.127393] pisound: Serial: PS-0WGWHD6
[ 8.127399] pisound: Version: 1.01
[ 8.127404] pisound: Id: 1e93153555313630360a032a
[ 8.131165] snd-rpi-pisound soc:sound: snd-soc-dummy-dai <-> 3f203000.i2s mapping ok

I deactivated intrenal sound card. Pisound is on hw:0,0
darkice finds it, but 0 byte…

So, i’m really sad : don’t know what is wrong.

Does Pisound get input and produce output when used with other software, like Pure Data, Audacity, etc…?

This command is a audio test utility, it should produce audio output on left and right channels, one at a time:

speaker-test -c2 -r48000 -Dhw:1,0

I get some “breath noise”, yes. left and right.
So, it means that it’s working “inside”, but why input sound doesn’t proceed with sound ?
My microphone an all stuff are received by Pisound : when i speak, red led lights. When i play music from my computer, pisound reacts with red led. But no sound out and nothing comes in for darkice.
Don’t understand.

Ok, i played a .wav on pisound with aplay, and it’s going to headphone.
aplay -D hw:0,0 file.wav
Pisound can treat a sound file and play it out.
But, nothing coming IN with jack entry is listenable with OUT jack entry.
When i “aplay” .wav if i launch darkice, same thing : no error and “0 bytes transferred to the encoders”.

sudo pisound-ctl :

[3699] main: Pisound Control Server 1.03 starting…
[3700] process: Processing thread started
[3701] monitor: dbus msg p=’(null)’ iface=’(null)’ memb=’(null)’, dest=’:1.15’
[3708] process: Processing thread started
[3699] main: Network init failed. (-1)

Why network init failed ?

[ 9.150803] pisound: Searching for spi device…
[ 9.150816] pisound: Found!
[ 9.197134] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
[ 9.199958] bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
[ 9.225796] pisound: Detected Pisound card:
[ 9.225806] pisound: Serial: PS-0WGWHD6
[ 9.225812] pisound: Version: 1.01
[ 9.225817] pisound: Id: 1e93153555313630360a032a
[ 9.228587] snd-rpi-pisound soc:sound: snd-soc-dummy-dai <-> 3f203000.i2s mapping ok
[ 9.262728] bcm2835_v4l2: module is from the staging directory, the quality is unknown, you have been warned.
[ 9.276622] bcm2835_codec: module is from the staging directory, the quality is unknown, you have been warned.
[ 9.473741] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 9.597005] cfg80211: Loaded X.509 cert ‘sforshee: 00b28ddf47aef9cea7’
[ 9.613854] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 9.613873] cfg80211: failed to load regulatory.db
[ 9.788980] brcmfmac: F1 signature read @0x18000000=0x1541a9a6
[ 9.794447] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[ 9.794691] usbcore: registered new interface driver brcmfmac
[ 9.892378] bcm2835-codec bcm2835-codec: Device registered as /dev/video10
[ 9.892389] bcm2835-codec bcm2835-codec: Loaded V4L2 decode
[ 9.895624] bcm2835-codec bcm2835-codec: Device registered as /dev/video11
[ 9.895636] bcm2835-codec bcm2835-codec: Loaded V4L2 encode
[ 9.899013] bcm2835-codec bcm2835-codec: Device registered as /dev/video12
[ 9.899022] bcm2835-codec bcm2835-codec: Loaded V4L2 isp
[ 10.097347] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[ 10.097454] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
[ 10.098132] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Aug 7 2017 00:46:29 version 7.45.41.46 (r666254 CY) FWID 01-f8a78378

Try running this command - it should forward whatever is coming to the input directly to the output.

arecord -D hw:pisound -c 2 -r 48000 -f S16_LE | aplay -D hw:pisound -

If this command works, then Pisound is functioning properly, that’d mean that the issue is most likely somewhere in the software configuration, but before getting into that we first must make sure that Pisound works OK.

The red LED lights up whenever the input signal is too loud, so once you get everything running, you should aim for it to never light up, otherwise sound clipping occurs. :slight_smile:

pisound-ctl is the background service for working with the Pisound mobile app, the init failed, because background instance is already running. It is an optional service, you can disable it with sudo systemctl stop pisound-ctl and sudo systemctl disable pisound-ctl.

Ok. Red light is a clip… good to know.

It works. Meaning i haven’t still understood how it should work.
So i have to aplay -D to get sound flow from Pisound.
Excellent ! Thanks a lot.
Darkice is now with that : DarkIce: DarkIce.cpp:1273: can’t open connector [0]
I’m going to find out how to make it works… I suppose it’s a bad option with my Icecast Server.

I just tried using the steps from https://blokas.io/pisound/docs/Example-projects/#internet-radio-station - it set up streaming successfully on my Raspberry Pi + Pisound. This is the output I get when I run darkice:

pi@raspberrypi:~ $ darkice
DarkIce 1.3 live audio streamer, http://code.google.com/p/darkice/
Copyright (c) 2000-2007, Tyrell Hungary, http://tyrell.hu/
Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz
This is free software, and you are welcome to redistribute it
under the terms of The GNU General Public License version 3 or
any later version.

Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:1,0
Using POSIX real-time scheduling, priority 4

/etc/darkice.cfg contains exactly the same stuff as in the guide.

I can hear the audio that goes to the Pisound’s input on another device by going to http://192.168.1.150:8000/ and opening the .m3u file with a media player. 192.168.1.150 is the IP address of the Raspberry Pi in my local network, it will likely be different in your case, but the :8000 part should be the same.

Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:0,0
Using POSIX real-time scheduling, priority 4
DarkIce: DarkIce.cpp:1273: can’t open connector [0]

My darkice config seems ok, i’ve tested an other way to stream to my Icecast server and it’s working fine. I’m just missing something, but what ?

# this section describes general aspects of the live streaming session
[general]
duration      = 0                # duration of encoding, in seconds. 0 means forever
bufferSecs    = 2                # size of internal slip buffer, in seconds
reconnect     = yes              # reconnect to the server(s) if disconnected

# this section describes the audio input that will be streamed
[input]
device        = hw:0,0           # Alsa soundcard device for the audio input
sampleRate    = 48000            # sample rate in Hz. try 48000, 96000 or 192000
bitsPerSample = 16               # bits per sample. try 16
channel       = 2                # channels. 1 = mono, 2 = stereo.
                                 # Only stereo mode is supported by Pisound.

# this section describes a streaming connection to an IceCast2 server
# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections
[icecast2-4]
bitrateMode   = cbr              # variable bit rate
bitrate       = 128
format        = mp3              # format of the stream: mp3
quality       = 0.8              # quality of the stream sent to the server
server        = [IP address]
port          = 8001             # port of the IceCast2 server, usually 8000
password      = mypassword (for admin)           # source password to the Icecast server
mountPoint    = live.ogg          # mount point of this stream on the IceCast2 server
name          = live           # name of the stream
description   = Live DarkIce on Pisound # description of the stream
url           = http://url.tld # URL related to the stream
genre         = radio         # genre of the stream
public        = no               # advertise this stream?
#localDumpFile = recording.mp3   # Record also to a file

You have hw:0,0 as the device, which is usually the built in raspberry Pi audio port, unless it is disabled. You can use hw:pisound instead just to be sure Pisound gets used.

There’s quite a few other differences there, like you have [icecast2-4] instead of [icecast2-0], the port is different, the IP address is not set (or has been redacted?), etc…

hw:0,0 is normal : i disabled internal soundcard to be sure there’s no conflict. I tried with hw:pisound, it’s working fine too.

I have a 2.4.0 icecast server. And i use 8000 for a playlist, 8001 is the second Icecast port listening, and mountpoint is live.ogg. It’s working perfectly with an other audio streamer (on Mac).
I changed IP adress, yes as passwords :-). But all theses parameters (real ip address, port 8001, real url, work with an other software). I think there’s something i don’t correctly write, but what ?

DarkIce: DarkIce.cpp:1273: can’t open connector [0]

This error probably means that Pisound’s input is currently in use by some other audio software, so darkice did not actually start.

Ok. But, yes : it’s
arecord -D hw:pisound -c 2 -r 48000 -f S16_LE | aplay -D hw:pisound -
Then, if i stop aplay :
Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:0,0
Using POSIX real-time scheduling, priority 4
0 bytes transferred to the encoders

So, i’m going back to my first issue : no sound when i don’t aplay pisound and so darkice does nothing, or i aplay, sound is coming but darkice can’t operate… because pisound is in use with aplay…

The arecord | aplay command was just for verifying that Pisound works, it does not need to be run to broadcast Pisound’s input via darkice. It should be possible to make multiple audio programs work with darkice if using Jack backend, or via Jack-ALSA bridge.

I don’t get such message at all on my system. How are you testing for audio output?

Yes, i understand it was for testing. But if i dont use aplay, there’s nothing into my headphones (plugged to pisound output). And so, if i dont use aplay, darkice doesn’t broadcast. Should i listen to my audio stream with headphones plugged to the pisound output without using aplay command or not ? That’s my issue i think so…

I plug my headphones to pisound output : nothing at all. But if i do aplay command, i get sound, my stream.

If you want to hear what’s being streamed, you have to listen to the stream either on another device, or with mplayer like this:

mplayer -ao alsa:device=hw=pisound http://192.168.1.150:8000/pisound

adjusted for your URL.

Or if you want to hear direct playback of the stream, then you should configure darkice to use Jack backend, it allows for doing custom routing between hardware and software as necessary.

I think it would be a good idea for you to first get the example config running, maybe on a ‘clean’ OS image, so that you have a simple working state, and then you can figure out how to customize according to your needs.

Ok. Understood. But would it means i’m obliged to setup a local Icecast ? My Icecast server is on the net and i can’t stream from pisound via darkice ? Hum… I’m going to setup jack and see if i can adjust routing, yes.