Control volume out of chip with pwm
stilgar
Posts: 47
In my project I have a LED that fades on. I would like to have sound to fade on with the LED. I am using wave player.
I use PWM to fade on the LED, could this be used to control volume? The amp used for the sound has no volume control to it, so I would need another way to do it.
http://www.jbhifi.com.au/images/gumball-3000-portable-speakers-sku-69414-large.gif
I first thought was to use a transistor connected to a extra pin and send the same PWM signal to it as the LED.
Is there a way to do this without adding hardware??
Thanks
I use PWM to fade on the LED, could this be used to control volume? The amp used for the sound has no volume control to it, so I would need another way to do it.
http://www.jbhifi.com.au/images/gumball-3000-portable-speakers-sku-69414-large.gif
I first thought was to use a transistor connected to a extra pin and send the same PWM signal to it as the LED.
Is there a way to do this without adding hardware??
Thanks
Comments
to read:
where volume is a volume level that ranges between 0 (muted) and 255 (full) and can be ramped up and down from your main program. The catch is that it adds some overhead to the playback, which will limit the rate. Hopefully, the rate you're currently using can stand the extra overhead.
-Phil
Ok, this may seem a dumb question. After I change the line in the player, in my main program I add the VAR as volume? then set it as " volume = 127 " near the fade on LED section?? or did I do this wrong again (still learning about variables)
my code:
wavcog := cognew(playsound(10, @Cylon, 0), @stack) + 1 ' start sound player
repeat luminosity from 0 to maxbright
volume := (volume + 1) 'ranp volume up need to stop at 64 (maxbright)
repeat x from 7 to _numleds-9
leds[x] := luminosity + 1
waitcnt(clkfreq / (rtime1 / 1000)+ cnt) ' center LEDs slowly go from 0 to maxbright = 64
-Phil
Thanks a bunch, I under stand " ++ " means ramp up, but I don't remember seeing " <# " before. does that mean, " less than number "?
-Phil