Skirmitt
Joined: 19 May 2009 Posts: 60
|
Playing wave sounds, change speed |
Posted: Wed Jun 03, 2009 7:49 am |
|
|
With the help of a script out of the library I made a working engine noise generator. Now I want to control the speed of it with the help of a PWM servo signal. How can I do this best without interrupting the sound ?
Code: | #include <18F1320.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, MCLR
#use delay(clock = 8000000)
#include "pullc.c"
int delayval;
void main(){
int8 i;
int8 c;
int8 currentbit;
c = sound_data[i];
setup_oscillator(OSC_8MHZ|OSC_INTRC);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);
while(1)
{
for (i=0; i<sound_length; i++){
c = sound_data[i];
for (currentbit = 0; currentbit < 8; currentbit++){
if( bit_test(c,currentbit) ){
output_high(pin_b3);
}
else{
output_low(pin_b3);
}
delay_us(delayval);
}
}
}
} |
As you see, I have to change the delayval. |
|