diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-14 22:18:51 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-14 22:18:51 +0200 |
commit | 1b4b78f5b6df7182ac066fcc26a7b4f0e8586a47 (patch) | |
tree | ef2bddec7b9f09c614012ac6ee2588cd732242ee /helpers/__init__.py | |
parent | 71715c049145a074b0f2b8d90c8c8c47830323c3 (diff) | |
download | MusicSampler-1b4b78f5b6df7182ac066fcc26a7b4f0e8586a47.tar.gz MusicSampler-1b4b78f5b6df7182ac066fcc26a7b4f0e8586a47.tar.zst MusicSampler-1b4b78f5b6df7182ac066fcc26a7b4f0e8586a47.zip |
Some new features:
- gain function moved to helpers/__init__
- cleanup some unused functions
- stop can now wait for fade_out to finish before returning
- volume can be incremented
- master volume
Diffstat (limited to 'helpers/__init__.py')
-rw-r--r-- | helpers/__init__.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/helpers/__init__.py b/helpers/__init__.py index 3b97f2f..2339b9b 100644 --- a/helpers/__init__.py +++ b/helpers/__init__.py | |||
@@ -2,6 +2,7 @@ | |||
2 | import argparse | 2 | import argparse |
3 | import sys | 3 | import sys |
4 | import os | 4 | import os |
5 | import math | ||
5 | 6 | ||
6 | class Config: | 7 | class Config: |
7 | def __init__(self, **kwargs): | 8 | def __init__(self, **kwargs): |
@@ -60,3 +61,10 @@ def duration_to_min_sec(duration): | |||
60 | return "{:2}:{:0>2}".format(minutes, seconds) | 61 | return "{:2}:{:0>2}".format(minutes, seconds) |
61 | else: | 62 | else: |
62 | return "{}:{:0>2}".format(minutes, seconds) | 63 | return "{}:{:0>2}".format(minutes, seconds) |
64 | |||
65 | def gain(volume, old_volume = None): | ||
66 | if old_volume is None: | ||
67 | return 20 * math.log10(volume / 100) | ||
68 | else: | ||
69 | return [20 * math.log10(max(volume, 0.1) / max(old_volume, 0.1)), max(volume, 0)] | ||
70 | |||