Showing posts with label Filter. Show all posts
Showing posts with label Filter. Show all posts

Friday, January 31, 2025

Filters clipping - current situation and solution

Edit: I've done a thorough testing of the situation here: 

https://atosynth.blogspot.com/2026/11/svf-clipping-and-fixes.html

and suggested fixes and tested them here:

https://atosynth.blogspot.com/2026/11/testing-filter-fixes.html

These fixes will be implemented on the 1.1.3 version of the Voicecard and onwards.

Filter clipping

All three filters clip but some are more extreme than others.

Juno clipping

The Juno filter has a major flaw, it has an output gain stage that clips for anything above 2V out. It outputs 2V from 10V in, which means that all resonance is clipped if it exceeds the max input signal.

JP6 clipping

The JP6 filter clips in the output selector/gain stage, but also slightly internally

Moog clipping

The moog filter clips the least as it has a fairly good soft clipping built-in. The output gain op amp still clips at extremes.


Fixes

I've worked a lot to find the best solution the last few days, and as such has come up with the following approach:

Bus mixer changes

Reduce amplitude from the bus mixer into the filters from max 10V to max 5V. This requires two changes:

- Double the input resistors to the wet/dry amps in the bus mixer, halving the output of the summer

- When turning on serial instead of parallel filters, disable input from sum B. 

- SVF must still somehow have unity gain, if not, chaining input will be too low.

This alone has a huge effect on most clipping, giving double the headroom. 


Reduce the post filter gain

Moog filter

For the Moog filter, this is simply done by using half the CV. It can be done in software for the current version. This stops any leftover clipping in the Moog filter.

Juno filter

For the Juno filter, we add a resistor to the output. This will end up in series with the 18k resistor in the post juno filter gain stage, and reduce the gain. A 22k resistor reduces gain from 5.5 to 2.5. This takes away most of the clipping, though the filter still clips when the resonance oscillation has the same frequency as the input signal. It does however require modification of the juno filter board. This requires some other mechanism, like soft clipping the signal. More on that later.

JP6 filter

For the JP filter, we need to keep unity gain through the filter, so we do the gain reduction in the output mixer. It does not prevent any clipping but is required to keep max levels the same as for the juno and moog filter. This is the simplest solution for now. 

 

Reducing JP clipping

Unfortunately, the JP filter clips very slightly at highest resonance at the point where oscillation is in sync with the signal. This is not easily changed as it happens inside the filter circuit, but it is also the least serious clipping. I will leave it as is for now. It also goes away if reducing the max input slightly, but requires at least another 20% reduction. Perhaps this is best done in software for now.

To prevent other clipping, we have to change the output gain that happens around the output selector. This can be done in two ways: 

- Changing the voice card. This is the correct solution, and should be done for future versions of the card. Gain for all but the BP2 cell is 100/65 = 1.54, so quite a bit of clipping can be removed here. We still may have to add some kind of soft clipping, though. If soft clipping is added, we may choose to reduce the input by the needed 20% and increase the output gain instead to get around the initial clipping.

- Making a drop-in-replacement for the IC56 DG408 mux that halves the output by adding more input resistors. Unfortunately, the maximum BP2 output is 8.6V, and this is followed by a 1.67x gain stage (IC52A) which immediately clips. This cannot be remedied by the card. Instead, we need to reduce the BP2 gain stage to unity by adding an output resistor > 39k (to make the sum of 56k + 3.9k + x = 100k) to the JP6 BP2 output. It may be possible to do with existing JP6 filter cards or we can order new cards with this modification, and use the current version with new voice cards.


TL;DR - these are the needed fixes

- Double the signal input resistors on the wet/dry mixer on the bus mixer board

- (fix the gain error on the bus mixer board)

- Reduce output amp gain for Moog, JP6 and Sines to 50% (in software)

- Set a max resonance for all filters to keep self resonance oscillation amplitude as low as possible.

 

To save the current voice cards

- Add a 22k resistor to the juno output boards (for this version).

- Double the Moog resonance CV somehow, possibly by adding a parallel resistor to the CV input to double the current.

- Create a drop-in for the DG408 JP output selector that reduces gain (and possibly adds soft clipping?)


For new version

- Replace the 18k juno post filter gain input resistor with a 39k one (or rather, move the post filter gain onboard the Juno filter PCB).

- Add soft clipping to the juno filter

- Fix Moog resonance CV on the moog board

- Update the circuit around the JP filter output selector to prevent clipping. May have to add soft clipping.


PS: Self oscillation with a very high frequency (>20kH<) makes what sounds like digital noise. Not sure exactly what to do with it, maybe a lower frequency output LPF would be a good idea.

PPS: There are a lot of weird things happening that may be caused by the ground plane noise from the waveshaper. 

PPPS: Knocking on the breadboard makes resonance wobble. I hope this is just poor connections but fear that some of the ceramic caps are picking it up. We'll see.

Sunday, February 11, 2024

FM and tracking

Just a quick thought about filter frequency modulation and tracking.

Since I've removed tracking-tuning and do CV lookup instead to get good filter CV tracking, FM may be an issue. 1V of exponential FM may not be 1 octave up anymore. 

However, I assume that the tracking across octaves will be pretty much stable, at least within the middle ranges. If for example +1V increases the pitch by 0.8 octaves (instead of the correct 1 octave), -1V should reduce the pitch by 0.8 octaves. This means that tracking correction can be done in the FM VCA. Also, this means tracking VCA should have a range > 0-5V.

As for linear FM, that changes the exponential converter's reference voltage and that is unaffected by the tracking pot anyway, so no issue there.

Tuesday, December 26, 2023

Stacking PCBs

To have enough room on the voice card PCB, I think I will have to stack at least the Juno and Moog filter PCBs on top of eachother. But I don't want to pay for double sided boards and I don't want to solder the connectors myself.

Here are some options that I've come up with. All of them requires the filter PCBs to be mounted with their parts facing downwards:

This is probably the best option. It has a clearing of 5mm between the middle and lower board, and 4.4mm between the top and middle. Further more, we can increase this to 5.9mm by not covering the whole connector of the middle board, this is necessary as the Moog board has some 5.7mm high capacitors.

It also has the smallest possible space needed on the bottom board, 1.28cm (at least if parts on the bottom board are not higher than 2.5mm). 


It would be possible to put the middle board closer to the bottom, but this only leaves 2.5mm for parts and we need more space without parts to be able to slide the card in. It does leave a lot of space between the middle and top though.

