Git Product home page Git Product logo

synthesizer's Introduction

synthesizer

All Contributors Workflow Licence Twitch Open Issues PRs Last Commit Twitter

This is a project on my live coding stream Codebase Alpha starting with episode 34. The aim of the project is to explore some of the features of the extensive the NAudio digital audio library. To do this, I'm using .NET Core 3.0 and WPF to develop a simple synthesizer, starting with a monophonic keyboard, but going on throughout the project to introduce such things as polyphony, ADSR envelopes, instruments and voices, and visualisations (such as a spectrum analyser). Basically, let's see how far we can take this!

Please note that, despite this being a .NET Core project, because I'm using NAudio and WPF, this code is Windows-only at this time.

The NAudio Github repo can be found here.

Twitter

Progress

Episode 34

A simple monophonic synthesizer was created. The code needs tidying up but its working at a basic level. Next up: add polyphony anf the ability to change the octave the keyboard covers!

Episode 35

Added a GUI octave selector and had initial stab at making the keyboard polyphonic. Merged a PR that added a T4 template to generate the view model.

Episode 36

Merged a PR that added a spectrum analyser and waveform visualizer to the GUI. Moved from wavetables to signal generators in the SynthWaveProvider class, and implemented ADSR envelopes to shape the sound profile of notes. Finally, created a low pass filter and a tremolo effect for the synthesizer. The GUI elements of these latter were left for another stream.

Episode 37

Tidied up the GUI, adding wave form selection and realtime controls for the low pass filter. Also developed LFO frequency modulation in order to add a vibrato effect to notes. No GUI controls for the vibrato are planned, as the feature will form part of the instrument/voice presets concept I want to develop for the project (although this may change!).

Episode 38

Added Sub-oscillator for sine wave and GUI controls for Vibrato and Tremolo.

In order to practice creating audio effects, I implemented a Chorus effect off-stream. It still requires wiring up to the GUI.

Episode 39

Merged a PR to make the T4 Template that builds our view model even more useful! Wired up the Chorus effect to the GUI and implemented a Phaser effect for the synth, including adding GUI control over the effect's parameters.

Off-stream, implemented a Delay effect but it's not wired into the GUI at this time.

Episode 40

Added 2 additional voices per note, complete with GUI controls for level, waveform, ADSR and relative tuning. Determined some settings that produced a nice bell sound; will use these for our first preset patch in a later stream.

Episode 41

Added support for using a MIDI controller to play the synthesizer - including velocity sensitivity. Also wired up the Delay effect to GUI controls. Hit a bug with the Delay effect - logged as Issue #29 (subsequently fixed off-stream).

Episode 42

Added the facility to save and load settings files as JSON, which we refer to as "patches". Some refactoring is required to tidy up the code.

Current state of the GUI is as follows:

image

Contributors

Thanks goes to these wonderful people (emoji key):

mrange
mrange

💻 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

synthesizer's People

Contributors

allcontributors[bot] avatar essenbee avatar mrange avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

synthesizer's Issues

Implement a Phase Shifter Effect

A phase shifters gives the impression that the sound of a note is moving away and then coming back in again, like a swirling effect that might be heard if the speaker was rotating. Need to work out the maths, but this should be an effect we can create.

See musicdsp.com

Add Sub-oscillators

Optionally, for each note played, mix the note and the same note one octave lower (i.e. freq / 2), to give a richer tone.

Add a Graphic Equaliser

Can we add a graphic equaliser to the synthesizer? In the graphic equalizer, the input signal is sent to a bank of filters. Each filter passes the portion of the signal present in its own frequency range or band. The amplitude passed by each filter is adjusted using a slide control to boost or cut frequency components passed by that filter. The vertical position of each slider indicates the gain applied at that frequency band, so that the knobs resemble a graph of the equalizer's response plotted versus frequency.

Record/Playback a Loop that can be Played over

Add the ability to record a loop, e.g. a chord progression, and play it back whilst playing notes from the synth over the top of the loop. As the name suggests, the loop should play continually until it is turned off.

Implement a Low Pass Filter

Using the NAudio BiQuadFilter class, implement a low pass filter sample provider. This will allow low frequencies to pass through, which can be useful for filtering out harsh-sounding high frequencies. GUI will need a slider for "cut-off frequency" in Hz and "resonance a.k.a. Q" (a float), which is an emphasis added through feedback at the cutoff frequency. Basically, Q defines how steep the cut-off curve is.

The BiQuadFilter class looks useful for other types of filter too.

Ditch Wave Tables in Favour of Signal Generators

Using wave tables limits what we can do, specifically around implementing a Low Frequency Oscillator to do some frequency modulation in the signal chain. Remove the use of wave tables and replace them with, initially, the NAudio SignalGenerator class.

Later, we can create a custom SignalGenerator to allow us to add LFOs as part of #9.

Add Instruments / Pre-set Voices

Find a way to create pre-defined instruments for the synthesizer. These would include pre-set:

  • ADSR envelope
  • combinations of different wave sources
  • possibility of adding white noise as a source
  • low frequency oscillator

Use one mixer per note? See #22.

Add Tremolo Effect

Modulate volume of the VolumeSampleProvider in the signal chain with a low frequency oscillator to create a tremolo effect.

Add a Waveform Selector

Need to be able to use the GUI to select different waveforms when not using a pre-set instrument/voice:

  • sine wave
  • sawtooth wave
  • square wave
  • triangle wave
  • white noise
  • pink noise

See also #11.

See #9 for option to feed in LFO frequency modulation.

Add ADSR Envelopes

Update or replace the SythWaveProvider class to allow user to create different Attack, Decay, Sustain and Release parameters via the GUI, so they can shape the sound envelope of notes. NAudio's AdsrSampleProvider only allows user control of Attack and Release, so we will not use this class directly, but bring its functionality into our SynthWaveProvider or its replacement.

Need to be able to control:

  • Attack seconds
  • Decay seconds
  • Sustain volume level
  • Release seconds

See also #11.

Add a Tremolo Frequency Multiplier

If the Tremolo Frequency is raised above 20 Hz, some interesting amplitude modulation effects occur - the appearance of sidebands. Add a Tremolo Frequency Multiplier so that frequencies of up to 1000 Hz can be set up, so that we can explore the sounds created from AM at these frequencies.

Add Parameter Smoothing

When many of the user-controlled parameters are changed rapidly, then clicks and other artefacts are evident in the synths output. We need to smooth the transition to new parameter values, using an equation such as the follows:

x = x - z (x - y)

where:

  • x = intermediate "smoothed" value
  • y = the target value
  • z = the smoothing factor e.g. 0.001

Create and Recall Patches

As a step towards creating preset voices or instruments, add a feature that allows the user to set up various effects and configurations of the synthesizer, and save them as “patches’. Allow these to be recalled, to instantly restore the synth to the saved preset values. Save settings as JSON?

Try Relative Low Pass Filters

Have the low pass filters for each note use a relative cutoff frequency, e.g. 4 octaves above the frequency of the note being played.

Add More Oscillators per Note

Add 2 maybe 3 oscillators that can be mixed into a note, with settings for:

  • Level (dB)
  • Wave Type (Sine, SawTooth, Square, Triangle, White Noise, Pink Noise)
  • Relative tuning

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.