/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAS_BLOCK_FILTER_H_
#define __GDAS_BLOCK_FILTER_H_

typedef struct _GdasBlockFilterClass GdasBlockFilterClass;
typedef struct _GdasBlockFilter GdasBlockFilter;

#include "gdasfilter.h"

GtkType gdas_block_filter_get_type();
#define GDAS_TYPE_BLOCK_FILTER   gdas_block_filter_get_type()
#define GDAS_BLOCK_FILTER(ptr) ((GdasBlockFilter*) gtk_type_check_object_cast ((GtkTypeObject*) (ptr), GDAS_TYPE_BLOCK_FILTER))
#define GDAS_BLOCK_FILTER_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GDAS_TYPE_BLOCK_FILTER, GdasBlockFilterClass))
#define GDAM_IS_BLOCK_FILTER(obj)           (GTK_CHECK_TYPE ((obj), GDAS_TYPE_BLOCK_FILTER))
#define GDAM_IS_BLOCK_FILTER_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GDAS_TYPE_BLOCK_FILTER))

struct _GdasBlockFilterClass {
	GdasFilterClass		filter_class;
        int                   (*process_block)(GdasBlockFilter   *filter,
                                               GdamSample        *output,
                                               const GdamSample  *input);
        void                  (*set_block_sizes)(GdasBlockFilter *block_sizes,
                                               int                input_size,
                                               int                output_size);
};

struct _GdasBlockFilter {
	GdasFilter		base;
	int			input_block_size;
	int			output_block_size;

        GdamSample             *output_block_buffer;
        GdamSample             *input_block_buffer;
        GdamSample             *output_at;
	int			cur_input_length;
	int			cur_output_length;

	/* Samples missed via `miss_data' */
	int			missed;
};

void gdas_block_filter_set_sizes(GdasBlockFilter *filter,
                                 int              input_sizes,
                                 int              output_sizes);
#endif