This is a slightly more stable version of the first, as it uses a double sided connector on both cards. This will however steal more than twice the space from the bottom board as we need a lot of space to slide the card into place.

Saturday, July 8, 2023

JP6 All-pass tested

I've breadboarded and tested the AP-filter from my all-pass simulation, version AP-C: https://atosynth.blogspot.com/2023/04/jp6-filter-allpass.html

It only required minor tweaks.

During testing, my BP outputs +/-3.5V and the HP/LP outputs +/-5.2V. I assume that BP is affected the same way HP/LP is by the resonance feedback, so adjusting feedback so that HP/LP are normally +/-5V probably also affects BP amplitude.

Anyway, to get AP we need to mix 2x BP with the inverted input. But the BP needs to be unity gain.

If we assume that unity gain is +/-5V when properly adjusted, it is 5.2 when HP/LP is 5.2. That means that to bring it up from 3.5V to 5.2V we need a gain of 1.48. The simulated circuit has a gain of 1.33 when using a 100k/33k combination. Replacing the 100k with 68k gives us the gain of 1.48 that we want. 

Here is a video of turning the cutoff CV knob, see how the phase changes.




The resulting circuit is like this:


PS: We need to sum everything BEFORE it reaches the filter as we need input both for AP and normal input. But this affects the polarity of the input and probably also the feedback circuit.

PPS: I am not sure how we can use AP/Phasing. Do we need to be able to pan wet/dry to different channels? Should this be an option anyway for filter outputs?


Update: Here is an alternative circuit, the AP output phase is 180 degrees different from the one above but it saves one op amp that can be used to sum stuff before the filter



Sunday, June 11, 2023

JP6 vs Jove revisited

As part of getting my JP6 filter working, I thought it would be a good idea to revisit the Jove JP6 filter (https://system80.net/product/jove/, https://github.com/minisystem/JOVE) to compare it to what I'm doing. It is especially interesting to see how the control signals differ, and what their ranges are.

The conclusion is that everything is very similar and my control signals cover the Jove signal ranges - but it is worth mentioning that the cutoff maxes out at around 23kHz on the Jove.

Here are my findings in detail:

Resonance

My simulation doc says the following about calibrating resonance CV:

Tune U30 until you get -125uA Reso I_abc per OTA (or to freq response is OK)

Tune U31 until you get -25uA or -4uA Reso I_abc per OTA (for similar response to 5 or 10V CV on the JP6)

Comparing to the Jove reso circuit, this is exactly what you get from trimmer extreme, -120uA to -4.2uA, so a range of -120uA to 0uA is what we want to be able to trim from software

In the following, the three lines correspond to min, center and max trimmer settings:

Jove resonance - voltage seen at expo converter input

Jove resonance 0-10V - I_abc in single 18k resistor


Jove resonance 0-5V

Jove resonance 0-5V, center trim only

Jove resonance response, 0V but trim min center max


Jove CV response 0, 5 and 10V CV

My own JP6 filter resonance I_abc. It has the same range as the Jove one but is of course not exponential, as this happens in software instead.

My resonance CV circuit

The Jove resonance circuit



Cutoff

Untrimmed, Jove maxes out I_abc at -600uA with a CV of 7V approx.

This gives a cutoff of around 20-25kHz.

The lowest current is -15.6nA


My trimmed version gives 169nA to 1.06mA, max is at approx 6V CV which gives a cutoff at 25khZ, similar to the Jove.

Jove expo converter input vs input CV

Jove I_abc in single 18k resistor

Jove I_abc for center only, shows max I_abc at approx 7V

Jove cutoff with CV 7.5V (center trim)

My version, I_abc from 0-10V CV

My version cutoff at around 6V CV


Buffer

Jove uses a transistor (J112, N-channel FET) as a buffer, with a 33k to gnd. Replacing the opamp buffer in my circuit with a nmos in the simulation gave a slightly lower gain out. Changing the 33k to 22k or 47k didnt affect the amplitude. 


Input vs output of first cell using op amp buffer


Input vs output of first cell using nmos-buffer

N-channel Mosfet buffer, pretty similar to what the Jove uses








Sunday, April 23, 2023

JP6 filter allpass

 Since breadboarding the first cell of the JP6 filter was successfull, it's time to revisit the allpass circuit. I sort of got this working in an earlier post: http://atosynth.blogspot.com/2019/01/jupiter-6-all-pass-filter.html, but had to remove resonance feedback it seems.

I tried the same circuit in LTSpice again, mixing Bandpass output with the input tapped after the input mixer. It gives a nice phase change but the response is -10dB for the "normal" case, up to 4dB at the cutoff frequency, not very usefull. 



I then realised that mixing with the input may refer to the original input, not what is seen after the mixer. However, the input at this point is inverted, so we don't get the phase reversal effect we're looking for

NB: Not original BP but unity gain one


This is easily fixed by inverting with unity gain. Now we're talking. We get a flat response with a -6dB notch and the phase reversal we're after



I started thinking that this could be the best option, but the notch made me uncertain. After a bit of googling, I once again found the multimode filter pages at electricdruid. There, the following is stated: 

"Phase shifters produce a notch in the frequency response by mixing this phase-shifted signal with the input, so technically they’re a type of notch filter." 

Ok, so a notch is to be expected. I then found the link to "Craig Anderton's Multiple Identity Filter" article. I thought for a moment this confirmed my -6dB notch as it says -6dB notch at the end, but I mixed up notch and allpass. It is worth a closer look though.

But then I realised, what if I make sure BP output is the same as HP/LP etc, though my non-inverting amplifier, just as I did with the BP output from cell 1?

That works great!



The closeup doesn't look that great until you look at the axis. The input is just very slightly attenuated (-170mdB). Looking at all combinations together shows that it is essentially flat:

Red line is unity BP + inverted input



Now, this is great news. Of course this is just a simulation, and as I have seen earlier, the actual result on the breadboard is different, but I think I have the best starting point at least - mix the inverted input with the unity gain BP and we get a good all pass version!

Saturday, April 15, 2023

JP6 filter debugging, part 1

 Trying to breadboard a single cell of the JP6 filter. Here are my mods:

Errata:

R to -12V in cutoff CV input is 3.9R, should be 390k

op amp + and - are mixed up in cell input mixer

Modifications:

Skipping the part of reso generator that reverses CV, and leave out trimmers in reso circuit.


I inject resonance CV at reso gain 2 to bypass the inversion, and leave the reso bal unconnected. This makes reso CV go from 5 to 0 instead of 0 to 5. I use a 27k input resistor. (TODO: Why did I do that again? plot in simulation looks good at least. Probably what it was set to before removing the CV reversing and stuff in LTspice).

The cutoff CV mixer has an error (3.9R instead of 390k to gnd), so instead of using it i use the reso input mixer and a 330k to -12V on the input, still leaving balance floating. I then connect the output to a 20k trimmer, set at approx 6k (8k really, but in simulation it is 6k) and connect the output to cutoff track 2, bypassing the cutoff CV mixer.

Reso CV is set to 5V by using a resistor divider - 100k on top and 68k + 3k3 = 71k (should have been 71.4k).

Input to the cell: The input mixer is fucked up here too, I flipped it so + and - are mixed up. I use an external op amp instead, with a 33k feedback and a 100k input resistor. The output is fed to the in+ (pin 2) of the cell.

NB: SOMETHING IS MISSING HERE! pin 4 should be connected to pin 2. Anyway:

Now I can see that all three modes working - LP, BP and HP, though the input is weak and BP never really cuts off much. Next up is re-adding pin 4:

Aaaah, much better!

This time output at LP/BP/HP works. BP has a very soft cutoff slope but it DOES attenuate both above and below somewhat.

With 3.6k input with 5V max amplitude and cutoff CV at 0:

HP outputs 7.1V, BP around 750mV,  LP at -150mV


With 100Hz input, cutoff at 5V:

HP outputs -30mV, BP around 650mV and LP 7.6V

With 100Hz input and cutoff at 0V:

HP and LP are less, BP is at its max, which is 3.5V

Filter sweep, CV 0 to 5V, 1kHz input:




Reso is not tested but at least cutoff seems to work fine :)

