-
Notifications
You must be signed in to change notification settings - Fork 0
/
combination_tone_matrix.scd
68 lines (63 loc) · 1.52 KB
/
combination_tone_matrix.scd
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
(
~get_frequency = {
arg multiplier, bass_multiple, melody;
var melody_multiple = melody * multiplier;
bass_multiple + melody_multiple;
};
~get_melody_column = {
arg multiplier, columns, bass, melody;
var bass_multiple = bass * multiplier;
var melody_column = Array.newClear(columns);
var add_frequency = {
arg column;
var frequency = ~get_frequency.value(column, bass_multiple, melody);
melody_column.put(column, frequency);
};
columns.do(add_frequency);
melody_column;
};
~get_matrix = {
arg bass, melody, count = 5;
var bass_rows = Array.newClear(count);
var add_column = {
arg row;
var column = ~get_melody_column.value(row, count, bass, melody);
bass_rows.put(row, column);
};
bass = bass.midicps;
melody = melody.midicps;
count.do(add_column);
bass_rows;
};
~display_matrix = {
arg matrix;
var post_row = {
arg item;
item.postln;
};
matrix.do(post_row);
};
~sort_frequencies = {
arg matrix, limit = 0;
var frequencies = matrix.flatten[1..].sort;
if (limit > 0) {
frequencies[..limit]
} {
frequencies
};
};
~play_matrix = {
arg matrix, as_chord = false;
var frequencies = ~sort_frequencies.value(matrix);
var amplitude = 0.1;
if (as_chord) {
amplitude = amplitude / frequencies.size;
frequencies = [frequencies];
};
Pbind(
\freq, Pseq(frequencies),
\dur, 0.2,
\amp, amplitude
).play;
};
)