News for hackers. Stuff that matters.
Re:My approach to automatic musical composition by coldcode on Sunday February 13, 2022 @09:27AM (#30321916)
The analysis was interesting but the end result was pretty terrible. Of course music in the past was often considered terrible by the following generation, a trend that still exists today.

What I would really like to see is an attempt to write multipart contrapuntal works like Bach with some kind of AI. The rules are fairly well understood, but Bach knew how to adapt and even violate them all but still wind up with amazing pleasant music.

Re:My approach to automatic musical composition by zozbot234 on Sunday February 13, 2022 @11:24AM (#30322825)
This comment should not be disregarded so easily. The reason why deep sequence learning has the best results in generating complex, highly contrapuntal music (it's more like noodling or improvisation than an actual compositional process, but it is generally compelling at its best) is precisely because of the loosely grammar-like structure mentioned in OP. The algorithmic operations they play with are not very well defined but the background theory is sound, and closely reflects what music theorists and composers in general have written about the subject in the 500 years or more it has been seriously studied.

As for deep learning models which create good contrapuntal music, see e.g. 'Biaxial RNN' https://github.com/danieldjohnson/biaxial-rnn-music-composit... by Daniel D. Johnson, who is now at Google Brain but wrote this as an independent(!) researcher. (Note that the existing code requires Python 2.x It would be interesting to forward-port it so it can work with Python 3.x and a maintained version of Theano. Replicating the model using Tensorflow would also be quite worthwhile.)

If you're interested in Bach's work specifically, the "BachBot" and "DeepBach" projects are also interesting but less accessible.

Example output for all of these models can be found on the Internet, just look around for it. The proprietary system AIVA is also worth mentioning because even though it's so proprietary and secretive, the compelling and "serendipitous" music it manages to come up with is a tell-tale sign that it's actually doing well-founded deep learning stuff behind the scenes, much like the aforementioned open systems. Note that much of the released output has been orchestrated (AFAICT) manually by humans, but at some point I was able to find some piano-format reductions that are most likely very close to what the AI actually created, somewhere on the official site.

Re:My approach to automatic musical composition by foolishbard on Monday February 14, 2022 @12:09AM (#30328593)
I was inspired by your comment and took a look at Daniel's work.

Forked it and spent the day upgrade to Aesara (the maintained Theano fork) and python3.

Haven't fully trained/tested the model, but feel free to take a look: https://github.com/kpister/biaxial-rnn-music-composition

Re:My approach to automatic musical composition by zozbot234 on Monday February 14, 2022 @07:48AM (#30331373)
Whoa, thanks! You could try issuing a pull request once the work is complete. Most likely the author will accept it, or else it can linger as an "open" request on github and others might find it.

Also, the old version could use a special incantation:

  theano.config.experimental.unpickle_gpu_on_cpu = True
to run CPU-based inference on a GPU-trained model, even without a supported hardware GPU. It would be nice to check how this stuff works with the newer packages, and document it properly. Most likely nothing much has changed.
Re:My approach to automatic musical composition by p1esk on Sunday February 13, 2022 @01:08PM (#30323948)
Deep learning needs a lot if training data. There’s not enough MIDI encoded music to train something like a GPT-3 model to generate MIDI sequences. A better way is to train on and generate raw audio, see OpenAI JukeBox. Unfortunately it’s extremely compute intensive (even compared to GPT-3), so it will probably be a few more years until they (or some other big player) releases JukeBox-2.
Re:My approach to automatic musical composition by zozbot234 on Sunday February 13, 2022 @01:16PM (#30324031)
The amount of data you need depends on the model architecture you're using. A generic model like GPT-3 is neither here nor there, but something specifically intended for music can make do with very little data.
Re:My approach to automatic musical composition by p1esk on Sunday February 13, 2022 @01:44PM (#30324326)
What do you mean “neither here nor there”?
Re:My approach to automatic musical composition by zozbot234 on Sunday February 13, 2022 @01:51PM (#30324400)
The structure of something like GPT-3 is far too weak and general to achieve good results for something as structurally complex as music. It's designed to generate text - and then mostly natural language text. Music is very different, as OP hints in the linked post.
Re:My approach to automatic musical composition by p1esk on Sunday February 13, 2022 @02:45PM (#30324915)
I thought you wanted to use deep learning. In DL transformers are the best we got currently. Both JukeBox and MuseNet use transformers. What makes you think they are not up to the task?
Re:My approach to automatic musical composition by zozbot234 on Sunday February 13, 2022 @06:13PM (#30326556)
"Transformers" is a general technique, comparable to "LSTM" or "attention". The details of just how much prior information about the domain you reflect in the model architecture are just as relevant, and it's not clear just how well MuseNet addresses this compared to the earlier work I mentioned above. As for JukeBox, it's trying to solve audio generation at the raw samples level, which is quite literally a complexity increase of several orders of magnitude.
Re:My approach to automatic musical composition by p1esk on Sunday February 13, 2022 @06:58PM (#30326906)
A transformer architecture does not change whether you use word tokens, musical chord encodings, audio waveform samples, image patches, or video frames. You can change a number of layers or attention heads, but the architecture remains the same - it does not care what is the nature of sequences it encodes/decodes. That's kind of the point - to have a universal algorithm. Human neocortex does not care which sensory receptors the signals are coming from, there's evidence that it processes all of them in the same manner.

Any prior information about the domain can be encoded in a way you prepare the input samples, and this would be equally useful and relevant regardless of the DL architecture you decide to use (RNNs, autoencoders, GANs, transformers).

Using raw audio samples has two advantages: First, you provide all available training data to a model, and trust that it will learn to extract what it needs from it. Second, unlike any other music representation formats, you have huge amounts of training data. So essentially all you need is a huge transformer and many thousands of GPUs to train it on, using all mp3s you can get your hands on, and you can reasonably expect a similar level of quality as the quality of text generated by GPT-3. What do you think?

Re:My approach to automatic musical composition by zozbot234 on Sunday February 13, 2022 @07:25PM (#30327096)
> Any prior information about the domain can be encoded in a way you prepare the input samples

Adding features to provide further information about the input data can be helpful, but not nearly as much as ensuring that strong priors are reflected in the actual model architecture, whenever relevant to the domain. Johnson's paper about biaxial RNN provides one example of how to do this in the context of music.

Re:My approach to automatic musical composition by TheOtherHobbes on Sunday February 13, 2022 @11:03AM (#30322628)
The reason the end result is pretty terrible is because classical harmony and melody are closely related, and you can't job-lot-replace one without ruining the other.

This project is quite similar to something I've been working on, but I realised early on that you can't split up features like this and get credible results - credible meaning "appropriate for the style grammar."

It's a bit - only a bit, but let's go with it - like trying to generate sentences by swapping out nouns and adverbs. You end up with something that is grammatically correct in theory but makes no sense in practice.

Classical music particularly is fundamentally integrated in a way that textbook analysis doesn't fully explore.

Re:My approach to automatic musical composition by Rochus on Sunday February 13, 2022 @12:12PM (#30323327)
See e.g. https://github.com/feynmanliang/bachbot. The companion site is no longer available, but here are some results on soundcloud: https://soundcloud.com/bachbot

Here is another very good one: https://openai.com/blog/musenet/

I'm a trained musician myself and interested in automatic music composition following the progress for the last thirty years, but only recent work (like the ones referenced) produce convincing results (besides Cope's work of course, but which required manual selection and editing).

You might also be interested in this survey paper: https://arxiv.org/abs/1709.01620

Re:My approach to automatic musical composition by hackoo on Sunday February 13, 2022 @12:33PM (#30323554)
Is "the end result" the Beethoven's sonata in Japanese scale?

If so, the most important reason that it sounds terrible is the music is generated with MuseScore, without adjusting dynamics, tempos, etc. Actually, the Beethoven's original sonata in this blog is also generated with MuseScore, and it sounds not so good even with dynamics added.

However, this is why I agree that deep leaning is more promising than this manual approach, since too many variables you need to adjust to make music sound good rather than syntactically correct.

Re:My approach to automatic musical composition by rsfern on Sunday February 13, 2022 @09:51AM (#30322047)
Meh. There’s plenty of deep learning music generation stuff out there, this is still a really cool approach

I think it would be cool to combine the two. Instead of generating raw midi, your GAN or reinforcement learning agent or whatever could try to generate sequences of transformations to melodic fragments. Neural program synthesis type stuff.

Or maybe one could build an automatic music analysis tool that can start from the score and try to infer the program that generated them. (Is that a thing already?)

Re:My approach to automatic musical composition by klyrs on Sunday February 13, 2022 @04:45PM (#30325985)
"Pretty terrible" is awfully strong. I've heard a lot of terrible music and this doesn't make that cut. What you're reading is a nice writeup of some theory, with a worked example to showcase how to utilize some features of a library which is a work in progress. The author even notes that the music is simplified for the example. It isn't meant to be Bethoven. It isn't even AI. If you want to see AI, other people have done that already.

What's cool about this library isn't the quality of the (midi, retch) output -- what's cool is the actual Python library behind it, and the writeup, which are both super easy to read and follow.

Re:My approach to automatic musical composition by whiddershins on Sunday February 13, 2022 @01:03PM (#30323889)
I don’t agree at all, and it’s not even experimental.

And I think that is not a very nice thing to say about other people’s work.

Re:My approach to automatic musical composition by Asooka on Sunday February 13, 2022 @06:51PM (#30326847)
I thought it sounded really good!
Re:My approach to automatic musical composition by ekianjo on Sunday February 13, 2022 @12:27PM (#30323488)
sid meier had a software like that he created for the 3do