Chinenual Development Thread

If you are allocating memory from your process call you will almost certainly create a priority inversion, and the pops and click that are inevitably created by that.

Mmm. I haven’t noticed this yet (and I’m testing on a single threaded relatively low powered laptop). CPU utilization is low, but perhaps memory allocation is lurking as a problem I haven’t noticed yet.

Definitely eager to hear from those that have kicked the tires - anyone seeing bad behavior? @Squinky : any advice for how to stress test this so I can measure something?

Yeah, it won’t happen all the time. I remember working at a pro audio company 10 or 15 years ago and we had a stop ship bug where we were getting like one click every 10 hours or so. Traced it to a place where the compiler had added a call to malloc that didn’t run very often.

There is much written on why one should not to this.

My own paper is pretty popular here:

But if you just google “audio pop and click malloc” you will get some good hits. This one is very much on point: Four common mistakes in audio development

For me, since I leaned this lesson long ago I have gone to great pains never to do it, so I have never called malloc from the audio thread in a VCV module. I have sometimes gone to great lengths to avoid it. Like when note data needs to be allocated in a my sequencers :wink:

There may be ways to demonstrate/test this, but nothing super easy occurs to me.

1 Like

Thanks @Squinky. That’s enough for me - I’ll find a way to fix this.

Meanwhile, I’m hoping to get feedback on the module as it is. So for those of you planning to help test, please don’t wait. I’d like early feedback on the rest of the new features and UI, even if there’s a theoretical performance problem lurking…

1 Like

it’s not a theory, it is a generally accepted fact. But as long is you fix it eventually, that’s great. And for sure not a reason for ppl to avoid testing - there are hundreds of module out there that do the same thing (I’m guessing).

1 Like

Trying to imagine a way to avoid allocating memory off the audio thread. Keep thinking of ways the concurrency will blow up any simple solution. If you have a thread to keep the allocation outside the audio thread, you have to find a fast way to pass the events to the allocation thread, preferably without having to use locks.

This is serious programming that people smarter than me solve all the time, but don’t know if anyone has solved it for Rack plugins.

none of my plugins block on the audio thread, and yes, it’s not easy. But I never made a plugin with an allocation pattern like this one, Seems they have a solution that seems sensible. And, yes, lock free programming is not super easy. I think @Vortico is pretty good at it, from what I’ve seen. But most VCV devs are not. It’s a pretty esoteric thing. unless you are just a genius (which I am not).

I would never make a plugin that blocked the audio thread. But that and a zillion other things conspire to make it such that making a “high quality” VCV module takes about 10X more effort than making a bad one. no thanks, I don’t want that job.

One simple solution - pre allocate 1GB of ram ahead of time. Everyone has a free gig, and you will never need that much. I’ve never done anything that dumb, but it would actually work fine.

I’ve fixed the allocation bug @Squinky highlighted. I adapted the same design that @Vortico uses in the VCV Recorder (a rotating set of buffers with all allocation on a worker thread). There’s a small chance of some thread synchronization overhead if the worker thread can’t keep up with the main audio thread, but I’ve tried to set the size of the buffers such that that’s unlikely to happen. In any case, it’s going to happen a lot less frequently than the allocations did in the old code. Code review, of course, welcome (see the new MIDIBuffer.hpp file).

Meanwhile, unless I hear back from testers soon, I’m inclined to submit to the library.

1 Like

I’ve submitted the new version (with the CC Expander) to the library. The original request from 9 days ago has not yet made it to the library - so not sure how long it will be before you’ll be able to get this via the library. Until then, you can install it as you have been installing the betas:

2 Likes

Congrats! This is a really helpful addition.

1 Like

The 2.1.1 version of the recorder and expander are now available in the VCV Library.

Meanwhile, I’ve added some new functionality and there’s a beta available for testing. It makes it easier to sync a MIDI recording with audio stems since the MIDI recording optionally delays capturing events until the first note gate. You can use the new ACTIVE gate to trigger the audio recording to start when the recorder decides to start recording. Looking forward to feedback.

  • New Output Port: ACTIVE can be used to synchronize the MIDI Recoding with an audio recording. When Align At First Note is enabled, this goes high after the first note is detected, else as soon as the recording is started.
  • An LED under the ACTIVE port lights up when the recorder is capturing events (it lights up when the ACTIVE gate is high.
  • Panel layout changes - the first column of ports is shifted left a bit to align with the Record button.
  • The Record button is now labeled REC (was RUN).
  • The Start/Stop Gate input is no longer labeled GATE. It shares the REC label with the Record button.

I’ve added a new module to the plugin - DrumMap - which converts percussion gates to V/oct based on General MIDI standard drum note assignments.

DrumMap_w_MIDIRecorder DrumMap_w_CV-MIDI

From the changelog:

Improved support for capturing percussion events:

  • If a track’s V/OCT input is not connected, the recorder defaults to MIDI C4 (so for drums, only a GATE input is necessary). When a polyphonic gate is connected, but no V/OCT, then each channel of the GATE gets a unique MIDI note pitch.
  • A new module, DrumMap, maps named gates to General MIDI “drum” notes (which can then be plugged into the MIDIRecorder or sent to a live drum machine via the core CV-MIDI module).

Looking forward to your feedback. Get a beta at: Release Release v2.3.0-beta1 · chinenual/Chinenual-VCV · GitHub

7 Likes

Awesome! I’m been wishing for a trig to midi combiner for a while. Makes external sequencing so much easier. Will give this a go.

1 Like

I wonder about the size of the intersection of people who use VCV Rack and who are interested in Arvo Pärt’s compositional approaches. It’s at least one, so I’ve created a new module, the Tintinnabulator.

Tint

It produces a harmonized pitch from an input chord and melody using Avro Pärt-style tintinnabulation where a harmony note is selected from a reference chord. Pärt’s music tends to use simple triads for his tintinnabulation, but the module allows you to specify any set of notes as the reference.

The module supports several variants of the harmonization - select first available pitch or next one, in both upwards or downwards direction. Also supports bidirectional tintinnabulation, where every other note switches between upward or downwards selection. An Octave offset can be used to offset the harmony up or down from the reference melody line.

Looking forward to your feedback.

Test it via the beta posted at:

9 Likes

I’m looking forward to trying this out. Somewhere over the past 50 years, I was introduced to tintinnabulation in electronic music, but probably in the Environments ambient series during the 60s and 70s. Not sure if the Avro Pärt-style is the same thing, but probably related. The sound of bells. In my earliest ambient works in the late 80s, I used a lot of tintinnabulation.

2 Likes

First test of Tint with Meander’s harmony and melody parts sound very good. I do not fully understand what I am doing here, but I’m having fun.

2 Likes

So the size of the intersection set is at least 2 :slight_smile:

1 Like

At least! It is absolutely amazing how good this sounds with Meander in Am diatonic, with bass added. Each of the Tint “modes” are very interesting… I’m ready to give this 5 stars right now!

Adding in the Meander chords sounds very good. So, Tint is providing the melody as a tintinnabulation of the Meander chords and melody.

3 Likes

Looking forward to trying this! Make that 3! Love Arvo Part.

3 Likes