--- /dev/null
+#! /usr/bin/env python
+
+from unit_timeside import *
+from timeside.decoder import *
+from timeside.analyzer.level import Level
+
+class TestAnalyzerLevel(TestCase):
+
+ def setUp(self):
+ self.analyzer = Level()
+
+ def testOnSweep(self):
+ "runs on sweep"
+ self.source = os.path.join (os.path.dirname(__file__), "samples", "sweep.wav")
+
+ def testOnGuitar(self):
+ "runs on guitar"
+ self.source = os.path.join (os.path.dirname(__file__), "samples", "guitar.wav")
+
+ def tearDown(self):
+ decoder = FileDecoder(self.source)
+ (decoder | self.analyzer).run()
+ results = self.analyzer.results()
+ print results
+ #print results.to_yaml()
+ #print results.to_json()
+ #print results.to_xml()
+
+if __name__ == '__main__':
+ unittest.main(testRunner=TestRunner())
+++ /dev/null
-#! /usr/bin/env python
-
-from unit_timeside import *
-from timeside.decoder import *
-from timeside.analyzer.max_level import MaxLevel
-
-class TestAubioMelEnergy(TestCase):
-
- def setUp(self):
- self.analyzer = MaxLevel()
-
- def testOnSweep(self):
- "runs on sweep"
- self.source = os.path.join (os.path.dirname(__file__), "samples", "sweep.wav")
-
- def testOnGuitar(self):
- "runs on guitar"
- self.source = os.path.join (os.path.dirname(__file__), "samples", "guitar.wav")
-
- def tearDown(self):
- decoder = FileDecoder(self.source)
- (decoder | self.analyzer).run()
- results = self.analyzer.results()
- print results
- #print results.to_yaml()
- #print results.to_json()
- #print results.to_xml()
-
-if __name__ == '__main__':
- unittest.main(testRunner=TestRunner())
# -*- coding: utf-8 -*-
-from max_level import *
-from mean_level import *
+from level import *
from dc import *
from aubio_temporal import *
from aubio_pitch import *
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2007-2009 Guillaume Pellerin <yomguy@parisson.com>
+# Copyright (c) 2009 Olivier Guilyardi <olivier@samalyse.com>
+
+# This file is part of TimeSide.
+
+# TimeSide is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# TimeSide is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with TimeSide. If not, see <http://www.gnu.org/licenses/>.
+
+# Author: Guillaume Pellerin <yomguy@parisson.com>
+
+from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
+from timeside.analyzer.core import *
+from timeside.api import IValueAnalyzer
+import numpy
+
+
+class Level(Processor):
+ implements(IValueAnalyzer)
+
+ @interfacedoc
+ def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
+ super(Level, self).setup(channels, samplerate, blocksize, totalframes)
+ # max_level
+ self.max_value = 0
+ # rms_level
+ self.mean_values = numpy.array([])
+
+ @staticmethod
+ @interfacedoc
+ def id():
+ return "level_analyzer"
+
+ @staticmethod
+ @interfacedoc
+ def name():
+ return "level analyzer"
+
+ def process(self, frames, eod=False):
+ if frames.size:
+ # max_level
+ max_value = frames.max()
+ if max_value > self.max_value:
+ self.max_value = max_value
+ # rms_level
+ self.mean_values = numpy.append(self.mean_values, numpy.mean(numpy.square(frames)))
+ return frames, eod
+
+ def results(self):
+ max_level = AnalyzerResult(id = "max_level", name = "Max level", unit = "dBFS")
+ max_level.value = numpy.round(20*numpy.log10(self.max_value), 3)
+ rms_level = AnalyzerResult(id = "rms_level", name = "RMS level", unit = "dBFS")
+ rms_level.value = numpy.round(20*numpy.log10(numpy.sqrt(numpy.mean(self.mean_values))), 3)
+ return AnalyzerResultContainer([max_level, rms_level])
+++ /dev/null
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2007-2009 Guillaume Pellerin <yomguy@parisson.com>
-# Copyright (c) 2009 Olivier Guilyardi <olivier@samalyse.com>
-
-# This file is part of TimeSide.
-
-# TimeSide is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-
-# TimeSide is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with TimeSide. If not, see <http://www.gnu.org/licenses/>.
-
-# Author: Guillaume Pellerin <yomguy@parisson.com>
-
-from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
-from timeside.analyzer.core import *
-from timeside.api import IValueAnalyzer
-import numpy
-
-
-class MaxLevel(Processor):
- implements(IValueAnalyzer)
-
- @interfacedoc
- def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
- super(MaxLevel, self).setup(channels, samplerate, blocksize, totalframes)
- self.value = 0
-
- @staticmethod
- @interfacedoc
- def id():
- return "maxlevel_analyzer"
-
- @staticmethod
- @interfacedoc
- def name():
- return "Max level analyzer"
-
- def process(self, frames, eod=False):
- if frames.size:
- max = frames.max()
- if max > self.value:
- self.value = max
- return frames, eod
-
- def results(self):
- result = AnalyzerResult(id = "maxlevel", name = "Max level", unit = "dBFS")
- result.value = numpy.round(20*numpy.log10(self.value), 3)
- return AnalyzerResultContainer([result])
+++ /dev/null
-# -*- coding: utf-8 -*-
-#
-# Copyright (c) 2007-2009 Guillaume Pellerin <yomguy@parisson.com>
-
-# This file is part of TimeSide.
-
-# TimeSide is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-
-# TimeSide is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with TimeSide. If not, see <http://www.gnu.org/licenses/>.
-
-# Author: Guillaume Pellerin <yomguy@parisson.com>
-
-from timeside.core import Processor, implements, interfacedoc, FixedSizeInputAdapter
-from timeside.analyzer.core import *
-from timeside.api import IValueAnalyzer
-import numpy
-
-
-class MeanLevel(Processor):
- implements(IValueAnalyzer)
-
- @interfacedoc
- def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
- super(MeanLevel, self).setup(channels, samplerate, blocksize, totalframes)
- self.values = numpy.array([])
-
- @staticmethod
- @interfacedoc
- def id():
- return "rmslevel"
-
- @staticmethod
- @interfacedoc
- def name():
- return "RMS level"
-
- @staticmethod
- @interfacedoc
- def unit():
- return "dBFS"
-
- def __str__(self):
- return "%s %s" % (str(self.value), unit())
-
- def process(self, frames, eod=False):
- if frames.size:
- self.values = numpy.append(self.values, numpy.mean(numpy.square(frames)))
- return frames, eod
-
- def result(self):
- return numpy.round(20*numpy.log10(numpy.sqrt(numpy.mean(self.values))), 3)