-
-
Notifications
You must be signed in to change notification settings - Fork 137
Frequently Asked Questions
Here are some issues you may encounter when using musicpy with solutions, some of them are existing bugs of the python libraries that musicpy has dependencies with, or just not giving you the desired result when the function parameters are set as default.
On Linux, the pygame library uses the freepats sound libraries to play MIDI files, so you need to install freepats.
Solution: open the terminal and run sudo apt-get install freepats and it will fix the errors. This solution works mostly for Ubuntu, for other Linux distributions you need to search the internet to find the install command to install freepats for them, on some Linux distributions you may also need to install timidity++.
When you use python IDE like Pycharm or VS Code, this issue will occur, since these IDE won't wait till the pygame's function that plays MIDI file ends, they will stops the whole process after all of the code are executed without waiting for the playback of the MIDI file. You won't encounter this issue with more interactive python IDE, such as Jupyter Notebook, Wing IDE, or directly use the interactive shell of python in terminal.
Solution: You can add wait=True in the parameter of the play function, which will block the function till the playback ends, so you can hear the sounds.
Yes, the default mechanism of the play function of musicpy is firstly write the musicpy data structure to a MIDI file, and then use pygame's mixer module to play the MIDI file, but you can change to another mechanism to play internally without any MIDI file generated by setting the parameter save_as_file of the play function to False. By doing this, the MIDI file data stream is generated and held internally, and pygame is able to play the MIDI file stream directly, there are no MIDI files will be generated.
Solution: Set the parameter save_as_file of the play function to False.
- Basic syntax of note type
- Basic syntax of chord type
- Basic syntax of scale type
- Basic syntax of piece type
- Basic syntax of track type
- Basic syntax of tempo type
- Basic syntax of pitch_bend type
- Basic syntax of pan type
- Basic syntax of volume type
- Basic syntax of drum type
- Basic syntax of rhythm type
- Musicpy composition code examples Part 1
- Musicpy composition code examples Part 2
- Musicpy composition code examples Part 3
- Introduction of musicpy algorithms module
- The algorithm to split the main melody and chords from a piece of music
- The algorithm to determine the chord type of any group of notes according to the logic of music theory
- The algorithm to analyze the chord progressions of a piece of music
- The algorithm to analyze tonality and modulations in a piece of music