Yahoo Groups archive

SynthModules

Index last updated: 2026-04-28 23:14 UTC

Thread

semi-tone math

semi-tone math

2004-05-18 by djbrow54

As I use my PSIM for CV functions, the output never seems to be 'in
tune' with what I expect.  If I use the basicqu2.bas program as an
example to sample and quantize my keyboard CV, there is a
significant difference between the output and the keyboard CV.

I thought I would try and do the calculations in semitones.  The
input is 1023 steps over 10 volts.  Every 8.5 steps is a semitone (83
mV).  If I could divide the input by 8.5 then I would have the
semitone value. Since I can't divide by 8.5, I can multiply by 2 and
divide by 17.

Since the output is 4095 steps over 10.666 volts, every 32 steps is a
semitone. To convert the input from a semitone to the correct output
voltage, I would multiply by 32.  Thus if I take the input, multiply
by 64 and divide by 17 I convert it to the correct output and
quantize to the semitone.

In basicqu2, replacing the RAWDAC1=((ADC1V/16)*32)+49152 calculation
with RAWDAC1=((ADC1V*64)/17)+49152 yields an output that tracks the
keyboard CV quite well.

Does this math make sense?  I haven't seen any code use anything
similar to this.  I've been having issues with a program I'm writing
that samples and delays my keyboard output and this seems to correct
the issue.

Dave

Re: semi-tone math

2004-05-18 by grantrichter2001

I am missing something here, a keyboard is already quantized, 
why would you want to quantize it again?

A quantizer expects an unquantized input to work properly, if you 
feed it an already quantized voltage, strange things will happen.

Think of it as a classifier. The software "classifies" the input into 
one discrete output step. The classifier rules are adjustable. 
That is you can program the 0 to 10 volt input to generate as 
many or few outputs steps as you want, by changing the 
classifier rules.

So it is not going to match the output steps of a keyboard, unless 
precisely calibrated to do so and with specific software. Also the 
absolute input precision on the PSIM is about 5%. (because the 
ADC reference is the untrimmed 5 volt supply) 

Quite good for most things, but to track another quantized source 
(like the Roland OP-8m tries to do) trim pots would be need on 
the inputs for both scale and offset for each input channel. And 
the 5 volt supply will need to be precisely trimmed.

--- In SynthModules@yahoogroups.com, "djbrow54" 
<davebr@e...> wrote:
> As I use my PSIM for CV functions, the output never seems to 
be 'in
> tune' with what I expect.  If I use the basicqu2.bas program as 
an
> example to sample and quantize my keyboard CV, there is a
> significant difference between the output and the keyboard CV.
> 
> I thought I would try and do the calculations in semitones.  The
> input is 1023 steps over 10 volts.  Every 8.5 steps is a 
semitone (83
> mV).  If I could divide the input by 8.5 then I would have the
> semitone value. Since I can't divide by 8.5, I can multiply by 2 
and
> divide by 17.
> 
> Since the output is 4095 steps over 10.666 volts, every 32 
steps is a
> semitone. To convert the input from a semitone to the correct 
output
> voltage, I would multiply by 32.  Thus if I take the input, multiply
> by 64 and divide by 17 I convert it to the correct output and
> quantize to the semitone.
> 
> In basicqu2, replacing the RAWDAC1=((ADC1V/16)*32)+49152 
calculation
> with RAWDAC1=((ADC1V*64)/17)+49152 yields an output that 
tracks the
> keyboard CV quite well.
> 
> Does this math make sense?  I haven't seen any code use 
anything
> similar to this.  I've been having issues with a program I'm 
writing
> that samples and delays my keyboard output and this seems 
to correct
Show quoted textHide quoted text
> the issue.
> 
> Dave

Re: semi-tone math

2004-05-18 by djbrow54

It wasn't so much that I wanted to quantize the keyboard but rather
sample it and play it back later. If I run my keyboard to a VCO, and
also to the PSIM for some processing and to a second VCO, they do not
track at all.

I was multiplying the sampled input by 4 to convert convert it for
output.  However, the scale factor is different.  The output is
10.666 volts so there is a multiplier of 1.0666.  Think of it as a
gain difference between the input and output of 4.266.  If you
sampled an input at 10 volts you would get a value of 1023.  Multiply
it by 4 and get 4092.  This will yield an output of 10.656, not 10. 
So, we need to multiply by 4/1.066 to have unity gain.  Thus the
multiplier from input to output is 3.75, not 4.  Since I can only do
integer math, I could multiply by 15 and divide by 4.

