Freq to V/Oct

Request a new device/modular module, and hope that some enterprising developer grants your wish!

Moderators: valis, garyb

User avatar
spacef
Posts: 2998
Joined: Sun Jun 17, 2001 4:00 pm
Contact:

Re: Freq to V/Oct

Post by spacef »

how do you get the phase and other variable values in Scope ? You would need something to compare two phases and extract the difference. Then , you would probably need micro delays here and there, and it takes DSP. That's one of the reason I would not include any phase alignment feature in my mixer, they would become too heavy and unusuable because it would have to be implemented on every channel at least, I suppose.

But I don't know, I am not the one who could implement such a thing in Scope :-)
plug-ins for scope
SpaceF website
SC website
User avatar
Spindrift
Posts: 95
Joined: Mon May 18, 2020 1:04 am

Re: Freq to V/Oct

Post by Spindrift »

For the oscillator code I linked to, the function calculates the phase of the oscillator for each sample and is in that way constructing the waveform. If you in theory would have a sample frequency of 4 instead of 44100 you would have value 0 at 0° phase, value 1 at 90° (the peak), value 0 at 180° and -1 at 270° phase (the valley). So phase is just where in the cycle it should generate the value for.

But all you need to do when using the oscillator is setting the frequency in Hz, the phase is just internal implementation details.

I just tried to put a half wave rectifier before the freq input of an oscillator to see if indeed the strange response to negative values is what throws automatic tuning off in Bitwig, and that seems to be the case. With a rectifier instead of getting jumbled information there is no pitch coming at all until it reaches positive, and it then tries to map upwards with a exponential response. It looks like it maps c1-c9, however the tuning is off :( Not by a lot, but too much to be useable. It seems to be an extremely narrow range for the bottom values so I guess it might be a precision issue since not only is it restricted to half the available range, but also uses very little of that range for the first few octaves.
However with the calibration data I pasted earlier it does work over full range without problems, so it must be possible to handle.
User avatar
spacef
Posts: 2998
Joined: Sun Jun 17, 2001 4:00 pm
Contact:

Re: Freq to V/Oct

Post by spacef »

OF course it is probably possible . But not by me I am afraid :-) (lacking some "know how" here).
PS: values in scope are no -1 to +1 but - 21 million to + 21 millions (which does not change much in final results, but it means i cannot use the numbers that you have uploaded).
plug-ins for scope
SpaceF website
SC website
User avatar
Spielraum
Posts: 602
Joined: Fri Apr 18, 2014 1:11 pm
Location: Raumschiff Erde

Re: Freq to V/Oct

Post by Spielraum »

