Csound Csound-dev Csound-tekno Search About

name error with pycall1

Date2016-11-06 16:28
FromRichard
Subjectname error with pycall1
I get the following error in a simple csd:

pycall1: python exception
Traceback (most recent call last):
   File "", line 1, in 
NameError: name 'getnext' is not defined

The function getnext is defined in pyruni

The csd is below:



-nm0
-odac


sr = 44100
kr = 441
nchnls = 1

pyinit

pyruni {{
def getnext(idx):
     line = sco[idx]
     print line
     return 1.0

sco =  [i 10           0.000000           0.125034    98    36,
         i 10           0.000000           0.125034    98    42,
         i 10           0.250000           0.125034    98    36,
         i 10           0.250000           0.125034    98    42,
         i 10           0.500000           0.125034    98    40,
         i 10           0.500000           0.125034    98    42,
         i 10           0.750000           0.125034    98    42]
}}


instr 1
     kCycle timeinstk
     printks "kCycle = %d\n", 0, kCycle
     kIndex = 0
     while kIndex < 8 do
         kret pycall1 "getnext", kIndex
         ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
         schedkwhen kIndex, 0, 1, 10, kIndex, 1
         kIndex += 1
     od
       ;stop after first control cycle
     if kCycle == 1 then
           turnoff
     endif
endin

instr 10
     print p2,p3
     a1 oscils 10000, 220+10*p2, 1
       out a1
endin



i 1 0 10
e



Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-11-06 17:02
FromFrancois PINOT
SubjectRe: name error with pycall1
The getnext function is not defined because there is a syntax error in the sco list definition. It should be defined like this:

sco =  ["i 10           0.000000           0.125034    98    36",
        "i 10           0.000000           0.125034    98    42",
        "i 10           0.250000           0.125034    98    36",
        "i 10           0.250000           0.125034    98    42",
        "i 10           0.500000           0.125034    98    40",
        "i 10           0.500000           0.125034    98    42",
        "i 10           0.750000           0.125034    98    42"]

In instr 1, the while statement should be like this:

while kIndex < 7 do

because there as only 7 items in the list.

François

2016-11-06 17:28 GMT+01:00 Richard <zappfinger@gmail.com>:
I get the following error in a simple csd:

pycall1: python exception
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'getnext' is not defined

The function getnext is defined in pyruni

The csd is below:

<CsoundSynthesizer>
<CsOptions>
-nm0
-odac
</CsOptions>
<CsInstruments>
sr = 44100
kr = 441
nchnls = 1

pyinit

pyruni {{
def getnext(idx):
    line = sco[idx]
    print line
    return 1.0

sco =  [i 10           0.000000           0.125034    98    36,
        i 10           0.000000           0.125034    98    42,
        i 10           0.250000           0.125034    98    36,
        i 10           0.250000           0.125034    98    42,
        i 10           0.500000           0.125034    98    40,
        i 10           0.500000           0.125034    98    42,
        i 10           0.750000           0.125034    98    42]
}}


instr 1
    kCycle timeinstk
    printks "kCycle = %d\n", 0, kCycle
    kIndex = 0
    while kIndex < 8 do
        kret pycall1 "getnext", kIndex
        ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
        schedkwhen kIndex, 0, 1, 10, kIndex, 1
        kIndex += 1
    od
      ;stop after first control cycle
    if kCycle == 1 then
          turnoff
    endif
endin

instr 10
    print p2,p3
    a1 oscils 10000, 220+10*p2, 1
      out a1
endin

</CsInstruments>
<CsScore>
i 1 0 10
e
</CsScore>
</CsoundSynthesizer>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-11-06 18:49
FromRichard
SubjectRe: name error with pycall1

Thanks Francois, I should have seen that..

Richard


On 06/11/16 18:02, Francois PINOT wrote:
The getnext function is not defined because there is a syntax error in the sco list definition. It should be defined like this:

sco =  ["i 10           0.000000           0.125034    98    36",
        "i 10           0.000000           0.125034    98    42",
        "i 10           0.250000           0.125034    98    36",
        "i 10           0.250000           0.125034    98    42",
        "i 10           0.500000           0.125034    98    40",
        "i 10           0.500000           0.125034    98    42",
        "i 10           0.750000           0.125034    98    42"]

In instr 1, the while statement should be like this:

while kIndex < 7 do

because there as only 7 items in the list.

François

2016-11-06 17:28 GMT+01:00 Richard <zappfinger@gmail.com>:
I get the following error in a simple csd:

pycall1: python exception
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'getnext' is not defined

The function getnext is defined in pyruni

The csd is below:

<CsoundSynthesizer>
<CsOptions>
-nm0
-odac
</CsOptions>
<CsInstruments>
sr = 44100
kr = 441
nchnls = 1

pyinit

pyruni {{
def getnext(idx):
    line = sco[idx]
    print line
    return 1.0

sco =  [i 10           0.000000           0.125034    98    36,
        i 10           0.000000           0.125034    98    42,
        i 10           0.250000           0.125034    98    36,
        i 10           0.250000           0.125034    98    42,
        i 10           0.500000           0.125034    98    40,
        i 10           0.500000           0.125034    98    42,
        i 10           0.750000           0.125034    98    42]
}}


instr 1
    kCycle timeinstk
    printks "kCycle = %d\n", 0, kCycle
    kIndex = 0
    while kIndex < 8 do
        kret pycall1 "getnext", kIndex
        ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
        schedkwhen kIndex, 0, 1, 10, kIndex, 1
        kIndex += 1
    od
      ;stop after first control cycle
    if kCycle == 1 then
          turnoff
    endif
endin

instr 10
    print p2,p3
    a1 oscils 10000, 220+10*p2, 1
      out a1
endin

</CsInstruments>
<CsScore>
i 1 0 10
e
</CsScore>
</CsoundSynthesizer>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here