Re: [pulseaudio-discuss] [PATCH] Implement Fortemedia SMA processing.

2011-01-15 Thread Colin Guthrie
'Twas brillig, and Alban Browaeys at 14/01/11 20:56 did gyre and gimble:
 Le jeudi 06 janvier 2011 à 10:30 +, Colin Guthrie a écrit :
 Hi Alban,

 'Twas brillig, and Alban Browaeys at 06/01/11 00:32 did gyre and gimble:
 From 853a4d96bf2624ef30f86cf4819382949d039c87 Mon Sep 17 00:00:00 2001
 From: Alban Browaeys pra...@yahoo.com
 Date: Wed, 5 Jan 2011 17:13:04 +0100
 Subject: [PATCH] Implement Fortemedia SMA processing.

 Those small array microphones returns two channels of opposite
 phase thus the default remap in pulseaudio doing the sum output
 silence.


 Many thanks for this patch, it's very interesting, especially as I've
 been helping a couple folk with mics that appear to be 180 deg OOP
 recently (although this could be an unrelated issue, see:
 https://qa.mandriva.com/show_bug.cgi?id=55930 and
 http://blog.moncef-mechri.com/?p=124 to see if you think this is a
 similar issue)
 
 Most likely yes . Acer uses fortemedia in quite many of its models (I
 have an acer ferrari one 200).
 
 Can you explain how to use the module and what users need to do to make
 it work?

 
 Currently one have to explicitely add:
 load-module module-fmaudiosma
 to /etc/pulse/default.pa
 restart pulse. (or one could use pacmd to load the module).
 
 Then I uses gnome-control-center 3 sound panel and in input tab select
 FMAudio SMA Source name of input stereo
 Same could be achieved via pavucontrol.
 
 
 That s it. I hope it could be improved. Ie for example the choice does
 not remains through sessions. That is the most annoying issue at this
 stage. Any requests (and clues as to how to implement them) welcomed !

I think in that case we need to find a way to enable this automatically,
rather than add this module which requires manual activation.

Personally I'd prefer to make it work at the ALSA level so that all
higher level things (PA included), but if that is not possible (which I
doubt) then I'd say we need to have some way to detect this and
compensate for it automatically.

Perhaps by some udev tags or such like which is then read and processed
within the mixer profile logic? Open to suggestions here.

FWIW, I'm still not 100% sure if this is caused by the use of front:0
and whether it would be avoided by using hw:0 (I'd be surprised if a
wider problem in pure-alsa was still completely unresolved, but not that
surprised :p).

Anyway, suggestions for fully automating this solution would be appreciated.

Col



-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Implement Fortemedia SMA processing.

2011-01-14 Thread Alban Browaeys
Le jeudi 06 janvier 2011 à 10:30 +, Colin Guthrie a écrit :
 Hi Alban,
 
 'Twas brillig, and Alban Browaeys at 06/01/11 00:32 did gyre and gimble:
  From 853a4d96bf2624ef30f86cf4819382949d039c87 Mon Sep 17 00:00:00 2001
  From: Alban Browaeys pra...@yahoo.com
  Date: Wed, 5 Jan 2011 17:13:04 +0100
  Subject: [PATCH] Implement Fortemedia SMA processing.
  
  Those small array microphones returns two channels of opposite
  phase thus the default remap in pulseaudio doing the sum output
  silence.
 
 
 Many thanks for this patch, it's very interesting, especially as I've
 been helping a couple folk with mics that appear to be 180 deg OOP
 recently (although this could be an unrelated issue, see:
 https://qa.mandriva.com/show_bug.cgi?id=55930 and
 http://blog.moncef-mechri.com/?p=124 to see if you think this is a
 similar issue)

Most likely yes . Acer uses fortemedia in quite many of its models (I
have an acer ferrari one 200).

 Can you explain how to use the module and what users need to do to make
 it work?
 

