]> git.parisson.com Git - telemeta.git/commitdiff
* Add analyzers
authoryomguy <>
Sat, 23 Aug 2008 13:40:42 +0000 (13:40 +0000)
committeryomguy <>
Sat, 23 Aug 2008 13:40:42 +0000 (13:40 +0000)
* Modify item detail template
* Cleanup

12 files changed:
debian/control
telemeta/analysis/__init__.py
telemeta/analysis/channels.py [new file with mode: 0644]
telemeta/analysis/core.py
telemeta/analysis/length.py
telemeta/analysis/max_level.py
telemeta/analysis/mean_level.py
telemeta/analysis/samplerate.py [new file with mode: 0644]
telemeta/htdocs/css/telemeta.css
telemeta/templates/mediaitem_detail.html
telemeta/visualization/wav2png.py
telemeta/visualization/waveform3.py

index a11586281410f16a2f7a7a9a512f1eefbb1323ad..6ea6f3f8d2cbe510823d8636be3541ae9941bc75 100644 (file)
@@ -8,7 +8,7 @@ Standards-Version: 3.7.3
 
 Package: telemeta
 Architecture: any
-Depends: ${python:Depends}, python-xml, python-mutagen, python-django (>= 0.96.2), sox, vorbis-tools, flac, normalize-audio, python-mysqldb, mysql-server, octave2.9, python-tk, libgd2-xpm, libsndfile1, python-numpy
+Depends: ${python:Depends}, python-xml, python-mutagen, python-django (>= 0.96.2), sox, vorbis-tools, flac, normalize-audio, python-mysqldb, mysql-server, octave2.9, python-tk, libgd2-xpm, libsndfile1, python-numpy, python-ctypes (>= 1.0.1), libsndfile1
 Recommends: lame
 Suggests: ecasound, festival, par2
 Description: web frontend to backup, transcode and tag any audio content with metadata
index cc434015d1f1d57719d413a8b969454f7fd034a9..0336b26dcb1209056dee20158cbafe449985dbec 100644 (file)
@@ -1,5 +1,7 @@
 from telemeta.analysis.api import *
 from telemeta.analysis.core import *
+from telemeta.analysis.channels import *
+from telemeta.analysis.length import *
+from telemeta.analysis.samplerate import *
 from telemeta.analysis.max_level import *
 from telemeta.analysis.mean_level import *
-from telemeta.analysis.length import *
diff --git a/telemeta/analysis/channels.py b/telemeta/analysis/channels.py
new file mode 100644 (file)
index 0000000..6adf356
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2008 Parisson SARL
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://svn.parisson.org/telemeta/TelemetaLicense.
+#
+# Author: Guillaume Pellerin <yomguy@parisson.com>
+
+from telemeta.analysis.core import *
+from telemeta.analysis.api import IMediaItemAnalyzer
+import numpy
+
+class ChannelAnalyser(AudioProcessor):
+    """Media item analyzer driver interface"""
+
+    implements(IMediaItemAnalyzer)
+
+    def get_id(self):
+        return "nb_channels"
+
+    def get_name(self):
+        return "Number of channels"
+
+    def get_unit(self):
+        return ""
+
+    def render(self, media_item, options=None):
+        self.pre_process(media_item)
+        return self.channels
index 93f44bc91507cba4e3cd008accc891233977e31d..ffc673cce6643f10976ca83e5c0be189c429a488 100644 (file)
@@ -50,7 +50,11 @@ class AudioProcessor(Component):
         # convert to mono by selecting left channel only
         if self.channels > 1:
             samples = samples[:,0]
