https://github.com/sinshu/odinysynth
A SoundFont MIDI synthesizer written in pure Odinlang
https://github.com/sinshu/odinysynth
audio meltysynth midi odin odinlang soundfont synthesizer
Last synced: 7 months ago
JSON representation
A SoundFont MIDI synthesizer written in pure Odinlang
- Host: GitHub
- URL: https://github.com/sinshu/odinysynth
- Owner: sinshu
- License: other
- Created: 2023-04-07T11:49:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-13T14:20:14.000Z (about 2 years ago)
- Last Synced: 2025-01-26T19:36:18.628Z (9 months ago)
- Topics: audio, meltysynth, midi, odin, odinlang, soundfont, synthesizer
- Language: Odin
- Homepage:
- Size: 455 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# OdinySynth
OdinySynth is a SoundFont MIDI synthesizer written in pure Odin, ported from [MeltySynth](https://github.com/sinshu/meltysynth).
## Demo
This is a demo video to show the synthesizer running on [raylib](https://www.raylib.com/)'s audio stream in real-time.
https://www.youtube.com/watch?v=edil47gQD1o
[](https://www.youtube.com/watch?v=edil47gQD1o)
## Features
* Suitable for both real-time and offline synthesis.
* Support for standard MIDI files.
* No dependencies other than the core library.## Examples
An example code to synthesize a simple chord:
```odin
using odinysynth// Load the SoundFont.
soundfont, _ := new_soundfont("TimGM6mb.sf2")
defer destroy(&soundfont)// Create the synthesizer.
settings := new_synthesizer_settings(44100)
synthesizer, _ := new_synthesizer(&soundfont, &settings)
defer destroy(&synthesizer)// Play some notes (middle C, E, G).
note_on(&synthesizer, 0, 60, 100)
note_on(&synthesizer, 0, 64, 100)
note_on(&synthesizer, 0, 67, 100)// The output buffer (3 seconds).
sample_count := 3 * settings.sample_rate
left := make([]f32, sample_count)
defer delete(left)
right := make([]f32, sample_count)
defer delete(right)// Render the waveform.
render(&synthesizer, left[:], right[:])
```Another example code to synthesize a MIDI file:
```odin
using odinysynth// Load the SoundFont.
soundfont, _ := new_soundfont("TimGM6mb.sf2")
defer destroy(&soundfont)// Create the synthesizer.
settings := new_synthesizer_settings(44100)
synthesizer, _ := new_synthesizer(&soundfont, &settings)
defer destroy(&synthesizer)// Load the MIDI file.
midi_file, _ := new_midi_file("flourish.mid")
defer destroy(&midi_file)// Create the sequencer.
sequencer := new_midi_file_sequencer(&synthesizer)// Play the MIDI file.
play(&sequencer, &midi_file, false)// The output buffer.
sample_count := int(f64(settings.sample_rate) * get_length(&midi_file))
left := make([]f32, sample_count)
defer delete(left)
right := make([]f32, sample_count)
defer delete(right)// Render the waveform.
render(&sequencer, left[:], right[:])
```## Todo
* __Wave synthesis__
- [x] SoundFont reader
- [x] Waveform generator
- [x] Envelope generator
- [x] Low-pass filter
- [x] Vibrato LFO
- [x] Modulation LFO
* __MIDI message processing__
- [x] Note on/off
- [x] Bank selection
- [x] Modulation
- [x] Volume control
- [x] Pan
- [x] Expression
- [x] Hold pedal
- [x] Program change
- [x] Pitch bend
- [x] Tuning
* __Effects__
- [ ] Reverb
- [ ] Chorus
* __Other things__
- [x] Standard MIDI file support
- [x] Performace optimization## License
OdinySynth is available under [the MIT license](LICENSE.txt).