Currently one have to explicitely add:
load-module module-fmaudiosma
to /etc/pulse/default.pa
restart pulse. (or one could use pacmd to load the module).

Then I uses gnome-control-center 3 sound panel and in input tab select
FMAudio SMA Source name of input stereo
Same could be achieved via pavucontrol.


That s it. I hope it could be improved. Ie for example the choice does
not remains through sessions. That is the most annoying issue at this
stage. Any requests (and clues as to how to implement them) welcomed !




PS: any tweak to make the small array of microphones work somewhat
applied by hand should be reverted . The most common fix used was to
mute one of the channel of the stereo input. This is not critical
though.

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Implement Fortemedia SMA processing.

2011-01-06 Thread Colin Guthrie
Hi Alban,

'Twas brillig, and Alban Browaeys at 06/01/11 00:32 did gyre and gimble:
 From 853a4d96bf2624ef30f86cf4819382949d039c87 Mon Sep 17 00:00:00 2001
 From: Alban Browaeys pra...@yahoo.com
 Date: Wed, 5 Jan 2011 17:13:04 +0100
 Subject: [PATCH] Implement Fortemedia SMA processing.
 
 Those small array microphones returns two channels of opposite
 phase thus the default remap in pulseaudio doing the sum output
 silence.


Many thanks for this patch, it's very interesting, especially as I've
been helping a couple folk with mics that appear to be 180 deg OOP
recently (although this could be an unrelated issue, see:
https://qa.mandriva.com/show_bug.cgi?id=55930 and
http://blog.moncef-mechri.com/?p=124 to see if you think this is a
similar issue)

Can you explain how to use the module and what users need to do to make
it work?

Many thanks.

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] Implement Fortemedia SMA processing.

2011-01-06 Thread David Henningsson

On 2011-01-06 01:32, Alban Browaeys wrote:

 From 853a4d96bf2624ef30f86cf4819382949d039c87 Mon Sep 17 00:00:00 2001
From: Alban Browaeyspra...@yahoo.com
Date: Wed, 5 Jan 2011 17:13:04 +0100
Subject: [PATCH] Implement Fortemedia SMA processing.

Those small array microphones returns two channels of opposite
phase thus the default remap in pulseaudio doing the sum output
silence.


Sounds very useful, but...


+void pa_fmaudiosma_run(pa_fmaudiosma *fs, const uint8_t *rec, uint8_t *out, 
int n) {
+unsigned i;
+
+float *d, *s;
+int n_frames = n / (sizeof(float) *  2);
+memset(out, 0, n_frames * sizeof (float) * 2);
+
+d = (float *)out;
+s = (float *)rec;
+for (i = n_frames; i  0; i--, s += 2, d += 2)
+   d[0] = d[1] = s[0] - (s[0] + s[1]);


s[0] - (s[0] + s[1]) can be simplified to -s[1], unless my junior 
high math fails me completely. Are you sure you don't mean s[0] - s[1]?


--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] Implement Fortemedia SMA processing.

2011-01-05 Thread Alban Browaeys
From 853a4d96bf2624ef30f86cf4819382949d039c87 Mon Sep 17 00:00:00 2001
From: Alban Browaeys pra...@yahoo.com
Date: Wed, 5 Jan 2011 17:13:04 +0100
Subject: [PATCH] Implement Fortemedia SMA processing.

Those small array microphones returns two channels of opposite
phase thus the default remap in pulseaudio doing the sum output
silence.

Signed-off-by: Alban Browaeys pra...@yahoo.com
---
 src/Makefile.am |   10 +-
 src/modules/module-fmaudiosma.c |  692 +++
 2 files changed, 700 insertions(+), 2 deletions(-)
 create mode 100644 src/modules/module-fmaudiosma.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 15a4644..755b01d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1036,7 +1036,8 @@ modlibexec_LTLIBRARIES += \