HP and LP outputs max out at almost the same level (7.1 to 7.6V) while BP is half of that. In my simulations it looks more like HP and LP are 5V max while BP is around 3.5V.

The fact that BP has a lower amplitude is to be expected. Looking at a simulation, we can see that the bandpass peak (purple) is where the HP (red) and LP (green) meet, as it is really just a combination of the two filters.


If we want to avoid a loudness drop when using BP, we can amplify the output slightly. In this case I've added a non-inverting op amp with a gain of 1 + 33k/100k = 1.33. The result is the blue line above and below.

An added bonus is that we can use the same input resistor (56k and 100k here) to the second cell (we could do this without the gain as well, it only leaves the BP at the low level). We can also tap all filter types after the mux and move the resistors to the mux output.


Update: Tried using a 27k resonance CV input resistor and the 1.33 gain BP op amp, turned out very well. I think I can get away with a single 56k + 100k resistor now.

I also tried the notch circuit, which works as it should.

An interesting thought:

What if we just skip the varying resistors and just make up for it in the VCA/gain section? 



Next up: 

Figure out if we should have the mix resistors before the cell 1 output mux or after, what gives the least amount of noise

See why we tap direct output after mux but before 100k res, shouldn't tapping be before the output resistors? or do we need to buffer the signal between? (Note: The JP6 uses this layout, with one 56k from HP and one from LP, and adds this to the 100k input, effectively using 156k input to the summer of cell 2). 

Check output polarity from cell 1, including notch.


Tuesday, March 28, 2023

JP6 filter resonance CV

I'm testing the component based JP6 filter on a breadboard. I have some initial problems getting it to work, but then I realised that resonance is probably turned up way too high.

This made me take a look at how I generate the CV and how it affects the circuit.

This is the current circuit. The reason it is so large is that the resonance works backwards, feedback is needed to stop resonance rather than introduce it, so the CV is inverted from 0-5V to 0- -5V, then moved up 5V to get the correct response: 


Measuring CV vs I_abc/V_abc/V_collector. NB: For +/-15v supply
CV (V)I_abc (uA)V_abc (V)V_tran (V)
0-126.0-13.38-12.11
1-101.7-13.39-12.37
2-77.0 -13.40-12.6
3-52.0 -13.42-12.9
4-27.5 -13.46-13.18
5-2.7 -13.58-13.55



I have noted in my simulation that the CV must increase rapidly and then slow down, which means that I will have to manipulate the output from the synth matrix. In that case I may just as well just invert it while we're at it, so 5V is no reso and 0V is max. That really simplifies the circuit. Also, just using a 20k resistor at the input seems to work fine though it needs testing. In that case I reduce the number of trimmers needed by two, which is really good.


Measurements again - the results are similar to the previous ones, just reversed

CV (V)I_abc (uA)V_abc (V)V_tran (V)
00 -14.3 -14.28
1-24.8 -13.46-13.2
2-49.5 -13.42-12.9
3-74.3 -13.40-12.7
4-99.0 -13.40-12.4
5-123.8-13.38-12.14

It is interesting to note that the max current is so low (125-ish uA). It probably means that no change to the R_abc (which is 2 x 10k now) when switching to 12V supplies, though that has to be tested.

Thursday, March 2, 2023

Frequency modulation

While testing filter FM I realised that I needed to know a little bit more about what is actually going on, so here we go. I'll explain things using VCO frequency modulation as it is a bit more intuitive, but the same happens with filter FM.

Linear FM

In linear FM, the change in Lin FM CV is directly propotional to the change in frequency. For example, if a 1V increase in Lin FM CV leads to a 200Hz increase, a 1V decrease leads to a 200Hz decrease - as long as the base frequency set by the (1V/oct) Pitch CV stays the same. 

