Coder Social home page Coder Social logo

odinysynth's Introduction

OdinySynth

OdinySynth is a SoundFont MIDI synthesizer written in pure Odin, ported from MeltySynth.

Demo

This is a demo video to show the synthesizer running on raylib's audio stream in real-time.

https://www.youtube.com/watch?v=edil47gQD1o

Youtube video

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:

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:

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
    • SoundFont reader
    • Waveform generator
    • Envelope generator
    • Low-pass filter
    • Vibrato LFO
    • Modulation LFO
  • MIDI message processing
    • Note on/off
    • Bank selection
    • Modulation
    • Volume control
    • Pan
    • Expression
    • Hold pedal
    • Program change
    • Pitch bend
    • Tuning
  • Effects
    • Reverb
    • Chorus
  • Other things
    • Standard MIDI file support
    • Performace optimization

License

OdinySynth is available under the MIT license.

odinysynth's People

Contributors

sinshu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.