Ctcsound.py

Why are there so many error messages by compiling this simple code ?
import ctcsound as ctc
import numpy as np
import scipy as sc
import matplotlib.pyplot as plt

csd_text = ‘’’


-odac


instr 1
out(linen(oscili(p4,p5),0.1,p3,0.1))
endin


i1 0 5 1000 440

‘’’

cs = ctc.Csound()
result = cs.compileCsdText(csd_text)
result = cs.start()
while True:
result = cs.performKsmps()
if result != 0:
break
result = cs.cleanup()
cs.reset()
del cs
sys.exit(result)
C:\Users\Dominique\PycharmProjects\Csoundsynthesis\venv\Scripts\python.exe C:/Users/Dominique/PycharmProjects/Csoundsynthesis/Csoundsynth1.py
Traceback (most recent call last):
File “C:\Users\Dominique\PycharmProjects\Csoundsynthesis\Csoundsynth1.py”, line 1, in
import ctcsound as ctc
File “C:\Users\Dominique\PycharmProjects\Csoundsynthesis\venv\lib\site-packages\ctcsound.py”, line 45, in
libcsound = ct.CDLL(ctypes.util.find_library(“csound64”))
File “C:\Python391\Lib\ctypes_init_.py”, line 374, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 n’est pas une application Win32 valide

Process finished with exit code 1
OS : windows 10 64 bits
Python 3.9 64 bits
Pycharm 2021 3.3
ctcsound 6.17.1
csound 6.17 x-64

Hi @Animalia. It seems like ctcsound.py can’t find csound64.dll/csound64.lib files :thinking:

If you are using ctcsound installed with pip you can try to remove it and use ctcsound that came with csound.

One way to do that is by manually adding path of your ctcsound.py file:

import sys
sys.path.append("C:\Program Files\Csound6_x64\bin")  
import ctcsound

If your path is different, then of course you need to change path above accordingly.