mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 13:08:08 +00:00
allow dumping of equalizer state
git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@557 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
parent
d280a46797
commit
77fd518de7
5 changed files with 63 additions and 16 deletions
|
|
@ -117,7 +117,7 @@ void audio_stream_set_mic_gain(AudioStream *stream, float gain);
|
|||
/*enable parametric equalizer in the stream that goes to the speaker*/
|
||||
void audio_stream_enable_equalizer(AudioStream *stream, bool_t enabled);
|
||||
|
||||
void audio_stream_equalizer_set_gain(AudioStream *stream, int frequency, float gain);
|
||||
void audio_stream_equalizer_set_gain(AudioStream *stream, int frequency, float gain, int freq_width);
|
||||
|
||||
/* stop the audio streaming thread and free everything*/
|
||||
void audio_stream_stop (AudioStream * stream);
|
||||
|
|
|
|||
|
|
@ -28,9 +28,17 @@ typedef struct _MSEqualizerGain{
|
|||
float width; ///< frequency band width around mid frequency for which the gain is applied, in Hz. Use 0 for the lowest frequency resolution.
|
||||
}MSEqualizerGain;
|
||||
|
||||
#define MS_EQUALIZER_SET_GAIN MS_FILTER_METHOD(MS_EQUALIZER_ID,0,MSEqualizerGain)
|
||||
#define MS_EQUALIZER_GET_GAIN MS_FILTER_METHOD(MS_EQUALIZER_ID,1,MSEqualizerGain)
|
||||
#define MS_EQUALIZER_SET_ACTIVE MS_FILTER_METHOD(MS_EQUALIZER_ID,2,int)
|
||||
#define MS_EQUALIZER_SET_GAIN MS_FILTER_METHOD(MS_EQUALIZER_ID,0,MSEqualizerGain)
|
||||
#define MS_EQUALIZER_GET_GAIN MS_FILTER_METHOD(MS_EQUALIZER_ID,1,MSEqualizerGain)
|
||||
#define MS_EQUALIZER_SET_ACTIVE MS_FILTER_METHOD(MS_EQUALIZER_ID,2,int)
|
||||
/**dump the spectral response into a table of float. The table must be sized according to the value returned by
|
||||
* MS_EQUALIZER_GET_NUM_FREQUENCIES
|
||||
**/
|
||||
#define MS_EQUALIZER_DUMP_STATE MS_FILTER_METHOD(MS_EQUALIZER_ID,3,float)
|
||||
|
||||
/**returns the number of frequencies*/
|
||||
#define MS_EQUALIZER_GET_NUM_FREQUENCIES MS_FILTER_METHOD(MS_EQUALIZER_ID,4,int)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -452,12 +452,12 @@ void audio_stream_enable_equalizer(AudioStream *stream, bool_t enabled){
|
|||
}
|
||||
}
|
||||
|
||||
void audio_stream_equalizer_set_gain(AudioStream *stream, int frequency, float gain){
|
||||
void audio_stream_equalizer_set_gain(AudioStream *stream, int frequency, float gain, int freq_width){
|
||||
if (stream->equalizer){
|
||||
MSEqualizerGain d;
|
||||
d.frequency=frequency;
|
||||
d.gain=gain;
|
||||
d.width=0.4*(float)frequency;
|
||||
d.width=freq_width;
|
||||
ms_filter_call_method(stream->equalizer,MS_EQUALIZER_SET_GAIN,&d);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,15 +217,15 @@ static void equalizer_state_run(EqualizerState *s, int16_t *samples, int nsample
|
|||
}
|
||||
|
||||
|
||||
void equalizer_init(MSFilter *f){
|
||||
static void equalizer_init(MSFilter *f){
|
||||
f->data=equalizer_state_new(128);
|
||||
}
|
||||
|
||||
void equalizer_uninit(MSFilter *f){
|
||||
static void equalizer_uninit(MSFilter *f){
|
||||
equalizer_state_destroy((EqualizerState*)f->data);
|
||||
}
|
||||
|
||||
void equalizer_process(MSFilter *f){
|
||||
static void equalizer_process(MSFilter *f){
|
||||
mblk_t *m;
|
||||
EqualizerState *s=(EqualizerState*)f->data;
|
||||
while((m=ms_queue_get(f->inputs[0]))!=NULL){
|
||||
|
|
@ -236,14 +236,14 @@ void equalizer_process(MSFilter *f){
|
|||
}
|
||||
}
|
||||
|
||||
int equalizer_set_gain(MSFilter *f, void *data){
|
||||
static int equalizer_set_gain(MSFilter *f, void *data){
|
||||
EqualizerState *s=(EqualizerState*)f->data;
|
||||
MSEqualizerGain *d=(MSEqualizerGain*)data;
|
||||
equalizer_state_set(s,d->frequency,d->gain,d->width);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int equalizer_get_gain(MSFilter *f, void *data){
|
||||
static int equalizer_get_gain(MSFilter *f, void *data){
|
||||
EqualizerState *s=(EqualizerState*)f->data;
|
||||
MSEqualizerGain *d=(MSEqualizerGain*)data;
|
||||
d->gain=equalizer_state_get(s,d->frequency);
|
||||
|
|
@ -251,23 +251,44 @@ int equalizer_get_gain(MSFilter *f, void *data){
|
|||
return 0;
|
||||
}
|
||||
|
||||
int equalizer_set_rate(MSFilter *f, void *data){
|
||||
static int equalizer_set_rate(MSFilter *f, void *data){
|
||||
EqualizerState *s=(EqualizerState*)f->data;
|
||||
s->rate=*(int*)data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int equalizer_set_active(MSFilter *f, void *data){
|
||||
static int equalizer_set_active(MSFilter *f, void *data){
|
||||
EqualizerState *s=(EqualizerState*)f->data;
|
||||
s->active=*(int*)data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int equalizer_dump(MSFilter *f, void *data){
|
||||
EqualizerState *s=(EqualizerState*)f->data;
|
||||
float *t=(float*)data;
|
||||
int i;
|
||||
*t=s->fft_cpx[0];
|
||||
t++;
|
||||
for (i=1;i<s->nfft;i+=2){
|
||||
*t=((float)s->fft_cpx[i]*(float)s->nfft)/(float)GAIN_ZERODB;
|
||||
t++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int equalizer_get_nfreqs(MSFilter *f, void *data){
|
||||
EqualizerState *s=(EqualizerState*)f->data;
|
||||
*(int*)data=s->nfft/2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MSFilterMethod equalizer_methods[]={
|
||||
{ MS_EQUALIZER_SET_GAIN , equalizer_set_gain },
|
||||
{ MS_EQUALIZER_GET_GAIN , equalizer_get_gain },
|
||||
{ MS_EQUALIZER_SET_ACTIVE , equalizer_set_active },
|
||||
{ MS_FILTER_SET_SAMPLE_RATE , equalizer_set_rate },
|
||||
{ MS_EQUALIZER_DUMP_STATE , equalizer_dump },
|
||||
{ MS_EQUALIZER_GET_NUM_FREQUENCIES, equalizer_get_nfreqs },
|
||||
{ 0 , NULL }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "mediastreamer-config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "mediastreamer2/mediastream.h"
|
||||
#include "mediastreamer2/msequalizer.h"
|
||||
#ifdef VIDEO_ENABLED
|
||||
#include "mediastreamer2/msv4l.h"
|
||||
#endif
|
||||
|
|
@ -290,14 +293,29 @@ void run_media_streams(int localport, const char *remote_ip, int remoteport, in
|
|||
commands[127]='\0';
|
||||
printf("Please enter equalizer requests, such as 'eq active 1', 'eq active 0', 'eq 1200 0.1'\n");
|
||||
while(fgets(commands,sizeof(commands)-1,stdin)!=NULL){
|
||||
int active,freq;
|
||||
int active,freq,freq_width;
|
||||
float gain;
|
||||
if (sscanf(commands,"eq active %i",&active)==1){
|
||||
audio_stream_enable_equalizer(audio,active);
|
||||
printf("OK\n");
|
||||
}else if (sscanf(commands,"eq %i %f",&freq,&gain)==2){
|
||||
audio_stream_equalizer_set_gain(audio,freq,gain);
|
||||
}else if (sscanf(commands,"eq %i:%f:%i",&freq,&gain,&freq_width)==3){
|
||||
audio_stream_equalizer_set_gain(audio,freq,gain,freq_width);
|
||||
printf("OK\n");
|
||||
}else if (sscanf(commands,"eq %i:%f",&freq,&gain)==2){
|
||||
audio_stream_equalizer_set_gain(audio,freq,gain,0);
|
||||
printf("OK\n");
|
||||
}else if (strstr(commands,"dump")){
|
||||
int n=0,i;
|
||||
float *t;
|
||||
ms_filter_call_method(audio->equalizer,MS_EQUALIZER_GET_NUM_FREQUENCIES,&n);
|
||||
t=(float*)alloca(sizeof(float)*n);
|
||||
ms_filter_call_method(audio->equalizer,MS_EQUALIZER_DUMP_STATE,t);
|
||||
for(i=0;i<n;++i){
|
||||
if (fabs(t[i]-1)>0.01){
|
||||
printf("%i:%f:0 ",(i*pt->clock_rate)/(2*n),t[i]);
|
||||
}
|
||||
}
|
||||
printf("\nOK\n");
|
||||
}else if (strstr(commands,"quit")){
|
||||
break;
|
||||
}else printf("Cannot understand this.\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue