3

My setup is Vortexbox 2.3, a Linux music distro based on Fedora. I have a multichannel sound card, USBStreamer from miniDSP. I have set up separate stereo devices in asound.conf so I can have multiple instances of squeezelite playing to separate output channels. Because their is only one clock for all players the audio needs to all be at the same sample rate. Most of my music is 44.1kHz but some 48kHz, so I need some resampling when a 48kHz file is played. I have got this working through asound.conf. However is seems ALSA is resampling everything to 44.1kHz, even if that's the original sample rate, not just the player outputting 48kHz as I'd expected. I'd like the native 44.1 files to be played without resampling. I'd like to handle the sample rate in ALSA rather than the player so I can add other players also.

Is there a way of making ALSA only resample when the rate doesn't match?

#
# Place your global alsa-lib configuration here...
#

#defaults.pcm.rate_converter "speexrate"

pcm_slave.miniDSP {
# pcm "hw:0,0"
pcm "hw:USBStreamer"
rate 44100        # fixed, because all dshare devices must use the same samplerate. Could use rate unchanged but not for here.
format S32_LE
channels 10
}

pcm.stereo_1_raw {
type plug
slave.pcm {
    type dshare
    ipc_key 662662
ipc_key_add_uid true
    slave miniDSP
    bindings [ 0 1 ]
}
}

pcm.stereo_2_raw {
type plug
slave.pcm {
    type dshare
    ipc_key 662662
ipc_key_add_uid true
    slave miniDSP
    bindings [ 2 3 ]
}
}

pcm.stereo_3_raw {
type plug
slave.pcm {
    type dshare
    ipc_key 662662
ipc_key_add_uid true
    slave miniDSP
    bindings [ 4 5 ]
}
}

pcm.stereo_4_raw {
type plug
slave.pcm {
    type dshare
    ipc_key 662662
ipc_key_add_uid true
    slave miniDSP
    bindings [ 6 7 ]
}
}

pcm.stereo_1_output {
    type rate
    slave {
            pcm stereo_1_raw
            rate 44100
    }
    #converter "speexrate_medium" This doesn't work for 4 channels.
converter "samplerate"
}

pcm.stereo_2_output {
    type rate
    slave {
            pcm stereo_2_raw
            rate 44100
    }
    converter "speexrate_medium"
}

pcm.stereo_3_output {
    type rate
    slave {
            pcm stereo_3_raw
            rate 44100
    }
#converter "speexrate_medium"
converter "samplerate"
}

pcm.stereo_4_output {
    type rate
    slave {
            pcm stereo_4_raw
            rate 44100
    }
    #converter "speexrate_medium"
converter "samplerate"
}
1

The plug plugin inserts a rate plugin only when needed, but when you insert a rate plugin manually, that is what you get.

Just drop the rate plugins; you can use the stereo_x_raw devices directly. (For the resampling algorithm, you can rely on the default setting.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.