Mercurial > hg > gpsynth
comparison 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 |
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 // Converter class for SuperCollider, handles converting to synthdefs and dot | |
20 // graphs | |
21 | |
22 #pragma once | |
23 | |
24 #include "converter.hpp" | |
25 #include "sc_grammar.hpp" | |
26 #include "synth_graph.hpp" | |
27 | |
28 #include <map> | |
29 #include <set> | |
30 #include <sstream> | |
31 #include <vector> | |
32 | |
33 namespace sc { | |
34 | |
35 class Converter : public ConverterInterface { | |
36 const std::vector<sc::Command>& commands_; | |
37 std::map<sg::Vertex, int> variable_map_; | |
38 std::set<int> available_variables_; | |
39 int variables_created_; | |
40 std::stringstream command_script_; | |
41 | |
42 public: | |
43 Converter(const sc::Grammar& grammar) : commands_(grammar.Commands()) {} | |
44 | |
45 // converts a graph to graphviz DOT format | |
46 std::string ToDOT(const sg::Graph& graph); | |
47 | |
48 // generates a supercollider script intended for realtime use | |
49 void Export(const sg::Graph& graph, | |
50 const std::string& export_folder, | |
51 const std::string& export_name); | |
52 | |
53 // converts a graph to a supercollider synthdef | |
54 std::string ToSynthDef(const sg::Graph& graph, | |
55 const std::string& synth_name, | |
56 bool prepare_for_render = true, | |
57 const std::string& synthdef_path = ""); | |
58 | |
59 // generates a supercollider score for the graph | |
60 std::string ToScore(const sg::Graph& graph, | |
61 const std::string& synth_name, | |
62 const std::string& score_variable, | |
63 bool prepare_for_render = true, | |
64 const std::string& synthdef_path = "", | |
65 double render_length = 0); | |
66 | |
67 private: | |
68 void SynthDefVertex(sg::Vertex vertex, const sg::Graph& graph); | |
69 void SynthDefCommand(sg::Vertex vertex, | |
70 const sg::Node& node, | |
71 const sg::Graph& graph); | |
72 void SynthDefSpecial(sg::Vertex vertex, | |
73 const sg::Node& node, | |
74 const sg::Graph& graph); | |
75 | |
76 int AssignVariable(sg::Vertex vertex); | |
77 int GetVariable(sg::Vertex vertex); | |
78 }; | |
79 | |
80 } // sc namespace |