All pastes #472805 Raw Edit

Untitled

public cpp v1 · immutable
·published 2007-05-05 20:38 UTC
rendered paste body
#ifndef NoteCounter_hxx#define NoteCounter_hxx#include <vector>#include <iostream>#include <algorithm> #include <iterator>#include <CLAM/InPort.hxx>#include <CLAM/OutPort.hxx>#include <CLAM/Processing.hxx>#include <CLAM/NullProcessingConfig.hxx>#include <numeric>// Those two configuration types could be the ones you choose.// Your own ones or any type already in CLAM.#include "CLAM/Fundamental.hxx"#include <CLAM/SpectralPeakArray.hxx>class NoteCounter : public CLAM::Processing{  		CLAM::InPort<CLAM::SpectralPeakArray> mIn;	typedef CLAM::NullProcessingConfig Config;public:	const char* GetClassName() const { return "NoteCounter";  }	NoteCounter(const Config & config=Config()) 		: mIn("CLAM::SpectralPeakArray", this)	{		Configure( config );	} 	~NoteCounter() {}		// Configuration to the minimal expression	bool ConcreteConfigure(const CLAM::ProcessingConfig&)	{		return true; // I got proper configuration	}	const CLAM::ProcessingConfig& GetConfig() const	{		static Config config;		return config;	}		bool Do()	{		bool result = Do(mIn.GetData()); 			// Tell the ports this is done		mIn.Consume();				return result;	}		bool Do(const CLAM::SpectralPeakArray & in)	{			const CLAM::Array<CLAM::TData> & magnitudes = mIn.GetData().GetMagBuffer();		return true;	}		bool ConcreteStop()	{int i = 0;while (i<magnitudes.Size()) {i++; std::cout << magnitudes[i]; << std::endl;}std::cout << "Done." << std::endl;				return 1;	}};#endif // NoteCounter_hxx