Jump to content
IGNORED

generative MIDI for fun and profit


Recommended Posts

During the past year I have found it really useful to have a bunch of tricks to generate a melody out of some random numbers generated by my friendly computer. It's nice for kickstarting inspiration and also for just discovering new melodies and rhythms that you otherwise would not have figured out.

Here's a plugin I made this week out of Live built in MIDI stuff.

https://www.dropbox.com/s/a7329u4qhugs7et/Mondo Generator.adg?dl=0

 

And here's the track I made with it:

 

Screenshot_2021-01-06_at_21.27.57.png

Link to comment
https://forum.watmm.com/topic/100506-generative-midi-for-fun-and-profit/
Share on other sites

A good chunk of what I did in 2020 was random-oriented. SC's Patterns can help hone in on a sweet spot of structure vs. random (or realtime-controlled) variety.

http://doc.sccode.org/Tutorials/A-Practical-Guide/PG_01_Introduction.html

Thanks, I hope I find time to check out SuperCollider as well. The only problem is that looks like the same code I stare at all day and this instantly makes it feel like work.

 

By the way, I wanted to clarify that so far I have got no profit out of the generative things, only loads of fun!

I'm slowly working on some stuff too. Just web things for now, but eventually I'd like to have a small "suite" of generative MIDI VSTs.. or at least, M4L patches.

Bounce - A "sequencer" inspired by the best Electroplankton level where you bounce balls off lines to make a melody

Window - Basic generative pattern sequencer where the note and timing data are decoupled

This is cool, thanks. Will try it out tomorrow.

Also that track you made with it sounds great, gave you a follow on SC.

  On 1/11/2021 at 3:51 AM, modey said:

I'm slowly working on some stuff too. Just web things for now, but eventually I'd like to have a small "suite" of generative MIDI VSTs.. or at least, M4L patches.

Bounce - A "sequencer" inspired by the best Electroplankton level where you bounce balls off lines to make a melody

Window - Basic generative pattern sequencer where the note and timing data are decoupled

Getting some insane The Incredible Machine flashbacks from Bounce. I wish the balls would not disappear when they hit the bottom edge, all the other "borders" seem solid and bouncy. Also in some cases I have seen the ball go through the lines without bouncing!

Because I am a quantization type of person, I would actually implement a grid version of this, so that you could still aim the balls wherever you want and mess with the speed, but the sounds would be quantized in time (you could optionally change the grid size too of course to make it more or less granular). Then you could build up your bouncy sound castle and add more ball guns etc etc.

Window's concept is pretty much exactly what I whipped up in Pure Data 2019 early 2020, to have notes and timings cycling separately. I kind of want to start to incorporate this kind of thing again but it is a bit difficult to integrate well with Live (no I don't want to build a M4L device). Anyway I think this approach is really good for being able to play and transition from one rhythm or melody to another - you just keep the timing part the same and switch out the melody or vice versa.

By the way, what did you use to make these?

thx! They were built in p5js so things like the balls moving through the lines are somewhat unavoidable (or my code sucks haha) but yeah, those suggestions sound good. I'm very slowly learning juce so maybe they'll be a bit more robust in VST form, where I can possibly use the audio engine to calculate the bounces etc. 

Different sounds/MIDI channels could be implemented as well. 

Edited by modey
  On 1/11/2021 at 11:53 AM, modey said:

thx! They were built in p5js so things like the balls moving through the lines are somewhat unavoidable (or my code sucks haha) but yeah, those suggestions sound good. I'm very slowly learning juce so maybe they'll be a bit more robust in VST form, where I can possibly use the audio engine to calculate the bounces etc. 

Different sounds/MIDI channels could be implemented as well. 

I am thinking that it would be more interesting/useful if the apps came with:

  • ability to select incoming outgoing MIDI port and channel (no need to support multichannel stuff)
  • ability to receive sync over MIDI

