Audio in v/Oct in pure data

Hi all,
So am working on a kind of random sequencer that takes pitch cv values from the adc~ via a snapshot~, am finding I need to offset and scale the input to get the output to reflect the input - is this correct? Am not at my machine right now to test stuff out, hoping someone can enlighten me if I maybe need to recalibrate or something? Or are my expectations wrong that sampling like this and passing the raw sampled value to dac~ should give same voltage?

Yes, you would need to calibrate it to get voltage offset and scalar, then you can output correct voltage as V/Oct pitch CV. Your idea of calibration sounds almost correct, I think that current procedure for Lich relies on calibrating output with a multimeter, then using calibrated output as voltage generator to calibrate input.

Converting pitch CV to frequency is explained here: Pure data Conversion v/oct to frequency - #2 by mars

To go the other way around and generate CV you’d need:

  1. get number of volts = log2(FREQUENCY/440) , where 440 is your base frequency (can multiply or divide this by anything that is a power of 2 to get different base octave)
  2. count the DAC value as out = volts / multiplier + offset

I suspect Martin has a stashed sample of PD code that does it, but this info should be added to our PD docs too.

1 Like

Thanks for your help - yes I think I get it now, my confusion with the calibration was that I was assuming that the inputs would be presented to pd ready scaled so was surprised at then having to scale within pd to get it to match up. I’ve tried a little test cv-through patch and managed to get a fairly good mapping (as good as my cheap voltmeter can go anyway lol).

I assume there is no way for pd to get the saved scalars/offset directly from memory? Am just thinking that if I share my patch with a friend they’ll need to update the values in the pd patch each time (or if I make public in the library).

Reading scalar/offset values - is a reasonable feature request. For now only C++ and Faust support reading them from firmware. I’m not sure what could be a good way to expose them to user patches, maybe @mars has some plans for this.

Not the end of the world but would be handy I think!
Thanks for your help, got my sequencer working nicely now:

2 Likes

I think I’m in the same spot here, but without the output part. Just trying to have the input L to be a v/Oct input for let’s say a simple Osc. My PD skills are basic so I just copied antisvin example but can’t figure out (with a tunner and a cv keyboard) how this exactly works so I just blindly tweek something till the tuner says “ok, that’s a C” but the other notes are not even near to what they should be… someone create a video tutorial please! O a step by step guide for dummies… Or point me in some direction :slight_smile: … My Lich is supossed to be calibrated so it should be a straigth forward piece of code, right?
Captura de pantalla 2022-07-31 a las 16.31.35

As I’ve mentioned above, calibration is currently only usable in C++ and FAUST patches.

In this patch, [*~ -2.1] is the multiplier that is used to set ratio from volts to samples. As the first step you’ll need to find a value such that X volts gives you Y Hertz and X + 1 volts give you Y * 2 Hertz. In other words, 1 Volt would give you 1 octave. At this time it doesn’t matter how many Hertz you get, only that V/Oct scaling is correct.

The second step is to find correct offset value. In the patch above [+~ 0.09] is offset from zero volts and you should find something that sets the expected frequency for 0 Volts. Typically it would be note C, but choosing exact octave is up to you.

Thank you very much @antisvin for your input, it brings some light! Abut the calibration, I thought it was related to a new firmware I don’t have so I assume mine was already calibrated as I did it some time ago…
I’ll mess around with it, thanks again