is it possible to record from mic/line in?
is it possible to record from mic/line in?
Hi,
First of all: thank you so much, nightradio, for making pixilang available. I've only just started playing around with it this weekend, and so far it seems awesome!
And now to my total beginners question:
Is there a way to record audio from mic/line in? The only mention of anything related I can find in the manual is enable_audio_input(), but I suspect that won't take me all the way..
I'd be extremely greatful for any pointers in the right direction!
First of all: thank you so much, nightradio, for making pixilang available. I've only just started playing around with it this weekend, and so far it seems awesome!
And now to my total beginners question:
Is there a way to record audio from mic/line in? The only mention of anything related I can find in the manual is enable_audio_input(), but I suspect that won't take me all the way..
I'd be extremely greatful for any pointers in the right direction!
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: is it possible to record from mic/line in?
Hello!
Of course, it is possible :) The problem is there is no mic/line recording examples in Pixilang. But i will make it for you
Of course, it is possible :) The problem is there is no mic/line recording examples in Pixilang. But i will make it for you
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: is it possible to record from mic/line in?
First. Simple Input (Mic/Line) Visualizer
Second. Input to Output (feedback)
Code: Select all
fn audio_callback(
$stream,
$userdata,
$channels,
$frames,
$output_time_in_system_ticks,
$in_channels,
$latency_in_frames )
{
if $in_channels >= 0
{
copy( visual_buf, $in_channels[ 0 ] )
}
ret( 0 ) //output is empty
}
visual_buf = new( 256, 1, INT16 )
clean( visual_buf )
set_audio_callback( audio_callback, 0, 44100, INT16, 2 )
enable_audio_input( 1 )
xsize = get_xsize( get_screen() )
ysize = get_ysize( get_screen() )
hxsize = xsize / 2
hysize = ysize / 2
while 1
{
transp( 64 );
clear()
transp( 256 );
x = 0 while( x < 256 )
{
line( x - 128, 0, x - 128, visual_buf[ x ] / 512, GREEN )
x + 1
}
while( get_event() ) { if EVT[ EVT_TYPE ] == EVT_QUIT { halt } }
frame()
}
Code: Select all
fn audio_callback(
$stream,
$userdata,
$channels,
$frames,
$output_time_in_system_ticks,
$in_channels,
$latency_in_frames )
{
if $in_channels >= 0
{
//Copy input channels to the output:
$ch = 0 while $ch < 2
{
copy( $channels[ $ch ], $in_channels[ $ch ], 0, 0, $frames )
$ch + 1
}
//Visualization:
copy( visual_buf, $in_channels[ 0 ] )
ret( 1 ) //output is not empty
}
ret( 0 )
}
visual_buf = new( 256, 1, INT16 )
clean( visual_buf )
set_audio_callback( audio_callback, 0, 44100, INT16, 2 )
enable_audio_input( 1 )
xsize = get_xsize( get_screen() )
ysize = get_ysize( get_screen() )
hxsize = xsize / 2
hysize = ysize / 2
while 1
{
transp( 64 );
clear()
transp( 256 );
x = 0 while( x < 256 )
{
line( x - 128, 0, x - 128, visual_buf[ x ] / 512, GREEN )
x + 1
}
while( get_event() ) { if EVT[ EVT_TYPE ] == EVT_QUIT { halt } }
frame()
}
Re: is it possible to record from mic/line in?
Hey! Thank you so much for the very quick reply, and even more for posting example code! It looks very easy to do something usable with audio in - I'll have a go at it tonight. This is exactly how you make people use your stuff!
Re: is it possible to record from mic/line in?
Hi again,
I'm back, bothering you for more help...
I've managed to understand and run the example code on my nexus 5, and it works great. Now my problem is that i need to switch from recording from mic to recording from line in. On win7, that is easily done by selecting the proper input device in the prefs, but on the android version the only option seems to be "auto", which defaults to the mic. I can hear the sound i'm playing through line in, so i know the connection is ok, but the example program only reacts to the sound coming in via the mic. Is there a way of switching devices from within the code, or is it maybe a matter of selecting the proper x for $in_channels[ x ] in the audio callback? I tried x = 2 and x = 3, but that didn't seem to make any change... Please help, and big thanks in advance!
I'm back, bothering you for more help...
I've managed to understand and run the example code on my nexus 5, and it works great. Now my problem is that i need to switch from recording from mic to recording from line in. On win7, that is easily done by selecting the proper input device in the prefs, but on the android version the only option seems to be "auto", which defaults to the mic. I can hear the sound i'm playing through line in, so i know the connection is ok, but the example program only reacts to the sound coming in via the mic. Is there a way of switching devices from within the code, or is it maybe a matter of selecting the proper x for $in_channels[ x ] in the audio callback? I tried x = 2 and x = 3, but that didn't seem to make any change... Please help, and big thanks in advance!
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: is it possible to record from mic/line in?
Hm... Nexus 5 has separate Line-in port? :) I've never seen Android devices with line-in.
Re: is it possible to record from mic/line in?
Oh, no, it's a single 4-pole connection. What i mean is that even though the cable is inserted, pixilang records from the built in mic. Very weird, i agree. Maybe it's a hardware thing on my part?
Re: is it possible to record from mic/line in?
I'll make sure that i can record sound via cable into other apps, and get back to you if the problem persists!
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: is it possible to record from mic/line in?
Ah, ok. Please try to insert the Line-in before Pixilang launch.
Re: is it possible to record from mic/line in?
Hi again,
This seems to be something that affects the phone in general, not just pixilang. Not sure if it's software or hardware, but after a couple of reboots and some disconnecting and reconnecting i finally get a signal from line in. Sorry to bother you about it when i should be bothering google (or possibly LG)! =)
This seems to be something that affects the phone in general, not just pixilang. Not sure if it's software or hardware, but after a couple of reboots and some disconnecting and reconnecting i finally get a signal from line in. Sorry to bother you about it when i should be bothering google (or possibly LG)! =)
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: is it possible to record from mic/line in?
Ok :)
Pixilang and all my Android apps use the OpenSL for audio. OpenSL uses default system Audio Input and Output. So theoretically it should switch between the different audio ports automatically :) But unfortunately it is very dependent on device. My LG E510 does not work perfectly too
Pixilang and all my Android apps use the OpenSL for audio. OpenSL uses default system Audio Input and Output. So theoretically it should switch between the different audio ports automatically :) But unfortunately it is very dependent on device. My LG E510 does not work perfectly too
Re: is it possible to record from mic/line in?
hi nightradio,NightRadio wrote:First. Simple Input (Mic/Line) VisualizerSecond. Input to Output (feedback)Code: Select all
... }
Code: Select all
... }
nice sample.
the second sample has a little echo.
i use standard audio on a notebook.
i test it with driver asio4all and the echo is less then the standard, but it is. I think thats a general problem with the latenz. is there a programming trick in pixilang to reduce the latenz?
greetings - kmatze
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: is it possible to record from mic/line in?
In code - no. But you can change the audio parameters in the pixilang_config.ini
Format is the same as in SunVox: http://www.warmplace.ru/wiki/sunvox:man ... figuration
Format is the same as in SunVox: http://www.warmplace.ru/wiki/sunvox:man ... figuration