This is a patch based on the MarkovGenerator from @Ingox and me. https://forum.pdpatchrepo.info/topic/10791/markovgenerator-a-music-generator-based-on-markov-chains-with-variable-length
We applied markov chains to midi data, and I was wondering how it would sound if I make markov chains from audio samples.
It works well if the sample has a maximum lenth of 500ms, otherwise the patch starts to slow down.
Its also possible to apply the markov matrix of one sample to another sample, if the old memory is used.
I attached some short drum samples.
The patch needs the cyclone, zexy and list-abs library.
AudioMarkovT.zip
here is a little experiment with a cowbell sample. the loop mechanism in video isnt implemented yet, because i dont really know whats happening (the waveform seems to be updated every loop from the markov chain):
-
AudioMarkov
-
Here is my modified version with the changes described above, it's slightly faster but not really enough to make a significant difference.
I think it's all vanilla, but so was the original patch. The [list.leak] abstraction is the name I gave to the optimised version of list-drip posted by @ingox, and I can't remember exactly where [nbuntil] comes from, but [nbuzi] uses that.
Perhaps the problem is that I'm trying to load 10+ seconds samples and calculate 17 order markov chains on them, and that might be too much regardless. But it's a shame if there is no way to do it, I think the results could be very interesting.
-
@weightless thanks a lot. also nice that you can watch the creation of the markov chain in the graphical array now.
i think if l2s and s2l from zexy would be replaced everything would be vanilla now, but i assume still its difficult to calculate samples that are longer than one second with this patch.
it would be nice to calculate and play the markov chain in realtime, but i think that impossible without an external.
there is one from derek kwan, but only for first and second order: https://github.com/derekxkwan/pdkmbut possible to create chains that are longer than the original sample, still it takes some time to calculate too.
-
@Jona Perhaps the patches here can replace l2s, but I haven't tried them, and the external might be faster after all. The reason I used @ingox's list-drip is because it is faster than the list-abs version, and on a patch like this we need all the power we can get.
I haven't played much with the patch but my feeling is that low-order chains end up sounding noisy, whereas longer chains might retain more of the "feel" of the original sample, despite the fact that on anything longer than 1 second my laptop freezes. But it's a very interesting idea, well worth exploring further I think. Thanks for sharing it
-
@weightless yes, something between 6th and 10th order sounds interesting for me. most of the time a lower order is too noisy, and a higher order has the problem of overfitting, it sounds almost like the original.
-
the vanilla list2symbol and reverse are significantly slower than the zexy ones. i was thinking if it would be possible just to use lists instead of symbols. Anyhow, once the array is created, the patch should be as fast as with every other array. Maybe i am missing something, don't have the time to test or investigate right now.
-
Because it seems to be difficult to process longer audio files or even to process markov chains in audio realtime, i thought about something different and made a variation of the patch. it plays audio samples as markoved midi notations. It contains the Additiv-syntes from Max Bjorverud. And it contains some single cycle .wav files.
I have one question: is it possible to get rid of the "soundfiler_read: truncated to n elements" message, because actually i want it like that and it looks like an error.
AudioToMidiMarkov.zip
-
@Jona I don't think so.....
You could post a message to the terminal...."Thank you, I know, that is what I wanted..... Jona"
You can suppress (by redirection) all messages to the Gui by starting Pd with the -stderr flag.
David. -
Maybe just don't truncate in soundfiler and truncate the array afterwards?
-
@ingox thanks, that works. i updated the patch.
in this version you can also draw into an empty array or into a sample and make markov chains from that drawing.
its also possible to resize the sample without reloading it, just press makeMarkov after changing the sample size:
AudioToMidiMarkov2b.zip