[Csnd] taking on low level algorithm implementation in csound
Date | 2013-08-19 13:27 |
From | Machina |
Subject | [Csnd] taking on low level algorithm implementation in csound |
Attachments | None None |
Date | 2013-08-19 13:47 |
From | Michael Gogins |
Subject | Re: [Csnd] taking on low level algorithm implementation in csound |
Write your algorithm in C or C++ as a plugin opcode. There is documentation on how to do this in the manual, and an example in GIT and in the Windows installer. If you write in C++, you can use the OpcodeBase.hpp template base class for writing opcodes, which simplifies things a bit. Some of the existing plugin opcodes are written this way, e.g. the STK opcodes and the FluidSynth opcodes.
Once you've compiled and linked your opcode and placed it in the OPCODEXXXX dir, Csound will automatically load and use it. You can run things at different rates in different ways. With user-defined opcodes, you can have a local ksmps. I'm not sure that's possible with regular opcodes. If not, you can connect an internal frame by frame processor with the opcode buffers using FIFO queues. They will be efficient enough. Hope this helps, Mike =========================== Michael GoginsIrreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Aug 19, 2013 at 8:27 AM, Machina <machinadeoro@gmail.com> wrote:
|
Date | 2013-08-19 13:50 |
From | Victor Lazzarini |
Subject | Re: [Csnd] taking on low level algorithm implementation in csound |
A few pointers: 1) There is an implicit loop in Csound code that runs at k-rate. Variables are updated at this rate. Audio (a-) rate ones hold a ksmps block and control (k-) rate ones hold a single sample. 2) if you need sample-by-sample calculation in this implicit loop, then you will need to set ksmps=1 in an UDO. In this case a- and k- vars are the same and hold a single sample. 3) You can access each sample in an audio var block via the vaget/vaset opcodes, if you need to. 4) you can treat ftables as arrays, use tabw/tablew to write, and tab/table to read. 5) in csound 6 you can also use arrays (a or k-rate). I think the key thing to understand is the implicit k-rate loop, and then write your code around that. Victor On 19 Aug 2013, at 13:27, Machina wrote: > Hi all. > following my questions about tartini and other pitch detectors, I'm thinking of implementing the low level algorithm myself. > i had some trouble before comparing csound to a standard programming language. treating ftables like arrays is usually buggy, or the flow is just unnatural to me. > > so i'd like to hear some thoughts on how is best to implement: > 1) correlation function of moving indexes - i thought of using the delay command but what it i want to create a product like: > sum(t->t+k)Signal^2(t)*(sum(t+k+m->t+m)Signal^2(t)) or something of that natue. what is the natural way to achieve this? will i have to load the relevant signal section into ftable and reverse? > 2)how would you implement (strategically) a peak picking algorithm - that has many repetitions over the data and should be done with a karg=karg+1 manner and not a phasor manner (or should it). > 3) would all these calculation (karg=karg+1) should be at a-rate? because i would like to output pitch every k-rate, so lets say there are 1200 a-cycles in a k-cycle ( 33Hz) am i going to be limited to 1200 cycles of calculations? (i.e. a 300 dots array would be scanned 4 times maximum) > > so how to go about this? > > thanks > Oro Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |