Author Topic: Soft synth idea - am I crazy?  (Read 44634 times)

0 Members and 1 Guest are viewing this topic.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #80 on: May 11, 2012 »
I'm using VST.Net to take care of all that for me :)

I didn't dig too far into the VST SDK from Steinberg, but it looked pretty similar. In my case, VST.Net provides me with midi events (note on, note off etc) which I pass on to my synth. As far for automatable params, that's just a flag in VST.Net to expose params externally.

raizor

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #81 on: June 21, 2012 »
I'm having some trouble getting my head around using one wavetable oscillator to act as a frequency modulator for another oscillator and wonder if anyone can share some insight please? I've been hunting around and reading various things but I'm still not clear on the concept. My oscillators fill a float buffer with values in the -1 to +1 range. How would I go about using the output of one oscillator to FM another? Maybe I'm getting a bit lost and thinking about this in the wrong way. I've been stuck with this for a number of days now so any advice would be great.

In terms of progress, things are still plodding along with my synth. I'm able to save banks or instruments and record and playback a tune now. It still sounds pretty nasty to be honest, but hopefully that will improve soon :)

Many thanks,

Raizor
raizor

Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Soft synth idea - am I crazy?
« Reply #82 on: June 21, 2012 »
Think of the frequency as a phase increment.
Code: [Select]
phaseInc= PI*2.0*frequency/SampleRate
phase= 0

for each sample
{
  amplitude= sin( phase )
  phase += phaseInc
}

So modulating the frequency is nothing else than modulating the phase:
Code: [Select]
// modulator:
modulatorAmp= sin( modulatorPhase )
modulatorPhase += modulatorPhaseInc

