/
Strip.pm
329 lines (284 loc) · 7.85 KB
/
Strip.pm
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/usr/bin/perl
package Strip;
use strict;
use warnings;
use Data::Dumper;
use Fx;
###########################################################
#
# STRIP OBJECT functions
#
###########################################################
sub new {
my $class = shift;
my $IOsection = shift;
#init structure
my $strip = {
'friendly_name' => "",
'status' => "new",
'can_be_backed' => "",
'type' => "",
'inserts' => {},
'channels' => "",
'connect' => "",
'group' => ""
};
bless $strip, $class;
return $strip;
}
sub init {
#fill the strip object with the passed hash info
my $strip = shift;
my $IOsection = shift;
my $midi_km = shift;
die "Error: can't init a strip without info\n" unless defined $IOsection;
warn "Warning: undefined value on midi option\n" unless defined $midi_km;
#don't insert channel if inactive
return unless $IOsection->{status} eq "active";
#update channel strip info from ini
$strip->{friendly_name} = $IOsection->{friendly_name} if $IOsection->{friendly_name};
$strip->{status} = $IOsection->{status} if $IOsection->{status};
$strip->{can_be_backed} = $IOsection->{can_be_backed} if $IOsection->{can_be_backed};
$strip->{group} = $IOsection->{group} if $IOsection->{group};
$strip->{type} = $IOsection->{type} if $IOsection->{type};
$strip->{return} = $IOsection->{return} if $IOsection->{return};
$strip->{channels} = $IOsection->{channels} if $IOsection->{channels};
$strip->{mode} = $IOsection->{mode} if defined $IOsection->{mode};
$strip->{touchosc_pages} = $IOsection->{touchosc_pages} if defined $IOsection->{touchosc_pages};
print " |_adding channel ".$strip->{friendly_name}."\n";
#en fonction du nombre de channels on crée une liste des inputs
my @tab;
#mono channel >> to be used on output buses to save hardware channels if needed
if (defined $IOsection->{mode} and $IOsection->{mode} eq "mono") {
#get connect port
push ( @tab , $IOsection->{"connect_1"});
}
#stereo channel or more
else {
#get connect port
push ( @tab , $IOsection->{"connect_$_"}) for (1 .. $IOsection->{channels});
}
#add the connect channel to structure
$strip->{connect} = \@tab;
#get list of inserts
my @effects = split ',',$IOsection->{insert} if $IOsection->{insert};
#add inserts
my $sequence_nb = 1;
foreach my $effect (@effects) {
die "Can't have more than 20 inserts on a track\n" if ($sequence_nb eq 21);
#verify if we want to add pan and volume
if ( $effect eq "panvol" ) {
#add pan and volume controls, applicable to ecasound engine only
if ($strip->is_mono) {
$strip->{inserts}{panvol} = Fx->new("mono_panvol",$midi_km);
}
elsif ($strip->is_stereo) {
$strip->{inserts}{panvol} = Fx->new("st_panvol",$midi_km);
}
}
else{
$strip->{inserts}{$effect} = Fx->new($effect,$midi_km);
}
#give an sequence number to the plugin
$strip->{inserts}{$effect}{nb} = $sequence_nb;
$sequence_nb++;
}
}
###########################################################
#
# ECASOUND functions
#
###########################################################
sub eca_aux_init {
my $strip = shift;
my $midi_km = shift;
#init values
$strip->{type} = "route";
$strip->{channels} = "2";
delete $strip->{group};
delete $strip->{status};
delete $strip->{connect};
delete $strip->{friendly_name};
delete $strip->{can_be_backed};
#add pan and volume
$strip->{inserts}{panvol} = Fx->new("st_panvol",$midi_km);
}
sub get_eca_chain_add_inserts {
my $strip = shift;
my $line;
#get a list of inserts
my @inserts = keys %{$strip->{inserts}};
#return empty line if there is no effects (should never be as panvol is added)
return '' unless @inserts;
#make sure to add effects with the correct order
for my $i (1..$#inserts+1) {
for my $nb (0..$#inserts){
my $insertname = $inserts[$nb];
next if $strip->{inserts}{$insertname}{nb} ne $i;
#when we found the good one, create line
my $insert = $inserts[$nb];
print " | |_adding effect $insert\n";
$line .= $strip->{inserts}{$insert}{ecsline} if (defined $strip->{inserts}{$insert}{ecsline});
}
}
return $line;
}
sub get_eca_input_chain {
my $strip = shift;
my $name = shift;
my $line = "-a:$name ";
$line .= "-f:f32_le,1,48000 -i:jack,," if $strip->is_mono;
$line .= "-f:f32_le,2,48000 -i:jack,," if $strip->is_stereo;
$line .= $name;
#add inserts if any
$line .= $strip->get_eca_chain_add_inserts();
return $line;
}
sub get_eca_loop_output_chain {
my $strip = shift;
my $name = shift;
return "-a:$name -f:f32_le,2,48000 -o:loop,$name";
}
sub get_eca_bus_input_chain {
my $strip = shift;
my $name = shift;
my $inserts = $strip->get_eca_chain_add_inserts();
return "-a:bus_$name -f:f32_le,2,48000 -i:jack,,bus_$name $inserts";
}
sub get_eca_bus_output_chain {
my $strip = shift;
my $name = shift;
return "-a:bus_$name -f:f32_le,2,48000 -o:jack,,$name";
}
sub get_eca_player_chain {
my $strip = shift;
my $name = shift;
return "-a:$name -f:f32_le,2,48000 -i:null -o:jack,,$name";
}
sub get_eca_submix_output_chain {
my $strip = shift;
my $name = shift;
return "-a:all -f:f32_le,2,48000 -o:jack,,$name";
}
###########################################################
#
# NON-MIXER functions
#
###########################################################
sub get_non_input_chain {
# body...
}
sub get_non_bus_input_chain {
# body...
}
###########################################################
#
# GLOBAL TEST functions
#
###########################################################
sub is_active{
my $io = shift;
return 1 if ($io->{status} eq "active");
return 0 if ($io->{status} eq "inactive");
return 0 if ($io->{status} eq "new");
}
sub is_main_in {
my $io = shift;
return 1 if (($io->{type} eq "hardware_in") or
($io->{type} eq "return") or
($io->{type} eq "player") or
($io->{type} eq "submix"));
return 0;
}
sub is_hardware_out {
my $io = shift;
return 1 if (($io->{type} eq "bus_hardware_out") or
($io->{type} eq "main_hardware_out") or
($io->{type} eq "send_hardware_out"));
return 0;
}
sub is_hardware_in {
my $io = shift;
return 1 if ($io->{type} eq "hardware_in");
return 0;
}
sub is_bus_in {
my $io = shift;
return 1 if ($io->{type} eq "player");
return 1 if ($io->{type} eq "submix");
return 0;
}
sub is_bus_out {
my $io = shift;
return 1 if ($io->{type} eq "bus_hardware_out");
return 0;
}
sub is_main_out {
my $io = shift;
return 1 if ($io->{type} eq "main_hardware_out");
return 0;
}
sub is_aux {
my $io = shift;
return 1 if ($io->{type} eq "send_hardware_out");
return 1 if ($io->{type} eq "bus_hardware_out");
return 0;
}
sub is_send {
my $io = shift;
return 1 if ($io->{type} eq "send_hardware_out");
return 0;
}
sub is_return {
my $io = shift;
return 1 if ($io->{type} eq "return");
return 0;
}
sub is_submix_in {
my $io = shift;
return 1 if ($io->{type} eq "audio_in");
return 0;
}
sub is_submix_out {
my $io = shift;
return 1 if ($io->{type} eq "audio_out");
return 0;
}
sub is_audio_player_track {
my $io = shift;
return 1 if ($io->{type} eq "audio_player");
return 0;
}
sub is_file_player {
my $io = shift;
return 1 if ($io->{type} eq "file_in");
return 0;
}
sub is_submix {
my $io = shift;
return 1 if ($io->{type} eq "submix");
return 0;
}
sub is_mono {
my $io = shift;
if ($io->{channels}) {
return 1 if ($io->{channels} eq "1");
}
return 0;
}
sub is_stereo {
my $io = shift;
if ($io->{channels}) {
return 1 if ($io->{channels} eq "2");
}
return 0;
}
sub is_summed_mono {
#applicable to outputs only
my $io = shift;
if (defined $io->{mode}) {
return 1 if (($io->{channels} eq "2")and($io->{mode} eq "mono"));
}
return 0;
}
1;