Esempio n. 1
0
int main(int argc, char *argv[]){
	if(argc != 3){
		usage(argv[0], stderr);
		exit(1);
	}

	FILE *inputFile = fopen(argv[1], "r");

	if(NULL == inputFile){
		fprintf(stderr, "File %s not exist.\n", argv[1]);
		exit(1);
	}

	FILE *outputFile = fopen(argv[2], "w");
	List *list = makeList(inputFile);
	removeInvalidData(list);
	lowPassFilter(list);
	setStatus(list);
	outputResult(list, outputFile);

	fclose(inputFile);
	fclose(outputFile);

	freeList(list);
	return 0;
}
Esempio n. 2
0
void bandpassFilter(vector<double> & in, double sampFreq,int order = 1, double lCutoff=.1,double hCutoff=25){
	while(order){
		highPassFilter(in,sampFreq,lCutoff);
		lowPassFilter(in,sampFreq,hCutoff);
		order--;
	}
}
Esempio n. 3
0
void performLowPass(const cv::Mat& image, cv::Mat& res, int rad) {
    cv::Mat grey, tmp;
    cv::cvtColor(image, grey, CV_BGR2GRAY);


    grey.convertTo(grey, CV_32F);
    grey.copyTo(res);
    res.convertTo(res, CV_8U);
    std::vector<cv::Mat> planes(2, cv::Mat());
    std::vector<cv::Mat> polar(2, cv::Mat());

    cv::dft(grey, tmp, cv::DFT_COMPLEX_OUTPUT);
    cv::split(tmp, planes);
    cv::cartToPolar(planes[0], planes[1], polar[0], polar[1]);
    visualization(polar[0], tmp);
    concatImages(res, tmp, res);

    rearrangeQuadrants(polar[0]);
    lowPassFilter(polar[0], rad);
    rearrangeQuadrants(polar[0]);

    visualization(polar[0], tmp);
    tmp.convertTo(tmp, res.type());
    concatImages(res, tmp, res);

    cv::polarToCart(polar[0], polar[1], planes[0], planes[1]);
    cv::merge(planes, tmp);
    cv::dft(tmp, tmp, cv::DFT_SCALE | cv::DFT_INVERSE | cv::DFT_REAL_OUTPUT);
    tmp.convertTo(tmp, CV_8U);
    concatImages(res, tmp, res);
}
Esempio n. 4
0
void twistCallback(const geometry_msgs::Twist& twist){
    double x =  twist.linear.x;
    double y = twist.linear.y;
	double z = twist.angular.z;

	x_ = lowPassFilter(x, x_, dt, T);
	y_ = lowPassFilter(y, y_, dt, T);
	z_ = lowPassFilter(z, z_, dt, T);


	geometry_msgs::Twist t;
	t.linear.x = x_;
	t.linear.y = y_;
	t.angular.z = z_;

	twistPublisher.publish(t);

}
//-----------------------------------------------------------------------------
// Name: paCallback( )
// Desc: Callback from PortAudio
//-----------------------------------------------------------------------------
static int paCallback( const void *inputBuffer,
        void  *outputBuffer, unsigned long framesPerBuffer,
        const PaStreamCallbackTimeInfo* timeInfo,
        PaStreamCallbackFlags statusFlags, void *userData ) 
{
    /* Cast Appropriate Types and Define Some Useful Variables */
    (void) inputBuffer;
    float* out = (float*)outputBuffer;
    paData *data = (paData*)userData;
    int i, numberOfFrames, numInFrames;

    /* This if Statement Ensures Smooth VariSpeed Output */
    if (fmod((double)framesPerBuffer, data->src_data.src_ratio) == 0)
    {
    	numInFrames = framesPerBuffer;
    }
    else
    	numInFrames = (framesPerBuffer/data->src_data.src_ratio) + 2;

    /* Read FramesPerBuffer Amount of Data from inFile into buffer[] */
    numberOfFrames = sf_readf_float(data->inFile, data->src_inBuffer, numInFrames);

    /* Looping of inFile if EOF is Reached */
    if (numberOfFrames < framesPerBuffer/data->src_data.src_ratio) 
    {
        sf_seek(data->inFile, 0, SEEK_SET);
    }

    /* Inform SRC Data How Many Input Frames To Process */
    data->src_data.input_frames = numberOfFrames;
    data->src_data.end_of_input = 0;

    /* Perform SRC Modulation, Processed Samples are in src_outBuffer[] */
    if ((data->src_error = src_process (data->src_state, &data->src_data))) {   
        printf ("\nError : %s\n\n", src_strerror (data->src_error)) ;
        exit (1);
    }

    /* Perform Lowpass Filtering */
    if (data->lpf_On == true) {
        lowPassFilter(data->src_outBuffer, data->sfinfo1.channels);
    }

    /* Perform Highpass Filtering */
    if (data->hpf_On == true) {
        highPassFilter(data->src_outBuffer, data->sfinfo1.channels);
    }

    /* Prevent Blowing Out the Speakers Hopefully */
    brickwall(data->src_outBuffer, data->sfinfo1.channels);

    // printf("%ld, %ld\n",data->src_data.output_frames_gen, data->src_data.input_frames_used);

    /* Write Processed SRC Data to Audio Out and Visual Out */
    for (i = 0; i < framesPerBuffer * data->sfinfo1.channels; i++)
    {
        out[i] = data->src_outBuffer[i] * data->amplitude;
    }

    g_ready = true;
    return 0;
}