Пример #1
0
int main(int, char **)
{
	ProcessorGroup g;

	ProcessorFactory::create("WaveGen")->
		init("wavegen", g, Properties("Frequency", 1000.)("PlungersPerSecond", 1.)
			("Stop After", 1.));
	SubProcessorFactory::createDom("FFT")->
		init("fft", g, Properties("Size", 512)("Step", 256));
	(new DomProcessor(new ModeFrequency))->init("modefrequency", g);
	(new PrintAverage)->init("printaverage", g);
	
	g["wavegen"][0] >>= g["fft"][0];
	g["fft"][0] >>= g["modefrequency"][0];
	g["modefrequency"][0] >>= g["printaverage"][0];
	
	if(!g.go(true))
		qFatal("Error starting processors!");
	
	g["printaverage"].waitUntilDone();
	
	g.stop();
	g.disconnectAll();
	g.deleteAll();
}
Пример #2
0
int main()
{
    Processor	*O = new PlungeGenerator,
    *D = new PlungeDetector,
    *E = new PlungeDetector,
    *F = new PlungeDetector,
    *I = new PlungeEater;

    ProcessorGroup objects;
    O->init("O", objects);
    D->init("D", objects);
    E->init("E", objects);
    F->init("F", objects);
    I->init("I", objects);

    std::cout << "Connecting..." << std::endl;
    (*O)[0].setSize(10).split();
    (*O)[0] >>= (*D)[0].setSize(10);
    (*O)[0] >>= (*F)[0].setSize(10);
    (*O)[0] >>= (*E)[0].setSize(10);
    (*E)[0] >>= (*I)[0].setSize(10);

    std::cout << "Checking network..." << std::endl;
    if (!objects.confirmTypes())
        qFatal("Couldn't confirm types.");

    theCount = 0;
    theMutex.lock();

    std::cout << "Starting objects..." << std::endl;
    objects.go();

    std::cout << "Waiting for 5 plungers..." << std::endl;
    while (theCount < 5)
        theCondition.wait(&theMutex);
    theMutex.unlock();

    std::cout << "Stopping objects..." << std::endl;
    objects.stop();

    std::cout << "Disconnecting..." << std::endl;
    (*O)[0] --;
    (*E)[0] --;
}
Пример #3
0
bool amaroK::CreateMood::doJob()
{
	//do some work in thread...
	QString theMoodName = theFilename;
	QString ext = theMoodName.right(3).lower();
	theMoodName.truncate(theMoodName.findRev('.'));
	theMoodName += ".mood";
	if(AmarokConfig::moodsWithMusic())
		theMoodName.insert(theMoodName.findRev('/') + 1, '.');
	else
	{	theMoodName.replace('/', ',');
		theMoodName = ::locateLocal("data", "amarok/moods/" + theMoodName);
	}
	if(QFile::exists(theMoodName))
	{	QFile mood(theMoodName);
		if(mood.open(IO_ReadOnly)) return true;
	}
	if(!QFile::exists(theFilename)) return false;
	{	QFile testopen(theFilename);
		if(!testopen.open(IO_ReadOnly)) return false;
	}
#ifdef HAVE_EXSCALIBAR
	debug() << "MakeMood: Creating mood with Exscalibar. Hold onto your hats..." << endl;
	ProcessorGroup g;
        Processor *proc = ProcessorFactory::create("Player");
        if( !proc )
        {
            g.deleteAll();
            return false;
        }
        proc->init("P", g, Properties("Filename", theFilename));
	if(g["P"].isInitFailed()) { /*amaroK::StatusBar::instance()->longMessageThreadSafe("<strong>Cannot generate Mood data:</strong> Format <em>"+ext+"</em> not supported by your Exscalibar installation.", KDE::StatusBar::Warning);*/ g.deleteAll(); return false; }
	SubProcessorFactory::createDom("Mean")->init("M", g);
	SubProcessorFactory::createDom("FFT")->init("F", g, Properties("Size", 1024)("Step", 512));
	SubProcessorFactory::createDom("Bark")->init("B", g);
	SubProcessorFactory::createDom("Fan")->init("S", g, Properties("Multiplicity", 3)("Consolidate", 1));
	MultiProcessor *W = (new MultiProcessor(new SubFactoryCreator("Magnitude"))); W->init("W", g, Properties("Multiplicity", 3));
	MultiProcessor *N = (new MultiProcessor(new FactoryCreator("Normalise"))); N->init("N", g, Properties("Multiplicity", 3));
	ProcessorFactory::create("Dumper")->init("D", g, Properties("Multiplicity", 3)("Pad Before", 0)("Pad After", 0)("Print Section", false)("Print Sample", false)("Print Time", false)("Field Delimiter", " ")("Output", theMoodName));
	g["P"] >>= g["M"];
	g["M"][0] >>= g["F"][0];
	g["F"][0] >>= g["B"][0];
	g["B"][0] >>= g["S"][0];
	g["S"] >>= (*W);
	(*W) >>= (*N);
	(*N) >>= g["D"];
	if(g.go())
	{
		debug() << "MakeMood: Processing..." << endl;
		g["D"].waitUntilDone();
		debug() << "MakeMood: Done processing. Stoping..." << flush;
		g.stop();
	}
	debug() << "MakeMood: Disconnecting..." << flush;
	g.disconnectAll();
	debug() << "MakeMood: Deleting..." << flush;
	g.deleteAll();
	debug() << "MakeMood: All tidied up." << endl;
	if(!QFile::exists(theMoodName)) { /*amaroK::StatusBar::instance()->longMessageThreadSafe("<strong>Cannot generate Mood data:</strong> Could not create file (check permissions and Exscalibar installation).", KDE::StatusBar::Warning);*/ return false; }
	QFile mood(theMoodName);
	if(!mood.open(IO_ReadOnly)) { /*amaroK::StatusBar::instance()->longMessageThreadSafe("<strong>Cannot generate Mood data:</strong> Could not verify file (check permissions).", KDE::StatusBar::Warning);*/ return false; }
	return true;
#else
	return false;
#endif
}