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

« back to all changes in this revision

Viewing changes to Opcodes/pitch0.c

  • 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:
21
21
    02111-1307 USA
22
22
*/
23
23
 
24
 
#include "csdl.h"       /*                                  PITCH.C       */
 
24
// #include "csdl.h"
 
25
#include "csoundCore.h"       /*                                  PITCH.C       */
25
26
#include "cwindow.h"
26
27
#include <limits.h>
27
28
#include "spectra.h"
45
46
 
46
47
int instcount(CSOUND *csound, INSTCNT *p)
47
48
{
48
 
    int n = (int) csound->strarg2insno(csound, p->ins, p->XSTRCODE);
 
49
    int n;
 
50
    if (p->XSTRCODE)
 
51
      n = (int) csound->strarg2insno(csound, p->ins, p->XSTRCODE);
 
52
    else
 
53
      n = *p->ins;
49
54
    if (n<0 || n > csound->maxinsno || csound->instrtxtp[n] == NULL)
50
55
      *p->cnt = FL(0.0);
 
56
    else if (n==0) {  /* Count all instruments */
 
57
      int tot = 1;
 
58
      for (n=1; n<csound->maxinsno; n++)
 
59
        if (csound->instrtxtp[n]) /* If it exists */
 
60
          tot += ((*p->opt) ? csound->instrtxtp[n]->instcnt :
 
61
                              csound->instrtxtp[n]->active);
 
62
      *p->cnt = (MYFLT)tot;
 
63
    }
51
64
    else {
52
65
      *p->cnt = ((*p->opt) ?
53
66
                 (MYFLT) csound->instrtxtp[n]->instcnt :
54
67
                 (MYFLT) csound->instrtxtp[n]->active);
55
68
    }
56
69
 
57
 
 
58
70
    return OK;
59
71
}
60
72
 
89
101
    return OK;
90
102
}
91
103
 
 
104
int pfunk_init(CSOUND *csound, PFUNK *p)
 
105
{
 
106
    int i, n = (int)MYFLT2LONG(*p->pnum);
 
107
    MYFLT ans, *pfield;
 
108
    if (n<1 || n>PMAX) ans = FL(0.0);
 
109
    else ans = csound->currevent->p[n];
 
110
    /* save the pfields of the current event */
 
111
    csound->AuxAlloc(csound, (csound->currevent->pcnt+1)*sizeof(MYFLT), &p->pfield);
 
112
    pfield = p->pfield.auxp;
 
113
    for (i=1; i<=csound->currevent->pcnt; i++)
 
114
      pfield[i] = csound->currevent->p[i];
 
115
    *p->ans = ans;
 
116
    return OK;
 
117
}
 
118
 
 
119
int pfunk(CSOUND *csound, PFUNK *p)
 
120
{
 
121
    int n = (int)MYFLT2LONG(*p->pnum);
 
122
    MYFLT ans, *pfield;
 
123
    if (n<1 || n>PMAX) {
 
124
      ans = FL(0.0);
 
125
    }
 
126
    else {
 
127
      pfield = p->pfield.auxp;
 
128
      ans = pfield[n];
 
129
    }
 
130
    *p->ans = ans;
 
131
    return OK;
 
132
}