In other words, if the initial frequency is 440Hz, the output should be between 240Hz and 640Hz. What we hear is close to the average of the two extremes (this moves into the field of psychoacoustics apparently, so this is not an exact science or at very least not something I'm proficient in). The average here, at least with a symmetrical waveform, is 440Hz, so the output stays in tune as we increase/decrease the CV.

BUT: Once you change the Pitch CV, 1V no longer corresponds to a 200Hz increase. However, increasing and decreasing the Lin FM CV will add or subtract the same number of Hz so the average stays the same as the base frequency. Also, the relationship between the modulated frequency in both cases to the base frequency stays the same.

For example - if a 1V Lin FM CV adds 200Hz when the base frequency is 440Hz, adding 1V will add 400Hz (one octave up) when the base frequency is 880Hz (one octave up), and 100Hz (one octave down) when the base frequency is 220Hz (one octave down). 

Linear FM stays in tune both as we change the FM CV and the Pitch CV, as long as the modulated frequency does not reach either 0Hz or the upper limit of the VCO pitch or filter cutoff.

Linear FM is usually implemented by modulating the reference current in the exponential converter.


Exponential FM

With exponential FM,  we modulate pitch as "semitones". If we use a 1V/oct input, and FM CV is, say, +/- 1V, frequency will go between +1 and -1 octave of the original frequency. For example, if the original frequency is 440Hz, the modulated signal will go from 220Hz to 880Hz.

What is the effect of this? Well, what we hear is not the original 440Hz tone, but again closer to the average of the two extreme. In our case this means 220 + (880-220)/2 = 550Hz

If we drop the original pitch by an octave to 220Hz, we would expect an output between 110 and 440Hz. The average is now 110 + (440-110)/2 = 275Hz, which is one octave down from 550Hz. In other words, the modulated output tracks the original pitch.

But what if we change the FM CV? If we go from +/-1V to +/-2V but keep the original frequency at 440Hz, we would now get a range of +/-2 octaves, or from  110Hz to 1760Hz.

The average of these is 935Hz, whereas for the +/-1V FM CV it was 550Hz. The perceived pitch increases. Similarly, if we decrease the CV the perceived pitch drops. As long as the CV range stays the same we're good though.

Exponential FM is usually implemented by mixing the FM CV with the normal V/Oct CV.


Through zero modulation

An exponential FM will always halve the cutoff frequency for every 1V decrease of CV. This means that the cutoff frequency will never reach zero.

For linear FM however, which controls the reference current in the exponential converter, cutoff WILL reach zero. 

Through zero modulation means that we detect when the CV changes polarity, and (at least for a VCO) reverse the polarity of the output. The frequency should be the same as for a positive CV of the same magnitude. In other words, we use the absolute value of the CV for frequency, and the sign to control the output phase. I am not sure how this will work for a filter but it will be interesting to test.

A bit of maths for the linear FM case

The output current of the exponential converter, which linearly controls the VCO pitch, is defined as

I_c = I_ref * e^(-V_b/V_T)

where -V_b is the exponential CV presented at the exponential converter (scaled down from 1V/oct)

Let's call E = e^(-V_b/V_T), giving us

I_c = I_ref * E

Now, say we increase I_ref with a current I_linfm that is 50% of I_ref. We now have that

1.5 * I_ref * E = 1.5 * I_c

In other words, we increased the pitch by 50%

The absolute increase in I_c is 0.5. 


Now, let's double E, going one octave up

I_ref * 2 * E =  2 * I_c

Again, we increase I_linfm by 50%:

1.5 * I_ref * 2 * E = 1.5 * 2 * I_c = 3 * I_c

We have still increased the pitch by 50%, but this time the absolute increase in I_c is 1. In other words, doubling E doubles the effect of changing I_ref. 


Substituting with numbers: Let's assume that E gives us an I_c that produces 440Hz

increasing I_ref by 50% would then produce a 1.5 * 440Hz = 660Hz wave. The change in Hz is 220.


If we double E without changing I_ref, we get an 880Hz wave.

Now if we increase I_ref by 50%, we get 1.5 * 880Hz = 1320Hz. The change in Hz is 440.


Comparing the two, we see that an increase in E makes a change in I_ref span more Hz. We also see that the relationship between the changed pitches - 660Hz and 1320Hz (2x, or one octave between), is the  same as the change in E.


Some sources

https://ask.video/video/fm-synthesis-explored/3-3-exponential-vs-linear-vs-thru-zero-fm

difference between linear and exponential applications: https://modwiggler.com/forum/viewtopic.php?t=52340

Exponential FM vs linear FM: https://gearspace.com/board/electronic-music-instruments-and-electronic-music-production/1100357-exponential-fm-vs-linear-fm.html

Understanding the Differences Between Exponential, Linear, and Through Zero FM: https://learningmodular.com/understanding-the-differences-between-exponential-linear-and-through-zero-fm/

Adding through-zero lin fm to CEM3340:

http://jhaible.com/legacy/tonline_stuff/hj2vco.gif

http://jhaible.com/legacy/tonline_stuff/hj_modul.html

SSI2130 VCO with TZFM

https://www.soundsemiconductor.com/downloads/ssi2130datasheet.pdf

SSI2130 TZFM control circuit


The SSI2130 has built-in time reverse that changes the direction of the waveforms. This little circuit both outputs the absolute value of the lin freq FM and a control signal for the direction control ("time reverse")

Tuesday, February 14, 2023

Filter CV range calculations

Update: I've used 17.9mV throughout this post as the V/oct input to the exponential converter. Not sure where I got this number from, but in my posts on temperature compensation I use 17.5mV per octave at 20C. The change in range per degree is approximately 60uV. This places 17.9V 0.4mV or 400/60 = 6.67 degrees up, at 26.67C. I've recalculated things and it doesn't really change anything except for the tracking so I've left this post as is. 

Now here's the fun part of the last post :-) 

I did a quick measurement of the input CV to the exponential converter.

For an output of 150nA we need an input of 72mV

For an output of 1.16mA we need an input of -149mV


This means we have a total range 231mV. With the expected 17.9mV/octave this covers 12.9 octaves. If we want to cover 14 octaves, we need 17.9 mV * 14 = 250.6mV.

It looks like 14 oct may be hard to achieve in practice, as < 150nA will give an output that always attenuates, and one additional octave when we're at 1.16mA would need 2.32mV which is much more than the max we're able to generate. But for the sake of this discussion, let's go for a 14V range, starting at 72mV.

We then want to add +/-3 octaves of tuneability, to cover temperature changes and parts differences. Normally, these 3 octaves will be useless, but being able to change the input voltage by a similar amount will give a voltage at the expo converter that is +/- 3*17.9mV.

To cover this, the range seen at the expo converter should have a range of 17.9mV * 20 = 358mV. It should start at 72mv - 3 * 17.9mV = 125.7mV and go down to -232.3mV

We know that the maximum output of the CV summer is around +/-10V with +/-12V rails. That means that if we set -10V out of the CV summer to end up as -232.3mV, we need an 1/43 attenuator.

Selecting a nice and round number for the attenuator, 1/40, we would need -9.25V in to reach -232.3mV

That would put the top voltage at 5.03V, giving a range of 5.03V - -9.25V = 14.28V

ok, so that is the MOST we can do. But let's pick a number that is easier to work with. Let's restrict the output of the CV summer to a range of 10V. Having a 0-5V CV input (that should cover 20 octaves) means we can use a -2x gain, that's pretty neat.

So, with a 10V range in, and a 358mV range out of the voltage divider before the expo converter, we need a 10V/0.358V = 27.93 attenuation. We already have a 560Ohm tempco at the bottom of the divider. Picking a 15kOhm resistor at the top will give us a 27.78 attenuation, that's pretty close - it gives 360mV out for 10V in.

Applying this to the original output values gives us:

Needed input top: 125.7mV * 27.78 = 3.49V

Needed input bottom: -232.3mV * 27.78 = -6.45V


So - we need a circuit that produces a 0 to -10V output from a 0-5V input, and then offsets that output by 3.49V

We already know that the first part is achieved by a -2x gain. Using a 100k feedback resistor we could use a 50k input to achieve that.

For the 3.49V we connect a resistor to -12V. The gain has to be 3.49 / -12 = -0.2908. With a 100k feedback resistor we thus require a 344k resistor. 

The nearest standard value is 330k or 360k if using a more fine grained scale. Using a 360k resistor will give a gain of 100 / 360 = 0.278 and an output of 3.33V. A 330k resistor gives a gain of 100/330 = 0.303 and an output of 3.64V. Let's go for the 360k first, just because -3.33(3333)V is such a nice number. The range at the input is now 3.33333V to -6.666V (mmmmm!).

Converting back to the output at the expo converter, we get 3.33/27.78 = 120mV and -6.66/27.78 = -240mV. 

If we instead go for the 330k resistor, it would set the range at 3.64 / 27.78 = 131mV to -6.36 / 27.78 = -228.9mV

Now, none of these cover the entire range we originally wanted. The 360k resistor is 5.7mV away from reaching the lowest point, the 330k resistor is 3.4mV away from the highest point. The worst offset is thus about 0.31 octave away from our intended range. As we have 3 octaves to work with in both directions, I'd say both options will work.

Backtracking a bit more, we get that our new range, 360mV (for the 360k resistor, or 359.9 for the 330k resistor), covers 360mV/17.9mV = 20.11 octaves. That's fairly accurate without any kind of tuning, which is a very good starting point!

To sum it up:

Use a 50k resistor between CV input and the negative op amp terminal

Use a 100k feedback resistor

Use a 330k resistor between -12V and the negative op amp terminal

Use a 15k resistor on top of the voltage divider (connected to the op amp output)

Use a 560R resistor to ground at the bottom of the divider

NB: 15V/-15V supply is really 12V/-12V, I just couldn't be bothered changing the labels.

Update:

When using 17.5mV the range is instead 124.5mV to -229.5mV. 20 octaves would be 350mV. Using a 0-10V input to the resistor divider would give perfect tracking for a 28.57 attenuation, which would require a 15.44k resistor on top.

If we keep the 15k resistor we will get 0.486V/octave instead of 0.5 at the input. It doesn't matter too much as we have a lot of tuning range, though we COULD combine a 15k and a 470Ohm resistor if we wanted to.

Now it's time to test this. Quick Batman, to the LTSpice-mobile!

(We have one last issue to tackle though, temperature compensation. But let's not spoil the fun yet!)


Edit: testing

Red: CV input, Blue: CV summer output, Green: I_abc

My calculations are correct. I see a 3.64V to -6.36V output after the CV (With a 330k offset resistor). 

The voltage at the expo converter is 130.87mV down to -161.3mV, after that it flattens out meaning we've reached the limit of the converter at its 25C state (we needed it to reac -149mV for a 1.16mA current so that's ok). This happens when CV is 4.44V btw.

I_abc is 15nA to 1.28mA.

Light blue: expo converter base voltage, Green: I_abc

We do see a bit of non-linearity when the expo converter base voltage reaches around -122mV (CV is around 3.6V). Not sure what is going on there, I saw the same thing with the unchanged circuit. It would mean that the last octave (-122mV to 149.9mV) is not tracking properly, though this either should not be a problem because it is so high anyway, or we have a bit of room to calibrate it out. 

Frequency response

I did some fairly manual frequency response measurements, plotting the filter response for various CVs and reading the -3dB cutoff frequency. It's not entirely accurate but gives a good indication:

CV: Frequency

0.75V: 3.48Hz (oct 0, but never gets above -2.2dB)

1.00V: 8.6Hz (oct 1)

1.25V: 17.9Hz (oct 2)

1.50V: 36Hz (oct 3) "Baseline" for expectations later

1.75V: 74.33Hz (oct 4)

2.00V: 150Hz (oct 5)

2.25V: 304Hz (oct 6)

2.50V: 606Hz (oct 7)

2.75V: 1.21kHz (oct 8)

3.00V: 2.34kHz (oct 9)

3.25V: 4.47kHz (oct 10)

3.50V: 8.20kHz (oct 11, expected 9.2kHz)

3.75V: 14.1kHz (oct 12, expected 18.4kHz)

4.00V: 22.34kHz (oct 13, expected 36.8kHz)

4.25V: 32.8kHz (oct 14, expected 73.7kHz)

4.50V: 41.9kHz (additional octave, highest reachable cutoff)

As we can see, tracking is quite accurate from between oct 1 and 2 up to between octave 10 and 11. We will be able to tune in 40kHz as well, with an additional 0.5V CV (=2 octaves) left for temperature compensation etc, meaning we can get a workable 4Hz to 40kHz.

PS: Since it looks like the most compensation is needed at the top range, we could perhaps go for the 360k shifting resistor option instead, it will shift everything up by about 2/3 octave and allow more calibration on top.


Temperature compensation

We're using a 560Ohm tempco. Let's see what PPM rating it should ideally have. Now, tempco values are usually defined with a 0% change at 25 degrees. At 25 degrees, we would expect the expo converter to need 17.5mV + 5 * 0.06mV = 17.8mV per octave. Let's calculate the necessary input voltage:

V_in * 560 / (15000+560) = 0.0178V, V_in = 0.494V

Now, if the temperature rises by 10 degrees, we would need 17.8mV + 10 * 0.06mV = 18.4mV for the same change. To keep the CV input equal, we see that

0.494 * x / (15000 + x) = 0.0184V

x = 580.32Ohm. In other words, the resistance needs to change by 20Ohm or 0.5Ohm per degree.

From my previos work I have that

560 * (1 + x * (10^-6)/10) = 580

x*10^-6 = 580/560 - 1

x = (580/560 - 1) / 10^-6 = 3571

Which should mean that the resistor should have a 3571ppm/C temperature coefficient.

The ones I have, Vishay Linear PTC, TFPT0805L5600FV (684-1021 from RS components), are nowhere near this. They are 4110+/-400 ppm/K, and a simple example says they are expected to be 560 * 1.042 = 583.52 at 35 degrees. The worst case scenario should be 1.046, = 585.76, let's round to 586. While this may not be good enough for a VCO, I think it has a fair chance of working for a VCF. Let's calculate.

The output of the voltage divider at 35 degrees should be near

0.494V * 586 / 15586 = 18.57mV, or 0.17mV off from what we expected.

At 35 degrees, a semitone is 18.4mV / 12  = 1.533mV. 0.17mV equals 11cents of error. Over a 14 octave range, the accumulated error will be 155 cents or 1.5 semitones. 

If instead the temperature rose by 25 degrees to 50C, the resistor should be at 1.110 * 560 = 622Ohm. The needed output would be 17.8mV + 0.06 * 25 = 19.3mV. The output from the divider would be 19.67 or 0.37mV off, equaling 24 cents, and over 14 octaves 338 cents, equaling 3.5 semitones.

Without temperature compensation

To get a better understanding of what we are up against, let's see what the offset looks like if we don't use a tempco.

Starting again at 25 degrees, we know that 0.494V in gives 17.8mV out.

But then, at 35 degrees, it STILL gives approximately 17.8mV out, while the exponential converter needs 18.4mV. We have a 0.6mV error instead of the 1mV we would get with the tempco.

Over 14 octaves that accumulates to 8.4mV or 5.5 semitones - or almost half an octave. This is for a 10V change. If the change is more drastic, say 25 degrees, the error will be 0.06 * 25 = 1.5mV/oct for a total of 21mV, or 1.14 octaves. As we have a +/-3 octave tuneability, this should also be within reach. We would, however, need to know the temperature!

Keeping multiple VCFs tracking

With a tempco in place, and assuming that it is somehow affected at least not too much differently than the internal temperature of the expo converter, and also assuming that the VCFs won't drift THAT much from each other in terms of temperature, say +/-5 degrees, we COULD see as little as 0.38 semitones difference (given all VCFs are tuned to the middle freq, we would see a +/-7 oct range to drift in). This would not be perceptible in terms of cutoff but perhaps for resonance. 

WITHOUT the tempco, we have different option - measuring temperature and keeping several lookup tables. Apparently, this is what some Sequential synths do their VCO calibration, making them playable without warmup. 

We would however need a temperature sensor close to the expo converter. It is an exciting thought and I should definitely explore it further, especially seeing as thermistors are hard to get, expensive (2-3USD per chip) and have to be manually soldered.

It may even be an idea to use a temperature sensor for tuning the filters even with the thermistor in place...

A thought about tuning

I started wondering about how to best tune the cutoff. We can send a sine-like wave and see how it is attenuated. This will work up to the maximul DCO frequency which is something like 20kHz, but above that, in the most troublesome territory, we have no built-in source (though we could possibly use a VCO, but they are themselves not completely stable).

But we DO have resonance. If the resonant frequency is directly and proportionately related to the cutoff frequency, could we measure the resonance wave (e.g. just frequency counting) instead?

Monday, February 13, 2023

Tuneable filter with 14 octave span

I intend to make the juno filter tuneable in software. To do this, I hoped to add a 20 octave range to the CV and just use that. But simulating the filter gave a few surprises:
- when using a 25k input resistor to get 20 oct range, the output of the initial op amp exceeds the rails, so it will clip.
- the maximum cutoff for the filter at the current implementation is around 48kHz
- Below 7-ish Hz the filter acts like a band pass filter so the input is always attenuated, meaning lower frequencies are not possible.

Now, the two last facts are not a big problem. They happen on the filter side of the exponential converter, which is not as temperature sensitive so range hopefully won't change that much with temperature.

The expo converter however will change a lot, meaning the input needed to get a certain output will not stay the same. THIS is where we need to apply tuning relative to temperature.

So what I need to look at is the circuit before the expo converter transistor pair. I need to make sure that THAT can go above and below what is needed for control at 25 degrees celcius. To do this I've started out mapping out what currents into the filter core gives what cutoff. Here is a short table:

2mA = 47.2kHz
1.5mA = 45kHz
1.2mA = 43.5kHz
1.1mA = 42.5kHz
1.0mA = 41.5kHz
0.8mA = 38.6kHz
0.7mA = 36.5kHz
0.6mA = 34.2kHz
0.5mA = 31.3kHz
0.4mA = 27.3kHz
0.3mA = 22.5kHz
0.2mA = 16.3kHz
0.1mA = 8.7kHz
50uA = 4.4kHz
25uA = 2.23kHz
12.5uA = 1.11kHz
6.25uA = 553Hz
3.125uA = 274Hz
1.56uA = 136Hz
781nA = 67.4Hz
390nA = 33Hz
195nA = 16Hz
97.7nA = 7.64Hz
48.8nA= n/a, alltid under -3dB

So... from around 100nA and up to 0.2mA, the tracking seems to follow the rule of doubling the current = double the -3dB cutoff point. After that it falls off a bit. I think that a range of approx 4-40kHz is fine, that's about 13.5 octaves. 

That means that the input range we're looking for is about 100nA to 1.2mA. Next up will be looking at the circuit as it is and see what the input to the expo converter is at these currents. Then I'll see if I can change how the circuit works to allow the input to go lower and higher than this. At a stable 25degrees this won't have any impact (it simply won't work), but it will allow us to correct for changes later. Maybe.

