Hi everyone,
I’ve been tinkering with Csound for a few months, trying to learn by hacking, but finally decided to ask for help here
I’ve been working on a handpan synth to play with a pad controller. I found a great patch through this linuxmusicians thread (hosted on http://juliencoder.de/sound/index.html). After trying to reproduce it in languages that I know better (mostly Pure data) and failing to reach the same sound quality, I am now building a VST plugin with Cabbage to use this synth in a DAW, ideally with presets for each scale (the initial patch requires editing/commenting out the giNotes
variable definitions).
Here is what I have so far: handpan_cabbage_test.csd (12.6 KB)
However, even before trying to switch scales, I’m noticing that the CPU usage increases slightly with each MIDI note I play, eventually causing performance issues and dropouts. This happens both in CsoundQt and in Cabbage.
Following advice from this form thread, I’ve implemented an always-on instrument which is confirming that kinstr
is increasing with every MIDI note played (and never decreasing), so one instrument seems to be running forever while also being re-triggered for every note.
As far as I could see from various csound tutorials and manuals, the instrument setup for this handpan is not really following the standard way of defining an instrument. The way I understand it:
- When the patch starts, the
"Setup"
instrument is triggered with a duration of 0.1s -
Setup
reads the number of notes ingiNotes[]
and creates one (always-on?)Tine
instrument and oneResonator
for eachiNote
. - upon MIDI input, a
Strike
instrument is created for the note, which again uses the correspondingTine
andResonator
instrument instances.
I have added printf()
commands at the end of each instrument to visualize when they stop running, and it looks like Tine
and Resonator
finish right after being set up by Setup
, while each Strike
starts and stops upon a MIDI note input. So I can’t figure out how Tines and Resonators actually run, and which instrument(s) are counted with kactive active kinstr
- but I feel like there is something basic I don’t grasp in how Csound instruments work, although it may be trivial for someone knowing csound a bit better, hence my question here
I hope someone can help me understand how this actually works and guide me to improve the performance! Thanks in advance
(spoiler: next questions in other threads will be on how to actually change the scale as selected in the UI dropdown, how to store the scale as a preset that can be stored in a DAW between sessions, and how to show feedback on the UI - but first things first!)