Changeset 2427:fd28722d924e in roaraudio
- Timestamp:
- 08/19/09 05:17:41 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroardsp/synth.c
r2426 r2427 26 26 27 27 #define _CHECK_BASIC() if ( state == NULL ) return -1 28 #define _CHECK_PCMOUT() _CHECK_BASIC(); if ( frames == 0 ) return 0; if ( out == NULL ) return -1 28 29 29 30 int roar_synth_init(struct roar_synth_state * state, struct roar_note_octave * note, int rate) { … … 54 55 _CHECK_BASIC(); 55 56 57 if ( func == NULL ) 58 return -1; 59 56 60 state->func = func; 57 61 … … 60 64 61 65 int roar_synth_pcmout_i16n(struct roar_synth_state * state, int16_t * out, size_t frames, int channels) { 62 _CHECK_BASIC(); 63 64 if ( out == NULL ) 65 return -1; 66 67 if ( frames == 0 ) 68 return 0; 66 _CHECK_PCMOUT(); 69 67 70 68 switch (channels) { … … 78 76 79 77 int roar_synth_pcmout_i161(struct roar_synth_state * state, int16_t * out, size_t frames) { 80 _CHECK_BASIC(); 78 float t_step; 79 float t_cur; 80 int i; 81 82 _CHECK_PCMOUT(); 83 84 t_step = 1.0/state->rate; 85 86 t_cur = t_step * state->pcmoffset; 87 88 for (i = 0; i < frames; i++, t_cur += t_step) { 89 out[i] = 32767.0*state->func(t_cur, state); 90 } 91 92 state->pcmoffset += frames; 81 93 82 94 return -1;
Note: See TracChangeset
for help on using the changeset viewer.