Author 
Message 
alby
Joined: Aug 08, 2004 Posts: 12 Location: berlin
G2 patch files: 1

Posted: Sun Aug 08, 2004 5:39 am Post subject:
math operators on G2 


Hi,
my Question: Is there a possibility to use mathematic operators like +,*, /,
and to have constants which are bigger than 127?
I want to calculate f(x)BPM = 7620 / x
x= 1 to 128 (rotary button constant)and than to display f(x) which is my BPM on the G2. For displaying a delay/tempo.
Help. Alby 

Back to top



Blue Hell
Site Admin
Joined: Apr 03, 2004 Posts: 22858 Location: The Netherlands, Enschede
Audio files: 237
G2 patch files: 319

Posted: Sun Aug 08, 2004 11:43 am Post subject:



Division is a problem in general on the G2, a while ago there was some discussion about this on the mailing list. Kees van der Maarel came up with this then :
Quote:  A couple of weeks ago I was experimenting with a "division circuit",
using the formula: Log(x/y) = Log(x)  Log(y).
Here is my theory: The Pitchtracker module is a hidden logconverter,
because incoming frequencies are in fact translated into notenumbers,
which are proportional to the logarithm of the frequency: every doubling
of the frequency should add 12 "claviaunits" to the output of the
pitchtracker. I used two oscillators with linear modulation inputs to to
get frequencies proportional to x and y, and two pitchtrackers to get
log(x) and log(y). With a mixer I subtracted log(y) from log(x) and I
finally used a Level Scaler module to get a signal proportional to x/y
(because the output of the Level Scaler has an exponential relationship
to its input signal.
I used a Control Sequencer to read out the signal.
However, I don't think this circuit is accurate, probably because I've
overlooked something.
Greetings,
Kees.

I've been puzzling a bit on your question, but coulddn't come up with anything reasonable.
Displaying numbers for instance is impossble (except for this gadget : http://electromusic.com/forum/topic2272.html which is very nice and clever but not very usefull). This is an item for the wishlist I'd say ...
The best thing one can do is couple the LED collarof a knob to get an indication of a value (see http://electromusic.com/forum/topic1792.html also by Kees vd Maarel ).
Addition, subtraction and multiplication can be done though with mixers and the level multiplier module. Large numbers is a broblem though as the highest number representable in the system seems to be 255, being about four times unity (64). All such calculations need to be scaled and their outcome interpreted in the right way.
Jan. 

Back to top



mosc
Site Admin
Joined: Jan 31, 2003 Posts: 17917 Location: Allentown, PA
Audio files: 149
G2 patch files: 60

Posted: Sun Aug 08, 2004 2:30 pm Post subject:



Alby... 

Back to top



cristian
Joined: Jul 15, 2004 Posts: 24 Location: Barcelona
G2 patch files: 1

Posted: Fri Aug 13, 2004 7:47 am Post subject:



Cant the ADC be used to do more complex math in binary? _________________ www.nofuture.com 

Back to top



cristian
Joined: Jul 15, 2004 Posts: 24 Location: Barcelona
G2 patch files: 1

Posted: Sat Aug 14, 2004 3:30 am Post subject:



the level multiplier module can also be used to divide, as you can multiply an incoming control signal with 0.01 to 0.97
but i;m certain that a binary math system should be possible  the building blocks are there. A way of checking the on off state of each bit, plus a counter, and a way of converting the result back into clavia control units, which although limited to 128, can be used to set the pitch of an oscillator logarithmically which will can deal with large numbers (i.e. the frequency range. I dont know enough about binary computing to build this... yet.
I made a little patch that can display the result of a multiplication or division on the front panel, by using the noteseqencer. But the value is a note, not a number which is not much use. _________________ www.nofuture.com 

Back to top



Blue Hell
Site Admin
Joined: Apr 03, 2004 Posts: 22858 Location: The Netherlands, Enschede
Audio files: 237
G2 patch files: 319

Posted: Sat Aug 14, 2004 5:52 am Post subject:



Ok a little freshening up on math :)
Division is equivalent to multiplication by the reciprocal value (the reciprocal of x is 1/x).
And indeed when I want to divide a signal by 2 I can multiply it by 1/2 by using a mixer or a multiplier but here one must first somehow calculate the reciprocal outside the machine.
The question however is how to perform division by a variable, where the machine itself must be able to make a reciprocal of that variable before multiplication can be used.
There is no way to get around division in general by multiplication, a possible way to get around it is using logarithms and exponentiation in a smart way such that division can be reduced to subtraction (as in the example I quoted earlier).
So the question as how to divide might be rephrased into the question as how to take a logarithm of a signal.
Jan. 

Back to top



jksuperstar
Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18

Posted: Fri Aug 20, 2004 12:53 pm Post subject:



Hey all..haven't upgraded to the G2 (yet), but happy with my trusty NM "classic" (for now, until I keep reading this forum about the G2 )
Anyway, it seems this topic would do well if it had some table for math operators.
Code: 
+ = MUX
 = MUX with negation/"inverter"
* = Gain block (A * B), or MUX (A * B, B<1)
A^C = Gain Block, (A * A), or ShapeExp(C=constant, 2,3,4,5)
tan(A) = sin(A)/cos(A)
sin(A) = use A to phase modulate a 0 Hz oscillator
cos(A) = sin(A+C), where C is constant of 90degrees.
abs(A) = rectifier (fullpos mode)

Don't forget you can do many approximations by using an 8input switch as a sort of "lookup table" method of doing math (or, depending on the equation, a mixer), by generating 8 different values that get selected by a control input. These 8 inputs might in turn be 8 approximations. Heavy on the DSP%, but worth experimenting with.
If an addressable memory block was available, it would not only be useful for sampling, but performing nearly any 1input math function like a real lookup table (tan(x) for example, or even 1/x!!!!) 

Back to top



Blue Hell
Site Admin
Joined: Apr 03, 2004 Posts: 22858 Location: The Netherlands, Enschede
Audio files: 237
G2 patch files: 319

Posted: Fri Aug 20, 2004 1:19 pm Post subject:



Good idea to make such a table, although for those who really need it, it might be a bit cryptic.
I assume that where you wrote MUX you meant mixer ?
In my experience the ShapeExp module is a bit of a fanatasy thing, I couldn't really use it to do exponentiation on the Classic (didn't try it yet on the G2). Usefull for audio shaping or to change the keyboard velocity curve, not so much to do math with.
I noted that some people think math is not very usefull for the NM. I think this is a pitty, as there really is a strong relation between music and math that goes back far into history.
In my opinion proper math is the basis to work from, after that deviations might make things more interesting, but without math the synthesizer could not even exist.
Jan. 

Back to top



jksuperstar
Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18

Posted: Fri Aug 20, 2004 1:43 pm Post subject:



Whoops..You are right...MUX = Mixer.
The dangers of being a digital designer currently at work specifying a design, while fantasizing about being in front of my NM, and posting in this forum to make up for it 

Back to top



Blue Hell
Site Admin
Joined: Apr 03, 2004 Posts: 22858 Location: The Netherlands, Enschede
Audio files: 237
G2 patch files: 319

Posted: Fri Aug 20, 2004 2:01 pm Post subject:



:)
Be welcome !
jan. 

Back to top



pstnotpd
Joined: Apr 09, 2004 Posts: 34 Location: Netherlands
G2 patch files: 5

Posted: Sat Aug 21, 2004 5:55 am Post subject:



I was looking a while ago how to make differentiators and integrators. Any ideas about that? 

Back to top



jksuperstar
Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18

Posted: Sat Aug 21, 2004 8:45 am Post subject:
calculus 


Filters!
A HP filter is basically a differentiator, at least for low frequencies, while a LP is a good approximation for a high frequency integrator. An envelope follower can also be good, though you'd need to scale the output (cheaper than a LP). 

Back to top



cristian
Joined: Jul 15, 2004 Posts: 24 Location: Barcelona
G2 patch files: 1

Posted: Mon Aug 23, 2004 4:59 am Post subject:
Re: calculus 


jksuperstar wrote:  Filters!
A HP filter is basically a differentiator, at least for low frequencies, while a LP is a good approximation for a high frequency integrator. An envelope follower can also be good, though you'd need to scale the output (cheaper than a LP). 
i don't really understand... Can you explain more? _________________ www.nofuture.com 

Back to top



mosc
Site Admin
Joined: Jan 31, 2003 Posts: 17917 Location: Allentown, PA
Audio files: 149
G2 patch files: 60

Posted: Mon Aug 23, 2004 8:37 am Post subject:



On the G2, use the Glide module for an Integrator. Set the slope to linear. It is a near perfect integrator module. In fact, it should not be called a Glide module, but and Integrator module, because glide is just one function an integrator.
A filter, depending on which one you use, is more of an approximation, IMHO, and it will use more DSP resources.
The HP filter will work as an differentiator. 

Back to top



cristian
Joined: Jul 15, 2004 Posts: 24 Location: Barcelona
G2 patch files: 1

Posted: Mon Aug 23, 2004 9:34 am Post subject:



nope  still not gettin it.
what is an integrator and differentiator? I remember my basic calculus at shool ... but i take it in the world of synthesis , you're referring to something else or what? _________________ www.nofuture.com 

Back to top



jksuperstar
Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18

Posted: Mon Aug 23, 2004 11:09 am Post subject:



Given a function [f(x)], and if you viewed the graph of such a signal (as in an oscilloscope), the differential of that signal is the instantaneous SLOPE of the function. So, in audio, for a triangle wave, as the triangle ramp goes up, you'd have a positive constant as the differential (the angle or slope of the triangle is constant), and when it starts going down again, you get a negative constant (again, the slope is a constant negative number). In essence, you get a square wave that lines up with the triangle waves peaks & valleys.
What an integrator does, is like a calculation of the "area under f(x)". So, if you put a square wave into an integrator, you get a ramp out of it for the "high" part (as time progresses, the area increases linearly), and when the square flips over, the ramp goes negative. End result: you get a triangle wave out.
If you connect your nord to a soundcard input, use some oscilloscope program to view these things (or help you tune the circuit your making). 

Back to top



pstnotpd
Joined: Apr 09, 2004 Posts: 34 Location: Netherlands
G2 patch files: 5

Posted: Mon Aug 23, 2004 11:19 am Post subject:



jksuperstar wrote: 
If you connect your nord to a soundcard input, use some oscilloscope program to view these things (or help you tune the circuit your making). 
I'm using wavetool. It contains a software scope which works quite well.
Anyway. Trying your suggestions, but I can't really get a pure integrator/differentiator yet. I suppose I have to do something with proportional gain. 

Back to top



mosc
Site Admin
Joined: Jan 31, 2003 Posts: 17917 Location: Allentown, PA
Audio files: 149
G2 patch files: 60

Posted: Mon Aug 23, 2004 12:04 pm Post subject:



As for proportional gain  if you use the glide module, it will be the time constant that controls the integration time. If you want an integrator for very fast events, like audio waveforms from oscillators, then just use a filter.
An integrator is really a numerical moving average of the current sample, plus each of some previous samples up to N, which is basically the time constant of the integrator. If you integrate over 100 samples that is a time of 100 * Sample Rate. If you integrate over 1000 samples, that time constant will be longer by a factor of 10. You could make an integrator using an 8 bit shift register, or several hooked up in series. Add all of the shift registers outputs in a mixer. You need to attenuate each output by about 1/N where N is the number of steps in the shift register. That is a true integrator.
As an asside, if you vary the settings on those summing mixers, then you have an FIR (Finite Impulse Response) filter. The setting of each knob is what is called a coefficient of the filter. It is possible to build very small FIR filters with the G2 in this manner, but you'll run out of resources if you want anything serious. Still, this is a good way to experiment and learn about FIR filters.
As for the differentiator, the simplist one would be the current sample minus the previous sample. Thus, the output of the differentiator is the difference signal. Why is this a high pass filter? Imagine if the signal changed from +1 to 1 every sample. The output would be +2 and 2 every clock tick. Virtually the same signal. (You'd want to scale the output by .5 obviously so you won't overload you systems dynamic range. Now imagine a very low frequency, say a DC signal that is always +!. The output of this would always be 0. Extrapolate these two examples and you'll see that at high frequencies go right through and low ones are blocked.
A differentiator is also sometimes called an AC coupler becasue it will pass AC but block DC. 

Back to top



mosc
Site Admin
Joined: Jan 31, 2003 Posts: 17917 Location: Allentown, PA
Audio files: 149
G2 patch files: 60

Posted: Mon Aug 23, 2004 12:19 pm Post subject:



Here's a simple FIR filter. It's has 16 "taps". As you load it is is an integrator because all of the coefficients are equal. There is a Xfade module so you can easily hear the difference between the input and the output.
Experiment with changing the coeffients by change the settings on the 8 channel mixers.
This might be educational.
Description: 
screen scrape of simple fir filter patch. 

Filesize: 
57.07 KB 
Viewed: 
33684 Time(s) 

Description: 
Simple FIR Filter for educational purposes. 

Download 
Filename: 
Simple FIR.pch2 
Filesize: 
1.3 KB 
Downloaded: 
2181 Time(s) 
Last edited by mosc on Mon Aug 23, 2004 12:26 pm; edited 1 time in total 

Back to top



Blue Hell
Site Admin
Joined: Apr 03, 2004 Posts: 22858 Location: The Netherlands, Enschede
Audio files: 237
G2 patch files: 319

Posted: Mon Aug 23, 2004 12:22 pm Post subject:



Integration would be the summation of input values over time.
So a mixer will do the trick, the output has to be fed back into an input on itself that is maximally opened. The input signal can be fed into another input that attenuates quite an awfull lot (maybe an extra preattenuation will be needed) to avoid (almost) instantaneous clipping.
To make the integration process go slower the feedback could be sent through a sample and hold, the clock rate will then determine the speed (but it shoulld be set to at least twice the maximum frequency to be processed by it, otherwise nonsense will come out).
Note that this is still not a perfect integrator as 1) it clips, which it shouldn.t, yet it must. And 2) it's discrrete in time (and value) it should be continues. So its an approximation, but a better one than a low pass filter I guess.
I have to think a bit on differentiation, my first impulse is to say it can be done with the same circuit but setting the feedback to be negative instead of posittive, but I'm not too sure here, would need to refresh my math here ... ideas anyone ?
Remember that when experimenting with this using an oscilloscope that the G2 outputs have DC blocking, so to see if it works your signals should have reasonable frequencies, let's say 500 Hz or above.
Jan. 