I started down this path thinking about quantizing. To quantize the
input, I can divide by 8.5 to round to the nearest semitone.  Again,
since I can only do integer math I can multiply by 2 and divide by
17.  This gives me the appropriate semitone.  Then, to convert this
for output, I need to multiply by 32.  64/17 is 3.76 which basically
gives me the same scale factor.  I think the difference is really
just roundoff.

I think 3.75 is the appropriate factor as it is the ratios of the two
voltage references and the number of bits.  All of the programs that
multiply by 4 include this additional error gain factor.

Dave

--- In SynthModules@yahoogroups.com, "grantrichter2001"
<grichter@a...> wrote:
> I am missing something here, a keyboard is already quantized, 
> why would you want to quantize it again?
> 
> A quantizer expects an unquantized input to work properly, if you 
> feed it an already quantized voltage, strange things will happen.
> 
> Think of it as a classifier. The software "classifies" the input
into 
> one discrete output step. The classifier rules are adjustable. 
> That is you can program the 0 to 10 volt input to generate as 
> many or few outputs steps as you want, by changing the 
> classifier rules.
> 
> So it is not going to match the output steps of a keyboard, unless 
> precisely calibrated to do so and with specific software. Also the 
> absolute input precision on the PSIM is about 5%. (because the 
> ADC reference is the untrimmed 5 volt supply) 
> 
> Quite good for most things, but to track another quantized source 
> (like the Roland OP-8m tries to do) trim pots would be need on 
> the inputs for both scale and offset for each input channel. And 
> the 5 volt supply will need to be precisely trimmed.
> 
> --- In SynthModules@yahoogroups.com, "djbrow54" 
> <davebr@e...> wrote:
> > As I use my PSIM for CV functions, the output never seems to 
> be 'in
> > tune' with what I expect.  If I use the basicqu2.bas program as 
> an
> > example to sample and quantize my keyboard CV, there is a
> > significant difference between the output and the keyboard CV.
> > 
> > I thought I would try and do the calculations in semitones.  The
> > input is 1023 steps over 10 volts.  Every 8.5 steps is a 
> semitone (83
> > mV).  If I could divide the input by 8.5 then I would have the
> > semitone value. Since I can't divide by 8.5, I can multiply by 2 
> and
> > divide by 17.
> > 
> > Since the output is 4095 steps over 10.666 volts, every 32 
> steps is a
> > semitone. To convert the input from a semitone to the correct 
> output
> > voltage, I would multiply by 32.  Thus if I take the input,
multiply
Show quoted textHide quoted text
> > by 64 and divide by 17 I convert it to the correct output and
> > quantize to the semitone.
> > 
> > In basicqu2, replacing the RAWDAC1=((ADC1V/16)*32)+49152 
> calculation
> > with RAWDAC1=((ADC1V*64)/17)+49152 yields an output that 
> tracks the
> > keyboard CV quite well.
> > 
> > Does this math make sense?  I haven't seen any code use 
> anything
> > similar to this.  I've been having issues with a program I'm 
> writing
> > that samples and delays my keyboard output and this seems 
> to correct
> > the issue.
> > 
> > Dave

Re: semi-tone math

2004-05-19 by grantrichter2001

That is a completely unanticipated operating mode. It never 
occured to any of the review team that a 1V/Oct. keyboard would 
be connected to the voltage inputs.

My conceptual problem is that there are not 10 octaves on a 
keyboard, so all the quantizers I design remap the 10 volt 
uncalibrated input to some number of output octaves. In the case 
of the Mini-Wave and Waveform City, 10 volts is remaped to 5 
octaves. In the case of the PSIM it is 64 steps for chromatic or 32 
steps for diatonic.

But none of them care what the absolute input voltage is. The 
assumption is that it is a random source with a 10 volt range that 
you wish to constrain to a scale.

--- In SynthModules@yahoogroups.com, "djbrow54" 
<davebr@e...> wrote:
> It wasn't so much that I wanted to quantize the keyboard but 
rather
> sample it and play it back later. If I run my keyboard to a VCO, 
and
> also to the PSIM for some processing and to a second VCO, 
they do not
> track at all.

