aboutsummaryrefslogtreecommitdiff
path: root/helpers/__init__.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-14 22:18:51 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-14 22:18:51 +0200
commit1b4b78f5b6df7182ac066fcc26a7b4f0e8586a47 (patch)
treeef2bddec7b9f09c614012ac6ee2588cd732242ee /helpers/__init__.py
parent71715c049145a074b0f2b8d90c8c8c47830323c3 (diff)
downloadMusicSampler-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__.py8
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 @@
2import argparse 2import argparse
3import sys 3import sys
4import os 4import os
5import math
5 6
6class Config: 7class 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
65def 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