vendredi 11 septembre 2015

Echo issue during audio streaming using native RTP lib in Android

I'm working on an Android app, which streams live audio from mic to the vlc using native android RTP lib (using AudioStream and AudioGroup) with in the same room on the speaker(it is conference app, so MIC and Speaker both will be in same room) the problem is, it is creating a lot of ECHO, i know the android have native Android API AcousticEchoCanceler and also NoiseSuppressor API but these APIs work with AudioRecord or MediaRecorder... I need some hep, how can i remove Echo using these native APIs with RTP lib OR Anyone can suggest me any 3rd party lib which streams live audio with built-in Echo canceler..

Here is the link you can see, they are streaming live audio in the same room, without any echo, we are working on the same concept of live streaming...

Thanks in advance...!



via Chebli Mohamed

Find file names containing value stored in a string variable or object and move that file

Hi Please help a Powershell newbie with a seemingly simple task which is doing my head in.

I have a folder containing a large list of hofixes. Each hotfix filename contains the KB number such as KB2993958 similar to Windows8.1-KB2957189-x64.msu

I'm trying to troubleshoot an issue caused by the installation of a particular hotfix. I have narrowed the selection down to about 50 possible hotfixes, far less than how many are contained in the master folder. I want to install 10 hotfixes at a time to try and isolate the issue.

I have the list of 50 hotfixes I need to install either in a get-hotfix object or probably converted to a string in a variable.

So I want to compare the Kb numbers listed in my object / variable against the file names in the master folder and if the file name contains any of the KB number stored in my variable then move this file into a folder, ready for installation. Seems simple. Can't work it out.

Please help. Feeling a bit dumb right now :( Many Thanks!!



via Chebli Mohamed

Emacs + windowed mode + non-ascii characters + utf8 file encoding

I've developed a little mode for emacs which applies enriched format (colors, different fonts, etc) to some pieces of text using regular expressions (as markdown does).

In some of these regular expressions, there's french and spanish characters (like ``), and unicode characters (like ☛). Usually I use emacs in no windows mode (-nw), but to edit files which uses my mode, I open emacs in windowed mode, and I've realized that in windowed mode I can't write non-ascii characters, like ` or ☛. So, I can't use these special patterns (files are utf8).

If I execute describe-input-method in emacs, it says that no input method is specified, both in windowed and nw mode. However, it's not crazy to say the input method is different in windows and nw mode, since in boths modes the characters I'm able to write are different; or have I misunderstood what the meaning of input mode in emacs is?



via Chebli Mohamed

Entities tracking in Entity Framework

I started reading more about EF. I believed that entities are tracked as long as the context is in scope. But when I try the code below I get different results. I'm sure I misunderstood what I read. Can you please explain.

Destination canyon;
DbEntityEntry<Destination> entry;
using (var context = new BreakAwayContext())
      {
          canyon = (from d in context.Destinations.Include(d => d.Lodgings)
                    where d.Name == "Grand Canyon"
                    select d).Single();
          entry = context.Entry<Destination>(canyon);
      }
Console.WriteLine(entry.State); //Unchanged
canyon.TravelWarnings = "Carry enough water!";
Console.WriteLine(entry.State); //Modified



via Chebli Mohamed

Java3D move individual Point3f in shape3D consisting of big Point3f array

I have the following code that paints 4 points in a canvas3D window

public final class energon extends JPanel {    

    int s = 0, count = 0;

    public energon() {
        setLayout(new BorderLayout());
        GraphicsConfiguration gc=SimpleUniverse.getPreferredConfiguration();
        Canvas3D canvas3D = new Canvas3D(gc);//See the added gc? this is a preferred config
        add("Center", canvas3D);

        BranchGroup scene = createSceneGraph();
        scene.compile();

        // SimpleUniverse is a Convenience Utility class
        SimpleUniverse simpleU = new SimpleUniverse(canvas3D);


        // This moves the ViewPlatform back a bit so the
        // objects in the scene can be viewed.
        simpleU.getViewingPlatform().setNominalViewingTransform();

        simpleU.addBranchGraph(scene);
    }
    public BranchGroup createSceneGraph() {
        BranchGroup lineGroup = new BranchGroup();
        Appearance app = new Appearance();
        ColoringAttributes ca = new ColoringAttributes(new Color3f(204.0f, 204.0f,          204.0f), ColoringAttributes.SHADE_FLAT);
        app.setColoringAttributes(ca);

        Point3f[] plaPts = new Point3f[4];

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j <2; j++) {
                plaPts[count] = new Point3f(i/10.0f,j/10.0f,0);
                //Look up line, i and j are divided by 10.0f to be able to
                //see the points inside the view screen
                count++;
            }
        }
        PointArray pla = new PointArray(4, GeometryArray.COORDINATES);
        pla.setCoordinates(0, plaPts);
        Shape3D plShape = new Shape3D(pla, app);
        TransformGroup objRotate = new TransformGroup();
        objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objRotate.addChild(plShape);
        lineGroup.addChild(objRotate);
        return lineGroup;
    }

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.add(new JScrollPane(new energon()));
        frame.setSize(300, 300);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

