no signal from sv input module (android11)

Pixilang programming language
Post Reply
rototom
Posts: 24
Joined: Mon Mar 14, 2022 4:12 pm

no signal from sv input module (android11)

Post by rototom »

hi, need some help with sv input module.
the most basic input to output like:

Code: Select all

 set_pixel_size( WINDOW_XSIZE / 480 )
resize( get_screen(), WINDOW_XSIZE, WINDOW_YSIZE )

sv = sv_new()
sv_lock(sv)

mod_input = sv_new_module(sv,"Input")//create input module
sv_connect_module(sv,mod_input,0)
sv_unlock(sv)

while 1
{

while( get_event() ) { if EVT[ EVT_TYPE ] == EVT_QUIT { halt } }
} 
NOT working here. (android 11)
do I miss something?

edit: also it seems the input module is not responding to sv_send_event() messages?
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: no signal from sv input module (android11)

Post by NightRadio »

Sorry, there is no direct (and simple) support of the Input module in the current version of Pixilang. I plan to implement this in the next updates.
But you can use it through the sv_render() function. Please see the code below

Code: Select all

//Input (Mic/Line) -> Amplifier -> Filter -> Output

set_pixel_size( WINDOW_XSIZE / 256 )
resize( get_screen(), WINDOW_XSIZE, WINDOW_YSIZE )

xsize = get_xsize( get_screen() )
ysize = get_ysize( get_screen() )
hxsize = xsize / 2
hysize = ysize / 2

fn audio_callback(
    $stream, 
    $userdata, 
    $channels, 
    $frames, 
    $output_time_in_system_ticks, 
    $in_channels, 
    $latency_in_frames )
{
    $rv = 0
    if $in_channels >= 0
    {
	copy( in_buf, $in_channels[ 0 ], 0, 0, $frames, 2, 1 ) //convert to interleaved format: LL RR -> LRLR
	copy( in_buf, $in_channels[ 1 ], 1, 0, $frames, 2, 1 ) //...
	$rv = sv_render( sv, out_buf, $frames, $latency_in_frames, $output_time_in_system_ticks, in_buf, 2 )
	copy( $channels[ 0 ], out_buf, 0, 0, $frames, 1, 2 ) //convert from interleaved format: LRLR -> LL RR
	copy( $channels[ 1 ], out_buf, 0, 1, $frames, 1, 2 ) //...

	//Visualization:
	copy( visual_buf, $channels[ 0 ] )
    }
    ret( $rv )
}

visual_buf = new( 256, 1, FLOAT )
in_buf = new( 8192, 1, FLOAT )
out_buf = new( 8192, 1, FLOAT )
clean( visual_buf )

sv = sv_new( 44100, SV_INIT_FLAG_OFFLINE )
set_audio_callback( audio_callback, 0, 44100, FLOAT, 2 )
enable_audio_input( 1 )

sv_lock( sv )
mod_input = sv_new_module( sv, "Input" )
mod_amp = sv_new_module( sv, "Amplifier" )
mod_filter = sv_new_module( sv, "Filter" )
sv_connect_module( sv, mod_input, mod_amp ) //Input -> Amplifier
sv_connect_module( sv, mod_amp, mod_filter ) //Amplifier -> Filter
sv_connect_module( sv, mod_filter, 0 ) //Filter -> OUTPUT
sv_unlock( sv )

sv_set_event_t( sv, 1, 0 ) //handle all incoming events as quickly as possible

//Input.02.Channels = 1 (stereo)
ctl_num = 2
ctl_val = 1
sv_send_event( sv, 0, 0, 0, mod_input + 1, ctl_num << 8, ctl_val )

//Amplifier.08.Gain = some value
ctl_num = 8
ctl_val = 16 //16000
sv_send_event( sv, 0, 0, 0, mod_amp + 1, ctl_num << 8, ctl_val )

while 1
{
    transp( 64 );
    clear()
    transp( 256 );

    x = 0 while( x < 256 )
    {
        line( x - 128, 0, x - 128, visual_buf[ x ] * 256, GREEN )
        x + 1
    }

    while( get_event() ) { if EVT[ EVT_TYPE ] == EVT_QUIT { breakall } }

    frame()
}

set_audio_callback( -1 )
sv_remove( sv )
remove( visual_buf )
remove( in_buf )
remove( out_buf )
rototom
Posts: 24
Joined: Mon Mar 14, 2022 4:12 pm

Re: no signal from sv input module (android11)

Post by rototom »

thank you very much for your help and for the example! @nightradio
i've been able to integrate it into my patch. it's working now.
looking forward for your impementation of the input module in the next version/s!
Post Reply