/*
 *
 *
 *    dec_card.h
 *
 *    Sound card-based NOAA NWS / EAS data decoder.
 *
 *    Copyright (C) 2018 by Matt Roberts.
 *    License: GNU GPL3 (www.gnu.org)
 *
 *
 */

#ifndef __NWS_DEC_CARD_H
#define __NWS_DEC_CARD_H

#include <stdint.h>

#include "decoder.h"
#include "dec_file.h"
#include "sc.h"

#include "localtypes.h"

//
//  sound card
//
class SoundCardWX : public SoundCard {
	private:
		// the demodulator
		detector_t demod;

		// the decoder
		Decoder decoder;

		#if CARD_FS != MODEM_FS
		// decimation and interpolation filters
		fir_filter_t m_DecFilter;

		// decimation counter
		size_t dec_ctr;
		#endif

		// clipping flag
		bool clipping;

	public:
		SoundCardWX(int id, const detector_t::Config &c, int win = 512);

		bool isClipping() {
			bool result = clipping;
			clipping = false;
			return result;
		}
	
	protected:
		virtual void event(int16_t *in, int16_t *out, size_t count);
};

#endif