// carrier:
carrierAmp= sin( carrierPhase + modIntensity*modAmp );
carrierPhase += carrierPhaseInc
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #83 on: June 21, 2012 »
Thanks Hellfire. I will give that a whirl.
raizor

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #84 on: July 19, 2012 »
I thought it was about time I posted a little update on the progess of my soft synth (which I'm currently calling "Zynth"). Those of you who've been following my previous posts will know that I've based my synth (the GUI at least) on Cakewalk's Z3TA VST Synth. As you can see from the image below, I'm currently using gfx based (ripped) on Z3TA, until I get a chance to make my own:



The shot above shows my VST Test App, which is how I test my Synth without having to load up a VST host (such as Renoise) repeatedly. It's a simple C# app that has the main VST control for my synth embedded in the form (C# WinForm). The keyboard and buttons at the bottom are part of the Test app and don't appear on when the VST is running in a host. I'll probably change that though as the mini keyboard is quite useful when designing patches (instruments). I've ended up writing a few C# components for the GUI for handling this like visualizing wavetables and envelopes and changing the modulation matrix, oh and for the knobs and sliders too. The VST core is written in C# and uses VST.Net. The VST core loads a C# DLL that contains a static synth lib, which is the only bit that'll be included in demos/intros, essentially the repalyer.

Oscillators are forever a work in progress, but I'm getting to where I want to be, albeit slowly. Support for standard waveforms (Sine, Saw, Triangle, Square) works pretty well and I've got a white noise generator available too. Each of these uses a single wavetable (which contains a single period [cycle of the wave] at 0.1hz). To play a specific pitched note, I increase the step size when sampling the wavetable in order to increase pitch. If I wanted to play a note at 0.1hz, I'd play every sample in turn. To increase the pitch, I sample every other sample or every 4th sample etc, which results in higher pitched output. I've also added support for oscillator sync.

Oscilator Sync (and Oscillator modes)

Oscillator (Hard) Sync

Oscillator Sync allows you to sync the output of one oscillator with another. What this does is cause the slave oscillator to reset when the master oscillator restarts. If both oscillators are tuned the same, you'll hear no effect as both oscillators produce a wave with the same frequency so the wave period for both oscillators starts and stops at the same point. If we were to increase the frequency of the master oscillator however, the period length for the master oscilator would then be shorter than that of the slave oscillator. If you look at the below image and imagine the top wave is the wave from the master oscillator and the bottom wave is the wave from the slave oscillator, this should help you visualize what I mean. As you can see, both oscillators start at full amplitude (let's call this +1.0) and then drop down to min amplitude (let's call this -1.0), and then rise back up to full ampltiude (+1.0 again) before dropping again. This dropping rising is a single period of the wave. With oscillator sync enabled, when the higher frequency master oscillator completes a cycle/period, the lower frequency slave oscillator is only halfway through a cycle because it is half the frequency of the master oscillator (slave has dropped from +1 to -1 while master has dropped from +1 to -1 and risen back up to +1). What happens now is the master oscillator signals to the slave oscillator to reset and the slave oscillator restarts a new cycle/period, regardless of how far through a cycle it was. By changing the frequencies of the master and slave oscillators (by detuning or modulation with an LFO etc), we can produce some very different sounds.



Other modes

There are other oscillator modes that are still in progress, such as 'fixed' and 'free'. 'Fixed' mode essentially produces an unpitched waveform, so regardless of which key is pressed on a keyboard, the note played is always the same pitch. This is useful for things such as drum sounds. 'Free' mode effectively makes the oscillator cycle free-running. Usually, when a oscillator is started due to a note-on command (keyboard key pressed), the oscillor will start to generate from the start of a cycle. In 'free' mode, the cycle isn't reset and the waveform cycle just loops up and down constantly in the background regardless of whether the oscillator is actually outputting sound.

Each of the oscillator modes also has an 'inverted' setting, which just inverts the oscillator output. So a value of +1 would become -1 if the oscillator was inverted.

PadSynth

One of my initial goals when I started creating the synth was to implement support for PadSynth sounds. If you're not familiar with PadSynth, have a look here and listen to some of the samples sounds on the page and I'm sure you'll instantly understand the appeal. What the PadSynth algorithm does is produce loopable wavetables that be used for Wavetable Oscillators to produce a wide range of sounds such as choirs, ensembles and organs.  Probably the biggest hurdle I had when working on implementing PadSynth was due to the fact that PadSynth requires an IFFT (Inverse Fast Fourier Transform) in order to produce the Wavetables. I won't go into what the PadSynth algorithm does as that's already covered on the website. The demonstration code that comes with the PadSynth algorithm uses the FFTW library to perform the IFFT transforms. The FFTW library weighs in at around 2.5mb, so that wasn't at all practical for a synth that needs to fit nicely inside a 64k intro. After some hacking about I managed to get a small and acceptably fast IFFT implemented that adds ~1.5kb to the compiled output, which is fine in terms of size for now.

Implementation

For my PadSynth implementation, I have a constant defined that controls how many PadSynth wavetables there are per octave. Initially, I tried using one large wavetable at a very low frequency played back at different frequencies (for different keyboard notes) by changing the sampling step. If I need to play at twice the frequency, I sample every other value when reading from the wavetable, which produces a higher pitched output. The handle step sizes that aren't integers, I do some interpolation too. While this works fairly well for the standard simple waveforms such as Sine and Square, it sounds ghastly when this technique is used with a PadSynth wavetable. I'm not totally sure why it sounds quite so bad, but I would guess that a lot of the lower harmonics are removed by the resampling and the higher harmonics end up exceeding the Nysquist limit and head off into screechy alias hell. If you're not familiar with the Nyquist frequency, it's the frequency that equals half your sample rate (44100 sample rate has a Nyquist frequency 22050). Any frequencies that fall above the Nyquist frequency will end up folding back to a lower frequency once they hit the Nyquist frequency. So to try and overcome this problem, I generate multiple PadSynth wavtables and sample from the one which has the base frequency closest to the frequency of the note I want to play. This improves things a lot but there is a noticable audiable difference when the wavetable that's being sampled switched as you play notes in sequence (running up or down the keyboard for example). Allowing yet more wavetables so we have several wavetable per octave and less difference in frequency, which goes further to help the problem. I'm still left with the earlier problem of the noticable jumps, but it's better than before.

Modulation

One of the cool things you can do with a synth is modulation. This essentially allows you to use the output from something (envelope generator, LFO etc) to alter something else (pitch of oscillator, volume/amplitude of oscillator). For instance, an LFO (low frequency oscillator) produces a wave at a very low frequency (speed) and this output could be used to change the frequency of an oscillator to give it a wobble sound. Another use of modulators and LFOs in particular is to vary something very slowly by having the LFO frequency set very low. This could then slowly change the cut-off for a low pass filter which sounds like someone slowly turning the treble knob on a hi-fi. If you listen to most modern tunes made with a soft-syth such as V2, you can often hear an LFO or evnvelope gate being used to change the cut-off frequncy of a low pass filter. Modulations in Zynth are working quite nicely for the simple waveforms and the only problem I currently have is the modulator output can push the frequency of an Oscillator above the Nyquist limit sometimes. I'm not sure if this is really a problem or something that should be left to the musician so they can tune the modulation by increasing the strength. The real problems start when trying to modulate the PadSynth wavetable oscillators. Those wavetable switches/jumps that I mentioned earlier are really noticable in this instance. I'm still not sure of the best solution, but I'm going to try cross-fading between the wavetable below and the wavetable above the frequency of the note I wish to play. This should either fix the problem or throw another load of awful into the mix.

That's it for now. I've got filters partially implemented (from studying the V2 code), but they're quite buggy and sound nasty at times. I've still not got reverb, echo, delay, chorus or distortion implemented but those should be underway soon. As always, any tips, comment or suggestions most gratefully received :)
« Last Edit: July 19, 2012 by Raizor »
raizor

Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Soft synth idea - am I crazy?
« Reply #85 on: July 20, 2012 »
Yeah, GUI looks fantastic!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Soft synth idea - am I crazy?
« Reply #86 on: July 20, 2012 »
Looks pretty good there Raizor, and nice explanation about of what you are doing.

