Cabbage Logo
Back to Cabbage Site

[WIP] Unamed Modular Project

Heyo! This is my first time posting here so I hope I’m doing this correctly. I’ve spent the better part of the last two days putting together a proof-of-concept thingy in the style of a modular synthesizer. Here’s a screenshot of it in it’s current state:


It essentially uses an array of global audio channels in order to communicate between each of the modules. However, everything defaults to N/A just so there isn’t a cacophony the second you start it up (and also so modules can be left inactive). I simplified a lot of the in/out code so that each module just imports the signals from the array, and can output them directly back into it. I also had to get a bit creative in terms of clearing the audio channels when there was nothing set to them, as it seemed that leaving the channels stuck at anything other than “0” would result in a pitch of random frequency/amplitude. I imagine this is probably just some aliasing issue, though, and was able to solve it pretty simply and involve that code in the custom “output” opcode so that things didn’t get too messy.

One thing that does make me sad (although this is more Csound-specific and I may just not know that there is a solution to this) is that my custom “input” opcode can only provide things in a-rate, whereas most official opcodes in Csound will let you have an option to have it provide values in a-rate or k-rate. I got around this by simply following the “input” line with a new variable of k-rate and equaling it, but it still feels a bit clunky to me. I imagine I could also just simply do k() around the input opcode, albeit I am still not very well versed in when Csound allows nesting and when it doesn’t.

One of the cooler parts of this project was the realization that I could have external audio (microphone / line input) and have that modulate things in the exact same way as an LFO (for example). This led to me immediately making some absolutely insane sounds involving modulating the frequency of the VCO and convincing myself I had somehow accidentally invented a new wonky form of synthesis (lol). Still want to add more modules so I can fiddle with this live input further. Maybe even have triggers based on amplitude? Who knows.

I have not considered what I am going to do once I run out of space on the screen yet, albeit that is somewhat a worry of mine. I imagine I’ll be able to come up with some workaround with having “pages” (aka just enabling and disabling groups of modules) but I will cross that bridge when the time comes.

I also am having some issues getting the Oscilloscope to update more than, like, two times a second. I modified the “updateRate,” but it didn’t seem to make much of a difference.

Oh also, the “de_dust2” is just a play on the name of the dust/dust2 opcode names and the map from the game Counter-Strike, just so people don’t get confused.

I have not implemented it yet, but my plan for if multiple modules use the same “output” channel is to simply add them and divide them by the total number.

But uhh yeah, that’s everything for now. I expect to be adding some more modules over the coming days. Here’s everything I have planned so far:

  • Gain & Bias
  • Sample & Hold (Maybe also a separate bitcrusher?)
  • Slew limiter
  • MIDI Support
  • Sampler player
  • Soundfont player
  • Sequencer
  • MIDI Player??? Maybe???

Anyway if you think of anything more in terms of modules that could be added feel free to let me know! This is a fun little project for me and it’s (relatively) easy to add most modules on the fly (especially if it’s really just running things through a single opcode LOL).

Current version (Freeverb and Envelope non-functional):
ModularTest.csd (14.8 KB)

Hi @Northalicious, welcome to the forum and thanks for posting. Did you mean to share some code? Without it it’s hard to make suggestions that might help improve things. Anyhow, here are some thoughts:

Did you try using the chnclear opcode? That’s what it’s for…

You can always provide k-rate versions. For example:

opcode MyOp, k, k
...
endop

opcode MyOp, a, a
...
endop

After that Csound will now which one to use depending on the arguments you pass to it.

Sounds like a good option. This synth packs a lot of features into a relatively small screen. And the source code is available too.

Sounds like a fun project. Do keep us updated :+1:

My bad! I’m still getting used to the more open nature of open-source communities (I come from game development so I feel somewhat strange just uploading full swaths of code places, but I’m not opposed to it!) Here’s the current version! I’m also gonna try to attach it to the initial post after I post this, just in case anybody is looking in the future.
ModularTest.csd (14.8 KB)
I should note that at the moment the Envelope module and Freeverb module are non-functional. Envelope because I simply haven’t implemented it yet, and Freeverb because there’s some odd bug that I’m in the process of figuring out. Everything else (should) work out the gate, though!

That’s actually a pretty good idea. I think I’ll probably do a bit of opcode nesting that way the final front-end for my usage is the same but I’m not just copying code between the two and switching “a” to “k”. That’s really just me thinking out loud, though, don’t worry about it too much LOL.

I’ll look into this! I don’t know if it’ll work with my weird audio array system, but it’s certainly worth a shot!

I’ll definitely be looking into this as I try to sort out a nice way to do multiple pages.

Thanks so much!!

New update for this project!!
I’ve slapped my name on it and marked the current version 1.1 because whyyyy not.
Here’s the newest version (various features added to VCOs/LFOs and fixed the Freeverb module (turned out to be a silly typo, as I suspected).
Modular Demo 2.csd (18.6 KB)
Envelope module is still a work in progress, and as such doesn’t work.
Enjoy, all!!

EDIT: Here’s a screenshot, by the way

I was looking at your code, and noticed that when I ran it, it was sapping the entire CPU time on my machine. After poking around a little, I was noticing you have the ‘setup’ instrument running all the time. As soon as I turned that off, the CPU usage when back to it’s normal levels of about 6% of the CPU usage by cabbage. I think it should only be run once.

Also, the ‘getvars’ instrument uses about 20% of the CPU time when it is running. You might get better performance if you use ‘cabbageChanged’ to check to see if those gui objects actually changed their data. Since this is running every k-cycle, it is using up a lot of time.

Mike

1 Like

Hello Northalicious,

I found this csound orchestra and score file that you might find interesting ( http://www.csounds.com/cook/ ). It is the first set of links on this page. It is also quite old, from 2001 or so, but still should be valid to study.

It is a loose implementation of the old Synthi VCS3 synthesizer from Steven Cook. The VCS3 synth was the first to offer a “patch system” to route the signals from one module to another.

It isn’t on the new Csound site, but this is a copy from the old site. There isn’t a GUI on it yet, but it does show how you can set up and use an underlying routing system for both audio and krate signals.

Hope this helps.

Thanks so much for all your advice, genuinely! I’ve been working on implementing the (admittedly pretty simple) fixes you’ve suggested above. This week has been largely chaotic for me, though, so I haven’t gotten a chance yet. I’ll also definitely look into the link you sent over. Looks like it would be super useful to reference. Thanks again! I’ll be sure to post some more screenshots/a newer version soon once some free time opens up!

1 Like