当前位置: 首页>>代码示例>>C++>>正文


C++ speex_preprocess_ctl函数代码示例

本文整理汇总了C++中speex_preprocess_ctl函数的典型用法代码示例。如果您正苦于以下问题:C++ speex_preprocess_ctl函数的具体用法?C++ speex_preprocess_ctl怎么用?C++ speex_preprocess_ctl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了speex_preprocess_ctl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Java_com_haitou_xiaoyoupai_imservice_support_audio_Speex_open

extern "C" JNIEXPORT jint JNICALL Java_com_haitou_xiaoyoupai_imservice_support_audio_Speex_open(
    JNIEnv *env, jobject obj, jint compression) {
    int tmp = 0;
    if (codec_open++ != 0)
        return (jint) 0;

    speex_bits_init(&ebits);
    speex_bits_init(&dbits);

    enc_state = speex_encoder_init(&speex_nb_mode);
    dec_state = speex_decoder_init(&speex_nb_mode);

    tmp = compression;
    speex_encoder_ctl(enc_state, SPEEX_SET_QUALITY, &tmp);
    speex_encoder_ctl(enc_state, SPEEX_GET_FRAME_SIZE, &enc_frame_size);
    speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &dec_frame_size);

    SpeexPreprocessState * m_st;
    m_st = speex_preprocess_state_init(enc_frame_size, 8000);
    int denoise = 1;
    int noiseSuppress = -25;
    speex_preprocess_ctl(m_st, SPEEX_PREPROCESS_SET_DENOISE, &denoise);
    speex_preprocess_ctl(m_st, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS,
                         &noiseSuppress);

    return (jint) 0;
}
开发者ID:treejames,项目名称:FreshMAn-Task,代码行数:27,代码来源:speex_jni.cpp

示例2: speex_filter_init

int speex_filter_init(AVFilterContext *avf)
{
    SpeexFilterContext *s = avf->priv_data;
	int opt = 1;

	if (avf->avctx->channels == 2) {
		av_log(avf, AV_LOG_ERROR, "Speex error: preprocessor does not support stereo encoding\n");
		return -1;
	}
	s->preproc = speex_preprocess_state_init(avf->avctx->frame_size, avf->avctx->sample_rate);
	
    if (avf->flags & FILTER_FLAG_SPEEX_VAD) {
        speex_preprocess_ctl(s->preproc, SPEEX_PREPROCESS_SET_VAD, &opt);
    }
    
    if (avf->flags & FILTER_FLAG_SPEEX_AGC) {
        float flevel = avf->agc_level;
    	speex_preprocess_ctl(s->preproc, SPEEX_PREPROCESS_SET_AGC, &opt);
		speex_preprocess_ctl(s->preproc, SPEEX_PREPROCESS_SET_AGC_LEVEL, &flevel);
	}

    opt = (avf->flags & FILTER_FLAG_SPEEX_DENOISER) ? 1 : 0;

    speex_preprocess_ctl(s->preproc, SPEEX_PREPROCESS_SET_DENOISE, &opt);

	av_log(avf, AV_LOG_INFO, "Speex preproc: using preprocessor (vad: %d, agc level: %d, denoiser: %d)\n",
		(avf->flags & FILTER_FLAG_SPEEX_VAD) ? 1 : 0,
		avf->agc_level,
		(avf->flags & FILTER_FLAG_SPEEX_DENOISER) ? 1 : 0);
	
	return 0;
};
开发者ID:paranojik,项目名称:multitv,代码行数:32,代码来源:speex.c

示例3: init_speex_encoder

void init_speex_encoder() {
    if (!gEncoderState) {
        gEncoderState = speex_encoder_init(&speex_nb_mode);
	int quality = 3; // 8000 bps
        speex_encoder_ctl(gEncoderState, SPEEX_SET_QUALITY, &quality);
	int complexity = 4; // net play is demanding, ok?
        speex_encoder_ctl(gEncoderState, SPEEX_SET_COMPLEXITY, &complexity);
        int tmp = kNetworkAudioSampleRate;
        speex_encoder_ctl(gEncoderState, SPEEX_SET_SAMPLING_RATE, &tmp);
        speex_bits_init(&gEncoderBits);

	// set up the preprocessor
	int frame_size;
	speex_encoder_ctl(gEncoderState, SPEEX_GET_FRAME_SIZE, &frame_size);
	gPreprocessState = speex_preprocess_state_init(frame_size, kNetworkAudioSampleRate);
	// turn on AGC and denoise
	tmp = 1;
	speex_preprocess_ctl(gPreprocessState, SPEEX_PREPROCESS_SET_DENOISE, &tmp);
	tmp = 1;
	speex_preprocess_ctl(gPreprocessState, SPEEX_PREPROCESS_SET_AGC, &tmp);
	
	float agc_level = 32768.0 * 0.7;
	speex_preprocess_ctl(gPreprocessState, SPEEX_PREPROCESS_SET_AGC_LEVEL, &agc_level);
    }
    
}
开发者ID:Aleph-One-Marathon,项目名称:alephone-psp,代码行数:26,代码来源:network_speex.cpp

