speaker-test: Support S24_3LE sample format
PATCH 1/1 speaker-test: Support S24_3LE sample format
Implement support signed 24 bit samples, packed in 3 bytes.
Signed-off-by Julian Scheel <[email protected]>
--- speaker-test/speaker-test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
speaker-test/speaker-test.c +38 -0
@@ -284,6 +284,7 @@ static const int supported_formats[] = {SND_PCM_FORMAT_S16_LE ,SND_PCM_FORMAT_S16_BE ,SND_PCM_FORMAT_FLOAT_LE , +SND_PCM_FORMAT_S24_3LE ,SND_PCM_FORMAT_S32_LE ,SND_PCM_FORMAT_S32_BE ,-1
@@ -341,6 +342,19 @@ static void generate_sine(uint8_t *frames, int channel, int count, double *_phas *samp_f++ =0.0 ; }break ; +case SND_PCM_FORMAT_S24_3LE : +if (chn==channel) { + res = (sin ((phase *2 *M_PI ) / max_phase -M_PI )) * generator_scale *0x7fffff ; + ires = res; + *samp8++ =LE_INT (ires); + *samp8++ =LE_INT (ires) >>8 ; + *samp8++ =LE_INT (ires) >>16 ; + }else { + *samp8++ =0 ; + *samp8++ =0 ; + *samp8++ =0 ; + } +break ;case SND_PCM_FORMAT_S32_LE :if (chn==channel) { res = (sin ((phase *2 *M_PI ) / max_phase -M_PI )) * generator_scale *0x7fffffff ;
@@ -415,6 +429,19 @@ static void generate_pink_noise( uint8_t *frames, int channel, int count) { *samp16++ =0 ; }break ; +case SND_PCM_FORMAT_S24_3LE : +if (chn==channel) { + res =generate_pink_noise_sample (&pink) * generator_scale *0x07fffff ; + ires = res; + *samp8++ =LE_INT (ires); + *samp8++ =LE_INT (ires) >>8 ; + *samp8++ =LE_INT (ires) >>16 ; + }else { + *samp8++ =0 ; + *samp8++ =0 ; + *samp8++ =0 ; + } +break ;case SND_PCM_FORMAT_S32_LE :if (chn==channel) { res =generate_pink_noise_sample (&pink) * generator_scale *0x07fffffff ;
@@ -482,6 +509,17 @@ static void generate_pattern(uint8_t *frames, int channel, int count, int *_patt *samp_f++ =0.0 ; }break ; +case SND_PCM_FORMAT_S24_3LE : +if (chn==channel) { + *samp8++ =LE_INT (pattern); + *samp8++ =LE_INT (pattern) >>8 ; + *samp8++ =LE_INT (pattern) >>16 ; + }else { + *samp8++ =0 ; + *samp8++ =0 ; + *samp8++ =0 ; + } +break ;case SND_PCM_FORMAT_S32_LE :if (chn==channel) { *samp32++ =LE_INT (pattern);
Signature · 1 line
2.16.1
Quoted 4 lines · Julian Scheel
Implement support signed 24 bit samples, packed in 3 bytes.
Signed-off-by Julian Scheel <[email protected]>
Thanks for the patch. The change itself is OK, but now I noticed that there are way too many open-codes for the same stuff. Let's kick them out and then apply the support for a new format.
I cleaned up the code now in git tree. Could you rebase your patch? Also, it'd be better to have both *_LE and *_BE formats. It shouldn't be hard.
thanks,
Takashi