Back to top



mosc
Site Admin
Joined: Jan 31, 2003 Posts: 17917 Location: Allentown, PA
Audio files: 149
G2 patch files: 60

Posted: Mon Aug 23, 2004 12:44 pm Post subject:



Here's a simple differentiator patch. Again, nothing special, just a learning device.
Description: 
screen scrape of differentiator patch 

Filesize: 
37.17 KB 
Viewed: 
33679 Time(s) 

Description: 
Differentiator for educational purposes. 

Download 
Filename: 
Differentiator.pch2 
Filesize: 
1.16 KB 
Downloaded: 
2298 Time(s) 


Back to top



Blue Hell
Site Admin
Joined: Apr 03, 2004 Posts: 22858 Location: The Netherlands, Enschede
Audio files: 237
G2 patch files: 319

Posted: Mon Aug 23, 2004 12:54 pm Post subject:



mosc wrote:  An integrator is really a numerical moving average of the current sample, plus each of some previous samples up to N 
All that follows is IMHO ... I have to go way back into the past for this ...
An integrator when fed with a short impulse on its input would exhibit a small DC jump at it's output and would not decay to zero. So a pure integrator does not have a finite imulse response ... am I right ?
A moving average OTOH does not have a finite impulse response (it's a leaky integrator, or a low pass filter), and (so) it can be modeled as a FIR filter (although to only make a moving average I think the (cheaper) circuit I suggested earlier can be used as well, only the sensitivity of the positive feedback must be reduced to below unity (again IHMO just according to the best of my rememberance)).
Question is, why would we need integration or differentiation ? I wanted it (integration) once as building blocks for filters ... any other uses for it ?
Jan. 

Back to top



cristian
Joined: Jul 15, 2004 Posts: 24 Location: Barcelona
G2 patch files: 1

Posted: Mon Aug 23, 2004 1:21 pm Post subject:



thanks Mosc and Blue Hell
thats really interesting stuff ... don't really understand a word of it right now, but will look at examples and ask some engineers down the pub..
I would be interested too, in what kind of potential there is for sound design using leaky integrators, FIRs etc.. What are the aesthetic results? _________________ www.nofuture.com 

Back to top



mosc
Site Admin
Joined: Jan 31, 2003 Posts: 17917 Location: Allentown, PA
Audio files: 149
G2 patch files: 60

Posted: Mon Aug 23, 2004 1:24 pm Post subject:



Blue Hell wrote: 
An integrator when fed with a short impulse on its input would exhibit a small DC jump at it's output and would not decay to zero. So a pure integrator does not have a finite imulse response ... am I right ? 
An impulse implies that the single goes up and then down. The Integrator would return to zero after N clock ticks. If the input was a step function, the integrator would ramp up to the maxium value, but it would take N clock ticks to get there. The slope of the ramp should be constant.
What can you do with these? Well, since we already have really nifty filter modules and the glide module, the answer isn't obvious  except for educational reasons.
Any ideas?
While we are still on this topic, an Infinite Impulse Response Filter (IIR Filter) doesn't sum the outputs of the shift register  it mixes them back in with the input. There is recirculation of the signal through the shift register. These filters achieve much more dramatic filter effects, but they are a bit tricky because they can "blow up"  something that can happen whenever you play with feedback. 

Back to top



jksuperstar
Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18

Posted: Mon Aug 23, 2004 1:59 pm Post subject:



Just 1 use:
You could use an integrator to detect how fast you are playing...by integrating the gate times for instance, or the times between each noteon. 

Back to top



