summaryrefslogtreecommitdiff
path: root/examp.rb
diff options
context:
space:
mode:
authorAlessio Treglia <alessio@debian.org>2011-03-24 09:13:51 +0100
committerAlessio Treglia <alessio@debian.org>2011-03-24 09:13:51 +0100
commite5328e59987b90c4e98959510b810510e384650d (patch)
tree0f140b79d942c4654701d8fb4cfe2f1dd904f9f0 /examp.rb
parent36cf8384e5699cda3f1ca607753fe4d4a8515b01 (diff)
Imported Upstream version 12.0
Diffstat (limited to 'examp.rb')
-rw-r--r--examp.rb31
1 files changed, 13 insertions, 18 deletions
diff --git a/examp.rb b/examp.rb
index 8c7b455..9405422 100644
--- a/examp.rb
+++ b/examp.rb
@@ -1,8 +1,8 @@
-# examp.rb -- Guile -> Ruby translation -*- snd-ruby -*-
+# examp.rb -- Guile -> Ruby translation
# Translator/Author: Michael Scholz <mi-scholz@users.sourceforge.net>
# Created: Wed Sep 04 18:34:00 CEST 2002
-# Changed: Thu Nov 26 19:34:47 CET 2009
+# Changed: Sat Feb 19 17:17:27 CET 2011
# module Examp (examp.scm)
# selection_rms
@@ -167,7 +167,7 @@ module Examp
sum = 0.0
len.times do
val = next_sample(reader)
- sum += val * val
+ sum = sum + val * val
end
free_sampler(reader)
sqrt(sum / len)
@@ -395,7 +395,7 @@ looks for successive samples that sum to less than 'limit', moving the cursor if
val0 = sf.call.abs
val1 = sf.call.abs
n = start
- until sampler_at_end?(sf) or c_g? or val0 + val1 < limit
+ until sampler_at_end?(sf) or val0 + val1 < limit
val0, val1 = val1, sf.call.abs
n += 1
end
@@ -477,7 +477,7 @@ end")
end
if flag
aufile = filename + ".au"
- File.unlink(aufile) if File.exist?(aufile)
+ File.unlink(aufile) if File.exists?(aufile)
system(format("ogg123 -d au -f %s %s", aufile, filename))
aufile
else
@@ -500,7 +500,7 @@ end")
def read_speex(filename)
wavfile = filename + ".wav"
- File.unlink(wavfile) if File.exist?(wavfile)
+ File.unlink(wavfile) if File.exists?(wavfile)
system(format("speexdec %s %s", filename, wavfile))
wavfile
end
@@ -569,6 +569,7 @@ end")
vct2channel(data, frame, loc, out_snd, 0)
end
end
+ out_snd
end
# make dot size dependent on number of samples being displayed
@@ -797,7 +798,6 @@ ffts an entire sound, removes all energy below low-Hz and all above high-Hz, the
"fft_squelch(squelch, [snd=false, [chn=false]]) \
ffts an entire sound, sets all bins to 0.0 whose energy is below squelch, then inverse ffts")
def fft_squelch(squelch, snd = false, chn = false)
- sr = srate(snd).to_f
len = frames(snd, chn)
fsize = (2.0 ** (log(len) / log(2.0)).ceil).to_i
rdata = channel2vct(0, fsize, snd, chn)
@@ -903,7 +903,6 @@ suppresses portions of a sound that look like steady-state")
"fft_env_data(fft-env, [snd=false, [chn=false]]) \
applies fft_env as spectral env to current sound, returning vct of new data")
def fft_env_data(fft_env, snd = false, chn = false)
- sr = srate(snd)
len = frames(snd, chn)
fsize = (2 ** (log(len) / log(2.0)).ceil).to_i
rdata = channel2vct(0, fsize, snd, chn)
@@ -1049,7 +1048,7 @@ returns 3 formant filters in parallel: map_channel(formants(0.99, 900, 0.98, 180
fr1 = make_formant(f1, r1)
fr2 = make_formant(f2, r2)
fr3 = make_formant(f3, r3)
- lambda do |inval| formant(fr1, inval) + formant(fr1, inval) + formant(fr1, inval) end
+ lambda do |inval| formant(fr1, inval) + formant(fr2, inval) + formant(fr3, inval) end
end
add_help(:moving_formant,
@@ -1128,8 +1127,6 @@ map_channel(ring_mod(10, [0, 0, 1, hz2radians(100)]))")
def ring_mod(freq, gliss_env)
os = make_oscil(:frequency, freq)
len = frames()
- sr = srate()
- dur = (len / sr).round
genv = make_env(:envelope, gliss_env, :length, len)
lambda do |inval| oscil(os, env(genv)) * inval end
end
@@ -1322,7 +1319,6 @@ turns a vocal sound into whispering: voiced2unvoiced(1.0, 256, 2.0, 2.0)")
formants = make_array(freq_inc) do |i| make_formant(i * bin, radius) end
old_peak_amp = new_peak_amp = 0.0
outlen.times do |i|
- break if c_g?
if ctr == freq_inc
fdr = channel2vct(inctr, fftsize, snd, chn)
if (pk = vct_peak(fdr)) > old_peak_amp
@@ -1366,7 +1362,6 @@ uses sum-of-cosines to manipulate speech sounds")
old_peak_amp = new_peak_amp = 0.0
formants = make_array(freq_inc) do |i| make_formant(i * bin, radius) end
out_data.map do |i|
- break if c_g?
outval = 0.0
if ctr == freq_inc
fdr = channel2vct(inctr, fftsize, snd, chn)
@@ -1580,7 +1575,7 @@ reads snd's channel chn according to env and time-scale")
sum = 0.0
readers.each_with_index do |rd, j|
if sampler?(rd)
- sum += env(grain_envs[j]) * next_sample(rd)
+ sum = sum + env(grain_envs[j]) * next_sample(rd)
end
end
sound_data_set!(data, 0, data_ctr, sum)
@@ -1679,7 +1674,8 @@ end")
def files_popup_buffer(type, position, name)
if snd = find_sound(name)
curr_buffer = Snd.snd
- width, height= widget_size(sound_widgets(curr_buffer)[0])
+ vals = widget_size(sound_widgets(curr_buffer)[0])
+ height = vals[1]
Snd.sounds.each do |s| hide_widget(sound_widgets(s)[0]) end
show_widget(sound_widgets(snd)[0])
set_widget_size(sound_widgets(snd)[0], [widht, height])
@@ -1803,7 +1799,6 @@ end")
len = frames()
samps_ctr = 0
(loc...len).each do |ctr|
- return ctr if c_g?
samp0, samp1, samp2 = samp1, samp2, next_sample(reader)
samps[samps_ctr] = samp0
if samps_ctr < 9
@@ -1824,7 +1819,7 @@ end")
add_help(:remove_clicks, "remove_clicks() tries to find and smooth-over clicks")
def remove_clicks
loc = 0
- while (click = find_click(loc)) and (not c_g?())
+ while (click = find_click(loc))
smooth_sound(click - 2, 4)
loc = click + 2
end
@@ -1973,7 +1968,7 @@ region_play_sequence([0, 2, 1])")
time = 0.0
region_play_list(data.map do |id|
cur = time
- time += region_frames(id) / region_srate(id)
+ time = time + region_frames(id) / region_srate(id)
[cur, id]
end)
end