How to generate a multictrl curve which is linear but mirrored? I've attached a file where I 've drawn what the goal is. I tried a lot of things to change the curve but I ended up trying for a few hours without reaching this simple goal. So the goal is the exact opposite of the default curve.
/*
Curve file generator for the SunVox modules like MultiSynth, WaveShaper and MultiCtl.
by Alexander Zolotov / nightradio@gmail.com / warmplace.ru
License: CC BY https://creativecommons.org/licenses/by/4.0
How to use: change the SETUP part and run this program to generate the new file with the curve.
Changelog:
2017.10.11: v1.1 (fixed bugs; new curve function examples)
2017.08.16: v1.0
*/
// ########################################
// ## SETUP ###############################
// ########################################
//Format:
format = 3
if format == 0
{
//MultiSynth: X = note; Y = velocity
type = INT8
items = 128
}
if format == 1
{
//MultiSynth: X = velocity; Y = velocity
type = INT8
items = 257
}
if format == 2
{
//WaveShaper
type = INT16
items = 257
}
if format == 3
{
//MultiCtl
type = INT16
items = 257
max = 32768
}
Function:
$x = 0
$y = 1
fn curve_function( $x )
{
$y = $x //goal: mirror Linear
//$y = sin( $x * M_PI * 4 ) / 3 + 0.5 //Sine
//$y = $x //Linear
//$y = pow( $x, 4 ) //Exponential
//$y = pow( $x, 2 ) //Exponential+
//$y = pow( $x, 0.6 )
//$y = $x * $x + pow( $x, 3 ) * ( 1 - $x ) //Something between the linear and the exponential curve
ret( $y )
}
// ########################################
// ## SETUP COMPLETE ######################
// ########################################
set_pixel_size( WINDOW_XSIZE / 480 )
resize( get_screen(), WINDOW_XSIZE, WINDOW_YSIZE )
scr = get_screen()
xsize = get_xsize( scr )
ysize = get_ysize( scr )
//Filename:
filename = "Multictrl"
curve = new( items, 1, type )
clean( curve )
if max == 0
{
if type == INT8 { max = 255 }
if type == INT16 { max = 65535 }
}
i = 0 while i < items
{
v = curve_function( i / ( items - 1 ) )
if v < 0 { v = 0 }
if v > 1 { v = 1 }
if type == INT8 { v * max }
if type == INT16 { v * max }
logf( "%d: %d\n", i, v )
curve[ i ] = v
i + 1
}
save( curve, filename, FORMAT_RAW )
clear( BLACK )
i = 0 while i < items
{
x = i / items * xsize - xsize / 2
y = - ( curve_function( i / items ) - 0.5 ) * ysize
dot( x, y, WHITE )
i + 1
}
while 1
{
frame( 100 )
while get_event() { if EVT[ EVT_TYPE ] == EVT_QUIT { halt } }
}
/*
Curve file generator for the SunVox modules like MultiSynth, WaveShaper and MultiCtl.
by Alexander Zolotov / nightradio@gmail.com / warmplace.ru
License: CC BY https://creativecommons.org/licenses/by/4.0
How to use: change the SETUP part and run this program to generate the new file with the curve.
Changelog:
2017.10.11: v1.1 (fixed bugs; new curve function examples)
2017.08.16: v1.0
*/
// ########################################
// ## SETUP ###############################
// ########################################
//Format:
format = 3
if format == 0
{
//MultiSynth: X = note; Y = velocity
type = INT8
items = 128
}
if format == 1
{
//MultiSynth: X = velocity; Y = velocity
type = INT8
items = 257
}
if format == 2
{
//WaveShaper
type = INT16
items = 257
}
if format == 3
{
//MultiCtl
type = INT16
items = 257
max = 32768
}
Function:
$x = 0
$y = 1
fn curve_function( $x )
{
$y = 1 - $x //mirror Linear
//$y = sin( $x * M_PI * 4 ) / 3 + 0.5 //Sine
//$y = $x //Linear
//$y = pow( $x, 4 ) //Exponential
//$y = pow( $x, 2 ) //Exponential+
//$y = pow( $x, 0.6 )
//$y = $x * $x + pow( $x, 3 ) * ( 1 - $x ) //Something between the linear and the exponential curve
ret( $y )
}
// ########################################
// ## SETUP COMPLETE ######################
// ########################################
set_pixel_size( WINDOW_XSIZE / 480 )
resize( get_screen(), WINDOW_XSIZE, WINDOW_YSIZE )
scr = get_screen()
xsize = get_xsize( scr )
ysize = get_ysize( scr )
//Filename:
filename = "Multictrl"
curve = new( items, 1, type )
clean( curve )
if max == 0
{
if type == INT8 { max = 255 }
if type == INT16 { max = 65535 }
}
i = 0 while i < items
{
v = curve_function( i / ( items - 1 ) )
if v < 0 { v = 0 }
if v > 1 { v = 1 }
if type == INT8 { v * max }
if type == INT16 { v * max }
logf( "%d: %d\n", i, v )
curve[ i ] = v
i + 1
}
save( curve, filename, FORMAT_RAW )
clear( BLACK )
i = 0 while i < items
{
x = i / items * xsize - xsize / 2
y = - ( curve_function( i / items ) - 0.5 ) * ysize
dot( x, y, WHITE )
i + 1
}
while 1
{
frame( 100 )
while get_event() { if EVT[ EVT_TYPE ] == EVT_QUIT { halt } }
}