~ubuntu-branches/ubuntu/precise/csound/precise

« back to all changes in this revision

Viewing changes to H/csoundCore.h

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2012-04-19 09:26:46 UTC
  • mfrom: (3.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20120419092646-96xbj1n6atuqosk2
Tags: 1:5.17.6~dfsg-1
* New upstream release
 - Do not build the wiimote opcodes (we need wiiuse).
* Add new API function to symbols file
* Disable lua opcodes, they were broken. Requires OpenMP to be enabled.
* Backport fixes from upstream:
  - Link dssi4cs with dl. Backport
  - Fix building of CsoundAC

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "sysdep.h"
32
32
#ifdef PARCS
33
33
#include <pthread.h>
34
 
#endif
 
34
#include "cs_par_structs.h"
 
35
#endif /* PARCS */
35
36
#include <stdarg.h>
36
37
#include <setjmp.h>
37
38
 
60
61
 
61
62
#ifdef __cplusplus
62
63
extern "C" {
63
 
#endif
 
64
#endif /*  __cplusplus */
64
65
 
65
66
#ifdef __MACH__
66
67
#define BARRIER_SERIAL_THREAD (-1)
72
73
 
73
74
#ifndef PTHREAD_BARRIER_SERIAL_THREAD
74
75
#define pthread_barrier_t barrier_t
75
 
#endif
76
 
#endif
 
76
#endif /* PTHREAD_BARRIER_SERIAL_THREAd */
 
77
#endif /* __MACH__ */
77
78
 
78
79
 
79
80
#define OK        (0)
118
119
                    (n<<8 & 0xFF0000L) | (n<<24 & 0xFF000000L))
119
120
 
120
121
#define OCTRES     8192
121
 
#define CPSOCTL(n) ((MYFLT)(1 << ((int)(n) >> 13)) * cpsocfrc[(int)(n) & 8191])
 
122
#define CPSOCTL(n) ((MYFLT)(1 << ((int)(n) >> 13)) * csound->cpsocfrc[(int)(n) & 8191])
122
123
 
123
124
#define LOBITS     10
124
125
#define LOFACT     1024
152
153
 
153
154
#ifndef PI
154
155
#define PI      (3.141592653589793238462643383279502884197)
155
 
#endif
 
156
#endif /* pi */
156
157
#define TWOPI   (6.283185307179586476925286766559005768394)
157
158
#define PI_F    ((MYFLT) PI)
158
159
#define TWOPI_F ((MYFLT) TWOPI)
168
169
   cause confusion
169
170
#define printf  use_csoundMessage_instead_of_printf
170
171
*/
 
172
  typedef struct CORFIL {
 
173
    char    *body;
 
174
    int     len;
 
175
    int     p;
 
176
  } CORFIL;
 
177
 
171
178
  typedef struct {
172
179
    int     odebug;
173
180
    int     sfread, sfwrite, sfheader, filetyp;
182
189
    int     rewrt_hdr, heartbeat, gen01defer;
183
190
    int     expr_opt;       /* IV - Jan 27 2005: for --expression-opt */
184
191
    float   sr_override, kr_override;
185
 
    char    *infilename, *outfilename, *playscore;
 
192
    char    *infilename, *outfilename;
 
193
    CORFIL  *playscore;
186
194
    char    *Linename, *Midiname, *FMidiname;
187
195
    char    *Midioutname;   /* jjk 09252000 - MIDI output device, -Q option */
188
196
    char    *FMidioutname;
196
204
#ifdef ENABLE_NEW_PARSER
197
205
    int     newParser; /* SYY - July 30, 2006: for --new-parser */
198
206
    int     calculateWeights;
199
 
#endif
 
207
#endif /* ENABLE_NEW_PARSE */
200
208
  } OPARMS;
201
209
 
202
210
  typedef struct arglst {
243
251
    int     lclpcnt, lclscnt;
244
252
    int     lclfixed, optxtcount;
245
253
    int16   muted;
246
 
    int32    localen;
247
 
    int32    opdstot;                /* Total size of opds structs in instr */
248
 
    int32    *inslist;               /* Only used in parsing (?) */
 
254
    int32   localen;
 
255
    int32   opdstot;                /* Total size of opds structs in instr */
 
256
    int32   *inslist;               /* Only used in parsing (?) */
249
257
    MYFLT   *psetdata;              /* Used for pset opcode */
250
258
    struct insds * instance;        /* Chain of allocated instances of
251
259
                                       this instrument */
719
727
/* These are used to set/clear bits in csound->tempStatus.
720
728
   If the bit is set, it indicates that the given file is
721
729
   a temporary. */
722
 
extern const uint32_t csOrcMask;
723
 
extern const uint32_t csScoInMask;
724
 
extern const uint32_t csScoSortMask;
725
 
extern const uint32_t csMidiScoMask;
726
 
extern const uint32_t csPlayScoMask;
 
730
  extern const uint32_t csOrcMask;
 
731
  extern const uint32_t csScoInMask;
 
732
  extern const uint32_t csScoSortMask;
 
733
  extern const uint32_t csMidiScoMask;
 
734
  extern const uint32_t csPlayScoMask;
727
735
 
728
736
#endif  /* __BUILDING_LIBCSOUND */
729
737
  /**
731
739
   * to run one instance of Csound.
732
740
   */
733
741
 
 
742
 
734
743
  struct CSOUND_ {
735
744
    /* Csound API function pointers (320 total) */
736
745
    int (*GetVersion)(void);
789
798
                                                     MYFLT value));
790
799
    int (*ScoreEvent)(CSOUND *,
791
800
                      char type, const MYFLT *pFields, long numFields);
 
801
    int (*ScoreEventAbsolute)(CSOUND *,
 
802
                      char type, const MYFLT *pFields, long numFields, double time_ofs);
792
803
    void (*SetExternalMidiInOpenCallback)(CSOUND *,
793
804
                int (*func)(CSOUND *, void **, const char *));
794
805
    void (*SetExternalMidiReadCallback)(CSOUND *,
1030
1041
    void (*Stop)(CSOUND *);
1031
1042
    void *(*GetNamedGens)(CSOUND *);
1032
1043
 /* SUBR dummyfn_1; */
1033
 
    SUBR dummyfn_2[76];
 
1044
    MYFLT (*Pow2)(CSOUND *, MYFLT a);
 
1045
    SUBR dummyfn_2[75];
1034
1046
    int           dither_output;
1035
1047
    void          *flgraphGlobals;
1036
1048
    char          *delayederrormessages;
1052
1064
    /** start time of current section    */
1053
1065
    double        timeOffs, beatOffs;
1054
1066
    /** current time in seconds, inc. per kprd */
1055
 
    long          icurTime;   /* Current time in samples */
 
1067
    int64_t       icurTime;   /* Current time in samples */
1056
1068
    double        curTime_inc;
1057
1069
    /** current time in beats, inc per kprd */
1058
1070
    double        curBeat, curBeat_inc;
1059
1071
    /** beat time = 60 / tempo           */
1060
 
    long          ibeatTime;   /* Beat time in samples */
 
1072
    int64_t       ibeatTime;   /* Beat time in samples */
1061
1073
#if defined(HAVE_PTHREAD_SPIN_LOCK) && defined(PARCS)
1062
1074
    pthread_spinlock_t spoutlock, spinlock;
1063
1075
#else
1064
1076
    int           spoutlock, spinlock;
1065
 
#endif
 
1077
#endif /* defined(HAVE_PTHREAD_SPIN_LOCK) && defined(PARCS) */
1066
1078
    /* Widgets */
1067
1079
    void          *widgetGlobals;
1068
1080
    /** reserved for std opcode library  */
1082
1094
    void          *rtRecord_userdata;
1083
1095
    void          *rtPlay_userdata;
1084
1096
    char          *orchname, *scorename;
 
1097
    CORFIL        *orchstr, *scorestr;
1085
1098
    int           holdrand;
1086
1099
    /** max. length of string variables + 1  */
1087
1100
    int           strVarMaxLen;
1099
1112
    pthread_spinlock_t memlock;
1100
1113
#else
1101
1114
    int           memlock;
1102
 
#endif
 
1115
#endif /* defined(HAVE_PTHREAD_SPIN_LOCK) && defined(PARCS */
1103
1116
    int           floatsize;
1104
1117
    int           inchnls;      /* Not fully used yet -- JPff */
1105
1118
    int   dummyint[7];
1152
1165
    int           Linefd;
1153
1166
    void          *csoundCallbacks_;
1154
1167
    FILE*         scfp;
 
1168
    CORFIL        *scstr;
1155
1169
    FILE*         oscfp;
1156
1170
    MYFLT         maxamp[MAXCHNLS];
1157
1171
    MYFLT         smaxamp[MAXCHNLS];
1174
1188
    EVTNODE       *OrcTrigEvts;             /* List of events to be started */
1175
1189
    EVTNODE       *freeEvtNodes;
1176
1190
    int           csoundIsScorePending_;
1177
 
    int           advanceCnt;
 
1191
    int64_t       advanceCnt;
1178
1192
    int           initonly;
1179
1193
    int           evt_poll_cnt;
1180
1194
    int           evt_poll_maxcnt;
1197
1211
    void          **cfgVariableDB;
1198
1212
    double        prvbt, curbt, nxtbt;
1199
1213
    double        curp2, nxtim;
1200
 
    int           cyclesRemaining;
 
1214
    int64_t       cyclesRemaining;
1201
1215
    EVTBLK        evt;
1202
1216
    void          *memalloc_db;
1203
1217
    MGLOBAL       *midiGlobals;
1330
1344
    struct dag_t        *multiThreadedDag;
1331
1345
    pthread_barrier_t   *barrier1;
1332
1346
    pthread_barrier_t   *barrier2;
 
1347
    /* Statics from cs_par_dispatch; */
 
1348
    struct global_var_lock_t *global_var_lock_root;
 
1349
    struct global_var_lock_t **global_var_lock_cache;
 
1350
    int           global_var_lock_count;
 
1351
    int           opcode_weight_cache_ctr;
 
1352
    struct opcode_weight_cache_entry_t
 
1353
                  *opcode_weight_cache[OPCODE_WEIGHT_CACHE_SIZE];
 
1354
    int           opcode_weight_have_cache;
 
1355
    struct        dag_cache_entry_t *cache[DAG_2_CACHE_SIZE];
 
1356
    /* statics from cs_par_orc_semantic_analysis */
 
1357
    struct instr_semantics_t *instCurr;
 
1358
    struct instr_semantics_t *instRoot;
 
1359
    int           inInstr;
1333
1360
#endif
1334
1361
    uint32_t      tempStatus;    /* keeps track of which files are temps */
1335
1362
    int           orcLineOffset; /* 1 less than 1st orch line in the CSD */
1342
1369
    char          *sstrbuf0[3]; /* For extra strings in scores */
1343
1370
    int           sstrlen0[3];  /* lengths for extra strings */
1344
1371
    int           genlabs;      /* Count for generated labels */
1345
 
 
 
1372
    MYFLT         *powerof2;    /* pow2 table */
 
1373
    MYFLT         *cpsocfrc;    /* cps conv table */
 
1374
    CORFIL*       expanded_orc; /* output of preprocessor */
 
1375
    char          *filedir[64]; /* for location directory */
1346
1376
#endif  /* __BUILDING_LIBCSOUND */
1347
1377
  };
1348
1378
 
1351
1381
 * in order to enable C++ to #include this file.
1352
1382
 */
1353
1383
 
 
1384
#define LINKAGE1(name)                                         \
 
1385
long name##_init(CSOUND *csound, OENTRY **ep)           \
 
1386
{   (void) csound; *ep = name; return (long) (sizeof(name));  }
 
1387
 
 
1388
#define FLINKAGE1(name)                                                 \
 
1389
NGFENS* name##_init(CSOUND *csound)                         \
 
1390
{   (void) csound; return name;                                     }
 
1391
 
1354
1392
#ifdef __cplusplus
1355
1393
}
1356
 
#endif
 
1394
#endif /* __cplusplus */
1357
1395
 
1358
1396
#endif  /* CSOUNDCORE_H */
1359