Master Sword SFX Update

New sfx with random choice for swings and hits
This commit is contained in:
Noe Ruiz 2019-07-30 13:52:25 -04:00
parent d116716c07
commit 5fef541a6f
11 changed files with 27 additions and 10 deletions

View file

@ -10,6 +10,7 @@ All text above must be included in any redistribution.
"""
import time
import random
import digitalio
import audioio
import busio
@ -19,24 +20,24 @@ import adafruit_lis3dh
# CUSTOMISE COLORS HERE:
COLOR = (0, 120, 120) # Default idle is light blue
ALT_COLOR = (255, 255, 255) # hit color is bright white
ALT_COLOR = (255, 50, 0) # hit color is bright white
# CUSTOMISE IDLE PULSE SPEED HERE: 0 is fast, above 0 slows down
IDLE_PULSE_SPEED = 0.05 # Default is 0.1 seconds
SWING_BLAST_SPEED = 0.01
IDLE_PULSE_SPEED = 0 # Default is 0.1 seconds
SWING_BLAST_SPEED = 0.007
# CUSTOMISE BRIGHTNESS HERE: must be a number between 0 and 1
IDLE_PULSE_BRIGHTNESS_MIN = 0.3 # Default minimum idle pulse brightness
IDLE_PULSE_BRIGHTNESS_MAX = 0.6 # Default maximum idle pulse brightness
IDLE_PULSE_BRIGHTNESS_MIN = 0.2 # Default minimum idle pulse brightness
IDLE_PULSE_BRIGHTNESS_MAX = 1 # Default maximum idle pulse brightness
# CUSTOMISE SENSITIVITY HERE: smaller numbers = more sensitive to motion
HIT_THRESHOLD = 500
SWING_THRESHOLD = 125
HIT_THRESHOLD = 250
SWING_THRESHOLD = 150
# Set to the length in seconds of the "on.wav" file
POWER_ON_SOUND_DURATION = 1.7
NUM_PIXELS = 30 # Number of pixels used in project
NUM_PIXELS = 83 # Number of pixels used in project
NEOPIXEL_PIN = board.D5
POWER_PIN = board.D10
@ -120,6 +121,22 @@ def mix(color_1, color_2, weight_2):
int(color_1[1] * weight_1 + color_2[1] * weight_2),
int(color_1[2] * weight_1 + color_2[2] * weight_2))
# List of swing wav files without the .wav in the name for use with play_wav()
swing_sounds = [
'swing1',
'swing2',
'swing3',
'swing4',
]
# List of hit wav files without the .wav in the name for use with play_wav()
hit_sounds = [
'hit1',
'hit2',
'hit3',
'hit4',
]
mode = 0 # Initial mode = OFF
@ -150,12 +167,12 @@ while True:
# comparing thresholds...use squared values instead.)
if accel_total > HIT_THRESHOLD: # Large acceleration = HIT
TRIGGER_TIME = time.monotonic() # Save initial time of hit
play_wav('hit') # Start playing 'hit' sound
play_wav(random.choice(hit_sounds)) # Start playing 'hit' sound
COLOR_ACTIVE = COLOR_HIT # Set color to fade from
mode = 3 # HIT mode
elif mode == 1 and accel_total > SWING_THRESHOLD: # Mild = SWING
TRIGGER_TIME = time.monotonic() # Save initial time of swing
play_wav('swing') # Start playing 'swing' sound
play_wav(random.choice(swing_sounds)) # Randomly choose from available swing sounds
# make a larson scanner animation_time
strip_backup = strip[0:-1]
for p in range(-1, len(strip)):

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.