Neuropyrox
Posts: 3
Joined: Tue Dec 09, 2014 8:33 pm
Occupation: Student

Python Midi File Generation

Postby Neuropyrox » Wed Dec 10, 2014 4:52 pm

I'm creating a music generator that uses artificial neural networks. It's programmed in Python. In order to do this project, I had to teach myself Python in the last few months. Now, everything is working fine except for one thing. I need to generate midi files note by note. To do this, I'm trying to use the Pyknon module, but it only generates the header of the midi file. The midi files that it generates should contain notes, tempos, and track names, but they don't. All I need is to generate a simple midi file note by note. I need to be able to open the file with a midi editing program that can play the file and print sheet music of it. This is only the first prototype, so there are still many other changes to be made.

The code is too long to put in here, so tell me if you need to see it.

MadelineB
Moderator
Posts: 323
Joined: Fri Jun 20, 2014 4:42 pm
Occupation: Biostatistician/Data Scientist

Re: Python Midi File Generation

Postby MadelineB » Wed Dec 10, 2014 10:17 pm

Hello Neuropyrox,

Welcome to Science Buddies,

Perhaps you could search the internet to find Python code to create your midi files.
I did a quick search and found several possibilities.

Hope this helps! Let us know if you have more questions.

Neuropyrox
Posts: 3
Joined: Tue Dec 09, 2014 8:33 pm
Occupation: Student

Re: Python Midi File Generation

Postby Neuropyrox » Thu Dec 11, 2014 8:17 am

For the past few weeks, that's exactly what I've been doing. The only information that I've found about Pyknon(the module I'm using) is creating midi files via the NoteSeq command. NoteSeq doesn't work for me because the notes are unevenly spread out. I need to generate a midi file one note at a time, and I found a command for this while searching through the code of Pyknon. AddNote is the command that I'm now trying to use, but it mysteriously won't work for me.

bfinio
Expert
Posts: 279
Joined: Mon Aug 12, 2013 2:41 pm
Occupation: Science Buddies Staff

Re: Python Midi File Generation

Postby bfinio » Thu Dec 11, 2014 11:16 am

Hi Neuropyrox,

Unfortunately I'm not a Python expert, but I do have a suggestion. There are several forums online where you might be able to get much more specific help with Python programming than you'll get here at Science Buddies. One site that I'm familiar with is stackexchange.com, which has a network of sub-sites like

http://codereview.stackexchange.com/

http://cs.stackexchange.com/

http://stackoverflow.com/

but if you google "python forum", you will find many other sites. A couple pieces of advice if you decide to post anything on those forums:

1. Explain right off the bat that you are a student doing a science project, and that you have already tried to troubleshoot extensively on your own, but you are stuck. People get mad when they think a student is just trying to get an easy answer on the internet without doing their own work.

2. Explain in as much detail as possible what you're trying to do, and provide all your source code (many of those sites provide ways to paste in code without making it look mess if it's really long). Again, some people will get irritated if you don't do this.

3. Don't cross-post your question to multiple forums on the same site. That's generally against the site rules and will make people upset.

Most forums like that will have an "FAQ" or list of rules for first-time users, so in general it might help to read those before you post anything.

Hope that helps.

-Ben

Neuropyrox
Posts: 3
Joined: Tue Dec 09, 2014 8:33 pm
Occupation: Student

Re: Python Midi File Generation

Postby Neuropyrox » Fri Dec 12, 2014 9:42 am

I found the problem, and I feel dumb now. The whole time, I was trying to use AddNote, when it was actually addNote. Thanks for giving me those websites though. I will probably go there next time I get stuck on something.

hhemken
Former Expert
Posts: 266
Joined: Mon Oct 03, 2005 3:16 pm

Re: Python Midi File Generation

Postby hhemken » Wed Dec 17, 2014 12:15 pm

Neuropyrox,

Welcome to software development! You can expect such slaps in the face on a more or less daily basis for as long as you write code. Don't worry, you will not only get used to it but will also derive all the more pleasure when things work as expected. It happend to all of us.

Good luck!
Heinz Hemken
Mentor
Science Buddies Expert Forum


Return to “Grades 9-12: Math and Computer Science”