
; attack_robot_SFX.EZ
; Foxonix / Metre Ideas and Design
; www.foxonix.com

; Program: Will Sakran
; Created: 09.02.15
; Public - Modify and share this program as you wish.

; Program description
;	Plays various attack robot sound effects in a continuous loop. When
;	the button is pressed, the sound effects begin to play. When the button
;	is pressed again the sound effects will stop playing.

; Hardware INPUTS
; 	Pushbutton connected to pin P1.0

; Hardware OUTPUTS
; 	Speaker connected to PWM speaker output


; Set the device name. A larger device number allows more audio space, but
; will take longer to upload and program.
[device]
SNC21030


; Specify the number of pins to be used as inputs.
[key]
direct=1


; List WAV files to be included in the program
[files]
raygun2_12k.wav
raygun1_12k.wav
lasershot1_12k.wav
exterminate_12k.wav


; Define the various input states for the program.
; This describes which pins will have buttons, switches, or
; other inputs attached to them, and defines when those
; inputs will be active and inactive. At least one input
; state must be defined even if it is not used.
[input_states]
; PIN		P1.0	
locked_out:	x	; locked_out state means no buttons are active
play_sfx:	loop	; loop: label will be called when play_sfx state is active
stop_sfx:	stop	; stop: label will be called when stop_sfx state is active


; Define the various output states for the program.
; Outputs are used to drive LEDs, motor circuits, or any
; other output device.
[output_states]
; No output devices are used in this program (only the speaker)


; Define the routines (paths) that the program will use.
; The init path is always called first on power up and reset.
[paths]
init:
	& locked_out		; Disable all inputs during init
;	& ppdac			; Not required for SNC21030 device
	& freq=12k		; Set the audio playback rate to 12 kHz
	& play_sfx		; Enable the play_sfx state so button can be used to start SFX
	& end			; Stop program and put chip to sleep (low power mode)


loop:
	& stop_sfx		; Enable the stop_sfx state so button can be used to stop SFX
	& exterminate_12k.wav	; Play wav file
	& delay(0.2)		; 200 mSec delay
	& exterminate_12k.wav
	& delay(0.2)
	& raygun1_12k.wav
	& delay(0.2)
	& raygun2_12k.wav
	& delay(0.2)
	& exterminate_12k.wav
	& delay(0.2)
	& lasershot1_12k.wav
	& delay(0.5)		; 500 mSec delay
	& loop

stop:
	& stop_v	; Stop all audio playback
	& play_sfx	; Enable the play_sfx state so button can be used to start SFX
	& end		; Stop program and put chip to sleep (low power mode)




