
Home  Forums  Rules  Articles  diyAudio Store  Blogs  Gallery  Wiki  Register  Donations  FAQ  Calendar  Search  Today's Posts  Mark Forums Read  Search 
Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators 

Please consider donating to help us continue to serve you.
Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving 

Thread Tools  Search this Thread 
1st May 2017, 10:12 PM  #1 
diyAudio Member
Join Date: Sep 2012

Algorithms for music: realtime parameter modification
Hi everybody,
I don't know how many people use rack fx these days, and how many dig into them to catch new sounds, but I would like to share with you what I obtained as complex waveforms to control parameters on my fx units. Basically, as you probably know, rack fxs have the possibility to assign some parameters to CC midi signals, or voltage on specific inlets, or volume pedals and so on. Lexicons (at least my lexicons) limit them to 5 per each unit. On Mesa Boogie Triaxis you can assign any of the stored values (gain, mid, lows, highs, volume, etc...) to an external information, in order to change it while playing. Same can be applied to the parameters of all rack fxs compatible with CC signals. Some of them are just a 1 bit signals (063 and 64127), some have full dynamic on the 128 values. You can then change in real time the shape of the chorus, the decay of a reverb, the pan, etc... After being in contact with Professor John Chowning of the Stanford University, the inventor of the FM modulation on the synths to emulate the real sound of the instruments, I came out with some algorythms to change in real time the parameters of my rack fxs. Here below you can find the code. I've done it in matlab to speedup the plots, but I've intentionally used the same commands that can be used in Arduino, that is the platform I'll use to send commands to the fxs. Code:
% #1 funzione per Chorus con AM ed FM fc = 0.29; % Carrier Freq (Hz) fm = 0.085; % Modulating Signal Freq (Hz) m = 9; % Modulation Index t = linspace(0, 10, 2^14); % Number of samples y = 0.45*sin(2*pi*fc*t*0.96) + 0.45*cos(2*pi*fc*t  (m*sin(2*pi*fm*t))) + 0.1*cos(2*pi*fc*t*2.8); subplot (3,2,1), plot(t,y); % #2 funzione per panning fc = 0.69; % Carrier Freq (Hz) fm = 0.23; % Modulating Signal Freq (Hz) m = 9; % Modulation Index t = linspace(0, 10, 2^14); % Number of samples y =  0.5*sin(2*pi*fc*t  (m*cos(2*pi*fm*t*0.618))) + 0.5*cos(2*pi*fc*t*2.8 + (m*sin(2*pi*fm*t*0.618))); subplot (3,2,2), plot(t,y); % #3 funzione per psychoflanger fc = 0.69; % Carrier Freq (Hz) fm = 0.23; % Modulating Signal Freq (Hz) m = 1; % Modulation Index t = linspace(0, 10, 2^14); % Number of samples y =  0.5*sin(2*pi*fc*t  (m*cos(2*pi*fm*t*1.32))) 0.5 + abs(cos(2*pi*fc*t*1.32 + (m*sin(2*pi*fm*t*0.618)))); subplot (3,2,3), plot(t,y); % #4 funzione per dimensione riverbero fc = 0.69; % Carrier Freq (Hz) fm = 0.23; % Modulating Signal Freq (Hz) m = 19; % Modulation Index p = 0; %numero del plot t = linspace(0, 10, 2^14); % Number of samples y =  0.6*sin(2*pi*fc*t  (m*cos(2*pi*fm*t*1.32))) + 0.4*cos(2*pi*fc*t*3  (m*sin(2*pi*fm*t*1.32))); subplot (3,2,4), plot(t,y); % #5 funzione per chorus lento fc = 0.069; % Carrier Freq (Hz) fm = 0.023; % Modulating Signal Freq (Hz) m = 19; % Modulation Index t = linspace(0, 10, 2^14); % Number of samples y =  abs(sin(2*pi*fc*t  (m*cos(2*pi*fm*t*1.32)))) + abs(cos(2*pi*fc*t*3  (m*sin(2*pi*fm*t*1.32)))); subplot (3,2,5), plot(t,y); % #6 funzione per chorus lento fc = 1.29; % Carrier Freq (Hz) fm = 0.385; % Modulating Signal Freq (Hz) m = 18; % Modulation Index t = linspace(0, 20, 2^14); % Number of samples y = cos(2*pi*fc*t  (m*sin(2*pi*fm*t*0.26))) ; subplot (3,2,6), plot(t,y); Has anyone done something similar to his rack? 
1st May 2017, 10:13 PM  #2 
diyAudio Member
Join Date: Sep 2012

The Matlab code I've developed to see the effect of each parameter in 25 different plots is the following:
Code:
% Plot funzioni con AM ed FM fc = 1.29; % Carrier Freq (Hz) fm = 0.385; % Modulating Signal Freq (Hz) m = 9; % Modulation Index p = 0; %numero del plot for fi = 0.1:0.04:1.06; p = p+1; t = linspace(0, 20, 2^14); % Number of samples y = cos(2*pi*fc*t  (m*sin(2*pi*fm*t*fi))) + 0.1*cos(2*pi*fc*t*2.8); subplot(5,5,p), plot(t,y); end 
1st May 2017, 10:14 PM  #3 
diyAudio Member
Join Date: Sep 2012

