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