diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sc_evaluator.hpp	Thu Aug 25 11:05:55 2011 +0100
@@ -0,0 +1,77 @@
+//  Copyright 2011, Ian Hobson.
+//
+//  This file is part of gpsynth.
+//
+//  gpsynth is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  gpsynth is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with gpsynth in the file COPYING. 
+//  If not, see http://www.gnu.org/licenses/.
+
+// Evaluator for SuperCollider synth graphs. Sends converted synthdefs to
+// SuperCollider for rendering.
+
+#pragma once
+
+#include "evaluator.hpp"
+#include "file_comparer.hpp"
+#include "sc_grammar.hpp"
+
+#include "boost/shared_ptr.hpp"
+#include "boost/thread/barrier.hpp"
+#include "boost/thread/condition_variable.hpp"
+#include "boost/thread/mutex.hpp"
+
+#include <queue>
+#include <string>
+
+namespace sc {
+
+// forward declaration of worker
+class EvaluatorWorker;
+typedef boost::shared_ptr<EvaluatorWorker> EvaluatorWorkerPtr;
+
+class Evaluator : public EvaluatorInterface {
+  friend class EvaluatorWorker;
+  const sc::Grammar& grammar_;
+  const std::string sc_app_path_;
+  const std::string sc_plugins_path_;
+  const std::string sclang_path_;
+  const std::string scsynth_path_;
+  std::string work_folder_;
+  std::string osc_folder_;
+  std::string audio_folder_;
+  std::string sc_folder_;
+  std::string synthdef_folder_;
+  std::queue<sg::Graph*> work_queue_;
+  boost::mutex work_mutex_;
+  boost::condition_variable queue_condition_;
+  boost::condition_variable work_done_condition_;
+  boost::shared_ptr<boost::barrier> work_done_barrier_;
+  std::vector<EvaluatorWorkerPtr> workers_;
+  std::size_t graphs_to_rate_;
+  EvaluatorListenerInterface* listener_;
+  int synth_name_zero_pad_length_;
+  
+public:
+  Evaluator(const sc::Grammar& grammar,
+            const std::string& sc_app_path,
+            const dsp::FileComparer& target,
+            int core_limit = 0);
+  ~Evaluator();
+  void RateGraphs(std::vector<sg::Graph>& graphs);
+  void SetWorkFolder(const std::string& path);
+  void SetListener(EvaluatorListenerInterface* listener) { 
+    listener_ = listener;
+  }
+};
+  
+} // sc namespace