0

This is how I have defined my soundcard's channels in .asoundrc:

pcm.!default {
    type plug
    slave {
       pcm "hw:1,0"
    }
}

ctl.!default { 
    type hw
    card 1
}

pcm_slave.usb_1 {
    pcm "hw:1,0"
    rate 44100
    channels 8
    buffer_size 4096
    period_size 1024
}

pcm.outch1 {
    type dshare
    ipc_key 1111
    slave usb_1
    bindings [ 0 ]
    hint.description "USB output/playback channel 1 (from output port 1)"
}

pcm.inch1 {
    type dsnoop
    ipc_key 1111
    slave usb_1
    bindings [ 0 ]
    hint.description "USB input/capture channel 1 (from input port 1)"
}

While the above works fine with aplay and arecord functions/commands in the terminal, trying to play a 8k audio sample with Audacity throws the following error :

Audacity Error

When I check the Audio device info option in Help menu (Help-->Audio device option), I see the following:

Device ID: 2
Device name: USB Audio (hw:1,0)
Host name: ALSA
Recording channels: 8
Playback channels: 8
Low Recording Latency: 0.008707
Low Playback Latency: 0.008707
High Recording Latency: 0.034830
High Playback Latency: 0.034830
Supported Rates:
    44100
    48000
    88200
    96000
==============================
Device ID: 10
Device name: outch1
Host name: ALSA
Recording channels: 0
Playback channels: 1
Low Recording Latency: -1.000000
Low Playback Latency: 0.023220
High Recording Latency: -1.000000
High Playback Latency: 0.023220
Supported Rates:
    44100
==============================
Device ID: 11
Device name: inch1
Host name: ALSA
Recording channels: 1
Playback channels: 0
Low Recording Latency: 0.023220
Low Playback Latency: -1.000000
High Recording Latency: 0.023220
High Playback Latency: -1.000000
Supported Rates:
==============================

As we can see, 8000 or 16000 is not a Supported Rate from the audio device info. So, it's quite clear why the error is thrown.

So, how and where can I add/set (modify my .asoundrc maybe?) these sample rates so that any application (including Audacity of course) can support playback and recording of audio files at any desired sample rate.

  • dmix/dshare/dsnoop always use a fixed rate. Try PulseAudio instead. – CL. Aug 2 '17 at 9:35
  • @CL. Okay. So, we should replace dshare and dsnoop with pulseaudio plugin? But still, I want to understand why it works well with the commands aplay -D plug:outch1 -c 1 -r 8000 play_filename.wav and arecord -D plug:inch1 -c 1 -d 20 -f S16_LE -r 8000 rec_filename.wav and not with Audacity? – skrowten_hermit Aug 2 '17 at 9:50
  • The plug plugin automatically resamples. If you want that, wrap it around the other plugins. – CL. Aug 2 '17 at 10:06
  • Is that possible with Audacity? Wrap around I mean. Could you explain a bit more on this? – skrowten_hermit Aug 2 '17 at 10:09
  • See the default PCM device. – CL. Aug 2 '17 at 11:18
2

The dmix/dshare/dsnoop plugins always use a fixed sample rate.

To allow the device itself to run at a different rate, use PulseAudio instead.

To resample the data from the application before it goes to the dshare plugin, wrap a plug plugin around it:

pcm.outch1 {
    type plug
    slave.pcm {
        type dshare
        ipc_key 1111
        slave usb_1
        bindings [ 0 ]
    }
}
  • That solved it! Out of sheer curiosity, I just wanted to ask if there is any disadvantage/drawback of using this automatic conversion plugin plug? Which particular cases would I need PulseAudio? It would be great if you could illustrate this. – skrowten_hermit Aug 3 '17 at 6:14
  • With this, the actual hardware device always runs at 44100 Hz. – CL. Aug 3 '17 at 6:20
  • Then, the software (that is, ALSA) does the conversion? And with PulseAudio, we can allow the hardware device to run at a different rate according to its capability. Right? – skrowten_hermit Aug 3 '17 at 6:27
  • Also, if I replace type plug with pulse (plugin), by default PulseAudio would be used? I want to make my device run at different rates. – skrowten_hermit Aug 3 '17 at 6:54
  • PulseAudio does not have a slave; you would have to configure the one-channel stuff in PA's configuration. – CL. Aug 3 '17 at 8:23

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.