Now i want to add a timertask that regularly updates the position of one of the points in the plaPts Point3f array. However, when i call plaPts[1].setX(2), nothing happens on the screen, they remain in the same position.

Do you have to have each point in a separate TransformGroup (consisting of a shape3D with a Point3f array of size 1) for this to be possible? I'm later going to use 100000 points, is it bad for performance if they all are in separate TransformGroups? Is there an easier way of doing this? Something like shape3D.repaint(), that automatically updates the position of the points based on the new values in plaPTS.



via Chebli Mohamed

Using scala.Future with Java 8 lambdas

The scala Future class has several methods that are based on functional programming. When called from Java, it looks like using lambdas from Java 8 would be a natural fit.

However, when I try to actually use that, I run into several problems. The following code does not compile

someScalaFuture.map(val -> Math.sqrt(val)).
       map(val -> val + 3); 

because map takes an ExecutionContext as an implicit argument. In Scala, you can (usually) ignore that, but it needs to be passed in explicitly in Java.

someScalaFuture.map(val -> Math.sqrt(val),
                    ec).
       map(val -> val + 3,
           ec);

This fails with this error:

error: method map in interface Future<T> cannot be applied to given types;
[ERROR] val),ExecutionContextExecutor
  reason: cannot infer type-variable(s) S
    (argument mismatch; Function1 is not a functional interface
      multiple non-overriding abstract methods found in interface Function1)
  where S,T are type-variables:
    S extends Object declared in method <S>map(Function1<T,S>,ExecutionContext)
    T extends Object declared in interface Future 

If I actually create an anonymous class extending Function1 and implement apply as such:

    someScalaFuture.map(new Function1<Double, Double>() {
            public double apply(double val) { return Math.sqrt(val); }
        },
        ec).
        map(val -> val + 3,
            ec);

I get an error that

error: <anonymous com.example.MyTestClass$1> is not abstract and does not override abstract method apply$mcVJ$sp(long) in Function1

I have not tried implementing that method (and am not sure if you can even implement a method with dollar signs in the middle of the name), but this looks like I am starting to wonder into the details of Scala implementations.

Am I going down a feasible path? Is there a reasonable way to use lambdas in this way? If there is a library that makes this work, that is an acceptable solution. Ideally, something like

import static org.thirdparty.MakeLambdasWork.wrap;
...
   wrap(someScalaFuture).map(val -> Math.sqrt(val)).
         map(val -> val + 3);



via Chebli Mohamed

Compose variadic template argument by transforming them

I have a simple situation which probably require a complex way to be solved but I'm unsure of it.

Basically I have this object which encapsulated a member function:

template<class T, typename R, typename... ARGS>
class MemberFunction
{
private:
  using function_type = R (T::*)(ARGS...);

  function_type function;

public:
  MemberFunction(function_type function) : function(function) { }

  void call(T* object, ARGS&&... args)
  {
    (object->*function)(args...);
  }   
};

This can be used easily

MemberFunction<Foo, int, int, int> function(&Foo::add)
Foo foo;
int res = function.call(&foo, 10,20)

The problem is that I would like to call it by passing through a custom environment which uses a stack of values to operate this method, this translates to the following code:

int arg2 = stack.pop().as<int>();
int arg1 = stack.pop().as<int>();
Foo* object = stack.pop().as<Foo*>();
int ret = function.call(object, arg1, arg2);
stack.push(Value(int));

This is easy to do directly in code but I'd like to find a way to encapsulate this behavior directly into MemberFunction class by exposing a single void call(Stack& stack) method which does the work for me to obtain something like:

MemberFunction<Foo, int, int, int> function(&Foo::add);
Stack stack;
stack.push(Value(new Foo());
stack.push(10);
stack.push(20);
function.call(stack);
assert(stack.pop().as<int>() == Foo{}.add(10,20));

But since I'm new to variadic templates I don't know how could I do in efficiently and elegantly.



via Chebli Mohamed