Unable to initialise AudioDeviceManager in Linux ( raspberry pi)


#1

Hi , I am building a player using JUCE and I was unable to get initialise audio device.
Here is my code and errors I got :

For
deviceManager.addAudioCallback (this);
deviceManager.setCurrentAudioDeviceType(“ALSA”,true);
#ifdef APPLE
juce::String status = deviceManager.initialise (2, 2, nullptr, true, {}, nullptr);
#else

AudioDeviceManager::AudioDeviceSetup AudioSetup;
AudioSetup.sampleRate = 44100;
AudioSetup.bufferSize = 512;
AudioSetup.inputChannels =2;
AudioSetup.inputDeviceName =  device.name; //"snd_rpi_hifiberry_dacplus";

// AudioSetup.inputDeviceName = “USB Audio CODEC”;

AudioSetup.outputChannels = 2;
AudioSetup.outputDeviceName = device.name; // "nd_rpi_hifiberry_dacplus" ;

// AudioSetup.outputDeviceName =“USB Audio CODEC” ;
juce::String status = deviceManager.initialise (1, 2, nullptr, true, {} , &AudioSetup);
#endif

I dont know which name to set for DeviceName:
Here is my device listing using JUCE :

type:ALSA
default
pulse
Bluetooth Speaker JBL Go
Bluetooth Speaker JBL Go (1)
Bluetooth Speaker Beoplay A1
Bluetooth Speaker UE Boom 2
Bluetooth Speaker Ministry of Sound Audio S
Bluetooth Speaker Jawbone Big Jambox
USB Audio CODEC, USB Audio; Front speakers
USB Audio CODEC, USB Audio; 2.1 Surround output to Front and Subwoofer speakers
USB Audio CODEC, USB Audio; 4.0 Surround output to Front and Rear speakers
USB Audio CODEC, USB Audio; 4.1 Surround output to Front, Rear and Subwoofer speakers
USB Audio CODEC, USB Audio; 5.0 Surround output to Front, Center and Rear speakers
USB Audio CODEC, USB Audio; 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
USB Audio CODEC, USB Audio; 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
USB Audio CODEC, USB Audio; IEC958 (S/PDIF) Digital Audio Output
USB Audio CODEC, USB Audio; Direct sample snooping device
USB Audio CODEC, USB Audio; Direct hardware device without any conversions
USB Audio CODEC, USB Audio; Hardware device with all software conversions

Thank you very much for any help


#2

First, if you put a line of ``` before and after your block of code, all of it will be formatted to look nice.

Then regarding your question, on the bottom you have listed all possible device names for your system. So you need to set inputDeviceName and outputDeviceName to something that matches these strings exactly. From your code it’s not clear what string is actually assigned there (what is in device.name?), you show some commented out line AudioSetup.outputDeviceName = “USB Audio CODEC” ; which is likely to not have worked as there is no such device name in the list you got. What should work should be something like AudioSetup.outputDeviceName = "USB Audio CODEC, USB Audio; Direct hardware device without any conversions" or AudioSetup.outputDeviceName = "USB Audio CODEC, USB Audio; Front speakers" - I think you get what I mean? Have you tried any device name that matches one of the list exactly?


#3

Hi,
Thank you , You are right, I changed the inputDeviceName and outputDeviceName to description as you mentionned and it goes a little further in debug.
Now I checked that the audio device exists and is open ( isOpen_ in juce_ALSA.cpp).
I got another error before starting :
I have a seg fault when calling audioDeviceAboutToStart :
void start (AudioIODeviceCallback* callback) override
{
if (! isOpen_)
callback = nullptr;

    if (callback != nullptr)
        callback->audioDeviceAboutToStart (this);

#4

Hi,

This is resolved and problem comes from some code lines before:

AudioIODevice *device = deviceManager.getCurrentAudioDevice();
auto latencyInput = device->getInputLatencyInSamples();

This works on MacOs using juce and fails on Raspberry !!