before work correctly in scope, converter is needed, c++ scipt.dll can do this? i don`t know, because additional datatransfer interface needed, i think.
need table or mult/div "double" * 32bit="int" with rounding errors.
dsp basicly must convert your table into scope integers syncvalues (format "double" 1.000000 not in sync)
min: -1 to -2147483648
max: 1 to 2147483647
e.g.
0 -0,32009429 x2147483647 = -687397253,27307563 = -687397253 (scope 32bit int value)
1 -0,31184876 x2147483647 = -669690112,43722772 = -669690112
2 -0,30360326 x2147483647 = -651983036,02588922 = -651983036
.
..
...
125 0,71825683 x2147483647 = 1542444796,77105901 = 1542444796
126 0,72740626 x2147483647 = 1562093048,07543022 = 1562093048
127 0,73655564 x2147483647 = 1581741192,00561908 = 1581741192

thx for this info!
Spindrift wrote: Thu Sep 09, 2021 12:50 pm Again, my understanding of DSP is not at expert level, but I have dabbled in it and can read code.
But I would say that typcially oscillators will do is just accept a frequency value as input.

First example of a C++ oscillator that shows up on google:
https://github.com/rcliftonharvey/rchoscillators

In helpers/skeleton.h there is a function to set the frequency:

Code: Select all

    /** Sets the oscillator center frequency in Hertz. */
    void setFrequency (const double& Hz)
    {
        // Only update and recalculate if new Hz value is different
        if (Hz != frequency)
        {
            // Import new center frequency
            frequency = Hz;
            
            // If the center frequency is changed while SR was already set
            if (samplerate > 0.0)
            {
                // Recalculate the per-sample phase modifier
                fractionFrequency = frequency / samplerate;
            }
            
            // Revert to reset state
            reset();
        }
    }
And in for example oscillators/templates/sine.h:

Code: Select all

        phase += M_2PI * fractionFrequency;
        phase += ((phase >= M_2PI) * -M_2PI) + ((phase < 0.0) * M_2PI);
        // Calculate sine value for current phase step and scale to desired volume. 
        state = std::sin(phase) * amplitude;
That is pretty much all there is to it, and it is certainly not necessary to use any tables for control values. Pitch is no different than amplitude in this regard, at least in a basic case like this.
I cannot see any advantage of using tables for neither, but probably I am missing something since I don't understand why Scope choose this odd control scheme.

For reference here is the Silent Way mapping that works with Scope:

Code: Select all

Silent Way Calibration Data
version: 1
0 0.00036621 
1 0.00039673 
2 0.00041199 
3 0.00044250 
4 0.00047302 
5 0.00048828 
6 0.00051880 
7 0.00054932 
8 0.00059509 
9 0.00062561 
10 0.00065613 
11 0.00070190 
12 0.00074768 
13 0.00077820 
14 0.00083923 
15 0.00088501 
16 0.00093079 
17 0.00099182 
18 0.00105286 
19 0.00111389 
20 0.00117493 
21 0.00125122 
22 0.00132751 
23 0.00140381 
24 0.00148010 
25 0.00157166 
26 0.00166321 
27 0.00177002 
28 0.00186157 
29 0.00198364 
30 0.00209045 
31 0.00222778 
32 0.00234985 
33 0.00248718 
34 0.00263977 
35 0.00279236 
36 0.00296021 
37 0.00314331 
38 0.00332642 
39 0.00352478 
40 0.00373840 
41 0.00395203 
42 0.00419617 
43 0.00444031 
44 0.00471497 
45 0.00498962 
46 0.00527954 
47 0.00559998 
48 0.00593567 
49 0.00628662 
50 0.00665283 
51 0.00704956 
52 0.00747681 
53 0.00791931 
54 0.00839233 
55 0.00889587 
56 0.00941467 
57 0.00997925 
58 0.01057434
59 0.01119995
60 0.01187134
61 0.01257324
62 0.01332092
63 0.01411438
64 0.01495361
65 0.01583862
66 0.01678467
67 0.01777649
68 0.01882935
69 0.01995850
70 0.02114868
71 0.02239990
72 0.02372742
73 0.02514648
74 0.02664185
75 0.02821350
76 0.02989197
77 0.03167725
78 0.03355408
79 0.03555298
80 0.03767395
81 0.03990173
82 0.04228210
83 0.04479980
84 0.04745483
85 0.05027771
86 0.05326843
87 0.05644226
88 0.05979919
89 0.06335449
90 0.06712341
91 0.07110596
92 0.07533264
93 0.07981873
94 0.08456421
95 0.08959961
96 0.09492493
97 0.10057068
98 0.10655212
99 0.11288452
100 0.11959839
101 0.12670898
102 0.13423157
103 0.14222717
104 0.15068054
105 0.15963745
106 0.16912842
107 0.17918396
108 0.18983459
109 0.20112610
110 0.21308899
111 0.22575378
112 0.23918152
113 0.25340271
114 0.26847839
115 0.28443909
116 0.30136108
117 0.31927490
118 0.33825684
119 0.35836792
120 0.37968445
121 0.40226746
122 0.42617798
123 0.45152283
124 0.47837830
125 0.50682068
126 0.53695679
127 0.56887817

According to silent way:
The first two lines are an identifying header and a version number. The remaining lines are simple pairs of numbers: the first number is a MIDI note number, and the second is the output CV value that corresponds to that note.
If I take my Generate 3 analog eurorack oscillator and tune it with SW I get this (of course changing a bit depending on what pitch oscillator is set to):

Code: Select all

Silent Way Calibration Data
version: 1
0 -0.32009429
1 -0.31184876
2 -0.30360326
3 -0.29535773
4 -0.28711224
5 -0.27886671
6 -0.27062121
7 -0.26237568
8 -0.25413018
9 -0.24588151
10 -0.23762968
11 -0.22937785
12 -0.22112602
13 -0.21287419
14 -0.20462236
15 -0.19637053
16 -0.18811870
17 -0.17986688
18 -0.17161505
19 -0.16336322
20 -0.15511139
21 -0.14685956
22 -0.13860773
23 -0.13035589
24 -0.12210261
25 -0.11384664
26 -0.10559067
27 -0.09733471
28 -0.08907873
29 -0.08082277
30 -0.07256679
31 -0.06431082
32 -0.05605485
33 -0.04779888
34 -0.03954291
35 -0.03128694
36 -0.02303097
37 -0.01477500
38 -0.00651903
39 0.00173806
40 0.00999934
41 0.01826062
42 0.02652190
43 0.03478318
44 0.04304447
45 0.05130575
46 0.05956703
47 0.06782831
48 0.07608960
49 0.08435088
50 0.09261216
51 0.10087345
52 0.10913473
53 0.11739601
54 0.12565717
55 0.13391691
56 0.14217666
57 0.15043642
58 0.15869616
59 0.16695590
60 0.17521565
61 0.18347540
62 0.19173515
63 0.19999489
64 0.20825464
65 0.21651439
66 0.22477414
67 0.23303388
68 0.24129362
69 0.24955338
70 0.25780487
71 0.26605591
72 0.27430695
73 0.28255796
74 0.29080901
75 0.29906005
76 0.30731109
77 0.31556210
78 0.32381314
79 0.33206418
80 0.34031519
81 0.34856623
82 0.35681728
83 0.36506832
84 0.37331933
85 0.38154343
86 0.38976064
87 0.39797786
88 0.40619507
89 0.41441229
90 0.42262948
91 0.43084669
92 0.43906391
93 0.44728112
94 0.45549834
95 0.46371555
96 0.47193274
97 0.48014995
98 0.48836717
99 0.49658439
100 0.50474554
101 0.51286680
102 0.52098805
103 0.52910930
104 0.53723061
105 0.54535186
106 0.55347311
107 0.56159437
108 0.56971562
109 0.57783693
110 0.58595818
111 0.59407943
112 0.60220069
113 0.61032194
114 0.61844325
115 0.62676257
116 0.63591200
117 0.64506143
118 0.65421087
119 0.66336024
120 0.67250967
121 0.68165910
122 0.69080853
123 0.69995797
124 0.70910740
125 0.71825683
126 0.72740626
127 0.73655564
As you can see it is a range starting negative, and for each note same value is added.
And the mapping curve displayed in Voice Controller looks like this:
Image

I can do the same, routing the SW Voice controller via scope and back to an oscillator in Bitwig, and the result will look basically the same. Linear going from negative to positive.

If I try to calibrate automatically with a Scope osc it fails and can only map notes 101 to 127, and the curve looks like this:
Image

Clearly the narrow range that is working has an exponential response instead of linear, but seems also something strange happens if you give it negative values which throws of all attempts at automatic tuning by SilentWay, Bitwig or Ableton. They should all be able to handle the non linear response I think.
|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅] Lange Welle ~ Mittelwelle ~ Kurze Welle ~ Ultra Kurze Welle
User avatar
Spindrift
Posts: 95
Joined: Mon May 18, 2020 1:04 am

Re: Freq to V/Oct

Post by Spindrift »

Yes, of course the "voltage" values as Expert Sleepers calls the values in configuration files is used as a multiplier for max int value.

Tried to see what is possible using logic modules, since there seems to be some sense in how the positive values are used at least.
So first modifying bipolar to positive and dividing to get the full range. Then converting so the response is exponential even if the input is linear.
And actually when tuning with Bitwigs CV instrument is can detect the full range! Not perfect though, and some notes is up to 20 cents off.

Image

I guess it is due to the fact that I the response is still not really linear, only close, so my linear to exponential conversion seems a bit off:
Image
Regular CV instruments will have a straight line all the way, and I think the slightly exponential response is throwing the tuning off a little.
Last edited by Spindrift on Sun Sep 12, 2021 4:53 am, edited 1 time in total.
User avatar
spacef
Posts: 2998
Joined: Sun Jun 17, 2001 4:00 pm
Contact:

Re: Freq to V/Oct

Post by spacef »

yes, i think it has to be fine tuned manually at the end. Thanks for your efforts in trying and for uploading all this information.
I would try if I had the time but for the moment I have already a bit too much on my shoulders and mind to get into this, as it requires long afternoons and evenings doing only this (copy/paste values, try stuff etc). You never know, it might pop-up one day from me or from another but I must be honest and tell you that I won't be able to think about it for at least the next 2 or 3 months. Also, I do not have all the tools you use (for some reason, bitwig does not want to work on my pc) so this is another element that would make it difficult.
plug-ins for scope
SpaceF website
SC website
User avatar
Spielraum
Posts: 602
Joined: Fri Apr 18, 2014 1:11 pm
Location: Raumschiff Erde

Re: Freq to V/Oct

Post by Spielraum »

Spindrift wrote: Sat Sep 11, 2021 3:38 am ...Not perfect though, and some notes is up to 20 cents off.
...
Regular CV instruments will have a straight line all the way, and I think the slightly exponential response is throwing the tuning off a little.
nice analysis, should mean, left below, and right above? but somewhere in the middle it is correct, but with offset? that would be the starting point!

if you evaluate scope > cv and create a table with actual and target scopevalues, then i could try to calibrate the curve with scopelogic.
Ps.: today i developed a logic for the other issue that I was about to give up. now it works perfectly ...

never say never
cheers
|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅] Lange Welle ~ Mittelwelle ~ Kurze Welle ~ Ultra Kurze Welle
User avatar
Spindrift
Posts: 95
Joined: Mon May 18, 2020 1:04 am

Re: Freq to V/Oct

Post by Spindrift »

spacef wrote: Sun Sep 12, 2021 12:21 am You never know, it might pop-up one day from me or from another but I must be honest and tell you that I won't be able to think about it for at least the next 2 or 3 months. Also, I do not have all the tools you use (for some reason, bitwig does not want to work on my pc) so this is another element that would make it difficult.
If you do get time to look it to it, let me know if there is anything I can do to help. But I'm only really using Bitwig to detect the resulting response curve.To get a rough idea about response I just used a bipolar constant vs a frequency constant module and studied value readouts. I guess to get really exact values one would do the same.
To detect the response curve either Silent Way or Ableton should work as well.
User avatar
Spindrift
Posts: 95
Joined: Mon May 18, 2020 1:04 am

Re: Freq to V/Oct

Post by Spindrift »

Spielraum wrote: Sun Sep 12, 2021 4:34 am nice analysis, should mean, left below, and right above? but somewhere in the middle it is correct, but with offset? that would be the starting point!

if you evaluate scope > cv and create a table with actual and target scopevalues, then i could try to calibrate the curve with scopelogic.
Ps.: today i developed a logic for the other issue that I was about to give up. now it works perfectly ...

never say never
cheers
Thanks!

The tracking doesn't drift over range, but seemingly randomly differs up to +- 20 cents on some notes.
It sounds like what Bitwig does when it tries to tune is it sends of one note per octave, and then I assume it interpolates between them. However while that makes sense from what I hear when it performs the tuning, I cannot really see that in the response curve or the per note drift values. But since the drift is smaller than when I simply tuned with a half wave rectifier it seems it has to do with the linear interpolation between measured points in an exponential curve.

As for the table, the values in the Silent Way mapping should be possible to use directly.
Staring with C0 it says 0.00036621
So if you convert signal to unipolar and scale it up again like in my example (updated the image in my previous post for clarity and can send the CLM if you like), when value is 2147483647 * 0.00036621, frequency out should be corresponding to the value you get when generating C0 in scope.
But maybe it is better getting the actual int values directly for better precision. I can try to set something up in modular and record the value for each note.
User avatar
Spindrift
Posts: 95
Joined: Mon May 18, 2020 1:04 am

Re: Freq to V/Oct

Post by Spindrift »

Seems I was wrong about the last one. First of all, looking at the silent way data, Scope doesn't seem to use the full positive range since note 127 is 0.56887817.

I did like this to read out the int and float values for a note, but doesn't make me any wiser:
Image

Some more head scratching to do it seems :\
User avatar
Spindrift
Posts: 95
Joined: Mon May 18, 2020 1:04 am

Re: Freq to V/Oct

Post by Spindrift »

Seem like I confused things with the freq 3 note. I figured I can use it to quantize freq, but note values are a completely different range. But doing quantization correctly I can easily find the values:

Image

Also I noticed that Silent Way doesn't really track perfectly. Only slightly better than the solution I did with logic modules (+-15 cents). Haven't really bothered me...I guess it can be called a feature for authentic analogue sound :)

There are slight differences sometimes what I get in scope and what is written in the mapping file, and if I adjust them to match what I see in scope tracking is improved. Will go through all notes an make an updated version.
User avatar
Spielraum
Posts: 602
Joined: Fri Apr 18, 2014 1:11 pm
Location: Raumschiff Erde

Re: Freq to V/Oct

Post by Spielraum »

Spindrift wrote: Sun Sep 12, 2021 9:07 am I guess it can be called a feature for authentic analogue sound :)
YEP, fluctuations avoid boredom. ...
... same philosophy as for the definition of heat. there is only inaccuracy behind
|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅] Lange Welle ~ Mittelwelle ~ Kurze Welle ~ Ultra Kurze Welle
Post Reply