A bit more testing

I did some more measuring and calculations today. First of all, I calculated the necessary resistor to get 1V/oct response. The Juno uses a resistor voltage divider with a 560Ohm tempco at the bottom. To get 1V in = 17.9mV out (17.9mV is the magic number for expo converters at 25C), the top resistor needs to be 31.745k to get perfect tracking. In the current design this is achieved by a 20k multiturn pot combined with a 10k and 8k2 resistor. 

In the 12V version of the filter, we have a few issues.

Without any changes, Iabc tops out at 1.07mA. We need at least 1.16mA to reach 40kHz.
Allowing a 20V input (or rather, changing to a 25k input to get 20 octaves from 5V input) will not work as the cv input opamp output will hit the low power rail (-12v) before going all the way.

So, what can be done:

1) By switching the 10k input resistors on the LM13700 Iabc inputs for 8.2k ones, we get a max Iabc of 1.3mA

2) By decreasing the top resistor in the resistor divider, we can get a response that is lower than 1V oct, for example 0.8V/oct. This means that the range output by the cv input summer can be within the power rails. 

I did some inital trials without calculating too much. For easier reading I use a 0-20V CV input with a 100k input resistor. Swapping R34 with a 5k (reducing the top resistor by 5k) and replacing 10k Iabc resistors with 8.2k, I get a CV AFTER the summer that goes from 6 to -10V (at 15.6V input). The Iabc response goes from 25nA at 0V to 1.3mA at 14V. 150nA, which we know from earlier is about the lowest we need, is output at 2V input. 

