Index: TODO
===================================================================
--- TODO	(revision 15)
+++ TODO	(revision 16)
@@ -5,2 +5,3 @@
  * add support for sync streams
  * add a lot other things
+ * add code to handle streams with more than ROAR_MAX_CHANNELS channels
Index: include/roaraudio/audio.h
===================================================================
--- include/roaraudio/audio.h	(revision 0)
+++ include/roaraudio/audio.h	(revision 16)
@@ -55,4 +55,6 @@
 #define ROAR_RATE_DEFAULT      44100
 
+#define ROAR_MAX_CHANNELS         64
+
 struct roar_audio_info {
  unsigned int rate;
@@ -65,5 +67,5 @@
  unsigned      channels;
  roar_intm16   scale;
- roar_intm16 * mixer;
+ roar_intm16   mixer[ROAR_MAX_CHANNELS];
 };
 
Index: roard/include/mixer.h
===================================================================
--- roard/include/mixer.h	(revision 0)
+++ roard/include/mixer.h	(revision 16)
@@ -12,4 +12,10 @@
 int mix_clients_32bit (void * output, void ** input, int samples);
 
+int change_vol       (void * output, int bits, void * input, int samples, int channels, struct roar_mixer_settings * set);
+int change_vol_8bit  (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set);
+int change_vol_16bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set);
+int change_vol_24bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set);
+int change_vol_32bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set);
+
 #endif
 
Index: roard/include/streams.h
===================================================================
--- roard/include/streams.h	(revision 0)
+++ roard/include/streams.h	(revision 16)
@@ -21,4 +21,5 @@
  size_t need_extra;
  void  * output;
+ struct roar_mixer_settings mixer;
 } * g_streams[ROAR_STREAMS_MAX];
 
Index: roard/mixer.c
===================================================================
--- roard/mixer.c	(revision 0)
+++ roard/mixer.c	(revision 16)
@@ -103,3 +103,62 @@
 }
 
+int change_vol (void * output, int bits, void * input, int samples, int channels, struct roar_mixer_settings * set) {
+ if ( bits == 8 ) {
+  return  change_vol_8bit(output, input, samples, channels, set);
+ } else if ( bits == 16 ) {
+  return  change_vol_16bit(output, input, samples, channels, set);
+ } else if ( bits == 24 ) {
+  return  change_vol_24bit(output, input, samples, channels, set);
+ } else if ( bits == 32 ) {
+  return  change_vol_32bit(output, input, samples, channels, set);
+ } else {
+  return -1;
+ }
+}
+
+int change_vol_8bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) {
+ char * in = input, out = output;
+ int    i;
+ int    s;
+
+ if ( !(in && out) )
+  return -1;
+
+ for (i = 0; i < samples; i++) {
+  s  = in[i];
+  s *= set->mixer[i % channels];
+  s /= set->scale;
+  out[i] = s;
+ }
+
+ return 0;
+}
+
+int change_vol_16bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) {
+ int16_t * in = input, out = output;
+ int       i;
+ int       s;
+
+ if ( !(in && out) )
+  return -1;
+
+ for (i = 0; i < samples; i++) {
+  s  = in[i];
+  s *= set->mixer[i % channels];
+  s /= set->scale;
+  out[i] = s;
+ }
+
+ return 0;
+}
+
+int change_vol_24bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) {
+ return -1;
+}
+
+int change_vol_32bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) {
+ return -1;
+}
+
+
 //ll
Index: roard/streams.c
===================================================================
--- roard/streams.c	(revision 0)
+++ roard/streams.c	(revision 16)
@@ -26,5 +26,5 @@
 
 int streams_new    (void) {
- int i;
+ int i, j;
  struct roar_stream * n = NULL;
 
@@ -46,8 +46,11 @@
    n->offset     = 0;
 
-   ((struct roar_stream_server*)n)->client     = -1;
-   ((struct roar_stream_server*)n)->buffer     = NULL;
-   ((struct roar_stream_server*)n)->need_extra = 0;
-   ((struct roar_stream_server*)n)->output     = NULL;
+   ((struct roar_stream_server*)n)->client      = -1;
+   ((struct roar_stream_server*)n)->buffer      = NULL;
+   ((struct roar_stream_server*)n)->need_extra  = 0;
+   ((struct roar_stream_server*)n)->output      = NULL;
+   ((struct roar_stream_server*)n)->mixer.scale = 65535;
+   for (j = 0; j < ROAR_MAX_CHANNELS; j++)
+    ((struct roar_stream_server*)n)->mixer.mixer[j] = 65535;
 
    g_streams[i] = (struct roar_stream_server*)n;
