Csound Csound-dev Csound-tekno Search About

[Csnd] ctcsound cookbook

Date2018-12-19 19:46
Fromjoachim heintz
Subject[Csnd] ctcsound cookbook
i am going through the examples of 
https://github.com/fggp/ctcsound/tree/master/cookbook.  in 07-icsound i 
get an error in creating the function tables:

cs.fillTable(1, array([8, 7, 9, 1, 1, 1]))
cs.fillTable(2, [4, 5, 7, 0, 8, 7, 9, 6])

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
 in ()
----> 1 cs.fillTable(1, array([8, 7, 9, 1, 1, 1]))
       2 cs.fillTable(2, [4, 5, 7, 0, 8, 7, 9, 6])

~/src/anaconda3/lib/python3.7/site-packages/csoundmagics.py in 
fillTable(self, num, arr)
     397                 self._debugPrint("Creating table ", num)
     398             self.makeTable(num, p.size, -2, 0)
--> 399             table = self.table(num)
     400         src = p.ctypes.data_as(ctypes.POINTER(ctcsound.MYFLT))
     401         dest = table.ctypes.data_as(ctypes.POINTER(ctcsound.MYFLT))

~/src/ctcsound/ctcsound.py in table(self, tableNum)
    1952         arrayType = np.ctypeslib.ndpointer(MYFLT, 1, (size,), 
'C_CONTIGUOUS')
    1953         p = cast(ptr, arrayType)
-> 1954         return np.ctypeslib.as_array(p)
    1955
    1956     def tableArgs(self, tableNum):

~/src/anaconda3/lib/python3.7/site-packages/numpy/ctypeslib.py in 
as_array(obj, shape)
     361             obj = ctypes.cast(obj, p_arr_type).contents
     362
--> 363         return array(obj, copy=False)
     364
     365     def as_ctypes(obj):

ValueError: '

Date2018-12-19 21:42
FromFrancois PINOT
SubjectRe: [Csnd] ctcsound cookbook
Hello Joachim,

which version of numpy do you use? You can get this info with the following commands:

import numpy
print(numpy.__version__)

Your problem seems related to this issue: https://github.com/numpy/numpy/issues/12421
If this is the case, you should revert your numpy to an older version...

François

Le mer. 19 déc. 2018 à 20:46, joachim heintz <jh@joachimheintz.de> a écrit :
i am going through the examples of
https://github.com/fggp/ctcsound/tree/master/cookbook.  in 07-icsound i
get an error in creating the function tables:

cs.fillTable(1, array([8, 7, 9, 1, 1, 1]))
cs.fillTable(2, [4, 5, 7, 0, 8, 7, 9, 6])

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-49943869b1ce> in <module>()
----> 1 cs.fillTable(1, array([8, 7, 9, 1, 1, 1]))
       2 cs.fillTable(2, [4, 5, 7, 0, 8, 7, 9, 6])

~/src/anaconda3/lib/python3.7/site-packages/csoundmagics.py in
fillTable(self, num, arr)
     397                 self._debugPrint("Creating table ", num)
     398             self.makeTable(num, p.size, -2, 0)
--> 399             table = self.table(num)
     400         src = p.ctypes.data_as(ctypes.POINTER(ctcsound.MYFLT))
     401         dest = table.ctypes.data_as(ctypes.POINTER(ctcsound.MYFLT))

~/src/ctcsound/ctcsound.py in table(self, tableNum)
    1952         arrayType = np.ctypeslib.ndpointer(MYFLT, 1, (size,),
'C_CONTIGUOUS')
    1953         p = cast(ptr, arrayType)
-> 1954         return np.ctypeslib.as_array(p)
    1955
    1956     def tableArgs(self, tableNum):

~/src/anaconda3/lib/python3.7/site-packages/numpy/ctypeslib.py in
as_array(obj, shape)
     361             obj = ctypes.cast(obj, p_arr_type).contents
     362
--> 363         return array(obj, copy=False)
     364
     365     def as_ctypes(obj):

ValueError: '<P' is not a valid PEP 3118 buffer format string


any idea?  thanks -
        joachim

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

Date2018-12-20 19:47
Fromjoachim heintz
SubjectRe: [Csnd] ctcsound cookbook
hello françois -

thanks for the help.  yes, my numpy version is 1.15.1, so it matches the 
bug you linked to.

i reverted to 1.14.6, and it worked all.

in particular the 07-icsound notebook is amazing!!!

best -
	joachim




On 19/12/18 22:42, Francois PINOT wrote:
> Hello Joachim,
>
> which version of numpy do you use? You can get this info with the
> following commands:
>
> import numpy
> print(numpy.__version__)
>
> Your problem seems related to this issue:
> https://github.com/numpy/numpy/issues/12421
> If this is the case, you should revert your numpy to an older version...
>
> François
>
> Le mer. 19 déc. 2018 à 20:46, joachim heintz  > a écrit :
>
>     i am going through the examples of
>     https://github.com/fggp/ctcsound/tree/master/cookbook.  in 07-icsound i
>     get an error in creating the function tables:
>
>     cs.fillTable(1, array([8, 7, 9, 1, 1, 1]))
>     cs.fillTable(2, [4, 5, 7, 0, 8, 7, 9, 6])
>
>     ---------------------------------------------------------------------------
>     ValueError                                Traceback (most recent
>     call last)
>      in ()
>     ----> 1 cs.fillTable(1, array([8, 7, 9, 1, 1, 1]))
>            2 cs.fillTable(2, [4, 5, 7, 0, 8, 7, 9, 6])
>
>     ~/src/anaconda3/lib/python3.7/site-packages/csoundmagics.py in
>     fillTable(self, num, arr)
>          397                 self._debugPrint("Creating table ", num)
>          398             self.makeTable(num, p.size, -2, 0)
>     --> 399             table = self.table(num)
>          400         src = p.ctypes.data_as(ctypes.POINTER(ctcsound.MYFLT))
>          401         dest =
>     table.ctypes.data_as(ctypes.POINTER(ctcsound.MYFLT))
>
>     ~/src/ctcsound/ctcsound.py in table(self, tableNum)
>         1952         arrayType = np.ctypeslib.ndpointer(MYFLT, 1, (size,),
>     'C_CONTIGUOUS')
>         1953         p = cast(ptr, arrayType)
>     -> 1954         return np.ctypeslib.as_array(p)
>         1955
>         1956     def tableArgs(self, tableNum):
>
>     ~/src/anaconda3/lib/python3.7/site-packages/numpy/ctypeslib.py in
>     as_array(obj, shape)
>          361             obj = ctypes.cast(obj, p_arr_type).contents
>          362
>     --> 363         return array(obj, copy=False)
>          364
>          365     def as_ctypes(obj):
>
>     ValueError: '
>
>     any idea?  thanks -
>             joachim
>
>     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

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