https://github.com/kgujral2612/simplysynth
A simplistic synthesizer in Python
https://github.com/kgujral2612/simplysynth
mido python synthesizer
Last synced: 11 months ago
JSON representation
A simplistic synthesizer in Python
- Host: GitHub
- URL: https://github.com/kgujral2612/simplysynth
- Owner: kgujral2612
- Created: 2022-06-16T20:34:28.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-11T20:29:17.000Z (over 3 years ago)
- Last Synced: 2024-12-28T03:26:37.753Z (over 1 year ago)
- Topics: mido, python, synthesizer
- Language: Python
- Homepage:
- Size: 179 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SimplySynth
Implementation of a simplistic synthesizer in Python
## 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](https://gitlab.cecs.pdx.edu/sound-engineering/simplysynth/-/blob/main/Files/wav%20files/savedrecording/silen_night_oboe.wav) and then implemented a [bell](https://gitlab.cecs.pdx.edu/sound-engineering/simplysynth/-/blob/main/Files/wav%20files/savedrecording/bell-1.wav), [flute](https://gitlab.cecs.pdx.edu/sound-engineering/simplysynth/-/blob/main/Files/wav%20files/savedrecording/notes-on-a-flute.wav) and [violin](https://gitlab.cecs.pdx.edu/sound-engineering/simplysynth/-/blob/main/Files/wav%20files/savedrecording/harry_potter-violin.wav).
## Division of responsibilities
All the tasks were accomplished through gitlab merge requests and thus can be verified here: [merged requests](https://gitlab.cecs.pdx.edu/sound-engineering/simplysynth/-/merge_requests?scope=all&state=merged)
| | Tasks |
|---|---|
| Harman | MIDI file input, envelopes, filters, Pygame GUI, flute |
| Kaushambi | Oscillators, additive synthesis, effects, user interface handler, oboe, bell |
## Lessons learned
- Frequency modulation was more difficult than we expected. We had not accounted for it in the beginning stages where we structured the code.
- Real, natural sounds are beautifully imperfect- simulating the 'imperfectness' is challenging.
- Using Gitlab helped us manage the project.
## Compositions
Check out a few pre-recorded examples [here](https://gitlab.cecs.pdx.edu/sound-engineering/simplysynth/-/tree/main/Files/wav%20files/savedrecording) or [here](https://gitlab.cecs.pdx.edu/sound-engineering/simplysynth/-/tree/main/Files/SimplySynthFinalDemo.mp4)
## Running the code
Please install these libraries using the following bash command:
```bash
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.
```bash
python synth.py
```
Alternatively, you could also run examples:
```bash
python examples.py
```
## Features
### Modes
- Mode A: Input notes and corresponding duration in form of text files
- Mode B: MIDI input file
- Mode C: Aleatoric
### Options
#### Wave Type
Sine, Square, Sawtooth, Triangle
Oboe, Flute, Bell
#### Envelopes
Trapezoidal, ADSR
#### Effects
- White noise: random signal
- Environmental noise: a soothing background sound of forest at night
- Time Stretch: increases the duration of each note
- Pitch Scaling: changes the pitch of the audio
- Inverse Polarity: reverses the amplitude of the signal
- 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
- Simulate the sound of complex instruments such as the piano, guitar, etc
- Simulate percussion instruments
## Authors
- Harmandeep Singh
- Kaushambi Gujral