Old 01-10-2017, 01:33 AM   #1
geoslake
Human being with feelings
 
Join Date: Apr 2007
Posts: 348
Default FM between 2 sources

Hi guys

Im looking for a js fx to do FM between 2 inputs (either 2 different tracks or 2 vstis). FARmodulator is great but theres no way to do that, right ?
geoslake is offline   Reply With Quote
Old 01-10-2017, 05:11 PM   #2
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 750
Default

So what I'm thinking is that you could probably take something like this and change it to accept an alternate input.

http://forum.cockos.com/showthread.php?t=172952
SaulT is offline   Reply With Quote
Old 01-10-2017, 09:12 PM   #3
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 750
Default

So something like this, perhaps.

I have widened the range of modulation depth (great for bass sounds), added additional inputs, and corrected the saturation algorithm.

I was just testing it by modulating a synthline with a drum buss.... sick. =)

Code:
desc:sault mod of Ze Self Delay Mod rev01
// Author: Thierry Rochebois
//       rev01:    x 4 oversampling    Aftertouch Ctl
// sault rev02:    now accepts inputs from different channels
//                 wider modulation depth
//                 saturation algo corrected

slider1:7<0,100>Mod depth
slider2:0<0,1>AfterTch ctl
slider3:0.5<0.01,2,0.000001>LP
slider4:0<0,3,{0/1,2/3,4/5,6/7}>Modulation source

// ___________________________________________________________________
@init
function dec2(x0 x1) 
  instance(R1 R2 R3 R4 R5 R6) local(h5x0 h3x0 h1x0) (
  h5x0 = DEC5_h5 * x0; h3x0 = DEC5_h3 * x0; h1x0 = DEC5_h1 * x0;
  R6 = R5 + h5x0; R5 = R4 + h3x0; R4 = R3 + h1x0;
  R3 = R2 + h1x0 + DEC5_h0 * x1;  R2 = R1 + h3x0;  R1 = h5x0;
  R6;
);
function dec4(x0 x1 x2 x3) (
  this.dec2(this.sub.dec2(x0, x1), this.sub.dec2(x2, x3)); 
);
DEC5_h0=346/692; DEC5_h1=208/692; DEC5_h3=-44/692; DEC5_h5=9/692;
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
l.t = 0; r.t = 16384;                            // delay line tables
co_downUp = 32768;
co_downUp[0] = 1/(srate * 0.100); co_downUp[1] = 1/(srate * 0.010);
// ___________________________________________________________________
@slider
depth = 2 * slider1 * 0.001 * srate;                 // ms to samples
co_lp = 1000 * slider3 / srate;               // low pass filter coef
// ___________________________________________________________________
@block
while(midirecv(offset, msg1, msg23))(  midisend(offset, msg1, msg23);
  msg1 & $xF0 == $xD0 ? aftTch = (msg23 & 0x7F) * (1/127);
);
modDepth = depth * (1 + slider2 * (aftTch * aftTch - 1));
// ___________________________________________________________________
@sample

  function sat(x) (
  (abs(x)>1.5) ? sign(x)*1.5 : (x * (1 - (4/27) * x*x));
  );

function interp(t x) local(x0 x1 a)(
  x0 = x|0; a = x - x0; x0 &= 16383; x1 = (x0 + 1) & 16383;
  t[x0] + a * (t[x1] - t[x0]);
);
function proc(x) instance(t lp i y)(
  i = (i + 1) & 16383;
  t[i] = x; lp += co_lp * (sat(x) - lp);
  interp(t, i + 16384 - depth + smoothModDepth * lp);
);
function ov4Proc(newSpl) instance(fSpl spl) local(dSpl)(
  dSpl = 0.25 * (newSpl - spl); // linear interpolation and LPF on input
  this.dec4( 
    this.proc(fSpl += 0.25 * ((spl += dSpl) - fSpl)),
    this.proc(fSpl += 0.25 * ((spl += dSpl) - fSpl)),
    this.proc(fSpl += 0.25 * ((spl += dSpl) - fSpl)),
    this.proc(fSpl += 0.25 * ((spl += dSpl) - fSpl))
  );
);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
smoothModDepth += co_downUp[modDepth > smoothModDepth] * (modDepth - smoothModDepth);

// inputs -> outputs

slider4 > 0 ? (
  in0 = spl2;
  in1 = spl3; ) : 

