All pastes #440248 Raw Edit

Rafb timed out

public text v1 · immutable
·published 2007-04-14 21:58 UTC
rendered paste body
#ifndef MyProcessing_hxx
#define MyProcessing_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"
 
class MyProcessing : public CLAM::Processing
{  	
	CLAM::InPort<CLAM::Fundamental> mIn;
	typedef CLAM::NullProcessingConfig Config;
public:
	
std::vector<float> notes;
int output;


	const char* GetClassName() const { return "MyProcessing";  }
	MyProcessing(const Config & config=Config()) 
		: mIn("CLAM::Fundamental", this)
		
	{
		Configure( config );
	}
 
	~MyProcessing() {}
	

	// 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()); 
		notes.reserve(450);
		
		// Tell the ports this is done
		mIn.Consume();
		return result;
	}

	bool Do(const CLAM::Fundamental& in )
	{	notes.push_back(in.GetCandidatesFreq()[0]); 
		//std::vector::value_type sum = std::accumulate(array.begin(), array.end(), 0.0f);
		std::sort(notes.begin(), notes.end());
		int c = sizeof notes / 2;
		output = notes[c];
		std::cout << output << std::endl;
//std::copy(output.begin(), output.end(), std::ostream_iterator<float>(std::cout,"\n"));	
				return true;
	}
};
#endif // MyProcessing_hxx