Difference between revisions of "Outputting Sound"

From veswiki
Jump to: navigation, search
Line 32: Line 32:
  
  
Here's an example of a creative soundeffect from Sean Riddles Lights Out:
+
Here's an example of a creative sound effect from Sean Riddles Lights Out:
  
 
<pre>
 
<pre>

Revision as of 22:24, 16 November 2012

You can originally make 3 sounds- a 500Hz beep, a 1KHz beep or a 120Hz beep.

Coming up are recordings of various sounds mentioned.

If you want to make any other sounds try the improved PlaySong subroutine, this however sounds like a broken speaker on the early systems. System II has improved support for this and also sound on the tv (you can lower the volume). In VES Pac-man the "Pac-man theme" is played before start and the PlaySong routine is also used for the other soundeffects.

How to: You examine the frequencies of the sound effect you want in very tiny steps and then mimic it playing very short notes with the correct medium frequency at that time, the shorter pieces it's divided into the better...

The PlaySong routine doesn't allow for any other computing while it's running, the song data and other computing (moving graphics perhaps) has to be done alternating in small portions if these are to be combined.

As different machines run on different clock speeds (1.78MHz, 2.00MHz etc) the pitch of the sound varies between PAL, NTSC and also between first and second generation PAL machines.


These are the three standard beeps:


                LI   $60                 ; high beep
                OUTS 5

                LI   $A0                 ; middle beep
                OUTS 5

                LI   $D0                 ; low beep
                OUTS 5


You might need a pause after, not to turn sound off immediately and a

               clr
               outs 5


Here's an example of a creative sound effect from Sean Riddles Lights Out:

                                ;make a bad sound
				li		$3f		; r1 loaded with $3f
				lr		1,a		
sndloop:
				li		$80		; $80 loaded into A
				outs	5			; send data to port
				lis		1		; A=1
				lr		5,a		; load r5 with 1
				pi		delay		; run the syscall "delay" (very short, only 1)
				lis		0		; same as clr
				outs	5			; send 0 on port
				ds		1		; r1 decreased
				bf		4,sndloop	; run the loop again until r1 is 0


Making sound effects with the PlaySong routine

Easiest example is Pac-man, e5frog studied the frequencies of the Pac-man's eating sound, the siren, death etc in very short pieces. Then set the data in the F8 to play that approximated medium frequency for exactly the same amount of time. I e it was hacked in little pieces, analyzed, thrown away and put together again with brand new pieces.

Recorded sound samples from a real Arcade Machine were analyzed. The result came out quite fine!


Here's the result from Pac-man's eating sound:

               ; Pac-man eats


	db	1,116,1,116,1,116,1,163,1,163,2,178,3,191,3,202
	db	20,255
	db	3,207,3,199,2,191,1,172,1,172,1,161,2,161,3,161
	db	20,255

	; repeated over and over again


There is also a siren in the background all the time that resulted in this data:

		; Pac-man background siren


	db	3,157,3,165,3,173,4,181,4,188,4,194,4,198,4,202,4,205,4,208,4,211,4,213
	db	4,211,4,208,4,205,4,202,4,198,4,194,4,188,4,181,3,173,3,165

	; repeated over and over again

Unfortunately they can't be heard in the game, it couldn't be used because they take to much cpu-time... Perhaps there could be simultaneous music and effects some day - if that's handled by a second processor or a mock multitasking song playing routine...

For now there's only a click when Pac-man eats his pills and an extra sound when monsters are blue. Death is accurately mimicked - no need for graphics speed there since everything is still and Pac-man only changes into his death-sprite between the partial PlaySong routines.


Like so:

;---------------------------------------------------------------------------
; Dying Song
;---------------------------------------------------------------------------

sfx.dying.0:
	.byte	4,189,4,188,4,184,4,182,4,181
	.byte	4,182,4,185,4,188,4,190,4,192,4,193
	.byte	4,184,4,182,4,179,4,176,3,173,3,171
	.byte	3,173,3,176,4,179,4,182,4,185,4,186
	.byte	0	
sfx.dying.1:
	.byte	3,179,3,176,3,173,3,170,3,165,3,163
	.byte	3,165,3,170,3,173,3,176,3,179,3,181
	.byte	3,165,3,161,3,157,3,152,2,147,2,143
	.byte	0	
sfx.dying.2:
	.byte	2,147,2,152,3,157,3,161,3,166,3,168
	.byte	3,155,3,152,3,147,2,141,2,139,2,128
	.byte	2,135,2,138
	.byte	0	
sfx.dying.3:
	.byte	2,126,3,170,3,192,4,205,5,214,6,220
	.byte	7,224,7,229,8,232,9,234,10,255
	.byte	2,126,3,170,3,192,4,205,5,214,6,220
	.byte	7,224,7,229,8,232,9,234
	.byte	0					; end of song

There's also this:

;---------------------------------------------------------------------------
; Extra Pac-man sound at 10000 points
;---------------------------------------------------------------------------

sfx.extraPacman:
	.byte	6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,6,121,6,122,12
	.byte 190,6,192,0