* ALSA: arecord : silennce recorded as 0x80
@ 2023-04-13 13:49 Muni Sekhar
2023-04-14 10:15 ` Luke Koch
0 siblings, 1 reply; 4+ messages in thread
From: Muni Sekhar @ 2023-04-13 13:49 UTC (permalink / raw)
To: alsa-devel, linux-sound; +Cc: LKML, kernelnewbies
Hi all,
I recorded the silence on the default audio card by running "arecord
-d 5 test.wav."
Once it exited, I checked the contents by running "hexdump test.wav,"
and I see that silence is recorded as a sequence of 0x80 instead of
0x00.
0000000 4952 4646 0024 8000 4157 4556 6d66 2074
0000010 0010 0000 0001 0001 1f40 0000 1f40 0000
0000020 0001 0008 6164 6174 0000 8000 8080 8080
0000030 8080 8080 8080 8080 8080 8080 8080 8080
0000040 8080 8080 8080 8080 8080 8080 8080 8080
...
What might be the reason for silence being recorded as 0x80 instead of 0x0?
--
Thanks,
Sekhar
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ALSA: arecord : silennce recorded as 0x80
2023-04-13 13:49 ALSA: arecord : silennce recorded as 0x80 Muni Sekhar
@ 2023-04-14 10:15 ` Luke Koch
2023-04-14 14:25 ` Muni Sekhar
0 siblings, 1 reply; 4+ messages in thread
From: Luke Koch @ 2023-04-14 10:15 UTC (permalink / raw)
To: Muni Sekhar; +Cc: LKML, alsa-devel, kernelnewbies, linux-sound
On Thu, Apr 13, 2023 at 3:50 PM Muni Sekhar <munisekharrms@gmail.com> wrote:
>
> Hi all,
>
> I recorded the silence on the default audio card by running "arecord
> -d 5 test.wav."
>
> Once it exited, I checked the contents by running "hexdump test.wav,"
> and I see that silence is recorded as a sequence of 0x80 instead of
> 0x00.
>
> 0000000 4952 4646 0024 8000 4157 4556 6d66 2074
> 0000010 0010 0000 0001 0001 1f40 0000 1f40 0000
> 0000020 0001 0008 6164 6174 0000 8000 8080 8080
> 0000030 8080 8080 8080 8080 8080 8080 8080 8080
> 0000040 8080 8080 8080 8080 8080 8080 8080 8080
> ...
>
> What might be the reason for silence being recorded as 0x80 instead of
0x0?
>
>
> --
> Thanks,
> Sekhar
This is what I found after Googling a bit:
Since you didn't specify a format, arecord defaults to 8 bit format (U8).
Being unsigned, a negative value for maximum negative amplitude is
impossible. Therefore the value is given a bias of 128,
making 0 the maximum negative amplitude, 255 the maximum positive, and 128
the center point (or silence).
Best Regards,
Luke
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ALSA: arecord : silennce recorded as 0x80
2023-04-14 10:15 ` Luke Koch
@ 2023-04-14 14:25 ` Muni Sekhar
2023-04-15 9:51 ` Luke Koch
0 siblings, 1 reply; 4+ messages in thread
From: Muni Sekhar @ 2023-04-14 14:25 UTC (permalink / raw)
To: Luke Koch; +Cc: LKML, alsa-devel, linux-sound
On Fri, Apr 14, 2023 at 3:45 PM Luke Koch <lu.ale.koch@gmail.com> wrote:
>
>
> On Thu, Apr 13, 2023 at 3:50 PM Muni Sekhar <munisekharrms@gmail.com> wrote:
> >
> > Hi all,
> >
> > I recorded the silence on the default audio card by running "arecord
> > -d 5 test.wav."
> >
> > Once it exited, I checked the contents by running "hexdump test.wav,"
> > and I see that silence is recorded as a sequence of 0x80 instead of
> > 0x00.
> >
> > 0000000 4952 4646 0024 8000 4157 4556 6d66 2074
> > 0000010 0010 0000 0001 0001 1f40 0000 1f40 0000
> > 0000020 0001 0008 6164 6174 0000 8000 8080 8080
> > 0000030 8080 8080 8080 8080 8080 8080 8080 8080
> > 0000040 8080 8080 8080 8080 8080 8080 8080 8080
> > ...
> >
> > What might be the reason for silence being recorded as 0x80 instead of 0x0?
> >
> >
> > --
> > Thanks,
> > Sekhar
>
> This is what I found after Googling a bit:
> Since you didn't specify a format, arecord defaults to 8 bit format (U8).
> Being unsigned, a negative value for maximum negative amplitude is impossible. Therefore the value is given a bias of 128,
> making 0 the maximum negative amplitude, 255 the maximum positive, and 128 the center point (or silence).
Thanks for the clarification.
So I tried passing signed 8-bit format (S8), and then the arecord died
immediately, as mentioned below.
$ arecord -f S8 test.wav
Recording WAVE 'test.wav' : Signed 8 bit, Rate 8000 Hz, Mono
arecord: begin_wave:2481: Wave doesn't support S8 format...
For other format S16_LE, the arecord hangs for a few seconds and
throws an I/O error.
$ arecord -f S16_LE test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
arecord: pcm_read:2032: read error: Input/output error
I am not sure why recording works only on the default format of U8.
For other formats, the record either dies immediately or hangs for a
timeout and then throws an I/O error. Any ideas about this behaviour?
>
> Best Regards,
> Luke
>
>
>
--
Thanks,
Sekhar
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ALSA: arecord : silennce recorded as 0x80
2023-04-14 14:25 ` Muni Sekhar
@ 2023-04-15 9:51 ` Luke Koch
0 siblings, 0 replies; 4+ messages in thread
From: Luke Koch @ 2023-04-15 9:51 UTC (permalink / raw)
To: Muni Sekhar; +Cc: LKML, alsa-devel, linux-sound
> > This is what I found after Googling a bit:
> > Since you didn't specify a format, arecord defaults to 8 bit format (U8).
> > Being unsigned, a negative value for maximum negative amplitude is impossible. Therefore the value is given a bias of 128,
> > making 0 the maximum negative amplitude, 255 the maximum positive, and 128 the center point (or silence).
> Thanks for the clarification.
> So I tried passing signed 8-bit format (S8), and then the arecord died
> immediately, as mentioned below.
>
> $ arecord -f S8 test.wav
> Recording WAVE 'test.wav' : Signed 8 bit, Rate 8000 Hz, Mono
> arecord: begin_wave:2481: Wave doesn't support S8 format...
>
> For other format S16_LE, the arecord hangs for a few seconds and
> throws an I/O error.
>
> $ arecord -f S16_LE test.wav
> Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
> arecord: pcm_read:2032: read error: Input/output error
>
> I am not sure why recording works only on the default format of U8.
> For other formats, the record either dies immediately or hangs for a
> timeout and then throws an I/O error. Any ideas about this behaviour?
The flag --dump-hw-params should show the formats arecord supports On
your installation. On top of that .wav does not support any big endian formats
as well as no signed formats below 9 bit. You could try testing with raw
file type instead.
The i/o error *might* relate to incorrect device selection.
I hope you can pinpoint your issue to something more specific - and
provide more information - so people with actual expertise in this driver can
help you, I just googled a bit to not leave your questions hovering around unanswered.
Maybe take a peek into the guide on how to ask good questions, linked on
the kernelnewbies site, to make your questions more concise and worth busy people's time.
Best regards,
Luke
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-18 11:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-13 13:49 ALSA: arecord : silennce recorded as 0x80 Muni Sekhar
2023-04-14 10:15 ` Luke Koch
2023-04-14 14:25 ` Muni Sekhar
2023-04-15 9:51 ` Luke Koch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox