bausa / Markovsky

A program that generates music from existing works using Markov chains
GNU General Public License v3.0
0 stars 0 forks source link

Need sliding frame in transitionmatrix #13

Closed JackYoustra closed 8 years ago

JackYoustra commented 8 years ago

I don't see a way to change the size of the frame in the transition matrix without totally reworking the code, should I make it myself?

Raykant commented 8 years ago

Jack, you just need to change they way you are importing data into the matrix. Figure out a way to pass in two nodes as the from, and keep the to the same. Then when you are generating your song, you just need to keep track of two nodes, and pass those in to get the next one.

Shouldn't really need to completely re-implement the chain, simply change how you import data. If you're notes have a good toString method, then simply concatenate their toStrings together and use the matrix by looking up the concatenated toString of the notes to get your next note.

Hope that helps.

Raykant commented 8 years ago

I can also send you a snippet of my text markov chain as an example. It will look a little different cause Sam's implementation is more abstracted and clear, but I will paste a github link to the code so you can take a look.

Sorry I didn't see this sooner. I felt horrible today, and couldn't make it to school.

https://github.com/Raykant/MarkChains.git

I'll try working on it and get back to you as well.

Raykant commented 8 years ago

Looking at the current status I only see one way to go about it without re-implementing the matrix. Create another wrapper class (I know, that sounds shitty, but it would be easy). I called it block, and put it in the project. Now, how we will use block is as follows.

For recording: As we are importing data, we have to keep track of three things: our previous note, our current note, and the next note. How we will record data is by throwing the previous note and the current note into the Block wrapper class. Then we will create a Block with the current note and the next note, and have the Block we created in our previous step added to the matrix with a connection to the newly created one. It will change slightly how we import data, but not too fundamentally different.

For generating: Using a current block we will first have to add its getCurrent Note to the file, and the ask the matrix for the next block. All we have to do differently for generating is just call the getCurrent() on each Block so that we are not adding repeat data to our file.

Hopefully this is pretty clear, and I will try to respond to any questions.

Raykant commented 8 years ago

Unfortunately I can't test anything because I don't know where to find a copy of the midi file. If one of you could email that to me, it would be great.

However I have implemented duplicate methods for generation of matrix and songs using blocks rather than notes in the Song class and the MusicGenerator class.

Something to be wary of, however, is that we may not have enough data for us to get original work out of the generation. I don't know how much they gave us, but if it's not more than about 1000 data points, we probably won't be getting much new work from our chain.

chainmailleandcats commented 8 years ago

The classical corpus is on GitHub https://github.com/samuelb2/Markovsky/blob/master/ClassicalCorpus.mid, but I’ve attached the copy here, as well.

On Apr 7, 2016, at 4:53 PM, Raykant notifications@github.com wrote:

Unfortunately I can't test anything because I don't know where to find a copy of the midi file. If one of you could email that to me, it would be great.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/samuelb2/Markovsky/issues/13#issuecomment-207141746

Raykant commented 8 years ago

OK. So I was able to test it. It works, but we only get songs of about two notes. If we want it to sound good, we need to use two point generation, but then we need a LOT more data than we have. So, unfortunately, it looks as though our project might be stuck with sounding quite random, unless we can manage to get tons of midi notes ourselves into the project.

Raykant commented 8 years ago

An idea I do have for a potential fix in generation: intertwine the single note and double note generation (it's something I did with text to get me better results with less data). We prioritize generation by looking at two notes, but we can also add data to our matrix that looks at just a single note as well (simply putting the previous field in a block as null, and setting current to the note we have) so that way if we hit a dead end, just look for a single note.

I will try implementing it and get back to you guys.

JackYoustra commented 8 years ago

Ok thanks. IntelliJ has an autogen equals and hash function that you might want to use in the future (in Source -> Generate equals/hashcode). Let me know if the hybrid matrix works.

JackYoustra commented 8 years ago

Hybrid matrix seems to perform well, thanks.