-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoftcode_functions.py
More file actions
134 lines (112 loc) · 3.83 KB
/
softcode_functions.py
File metadata and controls
134 lines (112 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
from village.devices.sound_device import sound_device
from village.settings import settings
from sound_functions import tone_generator, crescendo_looming_sound, white_noise
import numpy as np
from village.manager import manager
def function1():
# stop sound
sound_device.stop()
def function2():
# load the sound loaded in manager
sound_device.load(left=manager.task.twoAFC_sound, right=manager.task.twoAFC_sound)
def function3():
# play the sound
sound_device.play()
def function4():
# stop sound
sound_device.stop()
# create and play white noise of 1 second
noise = white_noise(duration=1.0, amplitude=0.02)
sound_device.load(right=noise, left=noise)
sound_device.play()
def function5():
amp_for_70dB = 0.05 # ~75 dB SPL
amp_for_20dB = 0.0001 # ?? dB SPL
# create a crescendo sound
crescendo_sound = crescendo_looming_sound(
amp_start=amp_for_20dB,
amp_end=amp_for_70dB,
ramp_duration=0.4,
ramp_down_duration=0.005,
hold_duration=0.595,
n_repeats=10,
)
# load the sound loaded in manager
sound_device.load(right=crescendo_sound, left=crescendo_sound)
# play the sound
sound_device.play()
def function10():
# create a loud noise
duration = 5
ramptime = 0.05
amplitude = 0.05
sample_rate = settings.get("SAMPLERATE")
frequency = 10000
# get the time steps
# Create time array
total_time_steps = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)
scary_sound = tone_generator(total_time_steps, ramptime, amplitude, frequency)
# load the sound loaded in manager
sound_device.load(right=scary_sound, left=scary_sound)
# play the sound
sound_device.play()
def function9():
# create a loud noise
duration = 5
ramptime = 0.05
amplitude = 0.003
sample_rate = settings.get("SAMPLERATE")
frequency = 5000
# get the time steps
# Create time array
total_time_steps = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)
scary_sound = tone_generator(total_time_steps, ramptime, amplitude, frequency)
# load the sound loaded in manager
sound_device.load(right=scary_sound, left=scary_sound)
# play the sound
sound_device.play()
def function8():
# create a loud noise
duration = 5
ramptime = 0.05
amplitude = 0.05
sample_rate = settings.get("SAMPLERATE")
frequency = 1000
# get the time steps
# Create time array
total_time_steps = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)
scary_sound = tone_generator(total_time_steps, ramptime, amplitude, frequency)
# load the sound loaded in manager
sound_device.load(right=scary_sound, left=scary_sound)
# play the sound
sound_device.play()
def function11():
# create a loud noise
duration = 5
ramptime = 0.05
amplitude = 0.05
sample_rate = settings.get("SAMPLERATE")
frequency = 20000
# get the time steps
# Create time array
total_time_steps = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)
scary_sound = tone_generator(total_time_steps, ramptime, amplitude, frequency)
# load the sound loaded in manager
sound_device.load(right=scary_sound, left=scary_sound)
# play the sound
sound_device.play()
def function12():
# create a loud noise
duration = 5
ramptime = 0.05
amplitude = 0.05
sample_rate = settings.get("SAMPLERATE")
frequency = 40000
# get the time steps
# Create time array
total_time_steps = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)
scary_sound = tone_generator(total_time_steps, ramptime, amplitude, frequency)
# load the sound loaded in manager
sound_device.load(right=scary_sound, left=scary_sound)
# play the sound
sound_device.play()