5

I am currently working on a specialization project on simulating guitar effects with Evolutionary Algorithms, and want to use Python and CSound to do this.

The idea is to generate effect parameters in my algorithm in Python, send them to CSound and apply the filter to the audio file, then send the new audio file back to Python to perform frequency analysis for comparison with the target audio file (this will be done in a loop till the audio file is similar enough to the target audio file, so sending/receiving between CSound and Python will be done alot).

Shortly phrased, how do I get Python to send data to a CSound(.csd file), how do I read the data in the .csd file, and how do I send a .wav file from CSound to Python? It is also preferred that this can work dynamically on its own till the criterions for the audio file is met.

Thanks in advance

wprl
  • 24,489
  • 11
  • 55
  • 70
jk87
  • 51
  • 2
  • Isn't Csound capable of doing the analysis for you? It seems this article is about it: [Tools for Real-time Spectral Processing (pvs opcodes)](http://www.csounds.com/manual/html/SpectralRealTime.html) – Wolf Sep 20 '15 at 11:34

2 Answers2

1

sending parameter values from python to csound could be done using the osc protocol

sending audio from csound to python could be done by routing jack channels between the two applications

Slater Victoroff
  • 21,376
  • 21
  • 85
  • 144
Nikolaus Gradwohl
  • 19,708
  • 3
  • 45
  • 61
  • I will look at the osc protocol, although I am not familiar with routing jack channels between two applications. – jk87 Nov 21 '11 at 16:14
  • 1
    If you are on a linux system the easiest way is to use qjackctl and simply draw a connection between the too applications – Nikolaus Gradwohl Nov 21 '11 at 21:59
  • I am working in Windows 7, and woun't be switching to a linux system anytime soon. – jk87 Nov 22 '11 at 14:59
  • qjackctl and jackd are also ported to windows there is an article in the csoundjournal that shows how to connect csound to ableton-live using jack http://www.csounds.com/journal/issue14/csoundlivecsound.html – Nikolaus Gradwohl Nov 22 '11 at 19:31
1

You can use Csound's python API, so you can run Csound within python and pass values using the software bus. See csound.h. You might also want to use the csPerfThread wrapper class which can schedule messages to and from Csound when it is running. All functionality is available from python.

Andres
  • 11
  • 1
  • I already have looked a bit into the Python API, so I think I will be able to send the parameters to CSound without too much trouble. But I haven't found a way to send the audio file from CSound to Python, it doesn't seem to have any easy built in function for it (correct me if I'm wrong, I may have overlooked it). – jk87 Nov 22 '11 at 14:57