Page 1 of 1

### Help needed in converting Hz to curve3

Posted: Sun Nov 08, 2020 2:41 pm
I am making a pixi tool to create tunings for sunvox. I want to be able to convert this simple 'freq_series.txt' file to Multisynth curve3. The problem I am facing now is that I have to convert the hertz value to the curve3 \$y value. Anyone ideas?

I have a few questions about pixilang:
(1 Can you create lists like you can do in python?
(2 Can anyone give a snippet of how to open and loop trough the lines of a txt file? What does it look like?

### Re: Help needed in converting Hz to curve3

Posted: Sun Nov 08, 2020 11:21 pm
sunvox_curve_generator.pixi
Can you create lists like you can do in python?
Can anyone give a snippet of how to open and loop trough the lines of a txt file? What does it look like?
Hm... I'm not sure about the lists in Python. There are no some built-in features for the list loading, but you can make your own :)
See load_list( \$fname ) in the file above

### Re: Help needed in converting Hz to curve3

Posted: Mon Nov 09, 2020 1:47 am
How kind of you to give the formula I am curious:

Code: Select all

``ret( log2( \$freq / 16.333984375 ) * 3072 + 16384 )``
Where does 16.333984375 come from? Also, the results are exactly one octave to low if I load it into sunvox... Multiplying the \$freq by 2 seems to fix this:

Code: Select all

``ret( log2( (\$freq * 2) / 16.333984375 ) * 3072 + 16384 )``

### Re: Help needed in converting Hz to curve3

Posted: Mon Nov 09, 2020 11:03 am
Also, the results are exactly one octave to low if I load it into sunvox
It depends on the module and its waveform.
I tested it with Analog Generator, waveform = sin
triangle and sawtooth are one octave higher

Where does 16.333984375 come from?
SunVox pitch notation is almost equivalent to Scientific Pitch Notation (SPN)

Code: Select all

``````SPN:
C0 = 16.352 Hz;         A4 = 440 Hz;
SunVox (reference values):
C0 = 16.333984375 Hz;   A4 = 439.526062 Hz;
SunVox with errors in integer calculations (the real frequency of most generators; may be fixed in future updates):
C0 = 16.3125 Hz;        A4 = 439.5 Hz;``````
Therefore the formulas are as follows:
Pitch for MultiSynth Curve3 = log2( freq / C0 ) * 256 * 12 + 16384;
Pitch for "Set Pitch XXYY" command = 30720 - log2( freq / C0 ) * 256 * 12;

### Re: Help needed in converting Hz to curve3

Posted: Mon Nov 09, 2020 12:29 pm
It depends on the module and its waveform.
I tested it with Analog Generator, waveform = sin
triangle and sawtooth are one octave higher
I meant that the graph in Multisynth results in one octave lower.
curve3graph.png (9.21 KiB) Viewed 1411 times
This graph was created using the default frequencies where key 69 is a 440

### Re: Help needed in converting Hz to curve3

Posted: Mon Nov 09, 2020 12:44 pm
I don't understand... If I take note 69 as a 440, C0 is 8.175799 so that explains my octave lower in graph. I was asuming that the graph is equal to midi notes and frequencies but apparently there is one octave difference between midi and the scientific base? (using http://newt.phys.unsw.edu.au/jw/notes.html as reference for midi note)

### Re: Help needed in converting Hz to curve3

Posted: Mon Nov 09, 2020 1:11 pm
This graph was created using the default frequencies where key 69 is a 440.
I was asuming that the graph is equal to midi notes
SunVox does not meet MIDI standard regarding note numbers.
SunVox Key 69 is 880 Hz.

In SunVox:
Key 0 (note C0) = 16.333984375 Hz;
Key 12 (note C1) = 32.667969 Hz;
Key 57 (note A4) = ~440 Hz;
Key 69 (note A5) = ~880 Hz;

In MIDI:
Key 0 (note C-1) = 8.1758 Hz;
Key 12 (note C0) = 16.352 Hz;
Key 57 (note A3) = 220 Hz;
Key 69 (note A4) = 440 Hz;

So the note names are the same.
The frequencies are almost the same.
But the note numbers (keys) are different.
Note0 in SunVox is 16.333984375 Hz; Name = C0
Note0 in MIDI is 8.1758 Hz; Name = C-1

So in default MultiSynth Curve3, the first item is equal to C0 (16.333984375 Hz) (SunVox key 0, MIDI key 12)
The first value in your freq_series.txt must be ~16.3

### Re: Help needed in converting Hz to curve3

Posted: Mon Nov 09, 2020 4:03 pm
Thank you for clarification!