{"id":16985668,"url":"https://github.com/sinshu/py-meltysynth","last_synced_at":"2025-04-12T03:30:43.847Z","repository":{"id":149214662,"uuid":"529533466","full_name":"sinshu/py-meltysynth","owner":"sinshu","description":"A SoundFont MIDI synthesizer written in pure Python","archived":false,"fork":false,"pushed_at":"2024-01-10T14:21:30.000Z","size":415,"stargazers_count":23,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T23:06:45.658Z","etag":null,"topics":["audio","meltysynth","midi","python","soundfont","synthesizer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinshu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-08-27T08:59:57.000Z","updated_at":"2025-03-25T17:39:45.000Z","dependencies_parsed_at":"2023-09-14T00:49:00.890Z","dependency_job_id":null,"html_url":"https://github.com/sinshu/py-meltysynth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2Fpy-meltysynth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2Fpy-meltysynth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2Fpy-meltysynth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2Fpy-meltysynth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinshu","download_url":"https://codeload.github.com/sinshu/py-meltysynth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248512460,"owners_count":21116603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","meltysynth","midi","python","soundfont","synthesizer"],"created_at":"2024-10-14T02:43:57.940Z","updated_at":"2025-04-12T03:30:43.804Z","avatar_url":"https://github.com/sinshu.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Py-MeltySynth\n\nPy-MeltySynth is a SoundFont MIDI synthesizer written in pure Python, ported from [MeltySynth for C#](https://github.com/sinshu/meltysynth).\nI believe this is the first fully functional SoundFont synthesizer made with Python without external libraries.\n\n\n\n## Features\n\n* Support for standard MIDI files.\n* No dependencies other than the standard library.\n* All the functionality is in a single file. Simply copy [the file](meltysynth.py) into your project and you are ready to go.\n\n\n\n## Demo\n\nhttps://www.youtube.com/watch?v=Pheb0pSzQP8  \n\n[![Demo video](https://img.youtube.com/vi/Pheb0pSzQP8/0.jpg)](https://www.youtube.com/watch?v=Pheb0pSzQP8)\n\n\n\n## Development status\n\nIt works, but it's slow. Without external libraries, sample-by-sample audio processing seems tough for Python...\nBut Python is said to be becoming more performance oriented, so it should be useful in the future.\n\nBelow is a comparison of the time it took to render a MIDI file in several languages.\nThe MIDI file is [flourish.mid](https://midis.fandom.com/wiki/Flourish) (90 seconds) and the SoundFont used is [TimGM6mb.sf2](https://musescore.org/en/handbook/3/soundfonts-and-sfz-files#gm_soundfonts).\nPython is still slow, but it is certainly improving in speed as the versions go up.\n\n![The bar graph compares the processing speeds of several programming languages. Python is notably slower, taking dozens of times longer than the other languages in comparison.](media/20240110_rendering_time.png)\n\n\n\n## Examples\n\nAn example code to synthesize a simple chord:\n\n```python\nimport meltysynth as ms\n\n# Load the SoundFont.\nsound_font = ms.SoundFont.from_file(\"TimGM6mb.sf2\")\n\n# Create the synthesizer.\nsettings = ms.SynthesizerSettings(44100)\nsynthesizer = ms.Synthesizer(sound_font, settings)\n\n# Play some notes (middle C, E, G).\nsynthesizer.note_on(0, 60, 100)\nsynthesizer.note_on(0, 64, 100)\nsynthesizer.note_on(0, 67, 100)\n\n# The output buffer (3 seconds).\nleft = ms.create_buffer(3 * settings.sample_rate)\nright = ms.create_buffer(3 * settings.sample_rate)\n\n# Render the waveform.\nsynthesizer.render(left, right)\n```\n\nAnother example code to synthesize a MIDI file. It will take a long time 😉\n\n```python\nimport meltysynth as ms\n\n# Load the SoundFont.\nsound_font = ms.SoundFont.from_file(\"TimGM6mb.sf2\")\n\n# Create the synthesizer.\nsettings = ms.SynthesizerSettings(44100)\nsynthesizer = ms.Synthesizer(sound_font, settings)\n\n# Load the MIDI file.\nmidi_file = ms.MidiFile.from_file(\"flourish.mid\")\n\n# Create the MIDI sequencer.\nsequencer = ms.MidiFileSequencer(synthesizer)\nsequencer.play(midi_file, False)\n\n# The output buffer.\nleft = ms.create_buffer(int(settings.sample_rate * midi_file.length))\nright = ms.create_buffer(int(settings.sample_rate * midi_file.length))\n\n# Render the waveform.\nsequencer.render(left, right)\n```\n\n\n\n## Todo\n\n* __Wave synthesis__\n    - [x] SoundFont reader\n    - [x] Waveform generator\n    - [x] Envelope generator\n    - [x] Low-pass filter\n    - [x] Vibrato LFO\n    - [x] Modulation LFO\n* __MIDI message processing__\n    - [x] Note on/off\n    - [x] Bank selection\n    - [x] Modulation\n    - [x] Volume control\n    - [x] Pan\n    - [x] Expression\n    - [x] Hold pedal\n    - [x] Program change\n    - [x] Pitch bend\n    - [x] Tuning\n* __Effects__\n    - [ ] Reverb\n    - [ ] Chorus\n* __Other things__\n    - [x] Standard MIDI file support\n    - [ ] Loop extension support\n    - [ ] Performace optimization\n\n\n\n## License\n\nPy-MeltySynth is available under [the MIT license](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinshu%2Fpy-meltysynth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinshu%2Fpy-meltysynth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinshu%2Fpy-meltysynth/lists"}