Does all those controls (sliders/buttons) are working?
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #87 on: July 20, 2012 »
Thanks Benny and Rbz.

Looks pretty good there Raizor, and nice explanation about of what you are doing.

Does all those controls (sliders/buttons) are working?

Most work, or will hopefully work eventually. The waveshaping stuff on the right hand side of the oscillator panel will be dropped and I may stick with a single waveform for the LFO instead of allowing 2 waveforms. Getting close to size limit already, so need to scale things back and bit :)

Trying to get the processing order for various things sorted out atm as there are lots of options for modulating one thing with another and I'm trying to process things to buffers in order for the output to be used for modulation. Giving me quite a headache this evening :|

raizor

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Soft synth idea - am I crazy?
« Reply #88 on: July 22, 2012 »
Trying to get the processing order for various things sorted out atm as there are lots of options for modulating one thing with another and I'm trying to process things to buffers in order for the output to be used for modulation. Giving me quite a headache this evening :|
I've never did anything like that myself, but my first try would be something like this:

[pseudo code]

//instrument setup
int instrument_comb[MAX_COMB] = {
3,  //execute function 3 = (delay)
1,  //highpass
2,  //reverb
0   //Lowpass
};


//loop
switch(instrument_comb[loop])
{
case 0:
  function0(buffer); //(Lowpass)

case 1:
  function1(buffer); //(highpass)

case 2:
  function2(buffer); //(reverb)

case 3:
  function3(buffer); //(delay)
}
//loop
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Soft synth idea - am I crazy?
« Reply #89 on: July 22, 2012 »
This looks epic, lots of parameters to tweak already and more to come by the sound of it.