No they would not. The input is arbitrarily remaped to the output 
numerically and not related to absolute input voltage at all.

That doesn't mean you can't calibrate your input. One method is 
to output 1920 or 1921 absolute value to all DACs (check with 
voltmeter which is closer to 5.000 volts), That should give 5 volts 
absolute. Loopback all channels to the inputs and use debug to 
measure the actual ADCs values read at 5.000 volts input for 
each channel. That should allow you to calculate a scale 
correction factor for each input channel on your specific PSIM.

Re: semi-tone math

2004-05-19 by djbrow54

I'm not really trying to 'quantize' the keyboard.  I just want to be 
able to 'sample' it and be able to output the same voltage.  This is 
the same question as Andrew Scheidler's - what is the multiplier 
between the input and output?  I think the multiplier is 3.752984.  
If I use this in my programs, I can output the correct voltage.  
Depending on the order of the math, I can also get it to quantize or 
not.

64/17 (which is 3.7647) tracks my keyboard much better.  This is 
only a 0.3% error and I know my keyboard is built with 1% resistors 
so this is certainly within the tolerance band.

The application I have mostly running scans four inputs: trigger, 
gate, CV, and delay control.  Whenever I see a 0 to 5V or 5V to 0 
transition on the gate or trigger, I timestamp the event, add the 
delay value to it, and put it into a buffer.  If the trigger 
transition was 5 to 0, then I also sample the CV and put it into the 
buffer as well.  When the timestamps match, I will output the 
appropriate trigger, gate, or CV on the outputs.  I have been 
running delays up to a couple of seconds as fast as I can play the 
keyboard.  I'm driving some VCOs and ADSRs with my keyboard and 
other VCOs and ADSRs with the PSIM. This is why I need the output 
voltage to be the same as the input voltage.  In this application, 
the order of the math does not quantize the output but keeps the 
VCOs in tune with each other.  I eventually want to turn this into a 
real-time arpeggiator.  Anyway, I got the inputs and outputs to 
match using this multiplier.

Dave

--- In SynthModules@yahoogroups.com, "grantrichter2001" 
<grichter@a...> wrote:
> That is a completely unanticipated operating mode. It never 
> occured to any of the review team that a 1V/Oct. keyboard would 
> be connected to the voltage inputs.
> 
> My conceptual problem is that there are not 10 octaves on a 
> keyboard, so all the quantizers I design remap the 10 volt 
> uncalibrated input to some number of output octaves. In the case 
> of the Mini-Wave and Waveform City, 10 volts is remaped to 5 
> octaves. In the case of the PSIM it is 64 steps for chromatic or 
32 
Show quoted textHide quoted text
> steps for diatonic.
> 
> But none of them care what the absolute input voltage is. The 
> assumption is that it is a random source with a 10 volt range that 
> you wish to constrain to a scale.

Re: [SynthModules] Re: semi-tone math

2004-05-19 by john mahoney

Another option would be to rescale the incoming pitch CV to be more
compatible with with 10mV steps of the ADC. A voltage divider will do this,
right? So, it's not much of a hassle from a hardware standpoint, as the main
ingredients are a pot or some precision resistors. But it would make your
program slightly incompatible with a "stock" PSIM, so to speak; that's not a
big deal, IMHO.

Scaling 1V/Octave to 0.96V/Octave yields an even 80mV/semitone. Is it worth
it? Probably not for a mere 0.33% error.

I've imagined a similar application. Before doing an arpeggiator, I want to
make a CV delay ("echo").
--
john


----- Original Message ----- 
Show quoted textHide quoted text
From: "djbrow54" <davebr@earthlink.net>
To: <SynthModules@yahoogroups.com>
Sent: Wednesday, May 19, 2004 3:55 PM
Subject: [SynthModules] Re: semi-tone math


