The Musical PWMPAL
hitsware
Posts: 156
Seems to work great [noparse]:)[/noparse]
Way less pops than 'freqout'
C maj scale:
SEROUT 0,6,[noparse][[/noparse]"!PWMSS",240] ' initialize outputs
ck CON 3600 ' set key of scale
cl CON 48:dl CON 54:el CON 60:fl CON 64 ' set ratios of note
gl CON 72:al CON 80:bl CON 90:ch CON 96 ' frequencies in major scale
dr VAR byte:x VAR nib:fr VAR byte ' set variables
FOR x= 0 to 7 ' start scale
LOOKUP x,[noparse][[/noparse]cl,dl,el,fl,gl,al,bl,ch],fr ' find notes
dr=ck/fr ' calculate duration from frquency
SEROUT 0,6,[noparse][[/noparse]"!PWMM1",dr,0,dr,0] ' play note
PAUSE 400 ' set time for each note
NEXT ' goto next note
SEROUT 0,6,[noparse][[/noparse]"!PWMSS",0] ' turn off all channels
END
Way less pops than 'freqout'
C maj scale:
SEROUT 0,6,[noparse][[/noparse]"!PWMSS",240] ' initialize outputs
ck CON 3600 ' set key of scale
cl CON 48:dl CON 54:el CON 60:fl CON 64 ' set ratios of note
gl CON 72:al CON 80:bl CON 90:ch CON 96 ' frequencies in major scale
dr VAR byte:x VAR nib:fr VAR byte ' set variables
FOR x= 0 to 7 ' start scale
LOOKUP x,[noparse][[/noparse]cl,dl,el,fl,gl,al,bl,ch],fr ' find notes
dr=ck/fr ' calculate duration from frquency
SEROUT 0,6,[noparse][[/noparse]"!PWMM1",dr,0,dr,0] ' play note
PAUSE 400 ' set time for each note
NEXT ' goto next note
SEROUT 0,6,[noparse][[/noparse]"!PWMSS",0] ' turn off all channels
END