Have you given it to any musicians to play with yet? 
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #90 on: July 22, 2012 »
Not yet Shockwave, it's still far too broken for that at the moment :)

rbz, thank you.
raizor

Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: Soft synth idea - am I crazy?
« Reply #91 on: July 25, 2012 »
Woot, that really does look epic! Haven't really commented yet because I still haven't read through the post in detail. Some day I will but for now the pics look really impressive!

Really interesting to play around with the building blocks of sound, have you encountered some weird/beautifull or interesting errors during the process?
www.kirl.nl
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #92 on: July 25, 2012 »
Woot, that really does look epic! Haven't really commented yet because I still haven't read through the post in detail. Some day I will but for now the pics look really impressive!

Really interesting to play around with the building blocks of sound, have you encountered some weird/beautifull or interesting errors during the process?

Thanks Kirl. I've had quite a few weird errors but I can't say any of them have sounded beautiful unfortunately, most have me frantically reaching for the volume knob to turn it down ;)

I must say, it's taking much more time to get things going that I would have hoped. Coming into this field with hardly any knowledge of sound/signal processing is probably why, but it's mostly fun and I'm learning a lot. Getting the PadSynth stuff working has been the nicest thing sound-wise so far. Hopefully I'll be able to show you something soon-ish.
raizor

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #93 on: August 21, 2012 »
Progress

Still plugging away in most of my free time, which isn't massive at the moment, due to me having to repoint the brickwork for most of the outside of the house this Summer :|

I've got most of the features in place now. This last week has been very productive, leading to the inclusion of Delay, Reverb, Distortion and Filters (high pass, low pass etc). I've still got to get Compression in place as well as a few misc effects such as Flanging, Phasing and hopefully some kind of funky glitch machine functionality for Dubstep style craziness. In terms of functionality, I seem to be getting close to exceeding what V2 can do, which is a bit shock to me, but kinda nice at the same time.

One of the areas that caused me some headaches has been the MIDI side of things in regard to the VST plugin. Trying to come up with a nice workflow for handling patch assignments to MIDI channels has been quite frustrating due to this being a mutli-timbral synth. Both V2 and 4KLang are also multi-timbral, but handle instrument/patch assignment differently. This probably needs some explaining, as I didn't understand this properly until quite recently:

In order to use the synth (or V2, 4KL), you must have a composition program (sequencer/tracker) to write your music. In my case, I've been using Renoise for this purpose, but you could use Cubase, Fruity Loops or whatever. When you create a new song in renoise, you have a bank of instruments for the song. These instrumnts can be plain old samples or VST instruments. VST instruments can be monophonic or multi-timbral. Say for example, you're making a dance music track. You may have a particular VST instrument to do the drum sounds, another different instrument for the lead lines and yet another for pad style effects. In this case, each of these VST instruments would probably be monophonic. They are effectively standalone instruments that are assigned to a single MIDI channel. When the song is playing, it may fire a note-on event on MIDI channel 1, which is assigned to the drum VST, therefore the drum VST would be responsible for making a drum sound for the note. Another totally separate VST may be assigned to channel 3 for lead sounds, so when a MIDI note-on event for channel 3 is fired, the lead sound VST would receive the event and be responsible to generating the sound. In a scenario like this, these VST instruments are totally independent and have no concept of each other or awareness that other VST instruments exist or are assigned to the track.

A multi-timbral synth (such as V2, 4KL or Zynth) shares a single VST plugin instance for all channels for a music track (renoise song). The way V2 handles having different patches (intruments/sounds) for different channels works by inserting MIDI program change commands into the track. As a track plays, various note-on and note-off commands are fired to simulate keys on a keyboard being pressed and released. In addition to these note-on/off commands, there are other special MIDI commands that can be fired for a particular MIDI channel to do various things. One of these commands in the 'program change' command. When using V2, you must send a program change command for a particular MIDI channel to change the V2 patch that is assigned to that channel. While this works, it can feel a little clunky from a user's perspective (imho). 4Klang on the other hand defaults to assigning patches sequentially to channels. So if a note is played on channel 1, it will use patch/insturment 1, for channel 2, patch/instrument 2 is used (etc etc). I'm not sure if 4KLang support program change commands, but I think not.