20V CV input and around 0.8V/oct tracking. +/-12V filter

Red: CV input, Green: Voltage after summer, shows saturation at around 16V CV. Blue: I_abc, tops out when CV is around 14V.



This means that our useable range is around 12V, from 2V to 14V, and that we have around 2V above and below this. We already have a fairly useable tuning range.

So, what should I do next?

Given 20V in and 100k input res (will be changed to 5V/25k)

1) Find the range we need for 14 octaves (150nA to whatever)
2) Find a gain + resistor divider that puts 3 V in at 150nA and 17V in at whatever is needed for 14 octaves up.
3) Input summer must not saturate, eg. stay within +/-10V output for the full range.

This will be fun!

BUUUT. What about the tempco resistor? Will it still adjust itself correctly when the top resistor is no longer the same? Well, that needs to be checked. 

And for later: At what input audio does the filter start to distort?

EDIT: Input to expo conv: 72mV in = 150nA out, -159mV in = 1.16mA out

Sunday, February 5, 2023

High frequency filtering in audio output

One thing that I've put off for a long time is selecting filter caps for various op amp output drivers. 

Today I had a look at some datasheets to figure out what others are doing. 

Generally, it seems that filtering (by putting a cap in parallell with the feedback resistor in an inverting op amp) is only done at the last stage of the circuit, not within the circuit itself. It seems that very little filtering is done except for biasing using electrolytics in the audio path to center the signal. I assume the final filtering is just to stop radio frequencies, stuff that we don't want to escape the circuit perhaps?

