Changeset 2432:d84ffcebf730 in roaraudio for libroardsp


Ignore:
Timestamp:
08/19/09 15:35:53 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support to set volume

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroardsp/synth.c

    r2431 r2432  
    3636 memset(state, 0, sizeof(struct roar_synth_state)); 
    3737 
    38  state->note = note; // NULL is valid here! 
    39  state->rate = rate; 
     38 state->note   = note; // NULL is valid here! 
     39 state->rate   = rate; 
     40 state->volume = 1; 
    4041 
    4142 state->func = ROAR_SYNTH_SYNF_SINE; 
     
    5960 
    6061 state->func = func; 
     62 
     63 return 0; 
     64} 
     65 
     66int roar_synth_set_volume(struct roar_synth_state * state, float volume) { 
     67 _CHECK_BASIC(); 
     68 
     69 state->volume = volume; 
    6170 
    6271 return 0; 
     
    9099 
    91100 for (i = 0; i < frames; i++, t_cur += t_step) { 
    92   out[i] = 32767.0*state->func(2.0*M_PI*freq*t_cur, state); 
     101  out[i] = 32767.0*state->volume*state->func(2.0*M_PI*freq*t_cur, state); 
    93102 } 
    94103 
Note: See TracChangeset for help on using the changeset viewer.