slider4 > 1 ? ( 
  in0 = spl4;
  in1 = spl5; ) : 

slider4 > 2 ? (
  in0 = spl6;
  in1 = spl7; ) : (
  in0 = spl0;
  in1 = spl1;
  );

spl0 = l.ov4Proc(in0);
spl1 = r.ov4Proc(in1);
SaulT is offline   Reply With Quote
Old 01-10-2017, 10:47 PM   #4
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,623
Default

In fact I don't know how FM synths such as NI FM8 do this.

To do FM to an audio stream you would need to do something using FFT or some granular algorithm .

A Phase modulation can be achieved doing a delay with varying delay time. Look at a Phaser JSFX and replace the LFO by a side chain input.

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 01-11-2017 at 06:32 AM.
mschnell is online now   Reply With Quote
Old 01-10-2017, 11:39 PM   #5
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 750
Default

...which is exactly what Smashed Transistor's plugin does after I modified it. Variable delay based on either self- or sidechain input.
SaulT is offline   Reply With Quote
Old 01-12-2017, 11:46 PM   #6
geoslake
Human being with feelings
 
Join Date: Apr 2007
Posts: 348
Default

Wow, thanks Sault !
Getting very interesting sounds of of that, although I dont quite understand.
Say I have 2 synths (on a single reaper track), I thought I had to set one to output 1/2, the other to 3/4, to have one as a carrier, other as modulator, but it doesnt seem to work this way...
geoslake is offline   Reply With Quote
Old 01-13-2017, 01:13 PM   #7
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 750
Default

The assumption that I made when I tweaked the code is that the carrier would be on 1/2 and the modulator would be coming either from 1/2 or 3/4. And for some reason I put down 0/1 instead of 1/2 because I was thinking of channel 1 = spl0. In retrospect, should probably have thought a little more about that one.

So yeah, original plugin was carrier modulating itself, this version assumes carrier is 1/2 and can be modulated by 1/2 (itself), 3/4 (the other synth in your case), 5/6, or 7/8.
SaulT is offline   Reply With Quote
Old 01-13-2017, 02:34 PM   #8
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 3,889
Default

Quote:
Originally Posted by SaulT View Post
In retrospect, should probably have thought a little more about that one.
When I did that comp and exciter, I just labeled them "main" and "aux", then name the in_pins so they read that way in the pin matrix, use 0,1 and 2,3 internally and let the user assign the actual track channels as they see fit.
ashcat_lt is online now   Reply With Quote
Old 01-14-2017, 05:31 AM   #9
geoslake
Human being with feelings
 
Join Date: Apr 2007
Posts: 348
Default

Mmm Im an idiot probably, but I must be missing something here.
Seems whatever the setting i use, its always modulating itself.
And ive added pins and played with routings etc, when i set your fx to 2/3 or 4/5 (which is indeed confusing to me), i can never get any sound out of it...
geoslake is offline   Reply With Quote
Old 01-14-2017, 09:04 PM   #10
SaulT
Human being with feelings
 
Join Date: Oct 2013
Location: Seattle, WA
Posts: 750
Default

Have you tried modulating with a very different sound source? E.g. Modulating a synth with drums.
SaulT is offline   Reply With Quote
Old 01-24-2017, 11:17 AM   #11
geoslake
Human being with feelings
 
Join Date: Apr 2007
Posts: 348
Default

Yep, no luck, cannot figure out how that works
geoslake is offline   Reply With Quote
Old 01-24-2017, 04:18 PM   #12
reapercurious
Human being with feelings
 
reapercurious's Avatar
 
Join Date: Jul 2007
Posts: 1,657
Default

there's a plugin that does this, just 32 bit vst though

http://bedroomproducersblog.com/2014...-phase-module/
reapercurious is offline   Reply With Quote
Old 01-25-2017, 02:47 PM   #13
Ozman
Human being with feelings
 
Join Date: Feb 2015
Posts: 508
Default

Phase modulation can be a bit close to FM but it isn't the same.
Ozman is online now   Reply With Quote
Old 01-28-2017, 03:43 PM   #14
reapercurious
Human being with feelings
 
reapercurious's Avatar
 
Join Date: Jul 2007
Posts: 1,657
Default