示例4: speex_callback

static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
{
	struct ast_datastore *datastore = NULL;
	struct speex_direction_info *sdi = NULL;
	struct speex_info *si = NULL;
	char source[80];

	/* If the audiohook is stopping it means the channel is shutting down.... but we let the datastore destroy take care of it */
	if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE || frame->frametype != AST_FRAME_VOICE) {
		return -1;
	}

	/* We are called with chan already locked */
	if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
		return -1;
	}

	si = datastore->data;

	sdi = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? si->rx : si->tx;

	if (!sdi) {
		return -1;
	}

	if ((sdi->samples != frame->samples) || (ast_format_rate(&frame->subclass.format) != si->lastrate)) {
		si->lastrate = ast_format_rate(&frame->subclass.format);
		if (sdi->state) {
			speex_preprocess_state_destroy(sdi->state);
		}

		if (!(sdi->state = speex_preprocess_state_init((sdi->samples = frame->samples), si->lastrate))) {
			return -1;
		}

		speex_preprocess_ctl(sdi->state, SPEEX_PREPROCESS_SET_AGC, &sdi->agc);

		if (sdi->agc) {
			speex_preprocess_ctl(sdi->state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &sdi->agclevel);
		}

		speex_preprocess_ctl(sdi->state, SPEEX_PREPROCESS_SET_DENOISE, &sdi->denoise);
	}

	speex_preprocess(sdi->state, frame->data.ptr, NULL);
	snprintf(source, sizeof(source), "%s/speex", frame->src);
	if (frame->mallocd & AST_MALLOCD_SRC) {
		ast_free((char *) frame->src);
	}
	frame->src = ast_strdup(source);
	frame->mallocd |= AST_MALLOCD_SRC;

	return 0;
}
开发者ID:bugrahantopall,项目名称:asterisk,代码行数:54,代码来源:func_speex.c

示例5: getBytesPerFrame

SoundPreprocessor::SoundPreprocessor(int sampleRate, int bytesPerSample, int channelNumber, int denoiseLevel){
	spx_int32_t i=1;
	spx_int32_t noisesuppress=(spx_int32_t)denoiseLevel;

	mBytesPerFrame = getBytesPerFrame(sampleRate, bytesPerSample, channelNumber);

	mpSpStat = speex_preprocess_state_init(mBytesPerFrame / sizeof(short), sampleRate);

	if(mpSpStat){
		speex_preprocess_ctl(mpSpStat, SPEEX_PREPROCESS_SET_DENOISE, &i);
		speex_preprocess_ctl(mpSpStat, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &noisesuppress);
	}else{
		mBytesPerFrame = 0;
	}
}
开发者ID:AngzAngy,项目名称:AudioProcess,代码行数:15,代码来源:SoundPreprocessor.cpp

示例6: speex_preprocess_ctl

void RakVoice::SetPreprocessorParameter(void* pre_state, int vartype, int val)
{
	if (pre_state){
		// Set parameter for just one preprocessor
		int ret = speex_preprocess_ctl((SpeexPreprocessState*)pre_state, vartype, &val);
		RakAssert(ret==0);
	} else {
		// Set parameter for all decoders
		for (unsigned int index=0; index < voiceChannels.Size(); index++)
		{
			int ret = speex_preprocess_ctl((SpeexPreprocessState*)voiceChannels[index]->pre_state, vartype, &val);
			RakAssert(ret==0);
		}
	}
}
开发者ID:pulkomandy,项目名称:.theRush-,代码行数:15,代码来源:RakVoice.cpp

示例7: encode_update