At this point I and anyone else can just plug it into their DAW as a source of MIDI notes, and already they would be pretty well usable for performances and many other cool things. Putting it in a VST is great too of course, but I feel it's orders of magnitude more work and since you are only passing on MIDI information, it's quite lightweight and JavaScript can handle that OK.

As for the collision stuff, yeah it's a fuck to implement properly because even AAA games get clipping problems. Once again using a grid (even if only in the backend) you can cheat and solve this simply - you check if the center of the ball is in a grid square that is noted for containing a line and then you play the ding dong sound. Of course it all depends how you have done it so far, but really it's not a big deal even if you get it 95% working because who the hell cares really it is an inspirational art tool. ?

AFAIK there is a browser MIDI support that has existed in Chrome (at least) for some time, I know because the Livid Instruments configuration app for my Code v2 came with a browser app.

me likey the generative midi road ..physics, aleatoric, ..mainly using Usine for that ...

 

this is also quite nice..

https://github.com/silveirago/The-Pendulum-Sequencer

 

 

 

I've been doing some generative stuff for a good while (check my signature if interested, especially AAP). Mostly it's with Renoise that allows random events and sort of selection of event with weighted probabilities. Like 50% this will be kick, 25% snare, 25 hihat. And so on. And you can layer them using phrases. Renoise also has Lua support so you could generate the sequences in the patterns and save them. That way you won't have the annoying thing that the track sounds different every time even though it was randomized.

I did some Python code that played randomized music some years ago also. It worked through General MIDI but I tried it with a synth also by just changing the MIDI device number and it worked fine. Using MIDI in Python is really easy. Just a couple of commands to initialize and then note_on, note_off, etc.

I'm utilizing Reaktor now more, but so far haven't got too deeply into the generative stuff with it. Just synth design with some S&H parameters. Then load the Reaktor instruments in Renoise and let Renoise do the (semi-)randomized sequencing.

electro mini-album Megacity Rainfall
"cacas in igne, heus"  - Emperor Nero, AD 64

  On 1/11/2021 at 12:16 PM, thawkins said:

I am thinking that it would be more interesting/useful if the apps came with:

  • ability to select incoming outgoing MIDI port and channel (no need to support multichannel stuff)
  • ability to receive sync over MIDI

At this point I and anyone else can just plug it into their DAW as a source of MIDI notes, and already they would be pretty well usable for performances and many other cool things. Putting it in a VST is great too of course, but I feel it's orders of magnitude more work and since you are only passing on MIDI information, it's quite lightweight and JavaScript can handle that OK.

As for the collision stuff, yeah it's a fuck to implement properly because even AAA games get clipping problems. Once again using a grid (even if only in the backend) you can cheat and solve this simply - you check if the center of the ball is in a grid square that is noted for containing a line and then you play the ding dong sound. Of course it all depends how you have done it so far, but really it's not a big deal even if you get it 95% working because who the hell cares really it is an inspirational art tool. ?

AFAIK there is a browser MIDI support that has existed in Chrome (at least) for some time, I know because the Livid Instruments configuration app for my Code v2 came with a browser app.

Expand  

Yeah, good point. JUCE is a whole world of pain in terms of even just getting things set up. I'm at the point with Window now though where it works as a straightforward 16th note sequencer in VST form, so it's only a matter of adding the remaining features and a few others. And I did want to make some basic synth engines to go along with these, but that's a long way down the line. Standalone with MIDI I/O only would be a breeze though ? 

Yeah the collision stuff is maybe not the best implementation. At every frame for each ball and for each line it measures the distance from each point, and if the distance between the ball and each point of a line adds up to the line's length (+/- a certain amount), it bounces. It doesn't work at high speeds, due to it measuring every frame (ie. it could miss the threshold) and for some reason I've noticed it doesn't work on a particular part on a line (not sure why!) so it's not 100% accurate, but hey, it works most of the time! I coded most of it up by hand so there's likely a much more efficient way to do it that I just don't know of yet, due to my limited math (trig? physics?) knowledge!

I was actually tempted to make a Unity version because I know that it'd handle the physics pretty well, and I could get away with all kinds of things, even 3d. But I'm not sure if Unity is capable of rock solid MIDI timing lol.

And yeah, I have WebMIDI support in one version of Window, just commented out, I should get back on that! Ideally though I'd love to be able to just save to a MIDI file. I'm not even sure how I'd do that in p5js though.

  On 1/12/2021 at 3:58 AM, modey said:

Yeah, good point. JUCE is a whole world of pain in terms of even just getting things set up. I'm at the point with Window now though where it works as a straightforward 16th note sequencer in VST form, so it's only a matter of adding the remaining features and a few others. And I did want to make some basic synth engines to go along with these, but that's a long way down the line. Standalone with MIDI I/O only would be a breeze though ? 

Yeah the collision stuff is maybe not the best implementation. At every frame for each ball and for each line it measures the distance from each point, and if the distance between the ball and each point of a line adds up to the line's length (+/- a certain amount), it bounces. It doesn't work at high speeds, due to it measuring every frame (ie. it could miss the threshold) and for some reason I've noticed it doesn't work on a particular part on a line (not sure why!) so it's not 100% accurate, but hey, it works most of the time! I coded most of it up by hand so there's likely a much more efficient way to do it that I just don't know of yet, due to my limited math (trig? physics?) knowledge!

I was actually tempted to make a Unity version because I know that it'd handle the physics pretty well, and I could get away with all kinds of things, even 3d. But I'm not sure if Unity is capable of rock solid MIDI timing lol.

And yeah, I have WebMIDI support in one version of Window, just commented out, I should get back on that! Ideally though I'd love to be able to just save to a MIDI file. I'm not even sure how I'd do that in p5js though.

Expand  

Yeah, Unity would solve your physics issues quite well, but then you would have a full blown game engine running in a thing that is supposed to generate MIDI. Whoops. ? Not sure how game engines deal with real-time requirements for rock solid MIDI timing either, so I would absolutely avoid this.

IIRC the deal with JUCE was that you needed to write your things in C++, which can have a terrifying learning curve and comes with some obscure gotchas too. I assume they have most of that covered in the tutorials by now though.

I'm only egging on the MIDI compatibility because I get all my sounds from the hardware modules and I use almost no VST or plugins for sound generation at all.

By the way your description of that collision checking now explains why sometimes I got the balls all over the place while I thought they would be bouncing off the first "wall". ?

  On 1/12/2021 at 3:58 AM, modey said:

And yeah, I have WebMIDI support in one version of Window, just commented out, I should get back on that! Ideally though I'd love to be able to just save to a MIDI file. I'm not even sure how I'd do that in p5js though.

I think I would record some MIDI with a DAW, export it and see how the file looks like, then try to get p5js output something similar.

Another fan of generative techniques here, the track in my sig was all randomly generated.

A comathematician is a device for turning cotheorems into ffee.

QKcDskr.gif

GET A LOAD OF THIS CRAP

  Reveal hidden contents

 

I know I'm kind of a broken record about this lately but this yet another thing I'd definitely use SuperCollider for. If only because I'm lazy and it's easy.

(Pbind(
    \scale, Scale.harmonicMinor,
    \degree, Pbrown(0, Scale.harmonicMinor.size, 3),
    \octave, Pbrown(3, 6, 2, inf),
    \dur, Pwrand(
        (1..4) / 8,
        [3, 5, 2, 1].normalizeSum,
        inf
    ),
).play)

Edited by sweepstakes
  On 1/19/2021 at 12:24 AM, sweepstakes said:

I know I'm kind of a broken record about this lately but this yet another thing I'd definitely use SuperCollider for. If only because I'm lazy and it's easy.

(Pbind(
    \scale, Scale.harmonicMinor,
    \degree, Pbrown(0, Scale.harmonicMinor.size, 3),
    \octave, Pbrown(3, 6, 2, inf),
    \dur, Pwrand(
        (1..4) / 8,
        [3, 5, 2, 1].normalizeSum,
        inf
    ),
).play)