Quote:
Originally Posted by Ozman View Post
Phase modulation can be a bit close to FM but it isn't the same.
the weird part about that is that under the patent that Yamaha bought from Stanford/Chowning in the 70s, the implementation they used is phase modulation. the "FM" we all grew up with was really just "PM" talk about cutting corners!

PM seems to be "FM after the fact" anyway. but if you use predelay compensation, you can get virtual FM using the PM method. it will be "thru zero" or close.

but i have seen a comparison of PM and FM on youtube and the two results were pretty much indistinguishable to me.

FM radio is as old as the hills, why doesn't somebody make some FM using the same principle (except at audio rate, not radio frequency)
reapercurious is offline   Reply With Quote
Old 01-28-2017, 11:35 PM   #15
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 811
Default

Quote:
Originally Posted by reapercurious View Post

FM radio is as old as the hills, why doesn't somebody make some FM using the same principle (except at audio rate, not radio frequency)
If the carrier is a regular wave form and you are generating the carrier, then FM is fairly simple, just multiply the frequency of the carrier by the amplitude of the modulator. This is the method I use for the ReaRack oscillator and I assume a similar method used for FM radio.

However, if the carrier is a non uniform signal of varying frequency, you must instantaniously detect the frequency at each sample in order to reproduce the signal at a higher or lower frequency (or something like that). It's a much more complex problem.
__________________
ReaRack JSFX Modular Synth - Mostly harmless: https://stash.reaper.fm/v/28403/ReaR...dularSynth.zip
The Wasters of Time: https://soundcloud.com/thewastersoftime
Time Waster is offline   Reply With Quote
Old 01-29-2017, 01:51 AM   #16
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,623
Default

FM Synthesis is a well defined mathematical algorithm.

A problem here is that at any time the frequency of the carrier is defined to be the actual amplitude of the modulator plus a constant (and the carriers own frequency at that point in time, if same varies). Hence the frequency easily can get negative, rolling the carrier backwards.

Not easily done with analogue gear at all, even for just Sine oscillators (The only I know is the Yamaha GS1 / GS2.)

Of course problematic with carrier waveform fetched from an audio stream.

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 01-29-2017 at 03:40 AM.
mschnell is online now   Reply With Quote
Old 02-01-2017, 05:08 PM   #17
reapercurious
Human being with feelings
 
reapercurious's Avatar
 
Join Date: Jul 2007
Posts: 1,657
Default

mathematic implementation of FM on sine waves is different than the way FM radio works. in ancient FM radio systems, a capacitor is used to change the frequency of the carrier signal, and capacitors take a positive amount of time to charge and discharge.

the breakups that can occur from "too much FM" for example, happen when the change in frequency exceeds that which can be described by the samplerate of the output. This is easily reproducable in a yamaha, just by moving the FM amount in a modulator up into the nineties. the carrier always moves forward, and in classical FM terms, the carrier is a fixed frequency really, it's only since Yamaha that most of us "non-Chownings" have been able to really abuse the method and get crackles.

the part within the compound sine function that creates a change in frequency is literally only increasing and decreasing the speed at which a capacitor discharges. I'm not sure what the limits of frequency response would be in an analog system. It's really simple, with all due respect to the honorable John Chowning and Stanford.

if anything, frequency modulation is a misnomer, because you can't really modulate the frequency. i normally think of frequency as a fixed number, such as the frequency of the carrier, not some kind of "frequency average" or RMS of all the holographic side bands. that would be impractical. What is being modulated in order to generate the sidebands, is phase. you don't say "im going to modulate the frequency of this carrier" every time, but every time you will be modulating the phase, regardless of the outcome.

in digital terms, as long as the floating point value has some kind of continuity, and not trying to describe high amplitude changes in a span of one sample, then this modulation process works fine. I'm trying to remember what happens in a "real" FM radio, and well for one thing you don't hear the carrier, that's filtered out. but when the station gets lost there was noise. I guess the noise comes from the capacitor receiving intermittent jobs to do. but analog noise was pleasing was it not? i'd really like to get a breadboard working on some of this stuff.

what do you think?

edit:

it ought to be possible to create a whole FM synth with analog audio ins and outs just using RF in a heterodyne configuration. (but the FCC might not like it)

Last edited by reapercurious; 02-01-2017 at 05:20 PM.
reapercurious is offline   Reply With Quote
Old 02-02-2017, 03:59 AM   #18
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,623
Default