static int encode_update(struct aufilt_enc_st **stp, void **ctx,
			 const struct aufilt *af, struct aufilt_prm *prm)
{
	struct preproc *st;
	unsigned sampc;
	(void)ctx;

	if (!stp || !af || !prm || prm->ch != 1)
		return EINVAL;

	st = mem_zalloc(sizeof(*st), speexpp_destructor);
	if (!st)
		return ENOMEM;

	sampc = prm->srate * prm->ch * prm->ptime / 1000;

	st->state = speex_preprocess_state_init(sampc, prm->srate);
	if (!st->state)
		goto error;

	speex_preprocess_ctl(st->state, SPEEX_PREPROCESS_SET_DENOISE,
			     &pp_conf.denoise_enabled);
	speex_preprocess_ctl(st->state, SPEEX_PREPROCESS_SET_AGC,
			     &pp_conf.agc_enabled);

#ifdef SPEEX_PREPROCESS_SET_AGC_TARGET
	if (pp_conf.agc_enabled) {
		speex_preprocess_ctl(st->state,
				     SPEEX_PREPROCESS_SET_AGC_TARGET,
				     &pp_conf.agc_level);
	}
#endif

	speex_preprocess_ctl(st->state, SPEEX_PREPROCESS_SET_VAD,
			     &pp_conf.vad_enabled);
	speex_preprocess_ctl(st->state, SPEEX_PREPROCESS_SET_DEREVERB,
			     &pp_conf.dereverb_enabled);

	info("speex_pp: Speex preprocessor loaded: srate = %uHz\n",
	     prm->srate);

	*stp = (struct aufilt_enc_st *)st;
	return 0;

 error:
	mem_deref(st);
	return ENOMEM;
}
开发者ID:FOSSRIT,项目名称:baresip,代码行数:48,代码来源:speex_pp.c

示例8: speex_ec_preprocess

static void speex_ec_preprocess(MSFilter *f){
	SpeexECState *s=(SpeexECState*)f->data;
	int delay_samples=0;
	mblk_t *m;

	s->echostarted=FALSE;
	s->filterlength=(s->tail_length_ms*s->samplerate)/1000;
	s->framesize=adjust_framesize(s->framesize_at_8000,s->samplerate);
	delay_samples=s->delay_ms*s->samplerate/1000;
	ms_message("Initializing speex echo canceler with framesize=%i, filterlength=%i, delay_samples=%i",
		s->framesize,s->filterlength,delay_samples);
	
	s->ecstate=speex_echo_state_init(s->framesize,s->filterlength);
	s->den = speex_preprocess_state_init(s->framesize, s->samplerate);
	speex_echo_ctl(s->ecstate, SPEEX_ECHO_SET_SAMPLING_RATE, &s->samplerate);
	speex_preprocess_ctl(s->den, SPEEX_PREPROCESS_SET_ECHO_STATE, s->ecstate);
	/* fill with zeroes for the time of the delay*/
	m=allocb(delay_samples*2,0);
	m->b_wptr+=delay_samples*2;
	ms_bufferizer_put (&s->delayed_ref,m);
	s->min_ref_samples=-1;
	s->nominal_ref_samples=delay_samples;
	audio_flow_controller_init(&s->afc);
	s->flow_control_time = f->ticker->time;
#ifdef SPEEX_ECHO_GET_BLOB
	apply_config(s);
#else
	if (s->state_str) ms_warning("This version of speex doesn't support echo canceller restoration state. Rebuild speex and mediatreamer2 if you want to use this feature.");
#endif
}
开发者ID:korobool,项目名称:linphonecdbus,代码行数:30,代码来源:speexec.c

示例9: Reset

void CSpeexEC::Init(int frame_size, int filter_length, int sampling_rate)
{
    Reset();
    
    if (frame_size<=0 || filter_length<=0 || sampling_rate<=0)
    {
        m_nFrameSize  =160;
        m_nFilterLen  = 160*8;
        m_nSampleRate = 8000;
    }
    else
    {
        m_nFrameSize  =frame_size;
        m_nFilterLen  = filter_length;
        m_nSampleRate = sampling_rate;
    }
    
    m_pState = speex_echo_state_init(m_nFrameSize, m_nFilterLen);
    m_pPreprocessorState = speex_preprocess_state_init(m_nFrameSize, m_nSampleRate);
    m_pfNoise = new int[m_nFrameSize+1];
    m_bHasInit = true;
    
    speex_echo_ctl(m_pState, SPEEX_ECHO_SET_SAMPLING_RATE, &m_nSampleRate);
    speex_preprocess_ctl(m_pPreprocessorState, SPEEX_PREPROCESS_SET_ECHO_STATE, m_pState);
}
开发者ID:ParisiLabs,项目名称:AudioMix,代码行数:25,代码来源:CSpeexEC.cpp

示例10: Pa_GetDeviceInfo