At the moment, my synth (Zynth) uses the 4KLang method, so by default patch 1 is associated with channel 1, patch 2 with channel 2 etc. You can also send program change commands to change this. Not ideal, but usable for now at least...

As my synth is primarily a wavetable based synth, I'm building a little PadSynth wavetable designer, that lets you create various types of PadSynth wavetables. These will be recreated prior to playback by the replayer in the demo/intro. I'm also working on a wavetable designer that lets you combine various existing wavetables in weird ways to create new ones. This works by having a stack of wavetables and various operators (add, subtract, multiply etc) to control how the values from the warious source wavetables are summed to produce the final wavetable. I'm hoping this will allow creation of some crazy sounds but may turn out to be totally useless :)

Question

One thing I am confused about is sync-to-tempo functionality. I've seen this in a lot of commercial synths (especially LFO sync) but I can't seem to find a description of what it actually does. My guess would be that the LFO (or whatever is being synched) repeats for each beat. So a 120 BMP song has an LFO that repeats a single cycle/period 120 times per minute. I've seen a denominator value used in these instances too, I guess that acts as a multiplier/divisor to make the LFO repeat 240 (*2) or 60(/2) times per minute. If anyone can shed any light on this, I'd appreciate it very much.

Well, that's it for now. Still nothing to show/demo yet :)
raizor

Challenge Trophies Won:

Offline neriakX

  • Atari ST
  • ***
  • Posts: 117
  • Karma: 29
  • CodeNoob
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #94 on: September 09, 2012 »
[At the moment, my synth (Zynth) uses the 4KLang method, so by default patch 1 is associated with channel 1, patch 2 with channel 2 etc.
I'm really happy you went this way. I hate the programm change method in V2 - sometimes it was very buggy when replaying the tune. That might be an issue with v2 but I love the fixed instrument per midi channel more. Also I'm used to it when composing in Cubase.

I've read the whole thread now in the last hour and have to admit, I'm glad you're still working on Zynth. Let me know when you need some testing! The GUI looks kickass. the z3ta is and always was my favourite soft-synth.

In answer to your question about the beat-synced LFO's: I think you're right with what you're saying. I'm totally bad in music-theory .. I just hit keys and have a sense for timing and  harmonies, but your explanation makes completely sense.  Beat-synced LFOs are petty awesome for gate effects, can be nicely used for  filters, sound-ducking and stuff like that. therfore it make sense to have a multiplier/divisor for it. it's very popular using this for eg. in dubstep tunes - for fast wicked filtering .. you mostly think in 1,2,4,8,16,32 and 64th steps plus the triplets (8. , 16. , ...)
 
cheers,
neriakX

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #95 on: September 09, 2012 »
Thanks neriakX, very useful info!

Still on Skype, yep. Haven't signed in for a while again though. Tried pinging you last night :)
raizor

Challenge Trophies Won:

Offline neriakX

  • Atari ST
  • ***
  • Posts: 117
  • Karma: 29
  • CodeNoob
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #96 on: September 09, 2012 »
Hey mate, found a cool workshop from farbrausch - might be of interest!

Revision 2012 - The possible next generation of demoscene 64k softsynths
cheers,
neriakX

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Soft synth idea - am I crazy?
« Reply #97 on: September 10, 2012 »
Hey mate, found a cool workshop from farbrausch - might be of interest!

Revision 2012 - The possible next generation of demoscene 64k softsynths

Cool! Looks very interesting. I think I had a quick look at it before but will watch it through this time. Thanks for the link matey :)
raizor

Challenge Trophies Won: