weiweichen / musicalnumbers Goto Github PK
View Code? Open in Web Editor NEWMusical Numbers - A quest to find out the most musical number in the universe. ๐ถ๐ข
License: MIT License
Musical Numbers - A quest to find out the most musical number in the universe. ๐ถ๐ข
License: MIT License
Neil: I have a... complex relationship with ML (read: I actively avoid it where possible), but perhaps this is one of the places that a neural net can do better than logic or stats, simply because of the endless self-referential and recursive nature of music. I like the idea of training a network to recognise good patterns of rhythm or harmony and using the deep-dream idea to find what the network believes is the 'best' pattern.
Weiwei: This can a very interesting setup to try out ML, as I likewise have been avoiding it, but since Iโm now working in a ML/AI infrastructure company, I probably should get my hands dirty sooner than later. To train a neural network, weโll need structured training data, probably some web crawling for abc notations + parsing infrastructures need to be in place first to be able to feed data to the model. Letโs see how will ML perform in doing creative things.
Neil:
But even without resorting to ML, here are some patterns you might be able to exploit in a more logical tune generator:
Some notes appear more than others; in (very) rough order of precedence: root, octave, fifth, fourth, second, seventh, third, sixth. The cool thing is that there are actually many root notes working in a tune at the same time - the root of the key, the root of the phrase (usually the root of the chord that goes with the phrase, and there could be many but the most basic one is usually also related to the key), the previous note... I think you could create some measure of how much a note 'fits' harmonically into the tune based on that and skew your algorithm towards notes that fit. But don't totally exclude the weirder notes; they make it interesting and can twist a phrase into having a different root. The position of the note in the tune also affects how much it needs to fit. The last note of the part is heavily skewed towards either being the root of the key or, occasionally, the fifth (you know those tunes that just never want to stop repeating - they usually end on an unresolved fifth). The end of a four-bar phrase usually also skews more towards a root, octave, fifth or fourth.
The reason behind that is super-interesting, but I can't find any good short explanations (here's a longer but very interesting read: https://arxiv.org/html/1202.4212), You can derive it from the fact that we like frequency multiples of the root note and that our brains are bad at distinguishing octaves (which are ratios of 2:1).
and maybe polka, waltz, ...
Neil:
My favourite way to skew an even distribution is to take the log base 2 of n (or 2^n if you want to skew the other way). Which I think is neat because we're dealing with ratios so much.
Rhythm is another pattern to explore. I don't have as much theory on this, maybe make the last note at least a crotchet and insert pseudo-random crotchets throughout the music. I like the idea of working the fibonacci sequence into it but I'm not sure how or whether it would work (since everything else is so based around integer ratios)
The other one is that folk tunes rely heavily on the call-and-response idea. Maybe there's a general way to measure how 'call-and-response'y a tune is and optimise for that. Or it's probably easier to hardcode a pattern where bar 9 is a repeat of bar 1 and bar 13 is a repeat of bar 5 (this is why we should use index 0 everyone, it makes much more sense than index 1!).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.