Changeset 16:c4585a26128b in roaraudio


Ignore:
Timestamp:
06/19/08 21:13:21 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

preperation to support mixing at diffrent levels

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • TODO

    r15 r16  
    55 * add support for sync streams 
    66 * add a lot other things 
     7 * add code to handle streams with more than ROAR_MAX_CHANNELS channels 
  • include/roaraudio/audio.h

    r0 r16  
    5555#define ROAR_RATE_DEFAULT      44100 
    5656 
     57#define ROAR_MAX_CHANNELS         64 
     58 
    5759struct roar_audio_info { 
    5860 unsigned int rate; 
     
    6567 unsigned      channels; 
    6668 roar_intm16   scale; 
    67  roar_intm16 * mixer; 
     69 roar_intm16   mixer[ROAR_MAX_CHANNELS]; 
    6870}; 
    6971 
  • roard/include/mixer.h

    r0 r16  
    1212int mix_clients_32bit (void * output, void ** input, int samples); 
    1313 
     14int change_vol       (void * output, int bits, void * input, int samples, int channels, struct roar_mixer_settings * set); 
     15int change_vol_8bit  (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set); 
     16int change_vol_16bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set); 
     17int change_vol_24bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set); 
     18int change_vol_32bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set); 
     19 
    1420#endif 
    1521 
  • roard/include/streams.h

    r0 r16  
    2121 size_t need_extra; 
    2222 void  * output; 
     23 struct roar_mixer_settings mixer; 
    2324} * g_streams[ROAR_STREAMS_MAX]; 
    2425 
  • roard/mixer.c

    r0 r16  
    103103} 
    104104 
     105int change_vol (void * output, int bits, void * input, int samples, int channels, struct roar_mixer_settings * set) { 
     106 if ( bits == 8 ) { 
     107  return  change_vol_8bit(output, input, samples, channels, set); 
     108 } else if ( bits == 16 ) { 
     109  return  change_vol_16bit(output, input, samples, channels, set); 
     110 } else if ( bits == 24 ) { 
     111  return  change_vol_24bit(output, input, samples, channels, set); 
     112 } else if ( bits == 32 ) { 
     113  return  change_vol_32bit(output, input, samples, channels, set); 
     114 } else { 
     115  return -1; 
     116 } 
     117} 
     118 
     119int change_vol_8bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) { 
     120 char * in = input, out = output; 
     121 int    i; 
     122 int    s; 
     123 
     124 if ( !(in && out) ) 
     125  return -1; 
     126 
     127 for (i = 0; i < samples; i++) { 
     128  s  = in[i]; 
     129  s *= set->mixer[i % channels]; 
     130  s /= set->scale; 
     131  out[i] = s; 
     132 } 
     133 
     134 return 0; 
     135} 
     136 
     137int change_vol_16bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) { 
     138 int16_t * in = input, out = output; 
     139 int       i; 
     140 int       s; 
     141 
     142 if ( !(in && out) ) 
     143  return -1; 
     144 
     145 for (i = 0; i < samples; i++) { 
     146  s  = in[i]; 
     147  s *= set->mixer[i % channels]; 
     148  s /= set->scale; 
     149  out[i] = s; 
     150 } 
     151 
     152 return 0; 
     153} 
     154 
     155int change_vol_24bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) { 
     156 return -1; 
     157} 
     158 
     159int change_vol_32bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) { 
     160 return -1; 
     161} 
     162 
     163 
    105164//ll 
  • roard/streams.c

    r0 r16  
    2626 
    2727int streams_new    (void) { 
    28  int i; 
     28 int i, j; 
    2929 struct roar_stream * n = NULL; 
    3030 
     
    4646   n->offset     = 0; 
    4747 
    48    ((struct roar_stream_server*)n)->client     = -1; 
    49    ((struct roar_stream_server*)n)->buffer     = NULL; 
    50    ((struct roar_stream_server*)n)->need_extra = 0; 
    51    ((struct roar_stream_server*)n)->output     = NULL; 
     48   ((struct roar_stream_server*)n)->client      = -1; 
     49   ((struct roar_stream_server*)n)->buffer      = NULL; 
     50   ((struct roar_stream_server*)n)->need_extra  = 0; 
     51   ((struct roar_stream_server*)n)->output      = NULL; 
     52   ((struct roar_stream_server*)n)->mixer.scale = 65535; 
     53   for (j = 0; j < ROAR_MAX_CHANNELS; j++) 
     54    ((struct roar_stream_server*)n)->mixer.mixer[j] = 65535; 
    5255 
    5356   g_streams[i] = (struct roar_stream_server*)n; 
Note: See TracChangeset for help on using the changeset viewer.