-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoftcode_functions.py
More file actions
144 lines (123 loc) · 4.76 KB
/
Copy pathsoftcode_functions.py
File metadata and controls
144 lines (123 loc) · 4.76 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
133
134
135
136
137
138
139
140
141
142
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
from village.custom_classes.direct_functions_base import DirectFunctionsBase
class DirectFunctions(DirectFunctionsBase):
def function1(self):
# stop sound
sound_device.stop()
def function2(self):
# load the sound loaded in manager
task_sound = manager.task.twoAFC_sound
if isinstance(task_sound, dict):
sound_device.load(left=task_sound["left"], right=task_sound["right"])
else:
sound_device.load(left=task_sound, right=task_sound)
def function3(self):
# play the sound
sound_device.play()
def function4(self):
""" 1s WN"""
# stop sound
print("inside function4")
sound_device.stop()
# create and play white noise of 1 second
noise = white_noise(duration=1.0, amplitude=0.1)
print("inside function4: noise created")
sound_device.load(right=noise, left=noise)
print("inside function4: noise loaded")
sound_device.play()
print("inside function4: noise played")
def function5(self):
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(self):
# 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(self):
# 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(self):
# 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(self):
# 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(self):
# 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()