Repository navigation
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·67 lines (49 loc) · 2.13 KB
/
Copy pathexample.py
File metadata and controls
executable file
·67 lines (49 loc) · 2.13 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
#!/usr/bin/env python
from copy import deepcopy
from esq1 import (Oscillator, LFO, ModulationSource, simple_patch,
esq1_patches_to_sysex, sysex_to_esq1_patches)
# read the provided 'tribel.syx' SYSEX file into a list.
tribel = sysex_to_esq1_patches('tribel.syx')
# this file is in 'single program dump' format, so the list will only have one
# patch.
print('"tribel.syx" contains %d patch(es).' % len(tribel))
print('the first patch is named "%s".' % tribel[0].name)
# create a simple patch...
patch = simple_patch()
# ...and name it. the ESQ-1 only supports six letter, uppercase names, so this
# will be truncated.
patch.name = 'Example'
# set some values.
patch.oscillators[0].waveform.value = Oscillator.SQUARE
# randomize all of the second LFO's values.
patch.lfos[1].randomize()
# copy the first oscillator's values into the second oscillator.
patch.oscillators[1] = deepcopy(patch.oscillators[0])
# set some values on the second oscillator.
patch.oscillators[1].waveform.value = Oscillator.FORMT_5
patch.oscillators[1].set_octave(1)
patch.oscillators[1].fine_tune.value = 4
# modulate the second oscillator's frequency with the randomized LFO.
patch.oscillators[1].frequency_modulation_sources[0].value =\
ModulationSource.LFO_2
patch.oscillators[1].frequency_modulation_amounts[0].value = 4
# set some more values.
patch.envelopes[0].levels[1].value = 42
patch.envelopes[0].times[0].value = 52
patch.envelopes[3].times[0].value = 29
# randomize the frequency of the first LFO.
patch.lfos[0].frequency.randomize()
# set some more values.
patch.lfos[0].humanize.value = True
patch.lfos[0].levels[0].value = 32
patch.lfos[0].waveform.value = LFO.SAW
patch.miscellaneous.frequency.value = 119
patch.miscellaneous.resonance.value = 14
patch.miscellaneous.filter_modulation_sources[0].value = ModulationSource.LFO_1
patch.miscellaneous.filter_modulation_amount[0].value = -15
# write the patch to a SYSEX file.
esq1_patches_to_sysex([patch], 'saved.syx')
# read the SYSEX file into a list.
read_patches = sysex_to_esq1_patches('saved.syx')
# the truncated, uppercase name will be shown.
print('read patch "%s".' % read_patches[0].name)