-        return samples    
+        return samples
+
+    def get_samples(self):
+        samples = self.audio_file.read_frames(self.frames)
+        return samples  
         
     def read(self, start, size, resize_if_less=False):
         """ read size samples starting at start, if resize_if_less is True and less than size
index 3c6cf7a2e837332109e323350cc8be209ea4b19c..c1817fba6f45940f7812abee1498b8bfed2917cb 100644 (file)
@@ -16,11 +16,6 @@ class LengthAnalyzer(AudioProcessor):
 
     implements(IMediaItemAnalyzer)
 
-    def __init__(self):
-        self.fft_size = 2048
-        self.window_function = numpy.hanning
-        self.window = self.window_function(self.fft_size)
-        
     def get_id(self):
         return "length"
 
@@ -32,4 +27,4 @@ class LengthAnalyzer(AudioProcessor):
 
     def render(self, media_item, options=None):
         self.pre_process(media_item)
-        return numpy.round(numpy.divide(self.frames, self.samplerate),2)
+        return numpy.round(float(self.frames)/float(self.samplerate),2)
index 6aaa48bebb857ea4ac3a7c042954ef798e5f2edc..bcc4343f57a6d2421a5c2c4eac99007e5c5f2d4e 100644 (file)
@@ -16,22 +16,16 @@ class MaxLevelAnalyzer(AudioProcessor):
 
     implements(IMediaItemAnalyzer)
 
-    def __init__(self):
-        self.fft_size = 2048
-        self.window_function = numpy.hanning
-        self.window = self.window_function(self.fft_size)
-        
     def get_id(self):
         return "max_level"
 
     def get_name(self):
-        return "Maximum level"
+        return "Maximum peak level"
 
     def get_unit(self):
         return "dB"
 
     def render(self, media_item, options=None):
         self.pre_process(media_item)
-        samples = self.get_mono_samples()
-        print str(numpy.max(samples))
+        samples = self.get_samples()
         return numpy.round(20*numpy.log10(numpy.max(samples)),2)
\ No newline at end of file
index 1efe14e5e9c1b1e8eeece565d6b5732fa07d6290..630080d98f7d835a357a201b585799a70aa81707 100644 (file)
@@ -16,16 +16,11 @@ class MeanLevelAnalyser(AudioProcessor):
 
     implements(IMediaItemAnalyzer)
 
-    def __init__(self):
-        self.fft_size = 2048
-        self.window_function = numpy.hanning
-        self.window = self.window_function(self.fft_size)
-        
     def get_id(self):
         return "mean_level"
 
     def get_name(self):
-        return "Mean level"
+        return "Mean RMS level"
 
     def get_unit(self):
         return "dB"
diff --git a/telemeta/analysis/samplerate.py b/telemeta/analysis/samplerate.py
new file mode 100644 (file)
index 0000000..6fcb5fe
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2008 Parisson SARL
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://svn.parisson.org/telemeta/TelemetaLicense.
+#
+# Author: Guillaume Pellerin <yomguy@parisson.com>
+
+from telemeta.analysis.core import *
+from telemeta.analysis.api import IMediaItemAnalyzer
+import numpy
+
+class SampleRateAnalyzer(AudioProcessor):
+    """Media item analyzer driver interface"""
+
+    implements(IMediaItemAnalyzer)
+
+    def get_id(self):
+        return "samplerate"
+
+    def get_name(self):
+        return "Samplerate"
+
+    def get_unit(self):
+        return "Hz"
+
+    def render(self, media_item, options=None):
+        self.pre_process(media_item)
+        return self.samplerate
index 1fe5a561abf5190acd66ab0d7302ae8fe959effa..1bbcd46c0a95598a554b0cd9beaf5822b8127f56 100644 (file)
@@ -120,7 +120,7 @@ h3 {
     border: 1px solid #adadad;\r
     text-align: center;\r
 }\r
-.item_visualization select { width: 210px; }\r
+.item_visualization select { width: 240px; }\r
 .item_visualization .viewport { width: 305px; border: 1px solid #adadad; overflow: auto; margin-top: 5px; background-color: #fff;}\r
 \r
 .exporter {\r
@@ -131,18 +131,18 @@ h3 {
     padding: 2px;\r
     height: 17px;\r
     margin: 5px 0 0;\r
-    overflow: auto;\r
+    /* overflow: auto; */\r
     font-size: 1em;\r
 }\r
 \r
-.analyser {\r
+.analyzer {\r
     background-color: #fff;\r
     color: #555;\r
     border: 1px solid #adadad;\r
     width: 301px;\r
     padding: 2px;\r
     margin: 5px 0 0;\r
-    overflow: auto;\r
+    /* overflow: auto; */\r
     font-size: 1em;\r
 }\r
 \r
index 5d4f8a4aa8edb923edc353e8fce382a8a5d854ec..83d5ac0c29243379b82e8d2b6799b32cce114b36 100644 (file)
             <input type="submit" value="OK" />\r
         </form>\r
     </div>\r
-    <div class="exporter">\r
-        <p>Download:\r
-        {% for format in export_formats %}\r
-        <a href="{% url telemeta-item-export item.id|urlencode,format.extension %}">{{ format.name }}</a>\r
-        {% endfor %}</p>\r
-    </div>\r
-    <div class="analyser">\r
-        <p>Analysis:</p>\r
-        <br>\r
-        <table>\r
+    <div class="analyzer">\r
+        <table width="100%">\r
+         <tr>\r
+          <td>Parameter</td>\r
+          <td>Value</td>\r
+          <td>Unit</td>\r
+         <tr>\r
         {% for analyser in analysers %}\r
          <tr>\r
           <td>\r
             {{ analyser.name }}\r
           </td>\r
-          <td> =\r
+          <td> \r
             {{ analyser.value }}\r
           </td>\r
           <td>\r
         {% endfor %}\r
        </table>\r
     </div>\r
+    <div class="exporter">\r
+        <p>Download:\r
+        {% for format in export_formats %}\r
+        <a href="{% url telemeta-item-export item.id|urlencode,format.extension %}">{{ format.name }}</a>\r
+        {% endfor %}</p>\r
+    </div>\r
+\r
 </div>\r
 {% endif %}\r
     <div id="leftcol">\r
index d0e37e016cbfac912d2467fb6b0c2ad208e992c5..e173f23d791ec53af2419987cce03f0add9f0e65 100755 (executable)
@@ -294,7 +294,7 @@ class WaveformImage(object):
         
         if alpha > 0.0 and alpha < 1.0 and y_max_int + 1 < self.image_height:
             current_pix = self.pix[x, y_max_int + 1]
-                
+            
             r = int((1-alpha)*current_pix[0] + alpha*color[0])
             g = int((1-alpha)*current_pix[1] + alpha*color[1])
             b = int((1-alpha)*current_pix[2] + alpha*color[2])
index e908dfd42e98ef95b9cfddb8d86c398e5c03d265..3fbb7e092e40fae3789a82e69bd7b4d2886e69a3 100644 (file)
@@ -31,7 +31,7 @@ class WaveFormVisualizer(Component):
         pngFile_w = NamedTemporaryFile(suffix='.png')
         pngFile_s = NamedTemporaryFile(suffix='.png')
         image_width = 305
-        image_height = 152
+        image_height = 150
         fft_size = 2048
         args = (wav_file, pngFile_w.name, pngFile_s.name, image_width, image_height, fft_size)
         create_png(*args)