if((data=(short *)calloc(1,sizeof(short)*samples)+offset)==NULL)
{
ast_log(LOG_ERROR,"Unable to create array for frame
data\n");
if(f!=NULL)
{
free(f);
f=NULL;
}
}
else
{
f->data=data;
}
return(f);
}
--- cut here ---
What am I doing wrong, can anyone help?
While on topic, i'm also interested how to create a beep frame. There
are some frequency generations in indications.c, but i guess i'll need
just a frame :)
Regards,
Atis
--
Atis Lezdins,
VoIP Project Manager / Developer,
IQ Labs Inc,
atis@iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Mon May 18, 2009 12:16 pm Post subject: [asterisk-dev] How to create a slinear silent frame?
2 Holger Wirtz:
I believe you should not use calloc/free to manipulate frames.
Also, I have no idea why you are trying to manipulate "offset" frame field. This is probably the thing which makes your code crash.
2 Atis Lezdins:
one frame (20ms) is not enough to produce any beep. You will need many frames for the beep to be heard.
In any case, apps/app_morsecode.c should be good start.
Regards,
Dmitry Andrianov
-----Original Message-----
From: asterisk-dev-bounces@lists.digium.com [mailto:asterisk-dev-bounces@lists.digium.com] On Behalf Of Atis Lezdins
Sent: Monday, May 18, 2009 3:17 PM
To: Asterisk Developers Mailing List
Subject: Re: [asterisk-dev] How to create a slinear silent frame?
On Mon, May 18, 2009 at 12:36 PM, Holger Wirtz <wirtz@dfn.de> wrote:
Quote:
Hi,
I tried to create an empty frame (with data set to 0000000...) but I get
crashes when I try to send this frames with ast_write() to a channel.
I created the frame like this:
--- cut here ---
struct ast_frame* frame_create_silent_voice(int offset,int samples)
{
struct ast_frame* f=NULL;
short *data=NULL;
int i=0;
if((f=calloc(1,sizeof(struct ast_frame)))==NULL)
{
ast_log(LOG_ERROR,"Unable to allocate memory for slinear
frame\n");
return(NULL);
}
if((data=(short *)calloc(1,sizeof(short)*samples)+offset)==NULL)
{
ast_log(LOG_ERROR,"Unable to create array for frame
data\n");
if(f!=NULL)
{
free(f);
f=NULL;
}
}
else
{
f->data=data;
}
return(f);
}
--- cut here ---
What am I doing wrong, can anyone help?
While on topic, i'm also interested how to create a beep frame. There
are some frequency generations in indications.c, but i guess i'll need
just a frame :)
Regards,
Atis
--
Atis Lezdins,
VoIP Project Manager / Developer,
IQ Labs Inc,
atis@iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Mon May 18, 2009 12:31 pm Post subject: [asterisk-dev] How to create a slinear silent frame?
Holger Wirtz wrote:
Quote:
Hi,
I tried to create an empty frame (with data set to 0000000...) but I get
crashes when I try to send this frames with ast_write() to a channel.
Take a look at the function silence_generator_generate() in
main/channel.c for an example of how to do this.
--
Russell Bryant
Digium, Inc. | Senior Software Engineer, Open Source Team Lead
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Mon May 18, 2009 2:31 pm Post subject: [asterisk-dev] How to create a slinear silent frame?
Atis Lezdins wrote:
Quote:
While on topic, i'm also interested how to create a beep frame. There
are some frequency generations in indications.c, but i guess i'll need
just a frame :)
As Dmitry pointed out, a single frame isn't going to do the job here.
If you need frame level access to a beep, your best bet is to use the
file stream API. You can open a beep sound file with ast_openstream()
and then call ast_readframe() to get each frame.
--
Russell Bryant
Digium, Inc. | Senior Software Engineer, Open Source Team Lead
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Mon May 18, 2009 3:13 pm Post subject: [asterisk-dev] How to create a slinear silent frame?
On Mon, 18 May 2009 10:16:52 -0500, Russell Bryant wrote
Quote:
Atis Lezdins wrote:
> While on topic, i'm also interested how to create a beep frame. There
> are some frequency generations in indications.c, but i guess i'll need
> just a frame :)
As Dmitry pointed out, a single frame isn't going to do the job here.
If you need frame level access to a beep, your best bet is to use the
file stream API. You can open a beep sound file with ast_openstream()
and then call ast_readframe() to get each frame.
ast_openstream() requires a channel ... is it possible to open a filestream in
SLINEAR without the need for a channel?
Quote:
--
Russell Bryant
Digium, Inc. | Senior Software Engineer, Open Source Team Lead
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Mon May 18, 2009 3:53 pm Post subject: [asterisk-dev] How to create a slinear silent frame?
Kaloyan Kovachev wrote:
Quote:
> If you need frame level access to a beep, your best bet is to use the
> file stream API. You can open a beep sound file with ast_openstream()
> and then call ast_readframe() to get each frame.
ast_openstream() requires a channel ... is it possible to open a filestream in
SLINEAR without the need for a channel?
You're right, it requires a channel.
If you do not have a channel, you can open a file stream with
ast_readfile(). res/res_convert.c is an example of a module that opens
a sound file and reads from it without a channel. It also uses
ast_writefile() to open a file to write audio to without a channel.
--
Russell Bryant
Digium, Inc. | Senior Software Engineer, Open Source Team Lead
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Tue May 19, 2009 8:14 am Post subject: [asterisk-dev] How to create a slinear silent frame?
On Mon, 18 May 2009 11:43:11 -0500, Russell Bryant wrote
Quote:
Kaloyan Kovachev wrote:
>> If you need frame level access to a beep, your best bet is to use the
>> file stream API. You can open a beep sound file with ast_openstream()
>> and then call ast_readframe() to get each frame.
>
> ast_openstream() requires a channel ... is it possible to open a filestream in
> SLINEAR without the need for a channel?
You're right, it requires a channel.
If you do not have a channel, you can open a file stream with
ast_readfile(). res/res_convert.c is an example of a module that opens
a sound file and reads from it without a channel. It also uses
ast_writefile() to open a file to write audio to without a channel.
Thanks i'll take a look at res_convert, but just a quick question about
transcoding - does ast_openstream() takes care for the transcoding to SLIN in
case there is just .gsm?
Quote:
--
Russell Bryant
Digium, Inc. | Senior Software Engineer, Open Source Team Lead
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
Posted: Tue May 19, 2009 11:33 am Post subject: [asterisk-dev] How to create a slinear silent frame?
On May 19, 2009, at 4:03 AM, Kaloyan Kovachev wrote:
Quote:
Thanks i'll take a look at res_convert, but just a quick question
about
transcoding - does ast_openstream() takes care for the transcoding
to SLIN in
case there is just .gsm?
Yes. The file stream API will set up a translation path internally.
--
Russell Bryant
Digium, Inc. | Senior Software Engineer, Open Source Team Lead
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum