2018-03-30 18:19:23 -07:00
|
|
|
import os
|
2021-01-06 10:39:34 -08:00
|
|
|
from manimlib.utils.file_ops import find_file
|
2018-03-30 18:19:23 -07:00
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-03-30 18:19:23 -07:00
|
|
|
def play_chord(*nums):
|
|
|
|
commands = [
|
|
|
|
"play",
|
|
|
|
"-n",
|
|
|
|
"-c1",
|
|
|
|
"--no-show-progress",
|
|
|
|
"synth",
|
|
|
|
] + [
|
2018-04-06 13:58:59 -07:00
|
|
|
"sin %-" + str(num)
|
2018-03-30 18:19:23 -07:00
|
|
|
for num in nums
|
|
|
|
] + [
|
2018-04-06 13:58:59 -07:00
|
|
|
"fade h 0.5 1 0.5",
|
2018-12-30 01:27:03 +08:00
|
|
|
">",
|
|
|
|
os.devnull
|
2018-03-30 18:19:23 -07:00
|
|
|
]
|
|
|
|
try:
|
|
|
|
os.system(" ".join(commands))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-03-30 18:19:23 -07:00
|
|
|
def play_error_sound():
|
|
|
|
play_chord(11, 8, 6, 1)
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-03-30 18:19:23 -07:00
|
|
|
def play_finish_sound():
|
2018-04-06 13:58:59 -07:00
|
|
|
play_chord(12, 9, 5, 2)
|
2019-01-24 22:24:01 -08:00
|
|
|
|
|
|
|
|
|
|
|
def get_full_sound_file_path(sound_file_name):
|
2021-01-06 10:39:34 -08:00
|
|
|
return find_file(
|
2019-01-24 22:24:01 -08:00
|
|
|
sound_file_name,
|
2021-01-05 23:14:16 -08:00
|
|
|
directories=[os.path.join("assets", "sounds")],
|
2019-01-24 22:24:01 -08:00
|
|
|
extensions=[".wav", ".mp3"]
|
|
|
|
)
|