Skip to content

kgujral2612/SimplySynth

Repository files navigation

SimplySynth

Implementation of a simplistic synthesizer in Python

main-page model-screen

How it went

Our vision was to build a synthesizer that bears some fundamental characteristics and is also fun to play with. We divided the tasks between the two of us and parallely began working on different pieces in a bottom-up fashion.

First, we created sine, square, sawtooth and triangle oscillators and tested those using notes fed from a text file. Having tested the waveforms, we were excited to use MIDI file inputs. One of the most intricate parts was reading the MIDI file and transforming it into a datastructure such that multiple notes may begin at the same time or overlapping intervals. Using additive synthesis, we combined multiple waves to deliver one coherent wave.

Furthermore, we worked on adding effects, filters and envelopes to make the synthesized sound more real. Side by side, we studied about timbre of musical instruments and sound and attempted to synthesize those. We used audacity to compare our shots with sounds of real instruments and improved our attempts incrementally. We were ecstatic after creating the sound of an oboe and then implemented a bell, flute and violin.

Division of responsibilities

All the tasks were accomplished through gitlab merge requests and thus can be verified here: merged requests

Tasks
Harman MIDI file input, envelopes, filters, Pygame GUI, flute
Kaushambi Oscillators, additive synthesis, effects, user interface handler, oboe, bell

Lessons learned

  1. Frequency modulation was more difficult than we expected. We had not accounted for it in the beginning stages where we structured the code.
  2. Real, natural sounds are beautifully imperfect- simulating the 'imperfectness' is challenging.
  3. Using Gitlab helped us manage the project.

Compositions

Check out a few pre-recorded examples here or here

Running the code

Please install these libraries using the following bash command:

pip install mido
pip install numpy
pip install soundaudio
pip install scipy
pip install pygame
pip install pygame-gui
pip install librosa

Load the GUI- Note: after typing the file name in the input box, press enter.

python synth.py

Alternatively, you could also run examples:

python examples.py

Features

Modes

  1. Mode A: Input notes and corresponding duration in form of text files
  2. Mode B: MIDI input file
  3. Mode C: Aleatoric

Options

Wave Type

Sine, Square, Sawtooth, Triangle Oboe, Flute, Bell

Envelopes

Trapezoidal, ADSR

Effects

  1. White noise: random signal
  2. Environmental noise: a soothing background sound of forest at night
  3. Time Stretch: increases the duration of each note
  4. Pitch Scaling: changes the pitch of the audio
  5. Inverse Polarity: reverses the amplitude of the signal
  6. Random Gain: increases the amplitude by some random value

Filters

Low-pass band

Known Issues

  • Unable to play midi files that don’t consistently contain a “note-off” message for every “note-on”
  • The GUI is not responsive which is why we suggest to use examples.py instead
  • ‘Click’ sound can be heard while playing some midi files
  • Selecting multiple options on a huge midi file is computationally expensive and takes more time
  • Aleatoric mode only plays for major notes
  • Violin is not in the GUI

Extensions

  1. Simulate the sound of complex instruments such as the piano, guitar, etc
  2. Simulate percussion instruments

Authors

  • Harmandeep Singh
  • Kaushambi Gujral

About

A simplistic synthesizer in Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages