}
self.dub2args_dict = {'title': 'tt', #title2
'creator': 'ta', #composer
- 'identifier': 'tl', #album
+ 'relation': 'tl', #album
#'type': 'tg', #genre
'publisher': 'tc', #comment
'date': 'ty', #year
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
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,
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,
% 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;