Hi guys,
I am attempting to write an OOT module to be implemented on Android and
am
finding myself out of my depth here.
As a first step I was able to make and execute my flowgraph on my
android
device following the instructions on the wiki, using a file sink to
store my
end result (demodulated string.)
Now I would like to create my own sink which takes char inputs and
updates a
TextView object as they are ‘spat out’ by the flowgraph. I followed the
general instructions on the wiki for coding an OOT module/object, so
gr_modtool generated all the boiler plate code and I have modified it
accordingly.
Where I am hitting an issue is that I must pass JNIEnv* and jobject
arguments to my make (hence impl) functions in order to interact with
the
TextView object in my work function… but when I try to build the module
I
get the following error for example: “error: ‘JNIEnv’ has not been
declared”,
and similarly for all the jobject, jclass, and jmethodID occurrences. It
would seem make doesn’t know how to find the JNI libraries (and I’m
guessing
volk is missing too,) and I’m unsure how to tell it where to look. Any
thoughts? Or is there a smarter / less roundabout way altogether to
display
my flowgraph output in my Android activity?
Thanks,
Vijay
From: [email protected] [mailto:[email protected]] On Behalf Of
Tom
Rondeau
Sent: March-19-15 07:36
To: Vijay G.
Cc: GNURadio D.ion List
Subject: Re: [Discuss-gnuradio] GNU Radio on Android
On Thu, Mar 19, 2015 at 3:28 AM, Vijay G. [email protected]
wrote:
Tom,
As you expected, disabling buffering on the file sink did not have any
effect. I have fixed the issue though by making two changes to
opensl_source_impl.cc:
- change scale_factor to 32768 (1/2^14 doesn’t make sense, it causes
clipping because the volk conversion method divides by scale_factor.)
- change buffer size (d_size) to 8k (2k was too small, tested
32/44.1/48kHz
on Nexus 4 and Nexus 7 2012 version.) Without this change the recorded
audio
will be very choppy (dropped samples?)
Vijay
Ah, ok, that makes sense. I think I was just playing around with those
parameters and must have checked them in at that state.
I’ll make those updates to the repo.
Thanks.
Tom
From: [email protected] [mailto:[email protected]] On Behalf Of
Tom
Rondeau
Sent: March-18-15 07:11
To: Vijay G.
Cc: GNURadio D.ion List
Subject: Re: [Discuss-gnuradio] GNU Radio on Android
On Wed, Mar 18, 2015 at 1:46 AM, Vijay G. [email protected]
wrote:
Tom,
What kind of sample rate / setup are you using for your opensl_source?
I’ve
set up a flowgraph that is just an opensl_source (sampling at 48kHz)
connected to a file sink, and when I play back the file through GRC on
my
desktop my audio is coming out pretty garbled, as if samples are being
dropped. I’ve also tried a couple other sampling rates (44.1kHz, 32kHz,
16kHz to name a few.) I’m using a Nexus 4 running Android 5.0.1. Pasted
below is some of my code.
Vijay
Flowgraph code:
JNIEXPORT void JNICALL
Java_com_example_grrecordmic_GrRecordMic_InitFlowgraph(JNIEnv* env,
jobject
thiz, jstring jsinkfilename)
{
int rate = 48000;
const char *sinkfilename = env->GetStringUTFChars(jsinkfilename, 0);
global_tb = gr::make_top_block("Record_Mic");
gr::grand::opensl_source::sptr micSource =
gr::grand::opensl_source::make(rate);
gr::blocks::file_sink::sptr fileSink =
gr::blocks::file_sink::make(sizeof(float), sinkfilename, false);
global_tb->connect(micSource, 0, fileSink, 0);
env->ReleaseStringUTFChars(jsinkfilename, sinkfilename);
}
I believe that I used either 32k and/or 44.1k. I was using a Nexus 7,
though, and the codec might play a significant role with this between
the
two devices.
Perhaps try setting the file sink to unbuffered mode?
fileSink->set_unbuffered(true);
Frankly, I feel like this is unlikely to help, but it’ll be interesting
to
know what happens.
Tom
From: [email protected] [mailto:[email protected]] On Behalf Of
Tom
Rondeau
Sent: March-17-15 07:37
To: Vijay G.
Cc: GNURadio D.ion List
Subject: Re: [Discuss-gnuradio] GNU Radio on Android
On Tue, Mar 17, 2015 at 12:10 AM, Vijay G. [email protected]
wrote:
Thanks Tom, that sorted it out. My audio output is a bit choppy but no
matter – time to move on to some more complex flowgraphs in my Android
app.
Thanks again,
Vijay
Yes, the skipping in the audio output is a known bug, and apparently
known
to be difficult in Android. It’s going to take some kind of double
buffering
to fix it at this level. I did not experience any problems with the
audio
source, though; I just saved it to a file, brought it back to my
computer,
and played it there and it sounded fine.
Tom
From: [email protected] [mailto:[email protected]] On Behalf Of
Tom
Rondeau
Sent: March-16-15 06:37
To: Vijay G.
Cc: GNURadio D.ion List
Subject: Re: [Discuss-gnuradio] GNU Radio on Android
On Mon, Mar 16, 2015 at 3:28 AM, Vijay G. [email protected]
wrote:
Hi Tom,
I have been following your notes on the wiki in an attempt to build a
test
app (a dial tone flowgraph.) I’m hitting a snag on the ndk-build step
though – when I use your example Android.mk listing, the linker isn’t
finding any of the static libraries we built (gnuradio, grand, boost,
fftw.)
Instead I’m getting a pile of undefined reference errors.
I tried editing the example Android.mk file by adding the following
before
the shared library build:
include $(CLEAR_VARS)
LOCAL_MODULE := grand_static_lib #for example
LOCAL_SRC_FILES := /opt/grandroid/lib/libgnuradio-grand.a
include $(PREBUILT_STATIC_LIBRARY)
However I quickly realised that while there are only a few gnuradio
libraries to add this way, there are a ton of boost libraries… Is
there a
smarter way to add all the prebuilt .a libraries at once? Or am I headed
in
the wrong direction entirely?
Any tips appreciated,
Vijay
Yep, you have to add all of the libraries into the Android.mk file. I’ve
updated the wiki:
http://gnuradio.org/redmine/projects/gnuradio/wiki/GRAndApps
You can go there and simply download GrAndroid.mk that does all of this
for
you and include it in your Android.mk file. Just follow the
instructions.
Hope that helps,
Tom
From: [email protected] [mailto:[email protected]] On Behalf Of
Tom
Rondeau
Sent: March-13-15 14:41
To: Vijay G.
Cc: GNURadio D.ion List
Subject: Re: [Discuss-gnuradio] GNU Radio on Android
On Fri, Mar 13, 2015 at 5:04 PM, Vijay G. [email protected]
wrote:
Hi,
Has a patched version of GNU Radio which runs on Android been released?
I’m working on a project where I’m transmitting information over audio
from a desktop system to an Android device, and since setting up the
transmitter end with GNU Radio was such a snap I would love to leverage
the GNU Radio system to build the receiver as well.
Thanks,
Vijay
Just yesterday, in fact:
http://gnuradio.org/redmine/projects/gnuradio/wiki/Android
I’ll try to release some of my apps soon. One of them captures from the
audio device, even. It’s not too hard since there’s the gr-grand opensl
audio source block to talk to the audio system.
Tom