Here is what I found

Self on audio (book) page 237: 100pF/4k7 = 339kHz

Self on audio (book) page 359: 27pF/10k = 589kHz

JP8 source mix: 10p/100k = 159kHz

JP8 VCA cont 15p/100k = 106kHz

Juno 6 out: 47p/3k3 = 1.02MHz - See juno 60 where the 3k3 is actually crossed out in the schematics and 27k written instead.

Juno 60 out: 47p/27k = 125kHz

Juno 106 out: 22p/33k = 219kHz - Interestingly enough, and supporting of my theory that filtering only happens at the last stage, the 106 has the same feedback resistor as the Juno 6 (3k3) right after the filter, but no cap, as it has a mixer at a later stage too, mixing in High-pass filter.

JX-3P out: 330p/10k = 48kHz

JX-8P synth mix: 100p/47k = 33.8kHz

JX-8P chorus: 100p/22k = 72kHz

THAT4301 reference: 47p/20k = 169kHz

Sooo, I can't say that the findings are exactly conclusive. Before starting this research I suspected that the cutoff would at very least be above 22kHz (being the upper limit of human hearing) and perhaps at least the double as we want to make sure to not remove anything wanted. Most of these results seem to support that, with roland ranging from 33kHz up to 219kHz (disregarding the Juno 6 which seems to be too high). I'd say somewhere between 100 and 150kHz is probably a nice compromise.

Now, I started looking at this to find a good cap for my distortion circuit, which has an output feedback resistor of 120k. Playing around with various caps and looking at the output of the scope, it seemed like 10p would give a result where frequencies up to 22kHz did not get much attenuated. Calculating the cutoff using 120k/10p gives 133kHz which incidentally fits nicely between 100k and 150k.

That said, as the distortion is in the middle of the circuit, I may as well skip filtering alltogether.

Sunday, January 30, 2022

Big Bug Weekend

This is another one of those not-too-exciting posts, but one that sums up a lot of stuff I've done over the weekend.

Filter

I started off with work on the filter. As mentioned in the previous post, it now tracks the keyboard. I also added a filter envelope, but envelope amount is still missing.

I then did some quick calculations on the consequences of using +/-12V instead of +/-15V.

First of all, the filter cutoff mixer has a 270k resistor to V-. It raises the initial cutoff frequency by 5.55 oct with -15v, and 4.44 oct with -12V. Similarly, we have a trimmer between +/-V which lets us trim the same range. We do lose some range when reducing from 15 to 12V, but I have not yet tried trimming the filter so I'm unsure if it's an issue.

Second, the reference current in the cutoff exponential converter uses a 1M5 res to -15V to generate a 0.01mV current. This will now be 0.008mV, and it linearly offsets the cutoff frequency. This can be trimmed away using the cutoff and tracking trimmer, but again I have not tried to do this.

Third, the dead bands for resonance and VCA, e.g. the minimum voltage needed to start changing the params, will change slightly - from 12mV to 12mV for resonance, and 10mV to 8mV for the VCA.

All in all, the filter will probably work well though it needs a bit more testing.

DCO

I decided to get the second DCO going yesterday. I had to find and set up my windows computer, but other than that programming it went without issues. I decided not to try to figure out more about why it outputs 5V instead of 10V at the moment, as I was simply too tired to look at the code. UPDATE: It is because the 3.3Vref combined with using a 22k load on the DAC actually turns it into a 0-2.5V range instead of 0-5, so the charging current is half of what it should be)

DCO calibration

I did however look into how to fix the calibration circuit. The DCO uses its Vcc as a reference when trying to calibrate wave amplitude, and also for detecting "overflows" when pitch changes.

The PIC16F18346 has an internal 6bit DAC which in my case uses Vcc as reference. This has been set to 26/32 * Vcc for calibration and 27/32 * Vcc for overflow detection. 

When Vcc changes from 5V to 3.3V, calibration threshold goes from 4.0625V to 2,68125.

The onboard calibration circuit is simply a resistor divider with a 100k and 68k resistor. It divides a 10V input down to 4.048V, so by using the 4.0625V threshold we should be able to get a 0-10V output from the DCO.