The paradigm of an audio FM synthesis includes a modulation so strong that the carrier frequency is negative. This is rather easily done in software or in digital hardware, if the carrier waveform is known from -inf to +inf (or at least all values that are necessary to be used.

RF-FM implementation only decently approximates the mathematical FM definition for small modulations. Larger modulations create distortion.

Of course you can base a new kind of synthesizer on that (in fact distortion can sound really nice) but it should not be called "FM".

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 02-02-2017, 01:54 PM   #19
reapercurious
Human being with feelings
 
reapercurious's Avatar
 
Join Date: Jul 2007
Posts: 1,657
Default

the speaker cone can only be in between -11 and 11, and it has a maximum speed, just like the human eardrum.

so what sort of sound would a negative frequency make? I think it would just sound like noise, which can be cool for a distortion effect.

I don't believe in negative frequencies in real world applications. Probably anything could be described and debated, but unless it's useful to me I'll sit that one out.
reapercurious is offline   Reply With Quote
Old 02-03-2017, 02:28 AM   #20
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,623
Default

With FM synthesis the "sound" is the result of the combined progression of modulater and the carrier. Even if the carrier frequency is not audible in itself the result is.

E.g. a 0.01 Hz sine carrier will result in something similar to an amplitude modulation of the modulator waveform, as the carrier waveform quickly runs forwards and backwards, while moving only very slowly in average.

-> https://en.wikipedia.org/wiki/Freque...tion_synthesis

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 02-04-2017, 07:53 PM   #21
reapercurious
Human being with feelings
 
reapercurious's Avatar
 
Join Date: Jul 2007
Posts: 1,657
Default

i disagree, nothing moves forwards and backwards in a signal on the time domain. a signal is really the instantaneous value measured at any discrete moment, even analogue signals. so theres really nothing moving backwards in time whatsoever. theres only really fast and zero change in signal position, and if the signal oscillates too fast (or stops too abruptly) it turns into noise because it is too hard for the medium to handle the physical turbulence. or perhaps i misunderstand where you're at.

patterns and stuff appear after the fact, which can be a radio broadcast or a bit of sound design. side bands, etc, don't exist in the moment, but are built over a span of time by the ear or by the math of some kind of buffer, like a wikipedia article for example.

the only way to implement FM in real life is some sort of delay, because the modulator amplitude is applied transversely to the rate of the carrier. this can be seen in a graphical way in let me find an old example...

from 7:20
https://youtu.be/xn6lzrMJUDs

i do appreciate the friendly banter, btw!

Last edited by reapercurious; 02-04-2017 at 08:11 PM.
reapercurious is offline   Reply With Quote
Old 02-05-2017, 12:54 AM   #22
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,623
Default

Quote:
Originally Posted by reapercurious View Post
i disagree ...,
It does not make sense to argue about definitions. they are just set, and not discussable. Here, "FW syntheses" originally has been defined/designed/calculated by Chowning, and first used by the Yamaha GS hardware, just using Sine as carrier and modulator and not "real live" audio streams. The special sound of such FM relies on the carrier running backwards when modulation is high. I do know that the Yamaha "SY 77" hardware and the NI "FM 8" software can use audio streams as modulator but not as a carrier (which in fact can be selected to be sine or some other cyclic wave forms).

You can define "real live FW syntheses" in any way you like, but if this does not completely include the original definition of "FW syntheses" it does not make much sense to me.

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 02-06-2017, 04:18 PM   #23
reapercurious
Human being with feelings
 
reapercurious's Avatar
 
Join Date: Jul 2007
Posts: 1,657
Default

Quote:
Originally Posted by mschnell View Post
It does not make sense to argue about definitions. they are just set, and not discussable. Here, "FW syntheses" originally has been defined/designed/calculated by Chowning, and first used by the Yamaha GS hardware, just using Sine as carrier and modulator and not "real live" audio streams. The special sound of such FM relies on the carrier running backwards when modulation is high. I do know that the Yamaha "SY 77" hardware and the NI "FM 8" software can use audio streams as modulator but not as a carrier (which in fact can be selected to be sine or some other cyclic wave forms).

You can define "real live FW syntheses" in any way you like, but if this does not completely include the original definition of "FW syntheses" it does not make much sense to me.

-Michael
the carrier frequency goes backwards, but cannot go slower than zero. it can move in a negative direction but not below zero. at least i've never heard of a signal that goes slower than zero in frequency
reapercurious is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.