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

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

; Program description
;	Press button1 to play the song (interruptable). The audio file contains
;	markers that trigger events in the program. For this example the markers
;	are used to turn LEDs on and off in time with the music. The marker events
;	are enabled the first time the song plays through. The marker events
;	are disabled the second time the song plays through.

; Hardware INPUTS
; 	One button connected to pin P1.0

; Hardware OUTPUTS
;	LED connected to pin P3.0
;	LED connected to pin P3.1
;	LED connected to pin P3.2
;	LED connected to pin P3.3
; 	Speaker connected to PWM speaker output


; Set the device name
[device]
SNC21030


; Specify the number of pins to be used as inputs.
; At lease one input must be defined even if it is not used.
[key]
direct=1


[files]
pictures_at_an_exhibition_edit_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]
; Port.Pin		P1.0
locked_out:		x
enabled:		button1


; Define output macros
[output_states]
led1_on:	P3=[0 0 0 1]
led2_on:	P3=[0 0 1 0]
led3_on:	P3=[0 1 0 0]
led4_on:	P3=[1 0 0 0]
all_off:	P3=[0 0 0 0]


; 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		; ignore inputs during init
	& freq=12k		; set sample playback rate to 12 kHz
	& enabled		; enable the inputs
	& end			; stop the program and enter low power mode


; when P1.0 is triggered, the button1: label is called.
button1:
	& eflag=1					; enable the wave mark function
	& pictures_at_an_exhibition_edit_12k.wav	; play song
	& eflag=0					; disable the wave mark function to ignore markers
	& pictures_at_an_exhibition_edit_12k.wav	; play song
	& end						; stop the program and enter low power mode


; List the event functions that are called by markers embedded in
; the audio file. Marker names in the program and in the audio files
; must be named e1, e2, e3, etc. up to e15.
[wavemark]
e1:	led1_on
e2:	led2_on
e3:	led3_on
e4:	led4_on
e5:	all_off

