]> git.parisson.com Git - telemeta.git/commitdiff
- Added main tags to streamed mp3. Closes: #9
authoryomguy <>
Sun, 27 May 2007 21:53:20 +0000 (21:53 +0000)
committeryomguy <>
Sun, 27 May 2007 21:53:20 +0000 (21:53 +0000)
- Made Octave quiet
- Downsampling data for waveform2
- Cleanup

telemeta/export/core.py
telemeta/export/flac.py
telemeta/export/mp3.py
telemeta/export/ogg.py
telemeta/visualization/octave/waveform2img.m
telemeta/visualization/octave_core.py

index 9fd7658eba96f58c5a90ead22e67a8e71f542172..3abbfd80bb5e12a6e15c1912e70aa59fc0c2f0bb 100644 (file)
@@ -260,7 +260,7 @@ def clean_word(word) :
     word = re.sub("^[^\w]+","",word)    #trim the beginning _
     #word = string.replace(word,' ','_')
     #word = string.capitalize(word)
-    dict = '&[];"*'
+    dict = '&[];"*:,'
     for letter in dict:
         word = string.replace(word,letter,'_')
     return word
index 3e96d1a52b52b1c5bdfc8a18d97d1be88e007c9a..acffa56d9d6d560c353b481e82e5e5b74ec466a1 100644 (file)
@@ -119,9 +119,8 @@ class FlacExporter(ExporterCore):
 
         # Processing (streaming + cache writing)
         stream = self.core_process(self.command, self.buffer_size, self.dest)
-        for chunk in stream:
-            yield chunk
-
+        return stream
+    
         # Post-proccessing
         self.post_process(self.item_id,
                          self.source,
index 21401b4f3929258374a52b052af0a1fdaff9ca63..72477415e4ed7dee467226663da81eff124462aa 100644 (file)
@@ -45,7 +45,7 @@ class Mp3Exporter(ExporterCore):
                              }
         self.dub2args_dict = {'title': 'tt', #title2
                              'creator': 'ta', #composer
-                             'identifier': 'tl', #album
+                             'relation': 'tl', #album
                              #'type': 'tg', #genre
                              'publisher': 'tc', #comment
                              'date': 'ty', #year
@@ -99,29 +99,29 @@ class Mp3Exporter(ExporterCore):
 
     def get_args(self, metadata, options=None):
         """Get process options and return arguments for the encoder"""
-        args = ''
+        args = []
         if not options is None: 
             self.options = options
-            
-            if 'verbose' in self.options and self.options['verbose'] != '0':
-                args = args
-            else:
-                args= args + '-S '  
-            
+            if not ( 'verbose' in self.options and self.options['verbose'] != '0' ):
+                args.append('-S')
             if 'mp3_bitrate' in self.options:
-                args = args+'-b '+self.options['mp3_bitrate']
+                args.append('-b ' + self.options['mp3_bitrate'])
             else:
-                args = args+'-b '+self.bitrate_default    
+                args.append('-b '+self.bitrate_default)
             #Copyrights, etc..
-            args = args + ' -c -o '
+            args.append('-c -o')
         else:
-            args = args + ' -S -c -o '
+            args.append('-S -c -o')
 
-        #for tag in self.metadata.keys():
-            #if tag in self.dub2args_dict.keys():
-                #arg = self.dub2args_dict[tag]
-                #value = clean_word(self.metadata[tag])
-                #args = args.append(' --' + arg + ' "' +value +'" '
+        for tag in self.metadata.keys():
+            print tag
+            if tag in self.dub2args_dict.keys():
+                arg = self.dub2args_dict[tag]
+                print arg
+                value = clean_word(self.metadata[tag])
+                print value
+                args.append('--' + arg)
+                args.append('"' + value + '"')
 
         return args
 
@@ -131,9 +131,10 @@ class Mp3Exporter(ExporterCore):
         self.metadata = metadata
         self.args = self.get_args(self.metadata,options)
         self.ext = self.get_file_extension()
-        self.command = 'sox "'+self.source+'" -q -w -r 44100 -t wav -c2 - '+ \
-                       '| lame '+self.args+' --tc "default" - '
-            
+        self.args = ' '.join(self.args)
+        self.command = 'sox "%s" -q -w -r 44100 -t wav -c2 - | lame %s -' \
+                       % (self.source,self.args)
+        
         # Pre-proccessing
         self.dest = self.pre_process(self.item_id,
                                          self.source,
@@ -143,11 +144,9 @@ class Mp3Exporter(ExporterCore):
                                          self.options)
 
         # Processing (streaming + cache writing)
-        # FIXME return stream
         stream = self.core_process(self.command,self.buffer_size,self.dest)
-        for chunk in stream:
-            yield chunk
-
+        return stream
+    
         # Post-proccessing
         self.post_process(self.item_id,
                          self.source,
index f473a1f07fe0ed66f5d68834aab19af211365645..6930b3688428db8b22f9deef74faa3e4bd7682f4 100644 (file)
@@ -115,11 +115,9 @@ class OggExporter(ExporterCore):
 
         # Processing (streaming + cache writing)
         stream = self.core_process(self.command,self.buffer_size,self.dest)
-        for chunk in stream:
-            yield chunk
-
+        return stream
+    
         # Post-proccessing
-
         self.post_process(self.item_id,
                         self.source,
                         self.metadata,
index 2562d4324a9756c475ccab4ab8f60b4dea4fc57a..4edeb2f4ca6926e137284c6c33c4276c183a773c 100644 (file)
@@ -27,21 +27,30 @@ step = 6;   % spectral slice period (ms)
 % step_length = fix(5*Fs/1000);
 window = 30;   % filter window (ms)
 % window = fix(40*Fs/1000);
-lim_x_length = 10; % (s)
+time_limit = 300; % length limit of the displayed sample (s)
+% Downsampling factor
+D = 100;
 
+% Read audio data
 [x, Fs] = wavread(wav_file);
 x = x(:,1);  % mono
 lx = length(x);
-lim_x_samples = Fs.*lim_x_length;
 
-if lx > lim_x_samples;
- x = x(1:lim_x_samples);
+% LIMITING time
+lx_lim = Fs.*time_limit;
+if lx > lx_lim;
+ x = x(1:lx_lim);
 end
+N = length(x);
 
-lx = length(x);
-t = [0:1:lx-1]./Fs;
+% Downsampling by D
+t = 1:1:lx;
+t = (t-1)./Fs;
+x2(1:ceil(N/D)) = x(1:D:N);
+t2(1:ceil(N/D)) = t(1:D:N);
+%x(ceil(N/D)+1:N) = zeros(1,N-ceil(N/D));
 
-img = plot(t,x);
+img = plot(t2,x2);
 print(dest_image, '-dpng');
 
 quit;
index 01ea89dd5bc1acc9ee91a93453aa0aecac2078e0..726851faed4e1a8d34991dbb4d71aeaba475079e 100644 (file)
@@ -51,12 +51,12 @@ class OctaveCoreVisualizer(Component):
         mFile_tmp.close()
 
         # Compute
-        proc = subprocess.Popen(command)               
+        proc = subprocess.Popen(command, stdout = subprocess.PIPE)               
         proc.wait()
         
         # Convert
-        os.system('convert ' + self.ppmFile.name + ' -scale x250 ' + self.pngFile.name)
-        #
+        os.system('convert ' + self.ppmFile.name + \
+                  ' -scale x250 ' + self.pngFile.name)
         
         # Stream
         while True  :