Expand  

I'm interested in trying this out - could I ask you to share a minimal project or some code I can copy and paste, hit play and get started?

  On 1/19/2021 at 9:25 AM, thawkins said:

I'm interested in trying this out - could I ask you to share a minimal project or some code I can copy and paste, hit play and get started?

For sure! That snippet right there should be runnable although I don't think it sounds great or anything, plus it will use the (super bland) default piano instrument.

I'll see if I can find some other cool sequences, but it might be faster for me to whip something up if you have some suggestions/prompts? 

  On 1/19/2021 at 2:03 PM, sweepstakes said:

For sure! That snippet right there should be runnable although I don't think it sounds great or anything, plus it will use the (super bland) default piano instrument.

I'll see if I can find some other cool sequences, but it might be faster for me to whip something up if you have some suggestions/prompts? 

If it should work like that, then I'll just give it a shot - I am just unfamiliar to SuperCollider and I figured you would need to set up some scaffolding for sounds and MIDI connections or something who knows!

  On 1/19/2021 at 4:43 PM, thawkins said:

If it should work like that, then I'll just give it a shot - I am just unfamiliar to SuperCollider and I figured you would need to set up some scaffolding for sounds and MIDI connections or something who knows!

Nope, that's part of why I love SC - I'm lazy :) The only "scaffolding" you should need to do (as long as your sound is properly configured) is booting the server.

Side note - the classes are worth introspecting for their properties (e.g. Scale.harmonicMinor) and also reading up on the docs in the SC IDE (by pressing Ctrl/Command+D on top of a class/property/method). It's easy to get started and there is also a lot to explore.

  On 1/19/2021 at 5:41 PM, sweepstakes said:

Nope, that's part of why I love SC - I'm lazy ? The only "scaffolding" you should need to do (as long as your sound is properly configured) is booting the server.

Yeah, tried it out yesterday and it's much faster to get started than with the TidalCycles thing (which did not work half the time too). If I have some more time I will try to implement some ideas in SuperCollider once I get it hooked up to Live properly with MIDI timecode sync etc.

  On 1/20/2021 at 8:31 AM, thawkins said:

Yeah, tried it out yesterday and it's much faster to get started than with the TidalCycles thing (which did not work half the time too). If I have some more time I will try to implement some ideas in SuperCollider once I get it hooked up to Live properly with MIDI timecode sync etc.

IIRC TidalCycles is a Haskell process talking to the SuperCollider server, no?

  On 1/20/2021 at 12:48 PM, rhmilo said:

IIRC TidalCycles is a Haskell process talking to the SuperCollider server, no?

Yes, but at least the last time I tried, it was a headache to set it up so that you can easily open a project and have your basic things work out of the box (i.e. after you set up some template stuff). I used it strictly as a MIDI sequencer too so that may have been my mistake - the general workflow seems to be to use TidalCycles sounds with it as well.

Maybe one of the things that put me off about TidalCycles was the sheer amount of Stuff it required to install - some Haskell things, SuperCollider. And all that for a MIDI sequencer? Overkill!

However I should stop hating on TidalCycles and just give it another shot to see if I get better results now. Who knows, maybe even learn me a Haskell for great good!

  On 1/20/2021 at 2:00 PM, thawkins said:

Maybe one of the things that put me off about TidalCycles was the sheer amount of Stuff it required to install - some Haskell things, SuperCollider. And all that for a MIDI sequencer? Overkill!

Shh ... don’t let @Nil hear you.

Haha, agreed though!

@thawkins man you're going to love Note probability and Velocity range in Live 11. Add some macro snapshots (killer new feature) and Follow Actions et boom!

Built-in  MIDI devices are indeed super powerful, I often use similar tricks when teaching synthesis (to avoid repetitive loops).

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   1 Member

×
×