Changeset 5980:334fe3fbca15 in roaraudio


Ignore:
Timestamp:
01/28/14 13:56:24 (5 years ago)
Author:
phi
Branch:
default
Message:

done some updates to the light control subsystem. This will help allowing a more modern infrstructure for light control filters

Location:
roard
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • roard/codecfilter_roardmx.c

    r5977 r5980  
    156156 
    157157 for (i = 0; i < g_light_state.channels; i++) { 
    158   if ( g_light_state.changes[i] ) { 
     158  if ( g_light_state.outputchanges[i] ) { 
    159159   if ( !have_message ) 
    160160    if ( roar_roardmx_message_new_sset(&mes) == -1 ) 
     
    163163   have_message = 2; 
    164164 
    165    if ( roar_roardmx_message_add_chanval(&mes, i, g_light_state.state[i]) == -1 ) { 
     165   if ( roar_roardmx_message_add_chanval(&mes, i, g_light_state.output[i]) == -1 ) { 
    166166    if ( roar_roardmx_message_send(&mes, &(ss->vio)) == -1 ) 
    167167     return -1; 
  • roard/include/light.h

    r5961 r5980  
    4040 uint8_t * state; 
    4141 uint8_t * changes; 
     42 uint8_t * output; 
     43 uint8_t * outputchanges; 
    4244} g_light_state; 
    4345 
  • roard/light.c

    r5961 r5980  
    5353 if ( (g_light_state.changes = roar_mm_malloc(channels)) == NULL ) { 
    5454  roar_mm_free(g_light_state.state); 
     55  return -1; 
     56 } 
     57 
     58 if ( (g_light_state.output = roar_mm_malloc(channels)) == NULL ) { 
     59  roar_mm_free(g_light_state.state); 
     60  roar_mm_free(g_light_state.changes); 
     61  return -1; 
     62 } 
     63 
     64 if ( (g_light_state.outputchanges = roar_mm_malloc(channels)) == NULL ) { 
     65  roar_mm_free(g_light_state.state); 
     66  roar_mm_free(g_light_state.changes); 
     67  roar_mm_free(g_light_state.output); 
    5568  return -1; 
    5669 } 
     
    87100 } 
    88101 
     102 if ( g_light_state.output != NULL ) { 
     103  roar_mm_free(g_light_state.changes); 
     104 } 
     105 
     106 if ( g_light_state.outputchanges != NULL ) { 
     107  roar_mm_free(g_light_state.changes); 
     108 } 
     109 
    89110 g_light_state.channels = 0; 
    90111 
     
    102123  return -1; 
    103124 
    104  memset(g_light_state.state,   0, g_light_state.channels); 
     125 memset(g_light_state.state,         0, g_light_state.channels); 
     126 memset(g_light_state.changes,       0, g_light_state.channels); 
     127 memset(g_light_state.output,        0, g_light_state.channels); 
     128 memset(g_light_state.outputchanges, 0, g_light_state.channels); 
     129 memset(g_light_state.events,        0, sizeof(g_light_state.events)); 
     130 
     131 g_light_state.eventsqueuelen = 0; 
     132 
     133 return 0; 
     134} 
     135 
     136// called at end of mainloop. 
     137int light_reinit(void) { 
     138 if ( g_light_state.changes == NULL ) 
     139  return -1; 
     140 
    105141 memset(g_light_state.changes, 0, g_light_state.channels); 
    106142 memset(g_light_state.events,  0, sizeof(g_light_state.events)); 
     
    111147} 
    112148 
    113 int light_reinit(void) { 
    114  if ( g_light_state.changes == NULL ) 
    115   return -1; 
    116  
    117  memset(g_light_state.changes, 0, g_light_state.channels); 
    118  memset(g_light_state.events,  0, sizeof(g_light_state.events)); 
    119  
    120  g_light_state.eventsqueuelen = 0; 
    121  
    122  return 0; 
    123 } 
    124  
     149// called at mid of mainloop. 
    125150int light_update(void) { 
     151 uint8_t * tmp; 
     152 unsigned int c; 
     153 
     154 // swap buffers: 
     155 // after that step we have the old values in outputchanges and output is a fresh buffer. 
     156 tmp = g_light_state.outputchanges; 
     157 g_light_state.outputchanges = g_light_state.output; 
     158 g_light_state.output = tmp; 
     159 
     160 // copy data for filters: 
     161 memcpy(g_light_state.output, g_light_state.state, g_light_state.channels); 
     162 
     163 // TODO: next run filters 
     164 
     165 // calculate diffrence: 
     166 // after this step we have only teh changes in the outputchanges array. 
     167 for (c = 0; c < g_light_state.channels; c++) 
     168  g_light_state.outputchanges[c] ^= g_light_state.output[c]; 
     169 
    126170 return 0; 
    127171} 
     
    180224 
    181225 if ( chans == 512 ) { 
    182   bufptr = g_light_state.state; 
     226  bufptr = g_light_state.output; 
    183227 } else { 
    184228  memset(buf, 0, 512); 
    185   memcpy(buf, g_light_state.state, chans); 
     229  memcpy(buf, g_light_state.output, chans); 
    186230  bufptr = buf; 
    187231 } 
  • roard/loop.c

    r5979 r5980  
    9393  midi_update(); 
    9494#endif 
     95#ifndef ROAR_WITHOUT_DCOMP_LIGHT 
     96  light_update(); 
     97#endif 
    9598 
    9699  if ( waveform_update_inputs() == -1 ) 
Note: See TracChangeset for help on using the changeset viewer.