void sound::start(){
	const PaDeviceInfo * info = Pa_GetDeviceInfo(indexInputDevice);
	inputStreamParameters.device = indexInputDevice;
	inputStreamParameters.channelCount = 1;
	inputStreamParameters.hostApiSpecificStreamInfo = 0;
	inputStreamParameters.sampleFormat = paInt16;
	inputStreamParameters.suggestedLatency = info->defaultLowInputLatency;

	PaError err = Pa_OpenStream(&input, &inputStreamParameters, 0, info->defaultSampleRate, BUFF_LONG, paNoFlag, sound::inputcallback, this);
	if (err != paNoError){
		throw std::exception("open stream err=%d", err);
	}
	err = Pa_StartStream(input);
	if (err != paNoError){
		throw std::exception("start stream err=%d", err);
	}

	speexppstate = speex_preprocess_state_init(BUFF_LONG*inputStreamParameters.channelCount, (int)info->defaultSampleRate);
	spx_int32_t on = 1;
	speex_preprocess_ctl(speexppstate, SPEEX_PREPROCESS_SET_AGC, &on);
	float agcLevel = 24000;
	speex_preprocess_ctl(speexppstate, SPEEX_PREPROCESS_SET_AGC_LEVEL, &agcLevel);    
	int denoise = 1;
	speex_preprocess_ctl(speexppstate, SPEEX_PREPROCESS_SET_DENOISE, &denoise); //½µÔë
	int noiseSuppress = -25;
	speex_preprocess_ctl(speexppstate, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &noiseSuppress); //ÉèÖÃÔëÉùµÄdB   

	speexechostate = speex_echo_state_init(BUFF_LONG*inputStreamParameters.channelCount, BUFF_LONG*inputStreamParameters.channelCount);
	
	info = Pa_GetDeviceInfo(indexOutputDevice);
	outputStreamParameters.device = indexOutputDevice;
	outputStreamParameters.channelCount = 1;
	outputStreamParameters.hostApiSpecificStreamInfo = 0;
	outputStreamParameters.sampleFormat = paInt16;
	outputStreamParameters.suggestedLatency = info->defaultLowOutputLatency;

	err = Pa_OpenStream(&output, 0, &outputStreamParameters, info->defaultSampleRate, BUFF_LONG, paNoFlag, sound::outputcallback, this);
	if (err != paNoError){
		throw std::exception("open stream err=%d", err);
	}
	err = Pa_StartStream(output);
	if (err != paNoError){
		throw std::exception("start stream err=%d", err);
	}
}
开发者ID:boyisgood86,项目名称:vchat,代码行数:45,代码来源:sound.cpp

示例11: m_context

NetworkSoundRecorder::NetworkSoundRecorder(State::Context* context)
: m_context(context)
, m_frameSize(160)
{
	speex_bits_init(&m_speexBits);
	m_speexState = speex_encoder_init(&speex_nb_mode);

	int quality = 6;
	speex_encoder_ctl(m_speexState, SPEEX_SET_QUALITY, &quality);

	int enabled = 1;
	int target = 16000;
	m_speexPreprocessState = speex_preprocess_state_init(m_frameSize, 8180);
	speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_SET_AGC, &enabled);
	speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_SET_AGC_TARGET, &target);

	setProcessingInterval(cpp3ds::milliseconds(100));
}
开发者ID:Cruel,项目名称:DrawAttack,代码行数:18,代码来源:NetworkSoundRecorder.cpp

示例12: pj_pool_create

/*
 * Create the echo canceller.
 */
