| 1 | /* |
| 2 | * C S O U N D |
| 3 | * |
| 4 | * An auto-extensible system for making music on computers |
| 5 | * by means of software alone. |
| 6 | * |
| 7 | * Copyright (C) 2001-2005 Michael Gogins, Matt Ingalls, John D. Ramsdell, |
| 8 | * John P. ffitch, Istvan Varga |
| 9 | * |
| 10 | * L I C E N S E |
| 11 | * |
| 12 | * This software is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU Lesser General Public |
| 14 | * License as published by the Free Software Foundation; either |
| 15 | * version 2.1 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This software is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | * Lesser General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this software; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | */ |
| 26 | #ifndef CSOUND_FILEBUILDING_H |
| 27 | #define CSOUND_FILEBUILDING_H |
| 28 | |
| 29 | #include "csound.h" |
| 30 | /** \file |
| 31 | * \brief Csound API functions to create, build up, and save CSD files. |
| 32 | * \author Michael Gogins |
| 33 | * |
| 34 | * \b Purpose |
| 35 | * |
| 36 | * The purpose of these functions is to make it easier for clients |
| 37 | * of the Csound API to programmatically build up CSD files, |
| 38 | * including set instrument definitions, set options, |
| 39 | * and especially append score statements. |
| 40 | * |
| 41 | * There are also convenience functions to compile and perform |
| 42 | * the saved CSD file. |
| 43 | */ |
| 44 | |
| 45 | #if (defined(WIN32) || defined(_WIN32)) && !defined(SWIG) |
| 46 | # define PUBLIC __declspec(dllexport) |
| 47 | #elif defined(__GNUC__) && !defined(__MACH__) |
| 48 | # define PUBLIC __attribute__ ( (visibility("default")) ) |
| 49 | #else |
| 50 | # define PUBLIC |
| 51 | #endif |
| 52 | |
| 53 | /** |
| 54 | * Enables Python interface. |
| 55 | */ |
| 56 | |
| 57 | #ifdef SWIG |
| 58 | #define CS_PRINTF2 |
| 59 | #define CS_PRINTF3 |
| 60 | #ifndef __MYFLT_DEF |
| 61 | #define __MYFLT_DEF |
| 62 | #ifndef USE_DOUBLE |
| 63 | #define MYFLT float |
| 64 | #else |
| 65 | #define MYFLT double |
| 66 | #endif |
| 67 | #endif |
| 68 | %module filebuilding |
| 69 | %{ |
| 70 | # include "sysdep.h" |
| 71 | # include "text.h" |
| 72 | # include "csound.h" |
| 73 | # include <stdarg.h> |
| 74 | %} |
| 75 | #else |
| 76 | # include "sysdep.h" |
| 77 | # include "text.h" |
| 78 | # include "csound.h" |
| 79 | # include <stdarg.h> |
| 80 | #endif |
| 81 | |
| 82 | #ifdef __cplusplus |
| 83 | extern "C" { |
| 84 | #endif |
| 85 | |
| 86 | |
| 87 | |
| 88 | /** |
| 89 | * Initialize an internal CSD file. |
| 90 | */ |
| 91 | PUBLIC void csoundCsdCreate(CSOUND *csound); |
| 92 | |
| 93 | /** |
| 94 | * Set the CsOptions element of the internal CSD file. |
| 95 | */ |
| 96 | PUBLIC void csoundCsdSetOptions(CSOUND *csound, char *options); |
| 97 | |
| 98 | /** |
| 99 | * Return the CsOptions element of the internal CSD file. |
| 100 | */ |
| 101 | PUBLIC const char* csoundCsdGetOptions(CSOUND *csound); |
| 102 | |
| 103 | /** |
| 104 | * Set the CsInstruments element of the internal CSD file. |
| 105 | */ |
| 106 | PUBLIC void csoundCsdSetOrchestra(CSOUND *csound, char *orchestra); |
| 107 | |
| 108 | /** |
| 109 | * Return the CsInstruments element of the internal CSD file. |
| 110 | */ |
| 111 | PUBLIC const char* csoundCsdGetOrchestra(CSOUND *csound); |
| 112 | |
| 113 | /** |
| 114 | * Append a line of text to the CsScore element of the internal CSD file. |
| 115 | */ |
| 116 | PUBLIC void csoundCsdAddScoreLine(CSOUND *csound, char *line); |
| 117 | |
| 118 | /** |
| 119 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 120 | */ |
| 121 | PUBLIC void csoundCsdAddEvent11(CSOUND *csound, double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8, double p9, double p10, double p11); |
| 122 | |
| 123 | /** |
| 124 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 125 | */ |
| 126 | PUBLIC void csoundCsdAddEvent10(CSOUND *csound, double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8, double p9, double p10); |
| 127 | |
| 128 | /** |
| 129 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 130 | */ |
| 131 | PUBLIC void csoundCsdAddEvent9(CSOUND *csound, double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8, double p9); |
| 132 | |
| 133 | /** |
| 134 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 135 | */ |
| 136 | PUBLIC void csoundCsdAddEvent8(CSOUND *csound, double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8); |
| 137 | |
| 138 | /** |
| 139 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 140 | */ |
| 141 | PUBLIC void csoundCsdAddEvent7(CSOUND *csound, double p1, double p2, double p3, double p4, double p5, double p6, double p7); |
| 142 | |
| 143 | /** |
| 144 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 145 | */ |
| 146 | PUBLIC void csoundCsdAddEvent6(CSOUND *csound, double p1, double p2, double p3, double p4, double p5, double p6); |
| 147 | |
| 148 | /** |
| 149 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 150 | */ |
| 151 | PUBLIC void csoundCsdAddEvent5(CSOUND *csound, double p1, double p2, double p3, double p4, double p5); |
| 152 | |
| 153 | /** |
| 154 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 155 | */ |
| 156 | PUBLIC void csoundCsdAddEvent4(CSOUND *csound, double p1, double p2, double p3, double p4); |
| 157 | |
| 158 | /** |
| 159 | * Append an 'i' event to the CsScore element of the internal CSD file. |
| 160 | */ |
| 161 | PUBLIC void csoundCsdAddEvent3(CSOUND *csound, double p1, double p2, double p3); |
| 162 | |
| 163 | /** |
| 164 | * Save the internal CSD file to the indicated filename, which must end in '.csd'. |
| 165 | */ |
| 166 | PUBLIC int csoundCsdSave(CSOUND *csound, char *filename); |
| 167 | |
| 168 | /** |
| 169 | * Convenience function that saves the internal CSD file to the indicated filename, |
| 170 | * which must end in '.csd, then performs the file. |
| 171 | */ |
| 172 | PUBLIC int csoundCsdCompile(CSOUND *csound, char *filename); |
| 173 | |
| 174 | /** |
| 175 | * Convenience function that saves the internal CSD file to the indicated filename, |
| 176 | * which must end in '.csd, then compiles the file for later performance. |
| 177 | */ |
| 178 | PUBLIC int csoundCsdPerform(CSOUND *csound, char *filename); |
| 179 | |
| 180 | /** |
| 181 | * Compiles a Csound input file (.csd file) |
| 182 | * which includes command-line arguments, |
| 183 | * but does not perform the file. Returns a non-zero error code on failure. |
| 184 | * In this (host-driven) mode, the sequence of calls should be as follows: |
| 185 | * /code |
| 186 | * csoundCompileCsd(csound, argc, argv); |
| 187 | * while (!csoundPerformBuffer(csound)); |
| 188 | * csoundCleanup(csound); |
| 189 | * csoundReset(csound); |
| 190 | * /endcode |
| 191 | */ |
| 192 | PUBLIC int csoundCompileCsd(CSOUND *, char *csdFilename); |
| 193 | |
| 194 | /** |
| 195 | * Compiles and renders a Csound performance, |
| 196 | * as directed by the supplied CSD file, |
| 197 | * in one pass. Returns 0 for success. |
| 198 | */ |
| 199 | PUBLIC int csoundPerformCsd(CSOUND *, char *csdFilename); |
| 200 | |
| 201 | #ifdef __cplusplus |
| 202 | } |
| 203 | #endif |
| 204 | |
| 205 | #endif |