1
+ var /global /datum /musical_config/musical_config = new
2
+
3
+ / datum / musical_config
4
+ var /highest_octave = 9
5
+ var /lowest_octave = 0
6
+
7
+ var /highest_transposition = 4
8
+ var /lowest_transposition = - 4
9
+
10
+ var /longest_sustain_timer = 50
11
+ var /gentlest_drop = 1.07
12
+ var /steepest_drop = 10.0
13
+
14
+ var /channels_per_instrument = 128
15
+ var /max_lines = 1000
16
+ var /max_line_length = 100
17
+ var /max_events = 2400
18
+ var /song_editor_lines_per_page = 20
19
+
20
+ var /usage_info_channel_resolution = 1
21
+ var /usage_info_event_resolution = 8
22
+
23
+ var /env_settings_available = 0
24
+ // Keep disabled until I figure out how to preserve environment settings
25
+
26
+ var /list /env_default = list (7.5 , 1.0 , - 1000 , - 100 , 0 , 1.49 , 0.83 , 1.0 , - 2602 , 0.0007 , 200 , 0.011 , 0.25 , 0.0 , 0.25 , 0.0 , - 5.0 , 5000 , 250.0 , 0.0 , 100 , 100 , 63 )
27
+ var /list /list/env_params_bounds = list (
28
+ list (1 , 100 , 1 ),
29
+ list (0 , 1 , 1 ),
30
+ list (- 10000 , 0 , 1 ),
31
+ list (- 10000 , 0 , 1 ),
32
+ list (- 10000 , 0 , 1 ),
33
+ list (0.1 , 20 , 1 ),
34
+ list (0.1 , 2.0 , 1 ),
35
+ list (0.1 , 2.0 , 1 ),
36
+ list (- 10000 , 1000 , 0 ),
37
+ list (0 , 0.3 , 1 ),
38
+ list (- 10000 , 2000 , 0 ),
39
+ list (0 , 0.1 , 1 ),
40
+ list (0.075 , 0.25 , 1 ),
41
+ list (0 , 1 , 1 ),
42
+ list (0.04 , 4.0 , 1 ),
43
+ list (0 , 1 , 1 ),
44
+ list (- 100 , 0.0 , 1 ),
45
+ list (1000 , 20000 , 0 ),
46
+ list (20 , 1000 , 1 ),
47
+ list (0 , 10 , 1 ),
48
+ list (0 , 100 , 1 ),
49
+ list (0 , 100 , 1 ),
50
+ list (0 , 256 , 0 ))
51
+ var /list /all_environments = list (
52
+ " None" ,
53
+ " Generic" ,
54
+ " Padded cell" ,
55
+ " Room" ,
56
+ " Bathroom" ,
57
+ " Living Room" ,
58
+ " Stone Room" ,
59
+ " Auditorium" ,
60
+ " Concert Hall" ,
61
+ " Cave" ,
62
+ " Arena" ,
63
+ " Hangar" ,
64
+ " Carpetted Hallway" ,
65
+ " Hallway" ,
66
+ " Stone Coridor" ,
67
+ " Alley" ,
68
+ " Forest" ,
69
+ " City" ,
70
+ " Mountains" ,
71
+ " Quarry" ,
72
+ " Plain" ,
73
+ " Parking Lot" ,
74
+ " Sewer Pipe" ,
75
+ " Underwater" ,
76
+ " Drugged" ,
77
+ " Dizzy" ,
78
+ " Psychotic" ,
79
+ " Custom" )
80
+ var /list /env_param_names = list (
81
+ " Env. Size" ,
82
+ " Env. Diff." ,
83
+ " Room" ,
84
+ " Room (High Frequency)" ,
85
+ " Room (Low Frequency)" ,
86
+ " Decay Time" ,
87
+ " Decay (High Frequency Ratio)" ,
88
+ " Decay (Low Frequency Ratio)" ,
89
+ " Reflections" ,
90
+ " Reflections Delay" ,
91
+ " Reverb" ,
92
+ " Reverb Delay" ,
93
+ " Echo Time" ,
94
+ " Echo Depth" ,
95
+ " Modulation Time" ,
96
+ " Modulation Depth" ,
97
+ " Air Absorption (High Frequency)" ,
98
+ " High Frequency Reference" ,
99
+ " Low Frequency Reference" ,
100
+ " Room Rolloff Factor" ,
101
+ " Diffusion" ,
102
+ " Density" ,
103
+ " Flags" )
104
+ var /list /env_param_desc = list (
105
+ " environment size in meters" ,
106
+ " environment diffusion" ,
107
+ " room effect level (at mid frequencies)" ,
108
+ " relative room effect level at high frequencies" ,
109
+ " relative room effect level at low frequencies" ,
110
+ " reverberation decay time at mid frequencies" ,
111
+ " high-frequency to mid-frequency decay time ratio" ,
112
+ " low-frequency to mid-frequency decay time ratio" ,
113
+ " early reflections level relative to room effect" ,
114
+ " initial reflection delay time" ,
115
+ " late reverberation level relative to room effect" ,
116
+ " late reverberation delay time relative to initial reflection" ,
117
+ " echo time" ,
118
+ " echo depth" ,
119
+ " modulation time" ,
120
+ " modulation depth" ,
121
+ " change in level per meter at high frequencies" ,
122
+ " reference high frequency (hz)" ,
123
+ " reference low frequency (hz)" ,
124
+ " like rolloffscale in System::set3DSettings but for reverb room size effect" ,
125
+ " Value that controls the echo density in the late reverberation decay." ,
126
+ " Value that controls the modal density in the late reverberation decay" ,
127
+ {"
128
+ Bit flags that modify the behavior of above properties
129
+ •1 - 'EnvSize' affects reverberation decay time
130
+ •2 - 'EnvSize' affects reflection level
131
+ •4 - 'EnvSize' affects initial reflection delay time
132
+ •8 - 'EnvSize' affects reflections level
133
+ •16 - 'EnvSize' affects late reverberation delay time
134
+ •32 - AirAbsorptionHF affects DecayHFRatio
135
+ •64 - 'EnvSize' affects echo time
136
+ •128 - 'EnvSize' affects modulation time"} )
137
+
138
+ var /list /echo_default = list (0 , 0 , 0 , 0 , 0 , 0.0 , 0 , 0.25 , 1.5 , 1.0 , 0 , 1.0 , 0 , 0.0 , 0.0 , 0.0 , 1.0 , 7 )
139
+ var /list /list/echo_params_bounds = list (
140
+ list (- 10000 , 1000 , 0 ),
141
+ list (- 10000 , 0 , 0 ),
142
+ list (- 10000 , 1000 , 0 ),
143
+ list (- 10000 , 0 , 0 ),
144
+ list (- 10000 , 0 , 0 ),
145
+ list (0 , 1 , 1 ),
146
+ list (- 10000 , 0 , 0 ),
147
+ list (0 , 1 , 1 ),
148
+ list (0 , 10 , 1 ),
149
+ list (0 , 10 , 1 ),
150
+ list (- 10000 , 0 , 0 ),
151
+ list (0 , 1 , 1 ),
152
+ list (- 10000 , 0 , 0 ),
153
+ list (0 , 10 , 1 ),
154
+ list (0 , 10 , 1 ),
155
+ list (0 , 10 , 1 ),
156
+ list (0 , 10 , 1 ),
157
+ list (0 , 16 , 0 ))
158
+ var /list /echo_param_names = list (
159
+ " Direct" ,
160
+ " Direct (High Frequency)" ,
161
+ " Room" ,
162
+ " Room (High Frequency)" ,
163
+ " Obstruction" ,
164
+ " Obstruction (Low Frequency Ratio)" ,
165
+ " Occlusion" ,
166
+ " Occlusion (Low Frequency Ratio)" ,
167
+ " Occlusion (Room Ratio)" ,
168
+ " Occlusion (Direct Ratio)" ,
169
+ " Exclusion" ,
170
+ " Exclusion (Low Frequency Ratio)" ,
171
+ " Outside Volume (High Frequency)" ,
172
+ " Doppler Factor" ,
173
+ " Rolloff Factor" ,
174
+ " Room Rolloff Factor" ,
175
+ " Air Absorption Factor" ,
176
+ " Flags" )
177
+ var /list /echo_param_desc = list (
178
+ " direct path level (at low and mid frequencies)" ,
179
+ " relative direct path level at high frequencies " ,
180
+ " room effect level (at low and mid frequencies)" ,
181
+ " relative room effect level at high frequencies" ,
182
+ " main obstruction control (attenuation at high frequencies)" ,
183
+ " obstruction low-frequency level re. main control" ,
184
+ " main occlusion control (attenuation at high frequencies)" ,
185
+ " occlusion low-frequency level re. main control" ,
186
+ " relative occlusion control for room effect" ,
187
+ " relative occlusion control for direct path" ,
188
+ " main exlusion control (attenuation at high frequencies)" ,
189
+ " exclusion low-frequency level re. main control" ,
190
+ " outside sound cone level at high frequencies" ,
191
+ " like DS3D flDopplerFactor but per source" ,
192
+ " like DS3D flRolloffFactor but per source" ,
193
+ " like DS3D flRolloffFactor but for room effect" ,
194
+ " multiplies AirAbsorptionHF member of environment reverb properties." ,
195
+ {"
196
+ Bit flags that modify the behavior of properties•1 - Automatic setting of 'Direct' due to distance from listener
197
+ •2 - Automatic setting of 'Room' due to distance from listener
198
+ •4 - Automatic setting of 'RoomHF' due to distance from listener"} )
199
+
200
+ var /list /n2t_int = list () // Instead of num2text it is used for faster access in n2t
201
+ var /list /free_channels = list () // Used to take up some channels and avoid istruments cancelling each other
202
+ var /free_channels_populated = 0
203
+ var /list /nn2no = list (0 ,2 ,4 ,5 ,7 ,9 ,11 ) // Maps note num onto note offset
204
+
205
+
206
+ / datum / musical_config/ proc / n2t(key) // Used instead of num2text for faster access in sample_map
207
+ if (! n2t_int. len)
208
+ for (var /i = 1 , i<= 127 , i++ )
209
+ n2t_int += num2text(i)
210
+
211
+ if (key== 0 )
212
+ return " 0" // Fuck you BYOND
213
+ if (! isnum(key) || key < 0 || key> 127 || round(key) != key)
214
+ CRASH (" n2t argument must be an integer from 0 to 127" )
215
+ return n2t_int[key]
216
+
217
+
218
+ / datum / musical_config/ proc / environment_to_id(environment)
219
+ if (environment in all_environments)
220
+ return all_environments. Find(environment) - 2
221
+ return - 1
222
+
223
+
224
+ / datum / musical_config/ proc / id_to_environment(id)
225
+ if (id >= - 1 && id <= 26 )
226
+ return all_environments[id+ 2 ]
227
+ return " None"
228
+
229
+
230
+ / datum / musical_config/ proc / index_to_id(index)
231
+ return max(min(index- 2 , 26 ), - 1 )
232
+
233
+
234
+ / datum / musical_config/ proc / is_custom_env(id)
235
+ return id_to_environment(id) == all_environments[28 ]
236
+
237
+
238
+ / datum / sample_pair
239
+ var /sample
240
+ var /deviation = 0
241
+
242
+ / datum / sample_pair/ New(sample_file, deviation_)
243
+ sample = sample_file
244
+ deviation = deviation_
0 commit comments