pjs_echo_canceller::pjs_echo_canceller(pj_pool_t *pool_, unsigned clock_rate,
		unsigned samples_per_frame_, unsigned tail_ms, unsigned latency_ms,
		unsigned options) {
	int sampling_rate = clock_rate;
	unsigned ptime, lat_cnt;
	unsigned delay_buf_opt = 0;

	lat_ready = PJ_FALSE;
	/* Create new pool and instantiate and init the EC */
	pool = pj_pool_create(pool_->factory, "ec%p", 256, 256, NULL);
	lock = new PPJ_SemaphoreLock(pool, NULL, 1, 1);
	samples_per_frame = samples_per_frame_;
	frm_buf = (pj_int16_t*) pj_pool_alloc(pool, samples_per_frame << 1);

    state = speex_echo_state_init(samples_per_frame,
    					clock_rate * tail_ms / 1000);

    speex_echo_ctl(state, SPEEX_ECHO_SET_SAMPLING_RATE,
		   &sampling_rate);

    preprocess = speex_preprocess_state_init(samples_per_frame,
						   clock_rate);
    tmp_frame = (pj_int16_t*) pj_pool_zalloc(pool, 2*samples_per_frame);

    speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_SET_ECHO_STATE,
 			state);

	pj_list_init(&lat_buf);
	pj_list_init(&lat_free);

	PJ_LOG(5, (THIS_FILE, "Creating echo canceler"));

	/* Create latency buffers */
	ptime = samples_per_frame * 1000 / clock_rate;
	if (latency_ms < ptime) {
		/* Give at least one frame delay to simplify programming */
		latency_ms = ptime;
	}
	lat_cnt = latency_ms / ptime;
	while (lat_cnt--) {
		struct frame *frm;

		frm = (struct frame*) pj_pool_alloc(pool,
				(samples_per_frame << 1) + sizeof(struct frame));
		pj_list_push_back(&lat_free, frm);
	}

	/* Create delay buffer to compensate drifts */
	if (options & PJMEDIA_ECHO_USE_SIMPLE_FIFO)
		delay_buf_opt |= PJMEDIA_DELAY_BUF_SIMPLE_FIFO;
	pjmedia_delay_buf_create(pool, NULL, clock_rate, samples_per_frame,
			1, (PJMEDIA_SOUND_BUFFER_COUNT + 1) * ptime, delay_buf_opt,
			&delay_buf);
	PJ_LOG(4, (THIS_FILE, "ECHO canceller created, clock_rate=%d, channel=%d, "
	"samples per frame=%d, tail length=%d ms, "
	"latency=%d ms", clock_rate, 1, samples_per_frame, tail_ms, latency_ms));
}
开发者ID:ddv2005,项目名称:intercom,代码行数:60,代码来源:echo_canceller.cpp

示例13: speex_preprocess_ctl

UtlBoolean MprSpeexPreprocess::attachEchoCanceller(SpeexEchoState* pEchoState)
{
   if (pEchoState && mpPreprocessState)
   {
      // attach echo canceller
      speex_preprocess_ctl(mpPreprocessState, SPEEX_PREPROCESS_SET_ECHO_STATE, pEchoState);
   }
   
   return FALSE;
}
开发者ID:Jaroslav23,项目名称:sipxtapi,代码行数:10,代码来源:MprSpeexPreProcess.cpp

示例14: speex_echo_state_init

  JNIEXPORT void JNICALL Java_com_pullmi_shanghai_TalkActivity_speex_1EchoCanceller_1open
(JNIEnv *env, jobject jobj, jint jSampleRate, jint jBufSize, jint jTotalSize)
{
  //init 
  int sampleRate = jSampleRate;
  st = speex_echo_state_init(jBufSize, jTotalSize);
  den = speex_preprocess_state_init(jBufSize, sampleRate);
  speex_echo_ctl(st, SPEEX_ECHO_SET_SAMPLING_RATE, &sampleRate);
  speex_preprocess_ctl(den, SPEEX_PREPROCESS_SET_ECHO_STATE, st);
}
开发者ID:hwppippo,项目名称:smartHouse,代码行数:10,代码来源:speex_jni.c

示例15: speex_preprocess_state_destroy

void AudioInput::resetAudioProcessor() {
	if (!bResetProcessor)
		return;

	int iArg;

	if (sppPreprocess)
		speex_preprocess_state_destroy(sppPreprocess);
	if (sesEcho)
		speex_echo_state_destroy(sesEcho);

	sppPreprocess = speex_preprocess_state_init(iFrameSize, iSampleRate);

	iArg = 1;
	speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_VAD, &iArg);
	speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC, &iArg);
	speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_DENOISE, &iArg);
	speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_DEREVERB, &iArg);

	iArg = 30000;
	speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_TARGET, &iArg);

	float v = 30000.0f / static_cast<float>(g.s.iMinLoudness);
	iArg = iroundf(floorf(20.0f * log10f(v)));
	speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_MAX_GAIN, &iArg);

	iArg = -60;
	speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_AGC_DECREMENT, &iArg);

	iArg = g.s.iNoiseSuppress;
	speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &iArg);

	if (iEchoChannels > 0) {
		sesEcho = speex_echo_state_init_mc(iFrameSize, iFrameSize * 10, 1, bEchoMulti ? iEchoChannels : 1);
		iArg = iSampleRate;
		speex_echo_ctl(sesEcho, SPEEX_ECHO_SET_SAMPLING_RATE, &iArg);
		speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_SET_ECHO_STATE, sesEcho);

		qWarning("AudioInput: ECHO CANCELLER ACTIVE");
	} else {
		sesEcho = NULL;
	}

	bResetEncoder = true;

	bResetProcessor = false;
}
开发者ID:AceXare,项目名称:mumble,代码行数:47,代码来源:AudioInput.cpp


注:本文中的speex_preprocess_ctl函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。