When using Vcc = 3.3V instead, we need to make divider divide 10V down to approx 2.68125. As both ends of the 68k resistor are exposed, we can but another resistor in parallel. Using a combination of a 75k and 3.3k resistor (in series, so 78.3k), we end up with 2.668V from a 10V input, which is close to the same "error" as the 5V version.

As for overflow detection, 27/32 * 3.3 = 2.78, which means the output will reach 10.4V before overflowing. That's about 4% higher than the correct value. I'm not sure if this is audible, we just have to test it.

DCO DAC ref voltage

This cannot be higher than 3.3V when running with Vcc = 3.3V. I have yet to calculate what this means for maximum charge current etc. 

DCO 2 on voice card controller

Now, this opened up a giant can of worms unfortunately. Once DCO 2 was in place, the top of the saw wave from both oscillators got cut off at around 4V. As the only thing connecting the two DCOs are the sync lines, I immediately suspected that something was going on there.

I completed the code for turning on and off sync, but that didn't help, so I decided to move DCO2 from its socket to a breadboard and run breadboard wires to the socket, to better be able to connect/disconnect the sync lines.

Unfortunately, while doing this, I swapped the DGND and +5V pins on DCO2. Fearing I broke something, I disconnected DCO2 and started testing the rest of the circuit. 

Now I noticed a sort of metallic sound on the attack portion of each note. This led me through a wild chase to pin down the problem. I swapped the DCOs, fortunately DCO2 still worked. I figured that the sound originated AFTER the filter and then realised it came from the envelope VCA CV. I tried replacing the CV DAC and sample & hold boards as well, with no result.

I then turned to the code and did a git diff. I quickly realised that I unintentionally updated DCO2 twice, once to the real CV and then to 0 to disable changes while debugging sync. This should really not have anything to do with the CV generation, but after a lot more debugging, it turns out that it somehow messes with the timings. It looks like every second update of the CV failed, and from the look of it one or more of the bits sent to the DAC was missing, or at least that is my theory. Removing the extra update fixed the metallic noise.

Envelope CV (bottom). The signal drops to an almost fixed level for every second update. The level follows the curve of the envelope, which leads me to believe that it's a case of missing bits in the DAC value.

I am quite certain that this issue will come back and bite me later!

DCO sync

Now, after all this, I finally went back to debug sync. I did realise that what was probably going on was something I've seen before - trying to input a voltage higher than Vcc to a pin on the MCU makes weird stuff happen. That was why I wanted to move DCO2 to the breadboard in the first place. I realised I've connected DCO out to the sync pin of the other DCO, meaning that it would see up to 10V! After carefully connecting DCO2 again, I could confirm that this was in fact the issue - though not exactly how I expected it to be.

What happens is that the OUTPUT of the DCO gets cut of at around 4V when connected to the sync pin. When I instead connected sync to the timer output of the other DCO, sync started working perfectly. I remember now that this was how I intended it to be done between two DCOs, I only opened up the posibility to also use an analog wave as input, but forgot that it has to be limited to 0-3.3v.

Hard sync. The waves are in phase in reality, I've only tapped them at different points in the circuit.



Missing +/-12V on the DCO debug headers 

This is just a tiny thing, but it threw me off for a bit. I have forgotten (?) to connect the analog power pins of the DCO to the debug pins next to the socket, so I didn't get any power to the DCO on the breadboard. This is fixed in v1.2.1 of the controller board.

Unexpected refresh rate and S&H caps

I can't remember what rate I was aiming for, but right now the S&H runs at 196kHz. That means around 12kHz per channel. I only wonder because I have a commented out line above it with twice that rate.

When replacing the S&H board, I realised that the one I have in the circuit uses 2.2nF caps. Not sure if I used the same board for testing in my earlier post, but it explains why I've seen a few examples where we couldn't charge the cap fast enough. However, it also tells me that 2.2nF is probably fine :)

Envelope nonlinearity and missing updates

This surprised me. When debugging the metallic noise, I realised that the envelope CV is not perfect, it has small drops along the way where it reverts to the previous sample instead of the next.

Turns out this is because the calculation of next step takes too much time, though not EVERY time for some reason, so the double buffered output array has not been updated and the old value is sent instead.

The output drops to the previous value for one cycle, then goes up again.

I added a counter that is incremented when this happens, and it looks like it actually happens A LOT. Matrix recalculations simply take too long, even with the very small number of params I'm using. This is extremely disappointing and something I need to look into

Here is a way of getting an average without constantly summing several numbers. I can use this to get average cycle time. If it overflows I can use two levels, first averaging 1000 and then averaging those again.


Update: It seems one update cycle takes about 80us. As it is run 12000 times per seconds, the updating alone takes 960000us, or 0.96s per second. This does of course include the time it takes to update the output, as that is interrupt based and happens during the calculations, but we need to look at what is actually taking so long. 80us should give us at least 600 * 80 = 48000 instructions to "play" with.

Testing using Little Phatty

I also had time to do a bit of testing and measuring with the Little Phatty.

Pitch bend

First of all, using the pitch bend on the LP made the stepping sounds go away, just as expected. The MPK25 simply does not have high enough resolution.

Clicks when filter keyboard tracking is off

I also confirmed that the LP makes some similar clicking sounds as the XM8 when filter keyboard tracking is turned off. Not entirely unexpected.

Pitch range

The LP pitch range is approximately 26Hz to 31000Hz when only using the keyboard - Osc set to 16' and lowest key + mod wheel all the way down = 26Hz, 2' Osc, highest key and mod wheel up = 31kHz (I'can't hear the last 5 semitones, and the last ones are pure sines on the scope).

The MPK25 sends midi note 0 to 120. Using midi from the MPK25 I was able to get down to approx 8.3Hz. As for the top, I can't get past oct#4 G# for some reason, and the pitch bend started working in the opposite direction??

I had some issues where bend up did not work for note 120, for 119 it works a bit so not entirely sure what is going on. I can't see from my notes if this was in fact for the LP or for XM8 though!

Electric Druid VCDO range

I started looking for what other DCOs do. The Electric Druid VCDO does 8-8kHz.

Juno range

The Juno apparently covers the entire midi spec range, by having a clock divider on the master clock for the two lowest octaves. It stays within 6 cents of the perfect pitch for all notes except midi note 127. More on this at Electric Druid.