-
Notifications
You must be signed in to change notification settings - Fork 2
/
songConfig.py
30 lines (21 loc) · 1.23 KB
/
songConfig.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
from ConfigParserDefault import ConfigParserDefault
import os
class SongConfig(object):
def __init__(self, config):
self.defaultThresholds = map(float, config.get_def('spectrum', 'thresholds').split(','))
self.defaultOffThresholds = map(float, config.get_def('spectrum', 'offThresholds').split(','))
self.defaultOrder = map(int, config.get_def('lights', 'channelOrder').split(','))
self.frequencyThresholds = self.defaultThresholds
self.frequencyOffThresholds = self.defaultOffThresholds
self.frequencyBandOrder = self.defaultOrder
def loadSongSettings(self, filename, *args):
self.frequencyThresholds = self.defaultThresholds
self.frequencyOffThresholds = self.defaultOffThresholds
self.frequencyBandOrder = self.defaultOrder
iniPath = filename + '.ini'
if os.path.exists(iniPath):
cp = ConfigParserDefault()
cp.read([iniPath])
self.frequencyThresholds = map(float, cp.get_def('spectrum', 'thresholds').split(','))
self.frequencyOffThresholds = map(float, cp.get_def('spectrum', 'offThresholds').split(','))
self.frequencyBandOrder = map(int, cp.get_def('lights', 'channelOrder').split(','))