Index: include/libroardsp/interleave.h
===================================================================
--- include/libroardsp/interleave.h	(revision 3034)
+++ include/libroardsp/interleave.h	(revision 3034)
@@ -0,0 +1,61 @@
+//interleave.h:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009
+ *
+ *  This file is part of libroar a part of RoarAudio,
+ *  a cross-platform sound system for both, home and professional use.
+ *  See README for details.
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 3
+ *  as published by the Free Software Foundation.
+ *
+ *  libroar 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 General Public License
+ *  along with this software; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  NOTE for everyone want's to change something and send patches:
+ *  read README and HACKING! There a addition information on
+ *  the license of this document you need to read before you send
+ *  any patches.
+ *
+ *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
+ *  or libpulse*:
+ *  The libs libroaresd, libroararts and libroarpulse link this lib
+ *  and are therefore GPL. Because of this it may be illigal to use
+ *  them with any software that uses libesd, libartsc or libpulse*.
+ */
+
+#ifndef _LIBROARDSP_INTERLEAVE_H_
+#define _LIBROARDSP_INTERLEAVE_H_
+
+#include "libroardsp.h"
+
+#define ROAR_INTERLEAVE_CTL_GET                   0x00
+#define ROAR_INTERLEAVE_CTL_SET                   0x01
+
+#define ROAR_INTERLEAVE_CTL_SET_MAX_BUFFER        (ROAR_INTERLEAVE_CTL_SET|0x10)
+
+#define ROAR_INTERLEAVE_MAX_CHANNELS              16
+
+struct roar_interleave {
+ size_t channels;
+ size_t bits;
+};
+
+int roar_interl_init  (struct roar_interleave * state, size_t channels, size_t bits);
+int roar_interl_uninit(struct roar_interleave * state);
+
+int roar_interl_ctl   (struct roar_interleave * state, int cmd, void * data);
+
+int roar_interl_uninit_calc_ext(struct roar_interleave * state, void * in, void ** out, size_t len);
+
+#endif
+
+//ll
Index: include/libroardsp/libroardsp.h
===================================================================
--- include/libroardsp/libroardsp.h	(revision 3029)
+++ include/libroardsp/libroardsp.h	(revision 3034)
@@ -38,4 +38,5 @@
 #endif
 
+#include "interleave.h"
 #include "midi.h"
 #include "synth.h"
Index: libroardsp/Makefile
===================================================================
--- libroardsp/Makefile	(revision 3010)
+++ libroardsp/Makefile	(revision 3034)
@@ -5,5 +5,5 @@
 
 TARGETS=$(SLIB) libroardsp.a
-OBJS=libroardsp.o convert.o midside.o poly.o filter.o filterchain.o remove.o transcode.o vio_transcode.o rms.o fader.o mixer.o amp.o
+OBJS=libroardsp.o convert.o midside.o poly.o filter.o filterchain.o remove.o transcode.o vio_transcode.o rms.o fader.o mixer.o amp.o interleave.o
 OLDROAR=midi.o
 FILTER=filter_lowp.o filter_highp.o filter_amp.o filter_quantify.o filter_add.o filter_clip.o filter_downmix.o filter_dcblock.o filter_swap.o filter_agc.o filter_speex_prep.o
Index: libroardsp/interleave.c
===================================================================
--- libroardsp/interleave.c	(revision 3034)
+++ libroardsp/interleave.c	(revision 3034)
@@ -0,0 +1,98 @@
+//interleave.c:
+
+/*
+ *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009
+ *
+ *  This file is part of libroardsp a part of RoarAudio,
+ *  a cross-platform sound system for both, home and professional use.
+ *  See README for details.
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 3
+ *  as published by the Free Software Foundation.
+ *
+ *  libroardsp 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 General Public License
+ *  along with this software; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include "libroardsp.h"
+
+int roar_interl_init  (struct roar_interleave * state, size_t channels, size_t bits) {
+ if ( state == NULL )
+  return -1;
+
+ // we can currently only hanle full bytes:
+ if ( bits % 8 )
+  return -1;
+
+ // currently we have a channel limit
+ if ( channels > ROAR_INTERLEAVE_MAX_CHANNELS )
+  return -1;
+
+ memset(state, 0, sizeof(struct roar_interleave));
+
+ state->channels = channels;
+ state->bits     = bits;
+
+ return 0;
+}
+
+int roar_interl_uninit(struct roar_interleave * state) {
+ if ( state == NULL )
+  return -1;
+
+ memset(state, 0, sizeof(struct roar_interleave));
+
+ return 0;
+}
+
+int roar_interl_ctl   (struct roar_interleave * state, int cmd, void * data) {
+ if ( state == NULL )
+  return -1;
+
+ return -1;
+}
+
+int roar_interl_uninit_calc_ext(struct roar_interleave * state, void * in, void ** out, size_t len) {
+ size_t chan = 0;
+ size_t ic;       // input counter
+ size_t bc   = 0; // bit counter
+ char   * op[ROAR_INTERLEAVE_MAX_CHANNELS]; // output pointer
+
+ if ( state == NULL )
+  return -1;
+
+ if ( in == NULL || out == NULL )
+  return -1;
+
+ if ( len == 0 )
+  return 0;
+
+ memcpy(op, out, sizeof(void*)*state->channels);
+
+ for (ic = 0; ic < len; ic++) {
+  // get char and copy it
+  *(op[chan]) = ((char*)in)[ic];
+  op[chan]++;
+
+  bc += 8;
+
+  if ( bc == state->bits ) {
+   bc = 0;
+   chan++;
+   if ( chan == state->channels )
+    chan = 0;
+  }
+ }
+
+ return -1;
+}
+
+//ll