module-cork-music-on-phone.la \
module-loopback.la \
module-virtual-sink.la \
-   module-virtual-source.la
+   module-virtual-source.la \
+   module-fmaudiosma.la
 
 # See comment at librtp.la above
 if !OS_IS_WIN32
@@ -1318,7 +1319,8 @@ SYMDEF_FILES = \
modules/dbus/module-dbus-protocol-symdef.h \
modules/module-loopback-symdef.h \
modules/module-virtual-sink-symdef.h \
-   modules/module-virtual-source-symdef.h
+   modules/module-virtual-source-symdef.h \
+   modules/module-fmaudiosma-symdef.h
 
 EXTRA_DIST += $(SYMDEF_FILES)
 BUILT_SOURCES += $(SYMDEF_FILES)
@@ -1495,6 +1497,10 @@ module_virtual_source_la_SOURCES = 
modules/module-virtual-source.c
 module_virtual_source_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_virtual_source_la_LIBADD = $(AM_LIBADD) libpulseco...@pa_majorminor@.la 
libpulsecomm...@pa_majorminor@.la libpulse.la
 
+module_fmaudiosma_la_SOURCES = modules/module-fmaudiosma.c
+module_fmaudiosma_la_LDFLAGS = $(MODULE_LDFLAGS)
+module_fmaudiosma_la_LIBADD = $(AM_LIBADD) libpulseco...@pa_majorminor@.la 
libpulsecomm...@pa_majorminor@.la libpulse.la
+
 # X11
 
 module_x11_bell_la_SOURCES = modules/x11/module-x11-bell.c
diff --git a/src/modules/module-fmaudiosma.c b/src/modules/module-fmaudiosma.c
new file mode 100644
index 000..636500e
--- /dev/null
+++ b/src/modules/module-fmaudiosma.c
@@ -0,0 +1,692 @@
+/***
+This file is part of PulseAudio.
+
+Copyright 2011 Alban Browaeys pra...@yahoo.com
+
+Base on module-echo-cancel.c
+
+Copyright 2010 Wim Taymans wim.taym...@gmail.com
+
+PulseAudio is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published
+by the Free Software Foundation; either version 2.1 of the License,
+or (at your option) any later version.
+
+PulseAudio is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with PulseAudio; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include stdio.h
+#include math.h
+
+#include pulse/xmalloc.h
+#include pulse/i18n.h
+#include pulse/timeval.h
+#include pulse/rtclock.h
+
+#include pulsecore/atomic.h
+#include pulsecore/macro.h
+#include pulsecore/core-error.h
+#include pulsecore/namereg.h
+#include pulsecore/sink.h
+#include pulsecore/module.h
+#include pulsecore/core-rtclock.h
+#include pulsecore/core-util.h
+#include pulsecore/core-error.h
+#include pulsecore/modargs.h
+#include pulsecore/log.h
+#include pulsecore/thread.h
+#include pulsecore/thread-mq.h
+#include pulsecore/rtpoll.h
+#include pulsecore/sample-util.h
+#include pulsecore/ltdl-helper.h
+
+#include module-fmaudiosma-symdef.h
+
+PA_MODULE_AUTHOR(Alban Browaeys);
+PA_MODULE_DESCRIPTION(Fortemedia Small Microphones Array);
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_LOAD_ONCE(FALSE);
+PA_MODULE_USAGE(
+_(source_name=name for the source 
+  source_properties=properties for the source 
+  source_master=name of source to filter 
+  format=sample format 
+  rate=sample rate 
+  channels=number of channels 
+  channel_map=channel map 
+));
+
+#define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
+
+/* Common data structures */
+
+typedef struct pa_fmaudiosma pa_fmaudiosma;
+
+struct pa_fmaudiosma {
+pa_bool_t   (*init) (pa_core *c,
+ pa_fmaudiosma *fs,
+ pa_sample_spec *source_ss,
+ pa_channel_map *source_map);
+void(*run)  (pa_fmaudiosma *fs, const uint8_t 
*rec, uint8_t *out, int n);
+void(*done)