comparison src/sc_evaluator.hpp @ 0:add35537fdbb tip

Initial import
author irh <ian.r.hobson@gmail.com>
date Thu, 25 Aug 2011 11:05:55 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:add35537fdbb
1 // Copyright 2011, Ian Hobson.
2 //
3 // This file is part of gpsynth.
4 //
5 // gpsynth is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // gpsynth is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with gpsynth in the file COPYING.
17 // If not, see http://www.gnu.org/licenses/.
18
19 // Evaluator for SuperCollider synth graphs. Sends converted synthdefs to
20 // SuperCollider for rendering.
21
22 #pragma once
23
24 #include "evaluator.hpp"
25 #include "file_comparer.hpp"
26 #include "sc_grammar.hpp"
27
28 #include "boost/shared_ptr.hpp"
29 #include "boost/thread/barrier.hpp"
30 #include "boost/thread/condition_variable.hpp"
31 #include "boost/thread/mutex.hpp"
32
33 #include <queue>
34 #include <string>
35
36 namespace sc {
37
38 // forward declaration of worker
39 class EvaluatorWorker;
40 typedef boost::shared_ptr<EvaluatorWorker> EvaluatorWorkerPtr;
41
42 class Evaluator : public EvaluatorInterface {
43 friend class EvaluatorWorker;
44 const sc::Grammar& grammar_;
45 const std::string sc_app_path_;
46 const std::string sc_plugins_path_;
47 const std::string sclang_path_;
48 const std::string scsynth_path_;
49 std::string work_folder_;
50 std::string osc_folder_;
51 std::string audio_folder_;
52 std::string sc_folder_;
53 std::string synthdef_folder_;
54 std::queue<sg::Graph*> work_queue_;
55 boost::mutex work_mutex_;
56 boost::condition_variable queue_condition_;
57 boost::condition_variable work_done_condition_;
58 boost::shared_ptr<boost::barrier> work_done_barrier_;
59 std::vector<EvaluatorWorkerPtr> workers_;
60 std::size_t graphs_to_rate_;
61 EvaluatorListenerInterface* listener_;
62 int synth_name_zero_pad_length_;
63
64 public:
65 Evaluator(const sc::Grammar& grammar,
66 const std::string& sc_app_path,
67 const dsp::FileComparer& target,
68 int core_limit = 0);
69 ~Evaluator();
70 void RateGraphs(std::vector<sg::Graph>& graphs);
71 void SetWorkFolder(const std::string& path);
72 void SetListener(EvaluatorListenerInterface* listener) {
73 listener_ = listener;
74 }
75 };
76
77 } // sc namespace