Mercurial > hg > gpsynth
view src/sc_converter.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 source
// 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/. // Converter class for SuperCollider, handles converting to synthdefs and dot // graphs #pragma once #include "converter.hpp" #include "sc_grammar.hpp" #include "synth_graph.hpp" #include <map> #include <set> #include <sstream> #include <vector> namespace sc { class Converter : public ConverterInterface { const std::vector<sc::Command>& commands_; std::map<sg::Vertex, int> variable_map_; std::set<int> available_variables_; int variables_created_; std::stringstream command_script_; public: Converter(const sc::Grammar& grammar) : commands_(grammar.Commands()) {} // converts a graph to graphviz DOT format std::string ToDOT(const sg::Graph& graph); // generates a supercollider script intended for realtime use void Export(const sg::Graph& graph, const std::string& export_folder, const std::string& export_name); // converts a graph to a supercollider synthdef std::string ToSynthDef(const sg::Graph& graph, const std::string& synth_name, bool prepare_for_render = true, const std::string& synthdef_path = ""); // generates a supercollider score for the graph std::string ToScore(const sg::Graph& graph, const std::string& synth_name, const std::string& score_variable, bool prepare_for_render = true, const std::string& synthdef_path = "", double render_length = 0); private: void SynthDefVertex(sg::Vertex vertex, const sg::Graph& graph); void SynthDefCommand(sg::Vertex vertex, const sg::Node& node, const sg::Graph& graph); void SynthDefSpecial(sg::Vertex vertex, const sg::Node& node, const sg::Graph& graph); int AssignVariable(sg::Vertex vertex); int GetVariable(sg::Vertex vertex); }; } // sc namespace