A tribute to Ken Stone’s Infinite Melody and Modulo Magic 4U CGS Serge CV generator and processor modules, now optimized for MIDI input and output.
You can find expandable development diary entries at the bottom of this post.
- MIDI Output (optional, but highly recommended)
- MIDI Input (optional)
- Crow CV in & out (optional, still needs testing)
nmMelodyMagic is a MIDI note and CC sequencer, synced to Norn’s clock. Connect it to your favorite synth and generate infinite melodies! A very basic PolyPerc audio engine sound is available as well for easier testing and learning.
My guides for the original 4U CGS Serge modules on GitHub, which will help you understand nmMelodyMagic better, while I haven’t finished the in-script manual yet:
K1: Hold for in-script manual
K2: Clock pulse
K3: Advance pulse
K1+K2: MIDI Panic (all notes off)
K1+K3: Save state (auto-loaded on startup)
E1: Switch page
E2: Select parameter
E3: Change parameter
Check out the EDIT menu “MIDI output settings”, where you can assign each of the script’s output values an individual MIDI channel and select between note or CC generation!
Go to the EDIT menu, scroll down and choose your MIDI output device.
Scroll down further, go into MIDI Output Settings and set “DAC1 Proc. Out” to Note and choose a MIDI channel for your connected synth (Default: 1).
Now go out of the menu, back to the Infinite Melody screen, which you saw on startup. The default values will let you experiment manually with nmMelodyMagic, before diving into clock-synced chaos.
On the Infinite Melody page, press K2 and K3 to watch the shift registers fill up and see what happens to the output values at the bottom. The (processed) D1 number is the note that will be sent to your synth. Later then, change Clock and Adv. to positive (faster) or negative (slower) values to automate melody generation, synced to Norns’ clock.
On the Diatonic Converter page, turn E2 and watch the shift register fill and generate octaves and notes. Later, change the Input to something other than Manual to automate note generation. You may go back to the MIDI output settings and assign note or CC output and a MIDI channel to “Dia Out” to sequence an external synth.
On the Modulo Magic page, turn E2 and watch the input bar on the left rise to Initiation threshold markers and see what happens to the output bar. Again, choose an Input other than Manual to process another signal from the script. You may go back to the MIDI output settings and assign a channel to “Modulo Out” to sequence an external synth.
The digital shift register “DSR In” is populated with ones and zeros on every Clock pulse, indicated by the left pointing arrow. The value depends on a comparator output, of which the threshold is set with the Sense parameter. By default, an internal noise generator is fed to the comparator. Is the noise value above the Sense threshold, the value is one (indicated by a small square next to the Sense label). If below, it’s zero.
On each Advance clock pulse, the DSR In values are pushed downwards to DSR 1, 2, 3 and Mix. DSR1-3 run through digital analog converters (DAC1-3) which output values between 0 and 127.
The lowest row DSR bits are multiplied by a value between 0 and 127 each (m1-6) and summed together at the Mix output. This lets you set up and combine half note steps, for example, which will not change all over the place, like with the DAC1-3 outputs. A little square next to the m1-6 labels indicates when that value is being multiplied by one. No square means multiplication by zero. Again, this corresponds to the lowest row of DSR bits on the left side.
Converts binary input values (from DSRs) into an octave number and a diatonic scale note number. Root offsets the output. Scale selects between major or minor output. Scaling lets your reduce the output range, which will also shift the output away from strict major or minor scales. Bits 5 and 6 can be disabled to reduce the octave range from eight to two.
Processes an integer input value, which may range from 0 to 127. When the input level reaches the Initiation value, the Step Size value will be added or subtracted. This may happen up to eight times, as set with the Steps value. Add and Subtract let you modulate the Step Size value. Offset shifts the Initiation threshold up.
On page 7 or in the EDIT menu, you’ll find a “MIDI Note Settings” menu. There, you may set which DSR bit will start and which bit will stop a certain output note. For example whenever DAC1’s bit 1 is high, it could start the note generated by DAC3-p. If DAC2’s bit 4 is high, it would stop the note. Like this you can achieve not only infinite melodies, but also infinite rhythms
Use E1 to scroll to the right until you reach the “Modulation” page. There you have three modulation slots, each with source, amount and target. This lets you create internal modulation and feedback paths, For example you could modulate the Infinite Melody’s Advance rate with DAC2’s output, to create even less static note generation. Or you can modulate the Diatonic Converter’s Root note to offset its melodies.
Scroll all the way to the right with E1 to reach a screen saver thing, generating modern art, based on you settings and rhythms.
- Maybe rename parameters to be more descriptive or offer an option to choose between the current, original module parameter names and new ones
- Implement a note quantizer feature to nudge MIDI note outputs into traditionally musical scales
- Maybe tweak MIDI Panic feature to send only necessary note off commands
- More testing
- Changing a MIDI output setting from note to CC will probably make the current note get stuck. If that happens, or if other notes should get stuck, hold K1 and press K2 to send an “all notes off” signal.
v0.5.0 - Initial release for further testing and feedback
v0.5.1 - MIDI panic implementation, tweaks and new default values
v0.5.2 - Notes will be cut off by DSR In bits now (see Gate Length EDIT menu)
v.0.5.3 - Added setting to set which DSR bits start and stop MIDI Notes, added internal modulation/feedback page
v0.6.0 - Added PolyPerc audio output, a UI for gate length setup and a Modern Art page
v0.6.3 - Added saving+loading, in-script manual (hold K1) and tweaked some stuff
v0.6.8 - Added a first try at Monome Crow CV in & out support
v0.6.9 - Another Crow test release, with added gate output and (hopefully) analog clock sync
v0.6.9.1 - Crow functionality code restructuring to make it run independently from MIDI
v0.7.0 - Added MIDI Clock output, made Modern Art more persistent and tweaked some bits and pieces
Via the community library in Maiden, or manually via the REPL command:
I’ve posted this thread before the script is released to share my process and thoughts with you and to encourage discussion. Expand the diary entries below to read on
2021-05-02 Hello and welcome to infinite melodies!
When I still had my “Best of CGS” Serge modular synthesizer in 2018, I went on a quest to fully understand its more complex (seeming) modules, specifically Ken Stone’s Infinite Melody and Modulo Magic. Due to little documentation, this meant having to understand the actual analog circuitry diagrams, which was a wonderful learning experience for me, as a synth DIY novice back then.
I shared my findings in text form, supported by hand-scribbled images, in threads on Modwiggler and also as .md files on my GitHub:
Before I continue, here’s a generative CGS Serge Modular synth jam I posted a while back, which is centered around melody CVs generated with a combination of both modules:
A few days ago, fellow synth nerd @gnome666 suggested that I should create a Norns port of the Infinite Melody module - a challenge which I happily accepted. And since the Infinite Melody goes so well together with the Modulo Magic, I (foolishly?) set my goal even higher, to create both modules and more in one script! The nmMelodyMagic!
The core functionality of the Infinite Melody was coded in Lua surprisingly quickly and I’ve got a working prototype script now, which is doing exactly what the module does, but optimized for MIDI instead of analog CV, meaning that parameter and output ranges are set to 0 to 127. It does not actually output MIDI yet, but I hope that this will be trivial to implement.
Again, my screenshot from above:
You can see the parameters from the module’s front panel, its DAC1-3 and Mix output values on the bottom and even a little grid visualization of the internal digital shift registers (DSRs), similar to my expertly painted drawings from the above mentioned guides:
My goals for this script: (in order of priority)
- simulate the Infinite Melody, Diatonic Converter and Modulo Magic functionalities as faithfully as possible
- add visualizations for what’s happening inside the virtual chips and wires
- optimize their inputs and outputs for a 7 bit MIDI value range (0 to 127)
- option for each individual output to send MIDI notes or CC
- additional “voltage processors” for each output to attenuate and offset the signals
- additional note quantizers for relevant outputs to tame the chaos even more
I look forward to share more of this project as it develops. In the meantime, let me know your thoughts and wishes and if you haven’t already, do check out those guides for an insight into Ken Stone’s brain
2021-05-04 Tackling the magic
Development continues very smoothly. Too smoothly? We’ll see! I still haven’t implemented an actual MIDI output, but I coded up the Diatonic Converter, a value processing screen and the Modulo Magic functionality and the output values (optimized for the MIDI range 0…127) seem correct.
The Diatonic Converter was an add on circuit for the Infinite Melody. It receives a 6 bit input from the Infinite Melody, splits it in two groups and derives an octave and note number from each 3 bit group:
This is very cool, as it provided a diatonic 1V/Oct CV output, which is more traditionally musical than the other CV outputs of the Infinite Melody. A modification of the Diatonic Converter also allowed to disable the 2nd and 3rd bits of the octave selection, to reduce the octave range from 8 to only 2. I’ve included this modification as well in my script and I also plan to let the user choose the input, which was usually hard-wired to an Infinite Melody DSR output. It might be fun to wire it to the input DSR too for example (the pink one from my guide drawings), or even to an external MIDI CC signal converted to binary!
This thing was coded surprisingly quickly. Either it is just that simple, or I am getting better at nornsing
Here’s another drawing from my guide just for fun:
Since the Modulo Magic is a standalone module, I implemented input selection from the get go. So the user may choose any Infinite Melody/Diatonic Converter output or a “Manual” parameter, which of course can be mapped to an external MIDI CC source! This means you can use the module stand-alone and not just in combination with the Infinite Melody.
It occurred to me that I’m actually not sure if there are any people here who know what I’m talking about CGS Serge modular synths are a niche within a niche already and the modules I’m porting are certainly of the more obscure kind. So my plan is to add some kind of “live manual” to the script, making it easier for newcomers to learn to use it.
At the moment I’m not using any buttons, so I thought while holding K1, the display would show a screen telling you about the currently selected module or even the currently selected parameter. This shouldn’t be difficult to code.
Before that though, I want to add some visualizations to the Diatonic Converter and Modulo Magic screens too. The Infinite Melody screen already has the animated DSR grid, which is very helpful in my opinion and the other modules need something like this as well.
2021-05-05 Optimzations and Parameter Naming
Included an internal noise generator as a signal source for the Infinite Melody. Alternatively, the user may select a “Manual” MIDI CC input to be used for noise generation through the IM’s comparator.
Improved the update rate of the three ported modules Infinite Melody, Diatonic Converter and Modulo Magic, so it runs smoothly and properly in sync to the Norns master clock.
Started with the animated visualizations for the inner workings of the DC and MM. Some binary counting knowledge will probably still be required by the user, but even if there is absolutely none, I believe that it will still be fun.
Added input selection to the Diatonic Converter, so now it runs stand-alone and the user may even choose a “Manual” or MIDI CC source to be processed and turned into diatonic notes.
Added routing options for all outputs to MIDI Note or CC# with individual channel selection. No actual MIDI output yet though
I always felt that some of the parameters on the original modular synth modules had slightly misleading names - at least in the context I read them.
For example on the Infinite Melody, there is an input called “Clock”. This however is the clock source for the comparator/noise generator input, which populates the first DSR with bits and has nothing to do with rhythm or note output. So feeding a clock signal into that socket will not generate anything at the module outputs. Instead, the “Advance” input requires a typical clock signal to make the module generate melodies and the “Clock” input should actually be rather fast, even audio rate, to generate very random values.
So I’m a bit torn wether to stick to the original parameter names from the modules or to choose new, maybe more fitting, ones. Since I assume that few people will actually have experience with the original modules, this might not be a bad thing.
2021-05-06 v0.5.0 First release
I got the MIDI note and CC output working all of a sudden, so I thought it would be a good time to present a first version of the script to this forum to gather some feedback. MIDI Note output is still very rudimentary though. Just one note playing at a time per output, lasting the whole clock subdivision length. So a gate length feature is needed and I also need to check for conditions in which notes get stuck, one of which I found already
I also finished the visualizations for the three modules and hope they help.
2021-05-08 v0.5.3 Feature creep and a surprise
With the functionality of the original 4U CGS Serge modules being completely coded, it’s now time to think about where this script should actually be heading in terms of scope and usability.
I feel like I’m my own worst enemy when it comes to feature creep Norns scripting being so fun and easy as it is, I keep having feature ideas for which I already know most of the code structure in my head, so implementing them is not that hard at all so far. But this of course makes the script even more complex for the end user than it already would be, with only those weird original CGS Serge modules being ported to simply output MIDI.
But - much to my surprise - MIDI is quite a different beast than CV. You cannot only have a “note pitch” output with MIDI apparently, like when a modular synth outputs 1V/Oct pitch CV. No, with MIDI you also need to generate a gate start and stop signal every time you want your connected synth to make a sound or go silent. But the original CGS Serge modules I ported were not meant for this. They are only used to output pitch CV melodies and process incoming CV. Gating and rhythm signals needed to be generated with something else in the rack.
So I definitely needed to expand my script here beyond infinite melodies, to infinite gates/rhythms too. Staying true to the spirit of the modules, I thought that I could use the many bits in the digital shift registers (DSRs), to create note start and stop signals. The user can simply select a bit for note on and another one for note off commands. When the bits go high then, the command is sent, making sure that only one note can sound at once. So a note needs to be stopped in order for a new one to be generated. Since there are 12 signal outputs in total, one can still achieve polyphony, by routing those outputs to the same MIDI channel.
I feel like this will be a fun way of handling the gate situation, although it does add another layer of complexity to the script, especially for users who are not yet familiar with the original module functionality and their many DSRs. To tackle this problem, I need to start developing the promised in-script manual ASAP and also think about some additional user interface pages and data visualizations. Hopefully before even more features creep in.
2021-05-10 v0.6.8 Krah!
OMG! What a ride this project is! I can’t imagine I wrote 2717 lines of code already!!! Well, okay, 2717 of very spaciously formatted and heavily redundant code. But still
I fell like I’m at a point now where I should do some research and learn about programming best practices and how to structure code properly. Also, I need to check how this whole “object oriented” thing actually works and maybe how to spread parts of my script across several .lua files, for a better overview and easier maintenance. I don’t know if that’s actually a thing or helpful at all, but it seems like it.
I also want to know how to write this cryptic Lua “shorthand” … don’t know how to describe it, but sometimes, in other scripts, people seem to get a lot done with just one line of code, which is then not that well readable to me though, compared to the usual “human readable” Lua snippets. But it seems like you can omit writing certain things in Lua and string together stuff.
Anyway, I just implemented Monome Crow CV in & out support and hope that it actually works. I don’t have a Crow myself, but maybe I should save up for that. CV is obviously really useful. Thanks again to @gnome666 for nudging me into this direction and for offering to test the functionality.
When Crow support is done and I’ve tweaked the script some more, I think I’ll need to take a little break from coding. I’ve spend several hours almost every day for over two weeks now coding Norns scripts and while I’m still totally fired up and full of ideas, I need to check wether I’m neglecting something/someone else in my life … uhm … well, yeah, I know I do and she has been totally, amazingly cool the whole time and I’m so grateful I’m still on business trips during the week, where it’s easy to code alone in hotel rooms after work, but I’m afraid I spent too much time doing this on the past weekends at home too. Whoops! Coding for fun can be so crazily addictive. It’s like brain games, where you have to build the games and puzzles yourself too before playing with them.
By the way, I’m still coding exclusively on my iPad with Textastic and while it’s not as great as Visual Studio Code or some other desktop software like that, it works surprisingly well still and I feel quite at home with it.