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?
Help needed in converting Hz to curve3
-
- Posts: 174
- Joined: Sat Mar 17, 2018 4:23 pm
Help needed in converting Hz to curve3
- Attachments
-
- freq_series.txt
- (1.37 KiB) Downloaded 173 times
-
- curve3_tuning_tool.pixi
- (3.65 KiB) Downloaded 177 times
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: Help needed in converting Hz to curve3
Please see the updated sunvox_curve_generator.pixi
I added some new functions, including your tuning_cents_offset() (slightly optimized)
See load_list( $fname ) in the file above
I added some new functions, including your tuning_cents_offset() (slightly optimized)
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 :)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?
See load_list( $fname ) in the file above
-
- Posts: 174
- Joined: Sat Mar 17, 2018 4:23 pm
Re: Help needed in converting Hz to curve3
How kind of you to give the formula I am curious:
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 / 16.333984375 ) * 3072 + 16384 )
Code: Select all
ret( log2( ($freq * 2) / 16.333984375 ) * 3072 + 16384 )
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: Help needed in converting Hz to curve3
It depends on the module and its waveform.Also, the results are exactly one octave to low if I load it into sunvox
I tested it with Analog Generator, waveform = sin
triangle and sawtooth are one octave higher
SunVox pitch notation is almost equivalent to Scientific Pitch Notation (SPN)Where does 16.333984375 come from?
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;
Pitch for MultiSynth Curve3 = log2( freq / C0 ) * 256 * 12 + 16384;
Pitch for "Set Pitch XXYY" command = 30720 - log2( freq / C0 ) * 256 * 12;
-
- Posts: 174
- Joined: Sat Mar 17, 2018 4:23 pm
Re: Help needed in converting Hz to curve3
I meant that the graph in Multisynth results in one octave lower. This graph was created using the default frequencies where key 69 is a 440It depends on the module and its waveform.
I tested it with Analog Generator, waveform = sin
triangle and sawtooth are one octave higher
- Attachments
-
- sunvox_curve_generator.pixi
- (6.9 KiB) Downloaded 170 times
-
- freq_series.txt
- (1.38 KiB) Downloaded 179 times
-
- Posts: 174
- Joined: Sat Mar 17, 2018 4:23 pm
Re: Help needed in converting Hz to curve3
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)
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: Help needed in converting Hz to curve3
SunVox does not meet MIDI standard regarding note numbers.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 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
-
- Posts: 174
- Joined: Sat Mar 17, 2018 4:23 pm
Re: Help needed in converting Hz to curve3
Thank you for clarification!