PDA

View Full Version : Cool Sound Effects?



Art
- 22nd January 2012, 07:21
Here's one:



ticksnd:
@ movlw 0x01 'set sound duration for intro
@ movwf _sbyte '
@ movlw 0x1B 'set sound step value for intro
@ movwf _soundcalc 'soundcalc = $1B
@ movlw 0xFF 'set the start frequency
@ movwf _sbuff '
xcr:
@ movf _soundcalc ,W 'calc the next sound
@ addwf _sbuff ,F '
@ call _audo 'make sound
@ decf _sbuff ,F '
@ incfsz _sbuff ,F '
@ goto _xcr 'check for exit blast routine
@ return 'exit when sound is finished
audo:
SOUND portc.7,[sbuff,sbyte] 'output sound
@ return
'


Just gosub ticksnd.

Anyone got any others to share?

Art
- 22nd January 2012, 11:13
Here's one that sounds like a blast from a futuristic laser:



blast: '
soundcalc = $FD : sndcnt = 0 'make blast sound
@ movlw 0x8F 'set the start frequency
@ movwf _sbuff '
xxxxx:
@ incf _sndcnt ,F '
IF sndcnt = $25 THEN return '
@ movf _soundcalc ,W 'calc the next sound
@ addwf _sbuff ,F '
@ call _audo 'make sound
@ decf _sbuff ,F '
@ incfsz _sbuff ,F '
@ goto _xxxxx 'check for exit blast routine
@ return 'exit when sound is finished
audo:
SOUND portc.7,[sbuff,sbyte] 'output sound
@ return

'

Darrel Taylor
- 23rd January 2012, 07:51
Translation to PBP. :D

SoundPin VAR PORTC.7

Post #1


ticksnd:
sbuff = $FF
WHILE sbuff != 0
sbuff = sbuff + $1B
SOUND SoundPin,[sbuff,1]
WEND
RETURN


Post #2


blast:
FOR sndcnt = $8F TO $20 STEP -3
SOUND Sound2Pin,[sndcnt,1]
NEXT sndcnt
RETURN


A little easier on the eyes.

Uht-Oh, I got an idea......

Heckler
- 23rd January 2012, 18:05
So I'd like to try some of these sound effects... But it seems this thread started out of thin air??? What am I missing? Is this a continuation of another thread? Is there a complete sample code that can be posted.

In the dark here... (though that is nothing new for me)
Thanks

Art
- 23rd January 2012, 23:07
That is the complete code, you only need to declare the byte sized variables used,
and use the sounds in some program of your own :)

rsocor01
- 23rd January 2012, 23:27
Translation to PBP.


It is always good to have a translator :D.

ScaleRobotics
- 19th February 2012, 16:20
Here are a couple more sound effects. All of these use the freqout command. I tried them on a PIC18F4550 at 48 mhz. You can listen to them on the attached sound file.


Howler


Howler:
FOR sndcnt = 1 TO 4
FREQOUT sound2pin, 500, 467, 687 ' was combine 1400 Hz and 2060 Hz
FREQOUT Sound2pin, 500, 817, 867 ' was combine 2450 Hz and 2600 Hz
NEXT sndcnt


Space Transporter


Space_Transporter:
'DEBUG "Space Transporter", CR
FOR sndcnt = 5 TO 5000 STEP 5 ' frequency sweep up
FREQOUT sound2pin, 15, sndcnt, sndcnt */ 323 ' play note, note * 1.26
NEXT sndcnt
FOR sndcnt = 5000 TO 5 STEP -5 ' frequency sweep down
FREQOUT sound2pin, 15, sndcnt;, sndcnt */ 323 ' play note, note * 1.26
NEXT sndcnt


Warp


Warp:
for sndcnt2 = 200 to 450 step 1
FREQOUT Sound2pin,7,sndcnt2;,(sndcnt2 -166)
next sndcnt2


warble/alarm sinusoidal - could use some work


sineval var byte[32]
sineval[0] = 128
sineval[1] = 148
sineval[2] = 167
sineval[3] = 185
sineval[4] = 200
sineval[5] = 213
sineval[6] = 222
sineval[7] = 228
sineval[8] = 230
sineval[9] = 228
sineval[10] = 222
sineval[11] = 213
sineval[12] = 200
sineval[13] = 185
sineval[14] = 167
sineval[15] = 148
sineval[16] = 128
sineval[17] = 108
sineval[18] = 189
sineval[19] = 171
sineval[20] = 156
sineval[21] = 143
sineval[22] = 134
sineval[23] = 128
sineval[24] = 126
sineval[25] = 128
sineval[26] = 134
sineval[27] = 143
sineval[28] = 156
sineval[29] = 171
sineval[30] = 189
sineval[31] = 208

warble: ;alarmish sinusoidal - needs some work!
for sbuff = 1 to 10
for sndcnt2 = 0 to 31 step 1
FREQOUT Sound2pin,7,(500 +sineval[sndcnt2]);,(sndcnt2 -166)
next sndcnt2
next sbuff

Art
- 20th February 2012, 01:25
Nice :)

___________________