* How to mix multiple pcm capture stream into one and save to wav file as if it's from one single multi channel alsa card device
@ 2023-04-27 5:53 semiydsemiyd
2023-04-28 15:52 ` Geraldo Nascimento
2023-05-04 12:50 ` Jaroslav Kysela
0 siblings, 2 replies; 4+ messages in thread
From: semiydsemiyd @ 2023-04-27 5:53 UTC (permalink / raw)
To: alsa-devel
Hi
I have 8 alsa capture devices for one card.
Each capture device support 1 channel only:
root@light-a-val:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: LightSoundCard [Light-Sound-Card], device 0: light-tdm-dai-slot1-ES7210 ADC 0 es7210.5-0042-1 [light-tdm-dai-slot1-ES7210 ADC 0 es7210.5-0042-1]
Subdevices: 1/8
Subdevice #0: subdevice #0
card 0: LightSoundCard [Light-Sound-Card], device 1: light-tdm-dai-slot2-ES7210 ADC 0 es7210.5-0042-1 [light-tdm-dai-slot1-ES7210 ADC 0 es7210.5-0042-1]
Subdevices: 2/8
Subdevice #1: subdevice #1
...
card 0: LightSoundCard [Light-Sound-Card], device 7: light-tdm-dai-slot8-ES7210 ADC 1 es7210.5-0042-1 [light-tdm-dai-slot1-ES7210 ADC 0 es7210.5-0042-1]
Subdevices: 8/8
Subdevice #7: subdevice #7
the signal comes in TDM format from external codec ES7210 to my soc's TDM controller.
each capture device has 1 channel that correspond to one of the slot in TDM. i have 8 TDM slots in configuration. so i have 8 devices in total.
the reason that i have so many capture devices with 1 channel each is that, our tdm IC design decides that each tdm slot data_register would be assigned a
dedicated dma channel. this is quite uncommon. thus i have 8 dma channels for 8 tdm slots.
since i can only register one rx dma channel and one tx using devm_snd_dmaengine_pcm_register().
like:
struct dmaengine_pcm {
struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; // there can be only one tx + one rx dma for struct dmaengine_pcm
...
};
i have to register like 8 times to create 8 devices.
the dts for the cpu dai driver for tdm slot1 would look like:
tdm: audio_tdm@0xffcb000000 {
#sound-dai-cells = <0>;
...
dmas = <&dmac2 31>;
dma-names = "rx";
...
};
now...i want to open all the devices at the same time. and have them save to one single wav file. As if i'm opening one single alsa capture device with 8 channels.
the saved wav file should look something like this (take this 8 channel wav file for example)
First Multichannel Sample
--------------------------
{BB FF FF} 3 bytes slot1
{A1 FF FF} 3 bytes slot2
{00 00 00} 3 bytes slot3
{00 00 00} 3 bytes slot4
{00 00 00} 3 bytes slot5
{00 00 00} 3 bytes slot6
{00 00 00} 3 bytes slot7
{00 00 00} 3 bytes slot8
Second Multichannel Sample
--------------------------
{E6 FF FF} 3 bytes slot1
.,.. etc ....
Is this possible and if yes how can i do that?
thank you guys
semiyd
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: How to mix multiple pcm capture stream into one and save to wav file as if it's from one single multi channel alsa card device
2023-04-27 5:53 How to mix multiple pcm capture stream into one and save to wav file as if it's from one single multi channel alsa card device semiydsemiyd
@ 2023-04-28 15:52 ` Geraldo Nascimento
2023-05-04 11:06 ` semiydsemiyd
2023-05-04 12:50 ` Jaroslav Kysela
1 sibling, 1 reply; 4+ messages in thread
From: Geraldo Nascimento @ 2023-04-28 15:52 UTC (permalink / raw)
To: semiydsemiyd; +Cc: alsa-devel
Hi Semyid,
On Thu, Apr 27, 2023 at 05:53:17AM -0000, semiydsemiyd@163.com wrote:
> now...i want to open all the devices at the same time. and have them save to one single wav file. As if i'm opening one single alsa capture device with 8 channels.
> the saved wav file should look something like this (take this 8 channel wav file for example)
>
> First Multichannel Sample
> --------------------------
> {BB FF FF} 3 bytes slot1
> {A1 FF FF} 3 bytes slot2
> {00 00 00} 3 bytes slot3
> {00 00 00} 3 bytes slot4
> {00 00 00} 3 bytes slot5
> {00 00 00} 3 bytes slot6
> {00 00 00} 3 bytes slot7
> {00 00 00} 3 bytes slot8
>
> Second Multichannel Sample
> --------------------------
> {E6 FF FF} 3 bytes slot1
> .,.. etc ....
>
>
> Is this possible and if yes how can i do that?
>
For such a task usually I'd use JACK on top of ALSA with the
alsa_in/alsa_out scripts or the Zita tools.
Good luck,
Geraldo Nascimento
> thank you guys
>
>
> semiyd
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: How to mix multiple pcm capture stream into one and save to wav file as if it's from one single multi channel alsa card device
2023-04-27 5:53 How to mix multiple pcm capture stream into one and save to wav file as if it's from one single multi channel alsa card device semiydsemiyd
2023-04-28 15:52 ` Geraldo Nascimento
@ 2023-05-04 12:50 ` Jaroslav Kysela
1 sibling, 0 replies; 4+ messages in thread
From: Jaroslav Kysela @ 2023-05-04 12:50 UTC (permalink / raw)
To: semiydsemiyd, alsa-devel
On 27. 04. 23 7:53, semiydsemiyd@163.com wrote:
> Hi
>
> I have 8 alsa capture devices for one card.
> Each capture device support 1 channel only:
>
> root@light-a-val:~# arecord -l
> **** List of CAPTURE Hardware Devices ****
> card 0: LightSoundCard [Light-Sound-Card], device 0: light-tdm-dai-slot1-ES7210 ADC 0 es7210.5-0042-1 [light-tdm-dai-slot1-ES7210 ADC 0 es7210.5-0042-1]
> Subdevices: 1/8
> Subdevice #0: subdevice #0
> card 0: LightSoundCard [Light-Sound-Card], device 1: light-tdm-dai-slot2-ES7210 ADC 0 es7210.5-0042-1 [light-tdm-dai-slot1-ES7210 ADC 0 es7210.5-0042-1]
> Subdevices: 2/8
> Subdevice #1: subdevice #1
> ...
> card 0: LightSoundCard [Light-Sound-Card], device 7: light-tdm-dai-slot8-ES7210 ADC 1 es7210.5-0042-1 [light-tdm-dai-slot1-ES7210 ADC 0 es7210.5-0042-1]
> Subdevices: 8/8
> Subdevice #7: subdevice #7
>
> the signal comes in TDM format from external codec ES7210 to my soc's TDM controller.
> each capture device has 1 channel that correspond to one of the slot in TDM. i have 8 TDM slots in configuration. so i have 8 devices in total.
>
>
> the reason that i have so many capture devices with 1 channel each is that, our tdm IC design decides that each tdm slot data_register would be assigned a
> dedicated dma channel. this is quite uncommon. thus i have 8 dma channels for 8 tdm slots.
> since i can only register one rx dma channel and one tx using devm_snd_dmaengine_pcm_register().
> like:
> struct dmaengine_pcm {
> struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; // there can be only one tx + one rx dma for struct dmaengine_pcm
> ...
> };
> i have to register like 8 times to create 8 devices.
> the dts for the cpu dai driver for tdm slot1 would look like:
> tdm: audio_tdm@0xffcb000000 {
> #sound-dai-cells = <0>;
> ...
> dmas = <&dmac2 31>;
> dma-names = "rx";
> ...
> };
>
> now...i want to open all the devices at the same time. and have them save to one single wav file. As if i'm opening one single alsa capture device with 8 channels.
> the saved wav file should look something like this (take this 8 channel wav file for example)
You may use the multi plugin from alsa-lib, just google "alsa multi plugin"
for details.
Jaroslav
--
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-04 12:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-27 5:53 How to mix multiple pcm capture stream into one and save to wav file as if it's from one single multi channel alsa card device semiydsemiyd
2023-04-28 15:52 ` Geraldo Nascimento
2023-05-04 11:06 ` semiydsemiyd
2023-05-04 12:50 ` Jaroslav Kysela
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox