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

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

; Program description
;	This program changes the playback sample rate of audio files in
;	order to speed up or slow down the audio. This is done by using
;	the freq command to set different values before an audio file is
;	played. Note that the sample rate of the actual audio file
;	does not change.

; Hardware INPUTS
; 	Button1 connected to pin P1.0 (sound effect slow)
;	Button2 connected to pin P1.1 (sound effect normal)
; 	Button3 connected to pin P1.2 (sound effect fast)
;	Button4 connected to pin P2.0 (drum loop slow)
; 	Button5 connected to pin P2.1 (drum loop normal)
;	Button6 connected to pin P2.2 (drum loop fast)

; Hardware OUTPUTS
; 	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=7


[files]
honk_12k.wav
drum_loop_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	P1.1	P1.2	P1.3	P2.0	P2.1	P2.2
enabled:		button1 button2 button3 x	button4 button5 button6


; Define the routines (paths) that the program will use.
; The init path is always called first on power up and reset.
[paths]
init:
	& enabled		; enable the inputs
	& end			; stop the program and enter low power mode


; when P1.0 is triggered, the button1: label is called.
button1:
	& freq=10k		; set sample playback rate to 10kHz
	& honk_12k.wav		; play sound effect file
	& end			; stop the program and enter low power mode

; when P1.1 is triggered, the button2: label is called, and so on...
button2:
	& freq=12k		; set sample playback rate to 12kHz
	& honk_12k.wav		; play sound effect file
	& end			; stop the program and enter low power mode

button3:
	& freq=14k		; set sample playback rate to 14kHz
	& honk_12k.wav		; play sound effect file
	& end			; stop the program and enter low power mode

button4:
	& freq=10k		; set sample playback rate to 10kHz
	& drum_loop_12k.wav	; play sound effect file
	& button4		; jump back to loop the drum beat

button5:
	& freq=12k		; set sample playback rate to 12kHz
	& drum_loop_12k.wav	; play sound effect file
	& button5		; jump back to loop the drum beat

button6:
	& freq=14k		; set sample playback rate to 14kHz
	& drum_loop_12k.wav	; play sound effect file
	& button6		; jump back to loop the drum beat

