x = x(:,1); % mono
lim_x_samples = Fs.*lim_x_length;
if length(x) > lim_x_samples;
- x = x(1:lim_x_samples)
+ x = x(1:lim_x_samples);
end
%fftn = 2^nextpow2(window); % next highest power of 2
cmap = colormap(jet(ncmap));
img = imagesc(t, f, S);
-%stdin(imagesc(t, f, S));
saveimage(dest_image, img, 'ppm', cmap);
-%print([img_dir wav_file '.eps'], '-depsc');
-quit
+quit;
+
mFile_path = os.path.dirname(__file__) + '/octave/' + self.mFile
mFile = open(mFile_path,'r')
- while True:
- line = mFile.readline()
- if 'quit' in line:
- break
+ for line in mFile.readlines():
if '$OCTAVEPATH' in line:
line = line.replace('$OCTAVEPATH','"'+octave_path+'"')
if '$WAVFILE' in line:
def octave_to_png_stream(self, media_item):
- self.pngFile = NamedTemporaryFile(suffix='.png')
- self.ppmFile = NamedTemporaryFile(suffix='.'+self.dest_type)
+ self.ppmFile = NamedTemporaryFile(suffix='.'+self.trans_type)
self.wavFile = self.get_wav_path(media_item)
- #command = 'octave2.9 ' + self.mFile_tmp.name
- command = 'octave2.9'
-
- proc = subprocess.Popen(command,
- shell = True,
- #bufsize = buffer_size,
- stdin = subprocess.PIPE,
- stdout = subprocess.PIPE,
- close_fds = True)
+ mFile_tmp = NamedTemporaryFile(suffix='.m')
+ mFile_name = mFile_tmp.name
+ mFile_tmp.close()
+ mFile_tmp = open(mFile_name,'w')
+ self.pngFile = NamedTemporaryFile(suffix='.png')
+ command = ['octave2.9', mFile_name]
for line in self.get_mFile_line():
- proc.stdin.write(line)
-
- # Wait for ppm
- status = os.stat(self.ppmFile.name).st_size
- while True:
- if status == os.stat(self.ppmFile.name).st_size and status != 0:
- break
- status = os.stat(self.ppmFile.name).st_size
- #print status
- time.sleep(1)
+ mFile_tmp.write(line)
+ mFile_tmp.close()
+ # Compute
+ proc = subprocess.Popen(command)
+ proc.wait()
+
# Convert
os.system('convert ' + self.ppmFile.name + ' -scale 300x300 ' + self.pngFile.name)
- os.kill(proc.pid, signal.SIGKILL)
-
# Stream
while True :
buffer = self.pngFile.read(self.buffer_size)
self.ppmFile.close()
self.pngFile.close()
+ os.remove(mFile_name)
+
+
\ No newline at end of file
def __init__(self):
self.set_m_file('spectrogram2img.m')
self.buffer_size = 0xFFFF
- self.dest_type = 'ppm'
+ self.trans_type = 'ppm'
def get_id(self):
return "spectrogram2"
def get_name(self):
- return "Spectrogram2"
+ return "Spectrogram2 (< 10s)"
def render(self, media_item, options=None):
"""Generator that streams the spectral view as a PNG image"""
def __init__(self):
self.set_m_file('waveform2img.m')
self.buffer_size = 0xFFFF
- self.dest_type = 'png'
+ self.trans_type = 'png'
def get_id(self):
return "waveform2"
def get_name(self):
- return "Waveform2"
+ return "Waveform2 (< 10s)"
def render(self, media_item, options=None):
"""Generator that streams the temporal view as a PNG image"""