Play samples with aplay

Hi,

Pisound is working, tested with a simple pure data patch.
I would like to play samples straight to pisound using aplay, but I cannot succed in the task yet.

Can somebody give me a tip to do this?
I tried:
aplay -D hw:1,0 /usr/lib/puredata/doc/sound/voice2.wav
but the output says:
Playing WAVE ‘/usr/lib/puredata/doc/sound/voice2.wav’ : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
aplay: set_params:1305: Channels count non available

How can i solve this?
ciao
:Dan

Hi, aplay doesn’t do any resampling of the files given to it, Pisound expects 2 channel data and one of 48kHz, 96kHz or 192kHz sampling rates.

This can be worked around by introducing an ALSA plugin in the software audio path which takes care of recoding.

Try saving this in your ~/.asoundrc:

pcm.!default {
        type plug
        slave.pcm "qhw"
}

pcm.qhw {
        type hw
        card 1
}

ctl.!default {
        type hw
        card 1
}

It specifies the default audio slot to be ALSA’s resampling plugin which is then supposed to forward the data in a compatible manner to card number 1, which should be Pisound.

Note that the ‘volumealsa’ widget at the top right of Raspbian will not work well with above contents, it does not do proper parsing of .asoundrc. To restore it to working state, you may delete or rename this .asoundrc file, switching the default card in volumealsa plugin should create a new, compatible .asoundrc file in your home folder.

Additional note, triggering samples using aplay could have very random delays as to when it actually starts playing, because every time the overhead of creating a linux process would have to happen, which is not necessarily constant time. A better way to implement sample triggering would be to use some audio software like Pure Data to achieve that functionality, you could create a patch that triggers samples based on the incoming MIDI note, or modify one of these patches to fit your needs.

Thanx,

I has a more complex ideas And also I’m trying yo understand in deep how PiSound works (I’m a total audio geek).

I have testes with PD, But I’m thinking to a data sonofication setup for data center totali based on command line.

Using espeak, aplay, ffmpeg…
I’ll post The complete idea ad long ad i have a clearer one in my mind!

In The mean time I’ll try Your advices And I’ll let you how it works!

Cheerz
:Dan

1 Like