00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: mpf_activity_detector.h 1474 2010-02-07 20:51:47Z achaloyan $ 00017 */ 00018 00019 #ifndef MPF_ACTIVITY_DETECTOR_H 00020 #define MPF_ACTIVITY_DETECTOR_H 00021 00022 /** 00023 * @file mpf_activity_detector.h 00024 * @brief MPF Voice Activity Detector 00025 */ 00026 00027 #include "mpf_frame.h" 00028 #include "mpf_codec_descriptor.h" 00029 00030 APT_BEGIN_EXTERN_C 00031 00032 /** Opaque (voice) activity detector */ 00033 typedef struct mpf_activity_detector_t mpf_activity_detector_t; 00034 00035 /** Events of activity detector */ 00036 typedef enum { 00037 MPF_DETECTOR_EVENT_NONE, /**< no event occurred */ 00038 MPF_DETECTOR_EVENT_ACTIVITY, /**< voice activity (transition to activity from inactivity state) */ 00039 MPF_DETECTOR_EVENT_INACTIVITY, /**< voice inactivity (transition to inactivity from activity state) */ 00040 MPF_DETECTOR_EVENT_NOINPUT /**< noinput event occurred */ 00041 } mpf_detector_event_e; 00042 00043 00044 /** Create activity detector */ 00045 MPF_DECLARE(mpf_activity_detector_t*) mpf_activity_detector_create(apr_pool_t *pool); 00046 00047 /** Reset activity detector */ 00048 MPF_DECLARE(void) mpf_activity_detector_reset(mpf_activity_detector_t *detector); 00049 00050 /** Set threshold of voice activity (silence) level */ 00051 MPF_DECLARE(void) mpf_activity_detector_level_set(mpf_activity_detector_t *detector, apr_size_t level_threshold); 00052 00053 /** Set noinput timeout */ 00054 MPF_DECLARE(void) mpf_activity_detector_noinput_timeout_set(mpf_activity_detector_t *detector, apr_size_t noinput_timeout); 00055 00056 /** Set timeout required to trigger speech (transition from inactive to active state) */ 00057 MPF_DECLARE(void) mpf_activity_detector_speech_timeout_set(mpf_activity_detector_t *detector, apr_size_t speech_timeout); 00058 00059 /** Set timeout required to trigger silence (transition from active to inactive state) */ 00060 MPF_DECLARE(void) mpf_activity_detector_silence_timeout_set(mpf_activity_detector_t *detector, apr_size_t silence_timeout); 00061 00062 /** Process current frame, return detected event if any */ 00063 MPF_DECLARE(mpf_detector_event_e) mpf_activity_detector_process(mpf_activity_detector_t *detector, const mpf_frame_t *frame); 00064 00065 00066 APT_END_EXTERN_C 00067 00068 #endif /* MPF_ACTIVITY_DETECTOR_H */