[Alsa-user] rate coverter after dmix

2017-05-09 Thread remu kelly
Hi,

I need to implement a rate converter after dmix, means dmix will mix 3
channels as input, and the output will be of 48KHz, but then i need to
convert it to 96KHz output and send to HW.
How this can be achieved, seeing that we can't have a plugin after dmix.

or we can do somethings like below:-

pcm.sl1{
   type hw
   card 0
   device 0
}

pcm_slave.sl2 {
pcm sl1
rate 96000
}

pcm.mix1{
type dmix
ipc_key 1024
slave sl2
}

pcm_slave.sl3{
pcm mix1
 }

pcm.play{
   type plug
   slave sl3
   rate_converter "myconverter"
}

here rate converter "myconverter" will be specific to my audio HW.

is the above config allowed?


Regards
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] regarding dmix plugin

2017-05-08 Thread remu kelly
Hi,

I need to implement a rate converter after dmix, means dmix will mix 3
channels as input, and the output will be of 48KHz, but then i need to
convert it to 96KHz output and send to HW.
How this can be achieved, seeing that we can't have a plugin after dmix.

Regards

On Mon, May 8, 2017 at 12:46 PM, remu kelly  wrote:

> Hi,
>
>
> Is it possible to have another plugin to place after dmix plugin.:-
>
> input -> some plugin -> dmix plugin -> one more plugin -> hw
>
>
> Regards,
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Alsa-user] regarding dmix plugin

2017-05-07 Thread remu kelly
Hi,


Is it possible to have another plugin to place after dmix plugin.:-

input -> some plugin -> dmix plugin -> one more plugin -> hw


Regards,
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Alsa-user] regarding rate plugin

2017-05-07 Thread remu kelly
Hi ,

I am trying to create a new "rate_converter". for start i am trying to
create a empty converter, but facing below error:
---
Playing WAVE '/home/Test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz,
Stereo
aplay: set_params:1297: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 48000
PERIOD_TIME: (21333 21334)
PERIOD_SIZE: NONE
PERIOD_BYTES: (4092 4100)
PERIODS: (3 5)
BUFFER_TIME: (85333 85334)
BUFFER_SIZE: 4096
BUFFER_BYTES: 16384
TICK_TIME: ALL
---

The asound conf is something like below(here 'rateconvtest' is the
converter created by me):-
---
pcm.sl1 {
type hw
card 0
device 0
}
pcm_slave.sl2 {
pcm sl1
rate 96000
}
pcm.rchg {
type rate
slave sl2
converter "rateconvtest"
}
-

command used is "aplay -vD rchg /home/Test.wav".

the code of the rate converter i have created is like this:-


#include 
#include 
#include 

static snd_pcm_uframes_t input_frames(void *obj, snd_pcm_uframes_t frames) {
printf("\nrate in frame callback %d\n", frames);
return frames ;
}

static snd_pcm_uframes_t output_frames(void *obj, snd_pcm_uframes_t frames)
{
printf("\nrate out frame callback %d\n", frames );
return (snd_pcm_uframes_t)(frames * 2);
}

static void pcm_src_free(void *obj) {
}

static int pcm_src_init(void *obj, snd_pcm_rate_info_t *info) {
printf("\n rate init rate in = %d rate out = %d\n", info->in.rate,
info->out.rate);
return 0;
}

static int pcm_src_adjust_pitch(void *obj, snd_pcm_rate_info_t *info) {
printf("\n rate pitch rate = %d\n", info->in.rate);
return 0;
}

static void pcm_src_reset(void *obj) {
printf("\n rate reset \n");
}

static void pcm_src_convert_s16(void *obj, int16_t *dst, unsigned int
dst_frames, const int16_t *src, unsigned int src_frames) {

unsigned int count = src_frames;

printf("\n rate in s16 convert srcfrm = %d dst frm = %d \n",
src_frames, dst_frames);
memcpy(dst, src, count );
memcpy(dst + count, src, count );
}

static void pcm_src_close(void *obj) {
 printf("\n rate close success\n");
}

#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
static int get_supported_rates(void *obj, unsigned int *rate_min, unsigned
int *rate_max) {
*rate_min = *rate_max = 0; /* both unlimited */
 printf("\n rate supoort rate success\n");
return 0;
}

static void dump(void *obj, snd_output_t *out) {
snd_output_printf(out, "Converter: lib-ratetest\n");
}
#endif

static snd_pcm_rate_ops_t pcm_src_ops = {
.close = pcm_src_close,
.init = pcm_src_init,
.free = pcm_src_free,
.reset = pcm_src_reset,
.adjust_pitch = pcm_src_adjust_pitch,
.convert_s16 = pcm_src_convert_s16,
.input_frames = input_frames,
.output_frames = output_frames,
#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
.version = SND_PCM_RATE_PLUGIN_VERSION,
.get_supported_rates = get_supported_rates,
.dump = dump,
#endif
};

static int pcm_src_open(unsigned int version, snd_pcm_rate_ops_t *ops) {
printf("\n rate  OPEN \n");

#if SND_PCM_RATE_PLUGIN_VERSION < 0x010002
if (version != SND_PCM_RATE_PLUGIN_VERSION) {
fprintf(stderr, "Invalid rate plugin version %x\n", version);
return -EINVAL;
}
#endif

#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
if (version == 0x010001)
memcpy(ops, &pcm_src_ops, sizeof(snd_pcm_rate_old_ops_t));
else
#endif
*ops = pcm_src_ops;
printf("\n rate OPEN complete\n");
return 0;
}

int SND_PCM_RATE_PLUGIN_ENTRY(ratehardsp) (unsigned int version, void
**objp, snd_pcm_rate_ops_t *ops) {
printf("\n rate ENTRY \n");
*objp = NULL;
return pcm_src_open(version, ops);
}



So , including all the printf statements, that i have added in my code, the
actual output looks like this:-

rate ENTRY

 rate  OPEN

 rate OPEN complete

 rate supoort rate success
Playing WAVE '/home/Test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz,
Stereo
aplay: set_params:1297: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 48000
PERIOD_TIME: (21333 21334)
PERIOD_SIZE: NONE
PERIOD_BYTES: (4092 4100)
PERIODS: (3 5)
BUFFER_TIME: (85333 85334)
BUFFER_SIZE: 4096
BUFFER_BYTES: 16384
TICK_TIME: ALL

 rate close success
-


>From above i see that call went successful till the ".get_supported_rates =
get_supported_rates", is the definition of function "get_supported_rates()"
is wrong? OR do i need to look at something else. I am using UBUNTU 16.04
for the development purpose.

please help me.
--

[Alsa-user] buffer size for alsa plugin

2017-04-23 Thread remu kelly
Hi alsa team,


I need some help regarding alsa external filter plugin.

i have to create a external alsa filter plugin in which the "transfer"
function will receive the input buffer, with say size "x". but then we will
have to apply some algo on input data and the output buffer will be of size
"2x".

but this "2x" buffer when will be given to slave pligin it will only
consider "x" size of data as valid, so how can we tell the slave plugin
that the valid size is "2x"?

also similar to buffer size we have to get input sample rate as 48K, but
the output buffer of "2x" applies to 96K sample rate.

Please let us know how to implement this change of buffer size and sample
rate within the plugin and how to communicate it to the slave plugin.


Regards,
remu
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user