Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 01:01:24 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperAudioPhase Distortion synth in Flash
Pages: [1]
Print
Author Topic: Phase Distortion synth in Flash  (Read 1622 times)
Triplefox
Level 9
****



View Profile WWW
« on: December 15, 2010, 01:48:11 AM »

http://dl.dropbox.com/u/254701/blog/testengine.swf (WARNING: It's LOUD!)

I've been working off and on to get this going. Tonight I made some breakthroughs and got it sounding more-or-less like the Casio CZ series does. While simple, it's not a super-well documented technique, and I'm still learning DSP, so I'm way happy it works now  Tears of Joy.

Play with it by drawing around in the top envelope window. Drawing at the top area (representing values down to 0) slows and smooths the waveform; the low area(values going up to 2) make it oscillate more. The most interesting timbres seem to be with mostly 0 or near-0 values - that is, at the top of the envelope. High values in the middle or bottom will mostly produce variations on resonant sounds.

How it works: (with more pictures)

1. Start from a sine wave running at the desired frequency.
2. Modify the phase of the sine wave according to the drawn envelope, which runs at some other frequency(in this test, modulated by an LFO so you can hear the sweep effects). What it looks like. The CZ synths contain built-in wavetables that reproduce "analog-like" waveforms - I like the flexibility of drawing though.
3. Hard-sync the resulting waveform. This allows the timbre to change with the phase modulator's frequency, producing all the cool resonant filter effects, without affecting the base frequency. (in DX-type FM synthesis, there's no sync; wavelengths with "nice-sounding" ratios(2:1 4:1 etc.) are generally used instead to preserve a musically useful timbre)
4. Apply a triangular downsloping volume envelope to the resulting waveform, also hard-sync'd. That is, volume starts at maximum at the outset of the sine, and drops linearly to 0. Between this and the use of a sine wave as the basic oscillator, most sources of aliasing are removed, since the discontinuities are naturally smoothed out. The test shows a single cycle, which clearly shows the envelope. I might try playing with this envelope's character at some point and see if it's worth modulating for additional timbres.

Why it's awesome:

It's computationally cheap and thus potentially suitable for use even in real-time web-games. Everything is done in the time-domain, yet it sounds good and can get "sort of" analog results, or near-identical-to-FM ones, depending on what you're doing. And it's quite easy to program sounds for, unlike the DX-type FM, which is theory-heavy and tends to explode into chaos easily.

I'm thinking that if I develop this further with dual oscillators, more modulation options, etc., and pair it with a basic sampler, I'll have a totally jawsome sound engine on my hands.

Some examples of Casio CZ patches:



3
Logged

dkanaga
Level 0
**



View Profile WWW
« Reply #1 on: December 15, 2010, 11:36:54 PM »

Very cool. The app's got a cool visual style, and the way that the wave animation reacts to input is really quite interesting Smiley... I'd be interested in playing with a version that could change pitches... I hope you keep on going with it--a jawsome sound engine, indeed!
Logged

Triplefox
Level 9
****



View Profile WWW
« Reply #2 on: December 16, 2010, 12:13:00 AM »

Thanks. I did some more work today getting pitch modulation working(I had some design errors in the hard sync algorithm that caused all sorts of aliasing/nastiness, and after a lengthy investigation figured it all out), but now that the basic algorithm is correct I need to start exposing more UI. This is my current build - it now oscillates around 440hz(exact pitch is displayed in the traces). If you push the phase distortion to extremes, you'll get some "whirling" alias artifacts at the higher pitches. Casio's solution to this was to only provide a fixed set of "good" waveforms - and they also did some stuff to customize the algorithm for each waveform, which I don't currently plan to do - I'd rather take my own approach from here.

The way the output waveform looks in the first build is actually coincidence, when I started playing with pitch it stopped behaving that way. It does look awesome though....I should bring it back.

I will take a break on this for a little while, and work on a game instead.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic