Debian Codegraph @

iOS/Csound iOS Obj-C Examples/csound-iOS/headers/CsoundFile.hpp

raw symbols SCIP
1 /*
2 * C S O U N D
3 *
4 * L I C E N S E
5 *
6 * This software is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this software; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 #ifndef CSOUNDFILE_H
21 #define CSOUNDFILE_H
22
23 #undef MYFLT
24 #ifdef USE_DOUBLE
25 #define MYFLT double
26 #else
27 #define MYFLT float
28 #endif
29
30 #if defined(_MSC_VER) && !defined(__GNUC__)
31 #pragma warning(disable: 4786)
32 #endif
33 #ifdef SWIG
34 %module csnd
35 %include "std_string.i"
36 %include "std_vector.i"
37 #if !defined(SWIGLUA)
38 %include "std_map.i"
39 %template(IntToStringMap) std::map<int, std::string>;
40 #endif
41 %{
42 #include <string>
43 #include <vector>
44 %}
45 #else
46 #include <iostream>
47 #include <string>
48 #include <vector>
49 #include <map>
50 #include <fstream>
51 #include <sstream>
52 #include <stdlib.h>
53
54 #if defined(WIN32)
55 #define PUBLIC __declspec(dllexport)
56 #include <io.h>
57 #elif defined(__GNUC__) && !defined(__MACH__)
58 #if !defined(PUBLIC)
59 #define PUBLIC __attribute__ ( (visibility("default")) )
60 #endif
61 #else
62 #define PUBLIC
63 #endif
64 #endif
65
66 void PUBLIC gatherArgs(int argc, const char **argv, std::string &commandLine);
67
68 void PUBLIC scatterArgs(const std::string commandLine, std::vector<std::string> &args, std::vector<char *> &argv);
69
70 std::string PUBLIC &trim(std::string &value);
71
72 std::string PUBLIC &trimQuotes(std::string &value);
73
74 /**
75 * Returns true if definition is a valid Csound instrument definition block.
76 * Also returns the part before the instr number, the instr number,
77 * the name (all text after the first comment on the same line as the instr number),
78 * and the part after the instr number, all by reference.
79 */
80 bool PUBLIC parseInstrument(const std::string &definition, std::string &preNumber, std::string &id, std::string &name, std::string &postNumber);
81
82 /**
83 * Manages a Csound Structured Data (CSD) file with facilities
84 * for creating an arrangement of selected instruments in the orchestra,
85 * and for programmatically building score files.
86 */
87 class PUBLIC CsoundFile
88 {
89 protected:
90 /**
91 * What are we storing, anyway?
92 */
93 std::string filename;
94 /**
95 * CsOptions
96 */
97 std::string command;
98 std::vector<std::string> args;
99 std::vector<char *> argv;
100 /**
101 * CsInstruments
102 */
103 std::string orchestra;
104 /**
105 * CsScore
106 */
107 std::string score;
108 /**
109 * CsMidi
110 */
111 std::vector<unsigned char> midifile;
112 public:
113 /**
114 * Patch library and arrangement.
115 */
116 std::string libraryFilename;
117 std::vector<std::string> arrangement;
118 CsoundFile();
119 virtual ~CsoundFile(){};
120 virtual std::string generateFilename();
121 virtual std::string getFilename() const;
122 virtual void setFilename(std::string name);
123 /**
124 * Clears all contents of this,
125 * then imports the indicated file,
126 * which can be a Csound unified file (.csd),
127 * Csound orchestra (.orc), Csound score (.sco),
128 * standard MIDI file (.mid), or MusicXML v2 (.xml)
129 * file.
130 *
131 * The MusicXML notes become instrument number + 1,
132 * time in seconds, duration in seconds, MIDI key
133 * number, and MIDI velocity number.
134 */
135 virtual int load(std::string filename);
136 virtual int load(std::istream &stream);
137 virtual int save(std::string filename) const;
138 virtual int save(std::ostream &stream) const;
139 /**
140 * Imports the indicated file,
141 * which can be a Csound unified file (.csd),
142 * Csound orchestra (.orc), Csound score (.sco),
143 * standard MIDI file (.mid), or MusicXML v2 (.xml)
144 * file. The data that is read replaces existing
145 * data of that type, but leaves other types of data
146 * untouched.
147 *
148 * The MusicXML notes become instrument number + 1,
149 * time in seconds, duration in seconds, MIDI key
150 * number, and MIDI velocity number.
151 */
152 virtual int importFile(std::string filename);
153 virtual int importFile(std::istream &stream);
154 virtual int importCommand(std::istream &stream);
155 virtual int exportCommand(std::ostream &stream) const;
156 virtual int importOrchestra(std::istream &stream);
157 virtual int exportOrchestra(std::ostream &stream) const;
158 virtual int importScore(std::istream &stream);
159 virtual int exportScore(std::ostream &stream) const;
160 virtual int importArrangement(std::istream &stream);
161 virtual int exportArrangement(std::ostream &stream) const;
162 virtual int exportArrangementForPerformance(std::string filename) const;
163 virtual int exportArrangementForPerformance(std::ostream &stream) const;
164 virtual int importMidifile(std::istream &stream);
165 virtual int exportMidifile(std::ostream &stream) const;
166 virtual std::string getCommand() const;
167 virtual void setCommand(std::string commandLine);
168 virtual std::string getOrcFilename() const;
169 virtual std::string getScoFilename() const;
170 virtual std::string getMidiFilename() const;
171 virtual std::string getOutputSoundfileName() const;
172 virtual std::string getOrchestra() const;
173 virtual void setOrchestra(std::string orchestra);
174 virtual int getInstrumentCount() const;
175 virtual std::string getOrchestraHeader() const;
176 virtual bool getInstrument(int number, std::string &definition) const;
177 //virtual bool getInstrumentNumber(int index, std::string &definition) const;
178 virtual bool getInstrument(std::string name, std::string &definition) const;
179 virtual std::string getInstrument(std::string name) const;
180 virtual std::string getInstrument(int number) const;
181 virtual std::string getInstrumentBody(std::string name) const;
182 virtual std::string getInstrumentBody(int number) const;
183 virtual std::map<int, std::string> getInstrumentNames() const;
184 virtual double getInstrumentNumber(std::string name) const;
185 virtual std::string getScore() const;
186 virtual void setScore(std::string score);
187 virtual int getArrangementCount() const;
188 virtual std::string getArrangement(int index) const;
189 virtual void addArrangement(std::string instrument);
190 virtual void setArrangement(int index, std::string instrument);
191 virtual void insertArrangement(int index, std::string instrument);
192 virtual void removeArrangement(int index);
193 virtual void setCSD(std::string xml);
194 virtual std::string getCSD() const;
195 virtual void addScoreLine(const std::string line);
196 virtual void addNote(double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8, double p9, double p10, double p11);
197 virtual void addNote(double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8, double p9, double p10);
198 virtual void addNote(double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8, double p9);
199 virtual void addNote(double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8);
200 virtual void addNote(double p1, double p2, double p3, double p4, double p5, double p6, double p7);
201 virtual void addNote(double p1, double p2, double p3, double p4, double p5, double p6);
202 virtual void addNote(double p1, double p2, double p3, double p4, double p5);
203 virtual void addNote(double p1, double p2, double p3, double p4);
204 virtual void addNote(double p1, double p2, double p3);
205 virtual bool exportForPerformance() const;
206 virtual void removeAll();
207 virtual void removeCommand();
208 virtual void removeOrchestra();
209 virtual void removeScore();
210 virtual void removeArrangement();
211 virtual void removeMidifile();
212 //virtual void getInstrumentNames(std::vector<std::string> &names) const;
213 virtual bool loadOrcLibrary(const char *filename = 0);
214 };
215
216 #endif // CSOUND_FILE_H
217