> I'm not really trying to 'quantize' the keyboard.  I just want to be
> able to 'sample' it and be able to output the same voltage.  This is
> the same question as Andrew Scheidler's - what is the multiplier
> between the input and output?  I think the multiplier is 3.752984.
> If I use this in my programs, I can output the correct voltage.
> Depending on the order of the math, I can also get it to quantize or
> not.
>
> 64/17 (which is 3.7647) tracks my keyboard much better.  This is
> only a 0.3% error and I know my keyboard is built with 1% resistors
> so this is certainly within the tolerance band.
>
> The application I have mostly running scans four inputs: trigger,
> gate, CV, and delay control.  Whenever I see a 0 to 5V or 5V to 0
> transition on the gate or trigger, I timestamp the event, add the
> delay value to it, and put it into a buffer.  If the trigger
> transition was 5 to 0, then I also sample the CV and put it into the
> buffer as well.  When the timestamps match, I will output the
> appropriate trigger, gate, or CV on the outputs.  I have been
> running delays up to a couple of seconds as fast as I can play the
> keyboard.  I'm driving some VCOs and ADSRs with my keyboard and
> other VCOs and ADSRs with the PSIM. This is why I need the output
> voltage to be the same as the input voltage.  In this application,
> the order of the math does not quantize the output but keeps the
> VCOs in tune with each other.  I eventually want to turn this into a
> real-time arpeggiator.  Anyway, I got the inputs and outputs to
> match using this multiplier.
>
> Dave
>

Re: semi-tone math

2004-05-20 by djbrow54

I'd be more than happy to send anyone the code I have.  It's not
quite ready for prime time.  I sometimes miss events and I'm not sure
why.  There is no debugging capability with interrupts so it's all
trial and error.  I'll take help in debugging it.  I've tried to
balance the code between the isr and main loops so there is ample
time for both processes to run.

Dave

--- In SynthModules@yahoogroups.com, "john mahoney" <jmahoney@g...>
wrote:
> I've imagined a similar application. Before doing an arpeggiator, I
want to make a CV delay ("echo").
> --
> john

Re: semi-tone math

2004-05-20 by Michael A. Firman

Dave,

Here is a little tip (if you haven't figured it out already). You don't
want to "balance" the code between interrupt and base level. What 
you want to do is as little execution on interrupt as possible. On
interrupt you should just set flags or save simple values. You should
never do any long calculations or other intensive work. Your main,
base level loop should do all the work. It can check the flags that
you set on interrupt and then go and do what is needed.


--- In SynthModules@yahoogroups.com, "djbrow54" <davebr@e...> wrote:
Show quoted textHide quoted text
> I'd be more than happy to send anyone the code I have.  It's not
> quite ready for prime time.  I sometimes miss events and I'm not sure
> why.  There is no debugging capability with interrupts so it's all
> trial and error.  I'll take help in debugging it.  I've tried to
> balance the code between the isr and main loops so there is ample
> time for both processes to run.
> 
> Dave
> 
> --- In SynthModules@yahoogroups.com, "john mahoney" <jmahoney@g...>
> wrote:
> > I've imagined a similar application. Before doing an arpeggiator, I
> want to make a CV delay ("echo").
> > --
> > john

Re: [SynthModules] Re: semi-tone math

2004-05-20 by john mahoney

I'm in the middle of a synth repair and building a synth kit, so time is
tight, but I'll do what I can. (As if everyone's time isn't tight...)

Send me the code and I'll try it tonight. "Fresh eyes" can be very helpful
in debugging.
--
john


----- Original Message ----- 
Show quoted textHide quoted text
From: "djbrow54" <davebr@earthlink.net>
To: <SynthModules@yahoogroups.com>
Sent: Wednesday, May 19, 2004 11:06 PM
Subject: [SynthModules] Re: semi-tone math


> I'd be more than happy to send anyone the code I have.  It's not
> quite ready for prime time.  I sometimes miss events and I'm not sure
> why.  There is no debugging capability with interrupts so it's all
> trial and error.  I'll take help in debugging it.  I've tried to
> balance the code between the isr and main loops so there is ample
> time for both processes to run.
>
> Dave
>

Re: semi-tone math

2004-05-23 by djbrow54

I tweaked up my system today so using a multiplier of 15/4 (3.75) now
works correctly.  My system was a bit 'off' so the 64/17 previously
matched my keyboard better.

Dave

--- In SynthModules@yahoogroups.com, "djbrow54" <davebr@e...> wrote:
Show quoted textHide quoted text
> This is the same question as Andrew Scheidler's - what is the
> multiplier between the input and output?  I think the multiplier
> is 3.752984. If I use this in my programs, I can output the
> correct voltage.  Depending on the order of the math, I can also
> get it to quantize or not.
> 
> 64/17 (which is 3.7647) tracks my keyboard much better.  This is 
> only a 0.3% error and I know my keyboard is built with 1% resistors 
> so this is certainly within the tolerance band.

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.