The basic code is really simple.
I modulate the frequency of a sine or cosine wave by varying the value of the radiants during the time: Code:
y = cos(2*pi*fc*t  (m*sin(2*pi*fm*t*0.26))) Code:
y = cos(2*pi*fc*t) Then I modulate the radiants of the funcion, so I change the speed of the radiants, so the frequency. Code:
 (m*sin(2*pi*fm*t*0.26)) The amount of modulation is set by the parameter m. This is the very basic one, then you can do whatever you want:  square waves by adding nth order harmonics at the amplitude 1/n;  absolute values of the sinewaves;  odd roots of the sine waves;  triangular waves;  sawtooth waves;  etc... 
1st May 2017, 10:15 PM  #4 
diyAudio Member
Join Date: Sep 2012

For example, do you want to do an AM modulation of a FM modulated sine?
Code:
y = cos(2*pi*am*t) * cos(2*pi*fc*t  (m*sin(2*pi*fm*t))) ;  am is the amplitude modulating frequency;  fm is the frequency modulation frequency. Do you want to modulate only from 0 to 50% of the total swing? Code:
y = 0.5*cos(2*pi*am*t) * cos(2*pi*fc*t  (m*sin(2*pi*fm*t))) Best way, is to keep the full range on the midi and reduce the range when assigning the midi cc to the effect parameter. This way you do not reduce the resolution in the transmission of the parameter while obtaining the same result. 
11th May 2017, 12:33 PM  #5 
diyAudio Member
Join Date: Oct 2002
Location: (Black Forest, Germany) currently southern Finland

wow, nice work! Modulating roomsize of reverbs for example creates very interesting sounds!

11th May 2017, 01:50 PM  #6 
diyAudio Member
Join Date: Sep 2012

Thanks bob, I'm still developing the code, and to bypass some limits of the Arduino (or mines, it depends from which side you see the issue. Basically I've to speedup the calculations in order to be always on time for the midi through.
I've got some hints, I'll apply them and will update the thread here. Room size of reverbs, as well as chorus/flanger shapes, eq parameters in the delay loop, predelays of the choruses, etc... The next step is to implement a pair of digital 10k pots to simulate a control pedal. That's for the morphing effect of my Lexicon Vortex, that cannot receive CC. 
11th May 2017, 03:33 PM  #7 
diyAudio Member
Join Date: Dec 2011
Location: Barrio Garay,Almirante Brown, Buenos Aires, Argentina

I apologize by my ignorance, but are you creating music mathematically? Such a job‼
__________________
Osvaldo F. Zappacosta. Electronic Engineer UTN FRA from 2001. Argentine Ham Radio LW1DSE since 1987. 
11th May 2017, 05:02 PM  #8  
diyAudio Member
Join Date: Sep 2012

Not exactly Osvaldo.
My goal is a realtime parameter modification of the multifx units. Just to explain you better: Lexicon MPX G2 Manual Go to pag. 57 (chapter 4): Quote:
Usually these parameters are patched to a control pedal or some basic LFOs, or Envelope, etc... This is quite limitating, because most of the time you can choose between sine or triangulat waves. My goal is to generate some complex functions (including frequency and amplitude modulation), scale them down to the midi range (0127) and transmit these information as control change. On the fx unit I'll patch the CCs sent by the Arduino to some specific parameters, and this way the effects will continuously modify, creating unexpected sounds. Then the 10k digital pot will add some more "randomness" by controlling the morphing of the Lexicon Vortex, that cannot read CC data. 

11th May 2017, 05:18 PM  #9 
diyAudio Member
Join Date: Dec 2011
Location: Barrio Garay,Almirante Brown, Buenos Aires, Argentina

To see if I understand (I like and enjoy music but I don't know anything about music, notes,pentagrams, etc.). Then You want to do an algorithm to modify music while playing?
The thread made me remember creating sounds in the legendary Commodore 64: attack, decay, sustain, etc., with its "Peeks" and Pokes"... I never understand nothing :)
__________________
Osvaldo F. Zappacosta. Electronic Engineer UTN FRA from 2001. Argentine Ham Radio LW1DSE since 1987. 
11th May 2017, 05:30 PM  #10 
diyAudio Member
Join Date: Sep 2012

I started programming a C16 when I was 5 or 6 yo.
It was a totally unexpected Christmas gift, I remember that I looked at my father and asked: "mmm.... nice... what's that for?" Then I read the manual and I made my first loop function that made the background black, and black, and black again. Well, I don't modify the pitch of the note that I'm playing, but I modify the parameters of the effects. To make it simple: I can change the volume of what I'm playing, I can change the quantity of reverb, the bass, the treble, etc... down to more subtle parameters like the ones I've written above. 
Thread Tools  Search this Thread 


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Real music power  Conta  Tubes / Valves  16  14th February 2008 04:19 PM 
Music Angel Modification  Imperial  Tubes / Valves  2  28th January 2008 02:13 PM 
Just Real Music  ESLs  Jms969  Planars & Exotics  8  7th September 2005 09:17 PM 
Modification of an headphone amp to real preamp  FrankDIY  Headphone Systems  6  4th December 2002 11:55 AM 
New To Site?  Need Help? 