-
Notifications
You must be signed in to change notification settings - Fork 1
/
CompSwapper.py
executable file
·65 lines (52 loc) · 1.94 KB
/
CompSwapper.py
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
#!/usr/bin/env python3
#
# Copyright 2022 Harmonicdog. All rights reserved.
#
#pip install pyobjc
from Foundation import *
#import objc
from objc import python_method
import math
from Utilities import *
class CompSwapper(NSObject):
"""Compressor settings"""
def __init__(self):
self._power = False
self._thresh = FloatToIntVol(1.0)
self._ratio = FloatToIntVol(0.5)
self._attack = FloatToIntVol(0.1)
self._release = FloatToIntVol(0.2)
def initWithCoder_(self, coder):
self._power = False
if coder.containsValueForKey_('power'):
self._power = coder.decodeBoolForKey_('power')
self._thresh = coder.decodeIntForKey_('thresh')
self._ratio = coder.decodeIntForKey_('ratio')
self._attack = coder.decodeIntForKey_('attack')
self._release = coder.decodeIntForKey_('release')
return self
def encodeWithCoder_(self, coder):
coder.encodeBool_forKey_(self._power, 'power')
coder.encodeInt_forKey_(self._thresh, 'thresh')
coder.encodeInt_forKey_(self._ratio, 'ratio')
coder.encodeInt_forKey_(self._attack, 'attack')
coder.encodeInt_forKey_(self._release, 'release')
def get_power(self):
return 'ON' if self._power else 'OFF'
def get_thresh(self):
return LinearInterp(-45.0, 0.0, IntVolToFloat(self._thresh))
def get_ratio(self):
return LinearInterp(1/100.0, 1.0, IntVolToFloat(self._ratio));
@python_method
def get_attack(self, samplerate):
ms = QuadraticInterp(0.1, 10.0, 400.0, IntVolToFloat(self._attack));
theAttack = math.exp(-1000.0 / (ms * samplerate))
return theAttack
@python_method
def get_release(self, samplerate):
ms = QuadraticInterp(1.0, 100.0, 2000.0, IntVolToFloat(self._release));
theRelease = math.exp(-1000.0 / (ms * samplerate))
return theRelease
@python_method
def description(self, samplerate):
return '%s (thresh: %.3f) (ratio: %.2f:1) (attack: %.3f) (release: %.3f)' % (self.get_power(), self.get_thresh(), 1.0/self.get_ratio(), self.get_attack(samplerate), self.get_release(samplerate))