summaryrefslogtreecommitdiff
path: root/snd-test.rb
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@umlautQ.umlaeute.mur.at>2016-01-25 11:25:59 +0100
committerIOhannes m zmölnig <zmoelnig@umlautQ.umlaeute.mur.at>2016-01-25 11:25:59 +0100
commit110d59c341b8c50c04f30d90e85e9b8f6f329a0e (patch)
tree174afbe2ded41ae03923b93a0c4e6975e3163ad5 /snd-test.rb
parente5328e59987b90c4e98959510b810510e384650d (diff)
Imported Upstream version 16.1
Diffstat (limited to 'snd-test.rb')
-rw-r--r--snd-test.rb13151
1 files changed, 5726 insertions, 7425 deletions
diff --git a/snd-test.rb b/snd-test.rb
index c321598..dda5069 100644
--- a/snd-test.rb
+++ b/snd-test.rb
@@ -1,18 +1,15 @@
# snd-test.rb -- Snd Ruby code and tests
# Translator/Author: Michael Scholz <mi-scholz@users.sourceforge.net>
-# Created: Sat Feb 18 10:18:34 CET 2005
-# Changed: Sun Mar 06 18:15:59 CET 2011
+# Created: 05/02/18 10:18:34
+# Changed: 15/03/05 13:28:53
-# Commentary:
+# Tags: FIXME - something is wrong
+# XXX - info marker
#
# Tested with:
-# Snd version 11.14 of 7-Mar-11
-# ruby 1.8.0 (2003-08-04)
-# ruby 1.8.7 (2010-08-16 patchlevel 302)
-# ruby 1.9.2p0 (2010-08-18 revision 29036)
-# ruby 1.9.3dev (2011-03-06 trunk 31031)
-
+# Snd 15.x
+# Ruby 2.x.x
#
# Reads init file ./.sndtest.rb or ~/.sndtest.rb for global variables,
# hooks, etc.
@@ -24,8 +21,6 @@
# $VERBOSE = true
# $DEBUG = true
-# (ENV["RUBYLIB"] or $HOME + "/share/snd").split(/:/).each do |f| $LOAD_PATH.unshift(f) end
-
$original_save_dir = set_save_dir(ENV["TMPDIR"])
$original_temp_dir = set_temp_dir(save_dir)
$info_array_print_length = 4
@@ -37,9 +32,7 @@ $with_big_file = true
# $bigtest_08 = true
# $tests = 2
-def bye(n = 0)
- exit(n)
-end
+alias bye exit
=end
#
@@ -89,7 +82,7 @@ $original_save_dir = (save_dir or $HOME + "/zap/snd")
$original_temp_dir = (temp_dir or $HOME + "/zap/tmp")
$original_sound_file_extensions = sound_file_extensions
$original_prompt = listener_prompt
-$default_file_buffer_size = 65536
+$default_file_buffer_size = mus_file_buffer_size()
$info_array_print_length = 24
$sf_dir = "/home/bil/sf1/"
@@ -118,17 +111,22 @@ require "clm"
$tests = ((integer?($tests) and $tests > 0) ? $tests : 1)
$clmtest = 0
-$with_test_nogui = provided? :snd_nogui
+$with_test_nogui = provided?("snd-nogui")
$with_test_gui = (not $with_test_nogui)
-$with_test_motif = provided? :snd_motif
-$with_test_gtk = provided? :snd_gtk
-$with_test_ladspa = provided? :snd_ladspa
-$with_test_gl = provided? :gl
-$with_test_gl2ps = provided? :gl2ps
-$with_test_gsl = provided? :gsl
-$with_test_alsa = provided? :alsa
+$with_test_motif = provided?("snd-motif")
+$with_test_gtk = provided?("snd-gtk")
+$with_test_gtk3 = provided?("gtk3")
+$with_test_ladspa = provided?("snd-ladspa")
+$with_test_gl = provided?("gl")
+$with_test_gl2ps = provided?("gl2ps")
+$with_test_gsl = provided?("gsl")
+$with_test_alsa = provided?("alsa")
if $with_test_nogui
+ def noop(*args, &body)
+ false
+ end
+
undef x_bounds
undef set_x_bounds
undef y_bounds
@@ -141,24 +139,25 @@ if $with_test_nogui
undef colormap
undef set_colormap
- # FIXME
- # snd-nogui.c defines "in"
+ # XXX: snd-nogui.c defines "in"
alias call_in in
+ alias integer2colormap noop
+ alias colormap2integer noop
+ alias axis_color noop
+ alias highlight_color noop
+
x_bounds_value = [0.0, 0.1]
make_proc_with_setter(:x_bounds,
- Proc.new do |*args| x_bounds_value end,
- Proc.new do |bounds, *args| x_bounds_value = bounds end)
+ Proc.new do |*args| x_bounds_value end,
+ Proc.new do |bounds, *args| x_bounds_value = bounds end)
y_bounds_value = [-1.0, 1.0]
make_proc_with_setter(:y_bounds,
- Proc.new do |*args| y_bounds_value end,
- Proc.new do |bounds, *args| y_bounds_value = bounds end)
+ Proc.new do |*args| y_bounds_value end,
+ Proc.new do |bounds, *args| y_bounds_value = bounds end)
- #
- # FIXME
- #
- # For ruby18 it's important to define Procs with arity 0 in this way:
+ # XXX: For ruby18 it's important to define Procs with arity 0 in this way:
#
# Proc.new do | | enved_filter_value end
# or Proc.new do enved_filter_value end
@@ -169,32 +168,30 @@ if $with_test_nogui
# lambda do | | enved_filter_value end
#
# Otherwise we can't correctly determine the arity in test 28.
- #
enved_filter_value = true
make_proc_with_setter(:enved_filter,
- Proc.new do | | enved_filter_value end,
- Proc.new do |val| enved_filter_value = val end)
+ Proc.new do | | enved_filter_value end,
+ Proc.new do |val| enved_filter_value = val end)
graph_cursor_value = 34
make_proc_with_setter(:graph_cursor,
- Proc.new do | | graph_cursor_value end,
- Proc.new do |val| graph_cursor_value = val end)
+ Proc.new do | | graph_cursor_value end,
+ Proc.new do |val| graph_cursor_value = val end)
enved_envelope_value = nil
make_proc_with_setter(:enved_envelope,
- Proc.new do | | enved_envelope_value end,
- Proc.new do |val| enved_envelope_value = val end)
+ Proc.new do | | enved_envelope_value end,
+ Proc.new do |val| enved_envelope_value = val end)
colormap_value = $hot_colormap
make_proc_with_setter(:colormap,
- Proc.new do | | colormap_value end,
- Proc.new do |val|
- if val.kind_of?(Numeric) and val.between?(0, 20)
- colormap_value = val
- end
- end)
-
- # These global variables are already defined and set to false in snd-nogui.c.
+ Proc.new do | | colormap_value end,
+ Proc.new do |val|
+ if val.kind_of?(Numeric) and val.between?(0, 20)
+ colormap_value = val
+ end
+ end)
+
$mouse_enter_graph_hook = Hook.new("$mouse_enter_graph_hook", 2)
$mouse_enter_label_hook = Hook.new("$mouse_enter_label_hook", 3)
$mouse_enter_listener_hook = Hook.new("$mouse_enter_listener_hook", 1)
@@ -218,26 +215,25 @@ require "dsp"
require "analog-filter"
require "rgb"
require "effects"
-require "xm-enved"
require "draw"
require "musglyphs"
if $with_test_motif
RXSetErrorHandler(lambda do |dpy, e|
- val, err = RXGetErrorText(dpy, Rerror_code(e), nil, 1024)
- $stderr.printf("Xlib error_code[%s]: %s\n", val, err)
- val, err = RXGetErrorText(dpy, Rrequest_code(e), nil, 1024)
- $stderr.printf("Xlib request_code[%s]: %s\n", val, err)
- val, err = RXGetErrorText(dpy, Rminor_code(e), nil, 1024)
- $stderr.printf("Xlib minor_code[%s]: %s\n", val, err)
- $stderr.printf("Ruby $!: %s\n", $!.inspect)
- $stderr.printf("Ruby $@: %s\n", $@.inspect)
- end)
+ val, err = RXGetErrorText(dpy, Rerror_code(e), nil, 1024)
+ $stderr.printf("Xlib error_code[%s]: %s\n", val, err)
+ val, err = RXGetErrorText(dpy, Rrequest_code(e), nil, 1024)
+ $stderr.printf("Xlib request_code[%s]: %s\n", val, err)
+ val, err = RXGetErrorText(dpy, Rminor_code(e), nil, 1024)
+ $stderr.printf("Xlib minor_code[%s]: %s\n", val, err)
+ $stderr.printf("Ruby $!: %s\n", $!.inspect)
+ $stderr.printf("Ruby $@: %s\n", $@.inspect)
+ end)
RXSetIOErrorHandler(lambda do |dpy|
- $stderr.printf("Xlib IO Error dpy: %s", dpy.inspect)
- $stderr.printf("Ruby $!: %s\n", $!.inspect)
- $stderr.printf("Ruby $@: %s\n", $@.inspect)
- end)
+ $stderr.printf("Xlib IO Error dpy: %s", dpy.inspect)
+ $stderr.printf("Ruby $!: %s\n", $!.inspect)
+ $stderr.printf("Ruby $@: %s\n", $@.inspect)
+ end)
end
# Returns Ascii value of KEY as a Fixnum.
@@ -284,17 +280,12 @@ end
reset_almost_all_hooks
-# to prepare view_files_infos in snd-xfile.c
-# (save_state calls save_view_files_dialogs() in snd-xfile.c)
-Snd.add_sound_path(Dir.pwd)
-
$test_functions = Array.new
def main_test
start_snd_test()
if false
- # FIXME
- # Instead of rand() one can use different command lines:
+ # XXX: Instead of rand() one can use different command lines:
# snd -noinit snd-test.rb 3 2 1
# snd -noinit snd-test.rb 1 3 2
# etc.
@@ -381,12 +372,14 @@ def snd_format(res, req, op = "!=", fmt = "", *args)
if res.nil?
res = "nil"
end
- str = snd_test_format("res #{op} req?\n# => res %s\n# => req %s", res, req, fmt, *args)
+ str = snd_test_format("res #{op} req?\n# => res %s\n# => req %s",
+ res, req, fmt, *args)
set_mus_array_print_length(old_alen)
set_print_length(old_vlen)
str
else
- snd_test_format("res %s #{op} req %s?", res.inspect, req.inspect, fmt, *args)
+ snd_test_format("res %s #{op} req %s?",
+ res.inspect, req.inspect, fmt, *args)
end
end
@@ -394,6 +387,10 @@ def snd_format_neq(res, req, fmt = "", *args)
snd_format(res, req, "!=", fmt, *args)
end
+def snd_format_eq(res, req, fmt = "", *args)
+ snd_format(res, req, "==", fmt, *args)
+end
+
def snd_test_equal?(res, req)
case req
when Float
@@ -443,17 +440,37 @@ def snd_test_any_eq(res, req, func, fmt = "", *args)
end
end
+def snd_test_lt(res, req, fmt = "", *args)
+ if res < req
+ snd_display_prev_caller(snd_format(res, req, "<", fmt, *args))
+ true
+ else
+ false
+ end
+end
+
+def snd_test_gt(res, req, fmt = "", *args)
+ if res > req
+ snd_display_prev_caller(snd_format(res, req, ">", fmt, *args))
+ true
+ else
+ false
+ end
+end
+
# command line args: last arg(s) may be zero or many test numbers
# snd -noinit -load snd-test.rb 3 7 20 # only tests 3, 7, 20
# snd -noinit -load snd-test.rb -23 # all tests except 23
lambda do
- # non existent tests, non wanted tests (negative arguments like -23) added here
+ # non existent tests, non wanted tests (negative arguments like -23)
+ # added here
nargs = [22, 24, 25, 26, 27, 29]
targs = []
if script_arg.positive?
script_args[script_arg..-1].each do |arg|
- if integer?(n = Snd.catch(:all, nil) do Integer(arg) end.first)
+ n = Snd.catch(:all, nil) do Integer(arg) end.first
+ if integer?(n)
if n < 0
nargs << n.abs
elsif n <= 30 # test_30 for short tests
@@ -510,7 +527,9 @@ end
# compares Arrays and Vcts
def vequal_err(val0, val1, err = 0.001)
- (v0 = any2vct(val0)) and (v1 = any2vct(val1)) and v0.subtract(v1).peak <= err
+ (v0 = any2vct(val0)) and
+ (v1 = any2vct(val1)) and
+ (v0.subtract(v1).peak <= err)
end
def vequal?(v0, v1)
@@ -560,6 +579,30 @@ def vcneql(a, b)
end
end
+def cequal?(a, b)
+ if number?(a) and number?(b)
+ fequal?(a.real, b.real) and fequal?(a.imag, b.imag)
+ else
+ false
+ end
+end
+
+def vcequal?(a, b)
+ if a.length != b.length
+ false
+ else
+ a.each_with_index do |x, i|
+ if cneq(x, b[i])
+ return false
+ end
+ end
+ true
+ end
+end
+
+alias cequal cequal?
+alias vcequal vcequal?
+
def vmaxdiff(v0, v1)
v0.dup.subtract(v1).peak
end
@@ -580,11 +623,12 @@ def any_arity(obj)
end
def arity_ok(func, args)
- if integer?(rargs = Snd.catch do any_arity(func) end.first)
+ rargs = Snd.catch do any_arity(func) end.first
+ if integer?(rargs)
if rargs >= 0
args == rargs
else
- args >= (rargs.abs - 1) # We have no idea how much optional args FUNC has.
+ args >= (rargs.abs - 1) # We have no idea how much optional args.
end
else
false
@@ -620,9 +664,11 @@ else
end
end
-def safe_display_edits(snd = false, chn = false, edpos = false, with_source = true)
- Snd.catch(:all, lambda do |*args| snd_display_prev_caller("display_edits: %s", args) end) do
- display_edits(snd, chn, edpos, with_source)
+def safe_display_edits(snd = false, chn = false, edpos = false, with_src = true)
+ Snd.catch(:all, lambda do |*args|
+ snd_display_prev_caller("display_edits: %s", args)
+ end) do
+ display_edits(snd, chn, edpos, with_src)
end.first
end
@@ -630,7 +676,6 @@ def safe_divide(a, b)
b.zero? ? a : (a / b)
end
-set_mus_file_buffer_size($default_file_buffer_size)
set_with_background_processes(false)
def make_color_with_catch(c1, c2, c3)
@@ -640,7 +685,7 @@ rescue
end
def file_copy(f1, f2)
- if File.exists?(f1)
+ if File.exist?(f1)
fin = File.open(f1, "r")
fout = File.open(f2, "w")
fout.write(fin.read) until fin.eof?
@@ -658,11 +703,11 @@ def delete_files(*files)
end
def with_file(file, verbose = $DEBUG, &body)
- if File.exists?(full_name = $sf_dir + file)
+ if File.exist?(full_name = $sf_dir + file)
body.call(full_name)
else
if verbose
- snd_info("%s missing?", full_name)
+ snd_display_prev_caller("%s missing?", full_name)
end
end
end
@@ -676,16 +721,20 @@ def with_gc_disabled
end
Snd_error_tags.each do |tag|
- if (res = Snd.catch(tag) do Snd.throw(tag, "snd-test") end).first != tag
+ res = Snd.catch(tag) do Snd.throw(tag, "snd-test") end
+ if res.first != tag
snd_display("Snd.catch (throwing 1): %s -> %s", tag.inspect, res.inspect)
end
- if (res = Snd.catch(tag) do Snd.raise(tag, "snd-test") end).first != tag
+ res = Snd.catch(:all) do Snd.raise(tag, "snd-test") end
+ if res.first != tag
snd_display("Snd.catch (raising 1): %s -> %s", tag.inspect, res.inspect)
end
- if (res = Snd.catch(tag, :okay) do Snd.throw(tag, "snd-test") end).first != :okay
+ res = Snd.catch(tag, :okay) do Snd.throw(tag, "snd-test") end
+ if res.first != :okay
snd_display("Snd.catch (throwing 2): %s -> %s", tag.inspect, res.inspect)
end
- if (res = Snd.catch(tag, :okay) do Snd.raise(tag, "snd-test") end).first != :okay
+ res = Snd.catch(:all, :okay) do Snd.raise(tag, "snd-test") end
+ if res.first != :okay
snd_display("Snd.catch (raising 2): %s -> %s", tag.inspect, res.inspect)
end
end
@@ -752,9 +801,10 @@ def start_snd_test()
"unknown"
end
snd_info("=== Snd version: %s (snd_%s)", snd_version, kind)
- snd_info("=== Ruby version: %s (%s) [%s]", RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM)
+ snd_info("=== Ruby version: %s (%s) [%s]",
+ RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM)
snd_info("")
- snd_info("%s", Time.now.localtime.strftime("%a %d-%b-%Y %I:%M %p %Z"))
+ snd_info("%s", Time.now.localtime.strftime("%a %d-%b-%Y %I:%M %p"))
snd_info("")
$overall_start_time = Snd_test_time.new
end
@@ -762,8 +812,6 @@ end
def finish_snd_test()
$overall_start_time.stop
Snd.regions.apply(:forget_region)
- set_view_files_sort(0)
- clear_sincs
stop_playing
reset_almost_all_hooks
set_ask_about_unsaved_edits(false)
@@ -771,7 +819,9 @@ def finish_snd_test()
snd_info("all done!")
snd_info("")
unless $timings.empty?
- $timings.each do |tst| snd_info("%s %s", tst.first, tst.last.inspect) end
+ $timings.each do |tst|
+ snd_info("%s %s", tst.first, tst.last.inspect)
+ end
end
snd_info("total %s\n", $overall_start_time.inspect)
set_show_listener(true)
@@ -784,12 +834,13 @@ end
def clear_test_files
fs = 0
[$original_save_dir, $original_temp_dir, "/tmp"].each do |path|
- if File.exists?(path)
+ if File.exist?(path)
fs += Dir[path + "/snd_*"].length
Dir[path + "/snd_*"].each do |f| delete_file(f) end
end
end
- snd_info("%s temporary file%s deleted", fs.zero? ? "no" : fs, fs.between?(0, 1) ? "" : "s")
+ snd_info("%s temporary file%s deleted",
+ fs.zero? ? "no" : fs, fs.between?(0, 1) ? "" : "s")
mus_sound_prune
$snd_opened_sound = false
["1",
@@ -839,7 +890,7 @@ def clear_test_files
"tmp.snd",
"with-mix.rbm",
"with-mix.snd"].each do |file| delete_file(file) end
- ["bad_data_format.snd.snd",
+ ["bad_sample_type.snd.snd",
"ce-c3.w02.snd",
"hcom-16.snd.snd",
"ieee-text-16.snd.snd",
@@ -847,9 +898,6 @@ def clear_test_files
"nasahal.avi.snd",
"nist-shortpack.wav.snd",
"o2_dvi.wave.snd",
- "oboe.g721.snd",
- "oboe.g723_24.snd",
- "oboe.g723_40.snd",
"oki.wav.snd",
"trumps22.adp.snd",
"wood.sds.snd"].each do |file|
@@ -858,6 +906,7 @@ def clear_test_files
end
def before_test(func)
+ set_sync_style(Sync_none)
set_mus_srate($clm_srate = $default_srate.to_i)
set_clipping(false)
set_mus_clipping(false)
@@ -875,7 +924,11 @@ def after_test(func)
set_ask_about_unsaved_edits(false)
set_remember_sound_state(false)
dismiss_all_dialogs
- snd_info("%s done%s\n#", func, $VERBOSE ? format(" (%s)", $timings.last.last) : "")
+ if $VERBOSE
+ snd_info("%s done (%s)\n#", func, $timings.last.last)
+ else
+ snd_info("%s done\n#", func)
+ end
end
# returns body's return value or error symbol (eg. :no_such_sound)
@@ -1086,7 +1139,8 @@ if $with_test_motif
if RWidget?(button)
if RXtIsSensitive(button)
if RXmIsPushButton(button) or RXmIsPushButtonGadget(button)
- if RXtHasCallbacks(button, RXmNactivateCallback) == RXtCallbackHasSome
+ if RXtHasCallbacks(button,
+ RXmNactivateCallback) == RXtCallbackHasSome
but = RXmPushButtonCallbackStruct()
Rset_click_count(but, 0)
e = RXEvent(RButtonPress)
@@ -1094,11 +1148,13 @@ if $with_test_motif
Rset_event(but, e)
RXtCallCallbacks(button, RXmNactivateCallback, but)
else
- snd_display("pushbutton %s has no active callbacks", RXtName(button))
+ snd_display("pushbutton %s has no active callbacks",
+ RXtName(button))
end
else
if RXmIsToggleButton(button) or RXmIsToggleButtonGadget(button)
- if RXtHasCallbacks(button, RXmNvalueChangedCallback) == RXtCallbackHasSome
+ if RXtHasCallbacks(button,
+ RXmNvalueChangedCallback) == RXtCallbackHasSome
tgl = RXmToggleButtonCallbackStruct()
Rset_set(tgl, value)
e = RXEvent(RButtonPress)
@@ -1106,11 +1162,13 @@ if $with_test_motif
Rset_event(tgl, e)
RXtCallCallbacks(button, RXmNvalueChangedCallback, tgl)
else
- snd_display("togglebutton %s has no valueChanged callbacks", RXtName(button))
+ snd_display("togglebutton %s has no valueChanged callbacks",
+ RXtName(button))
end
else
if RXmIsArrowButton(button)
- if RXtHasCallbacks(button, RXmNactivateCallback) == RXtCallbackHasSome
+ if RXtHasCallbacks(button,
+ RXmNactivateCallback) == RXtCallbackHasSome
arr = RXmArrowButtonCallbackStruct()
Rset_click_count(arr, 0)
e = RXEvent(RButtonPress)
@@ -1118,7 +1176,8 @@ if $with_test_motif
Rset_event(arr, e)
RXtCallCallbacks(button, RXmNactivateCallback, arr)
else
- snd_display("arrowbutton %s has no active callbacks", RXtName(button))
+ snd_display("arrowbutton %s has no active callbacks",
+ RXtName(button))
end
else
snd_display("%s (%s) is not a push or toggle button",
@@ -1153,7 +1212,8 @@ if $with_test_motif
end
def take_keyboard_focus(wid)
- if RXmIsTraversable(wid) and (RXmGetVisibility(wid) != RXmVISIBILITY_FULLY_OBSCURED)
+ if RXmIsTraversable(wid) and
+ (RXmGetVisibility(wid) != RXmVISIBILITY_FULLY_OBSCURED)
RXmProcessTraversal(wid, RXmTRAVERSE_CURRENT)
end
end
@@ -1187,9 +1247,11 @@ if $with_test_motif
end
dpy = RXtDisplay(main_widgets[1])
natom = RXInternAtom(dpy, winat, false)
- if RWindow?(window = find_window.call(dpy, RDefaultRootWindow(dpy), natom))
- RXChangeProperty(dpy, window, RXInternAtom(dpy, name, false), RXA_STRING, 8,
- RPropModeReplace, command)
+ window = find_window.call(dpy, RDefaultRootWindow(dpy), natom)
+ if RWindow?(window)
+ RXChangeProperty(dpy, window,
+ RXInternAtom(dpy, name, false),
+ RXA_STRING, 8, RPropModeReplace, command)
RXFlush(dpy)
command
else
@@ -1198,19 +1260,19 @@ if $with_test_motif
end
make_proc_with_setter(:beep_state,
- # returns amp pitch duration
- lambda {
- vals = RXGetKeyboardControl(RXtDisplay(main_widgets.cadr))[1, 3]
- },
- # amp pitch dur
- # set_beep_state([100, 200, 100])
- lambda { |lst|
- RXChangeKeyboardControl(RXtDisplay(main_widgets.cadr),
- RKBBellPercent |
- RKBBellPitch |
- RKBBellDuration,
- [0] + lst)
- })
+ # return amp pitch duration
+ lambda do
+ vals = RXGetKeyboardControl(RXtDisplay(main_widgets.cadr))[1, 3]
+ end,
+ # amp pitch dur
+ # set_beep_state([100, 200, 100])
+ lambda do |lst|
+ RXChangeKeyboardControl(RXtDisplay(main_widgets.cadr),
+ RKBBellPercent |
+ RKBBellPitch |
+ RKBBellDuration,
+ [0] + lst)
+ end)
def beep
RXBell(RXtDisplay(main_widgets.cadr), 100)
@@ -1222,15 +1284,12 @@ end
# snd-test.scm translations
# ---------------- test 00: constants ----------------
-Tiny_font_string = $with_test_motif ? "6x12" : $with_test_gtk ? "Sans 8" : "9x15"
-Tiny_font_set_string = $with_test_motif ? "9x15" : $with_test_gtk ? "Monospace 10" : "6x12"
+Tiny_font_string = $with_test_motif ? "6x12" :
+ $with_test_gtk ? "Sans 8" : "9x15"
+Tiny_font_set_string = $with_test_motif ? "9x15" :
+ $with_test_gtk ? "Monospace 10" : "6x12"
-# FIXME
-#
-# temp_dir
-# save_dir
-# ladspa_dir
-# peak_env_dir
+# XXX: temp_dir save_dir ladspa_dir peak_env_dir
#
# These variables default to NULL (snd.c/snd-0.h).
# snd-test.scm checks for #f
@@ -1270,7 +1329,6 @@ def test_00
[:Cursor_in_view, 0],
[:Cursor_on_left, 1],
[:Cursor_on_right, 2],
- [:Dolph_chebyshev_window, 16],
[:Exponential_window, 9],
[:Flat_top_window, 23],
[:Sync_none, 0],
@@ -1298,8 +1356,6 @@ def test_00
[:Rv2_window, 30],
[:Rv3_window, 31],
[:Rv4_window, 32],
- [:Samaraki_window, 19],
- [:Ultraspherical_window, 20],
[:Graph_as_sonogram, 1],
[:Graph_as_spectrogram, 2],
[:Graph_once, 0],
@@ -1342,7 +1398,7 @@ def test_00
[:Show_x_axis_unlabelled, 4],
[:Show_bare_x_axis, 5],
# sndlib constants
- [:Mus_unsupported, 0],
+ [:Mus_unknown_header, 0],
[:Mus_next, 1],
[:Mus_aifc, 2],
[:Mus_riff, 3],
@@ -1368,7 +1424,7 @@ def test_00
[:Mus_chebyshev_first_kind, 1],
[:Mus_chebyshev_second_kind, 2],
#
- [:Mus_unknown, 0],
+ [:Mus_unknown_sample, 0],
[:Mus_bshort, 1],
[:Mus_lshort, 10],
[:Mus_mulaw, 2],
@@ -1393,16 +1449,23 @@ def test_00
[:Mus_ldouble_unscaled, 22]].each do |sym, req|
snd_test_neq(Module.const_get(sym), req, "%s", sym)
end
+ if $with_test_gsl
+ [[:Dolph_chebyshev_window, 16],
+ [:Samaraki_window, 19],
+ [:Ultraspherical_window, 20]].each do |sym, req|
+ snd_test_neq(Module.const_get(sym), req, "%s", sym)
+ end
+ end
#
old_dir = temp_dir
set_temp_dir(false)
[[:region_graph_style, Graph_lines],
[:ask_about_unsaved_edits, false],
[:show_full_duration, false],
+ [:show_full_range, false],
[:initial_beg, 0.0],
[:initial_dur, 0.1],
[:ask_before_overwrite, false],
- [:audio_output_device, 0],
[:auto_resize, true],
[:auto_update, false],
[:channel_style, 1],
@@ -1414,16 +1477,15 @@ def test_00
[:cursor_location_offset, 0],
[:dac_combines_channels, true],
[:dac_size, 256],
- [:minibuffer_history_length, 8],
[:clipping, false],
[:default_output_chans, 1],
- [:default_output_data_format, Mus_lfloat],
+ [:default_output_sample_type, Mus_lfloat],
[:default_output_srate, 44100],
[:default_output_header_type, Mus_next],
[:dot_size, 1],
[:cursor_size, 15],
[:cursor_style, Cursor_cross],
- [:tracking_cursor_style, Cursor_cross],
+ [:tracking_cursor_style, Cursor_line],
[:enved_base, 1.0],
[:enved_clip?, true],
[:enved_filter, true],
@@ -1455,12 +1517,10 @@ def test_00
[:listener_prompt, ">"],
[:max_transform_peaks, 100],
[:max_regions, 16],
- [:max_virtual_ptrees, 32],
[:min_dB, -60.0],
[:log_freq_start, 32.0],
[:selection_creates_region, true],
[:transform_normalization, Normalize_by_channel],
- [:view_files_sort, 0],
[:print_length, 12],
[:play_arrow_size, 10],
[:save_state_file, "saved-snd.rb"],
@@ -1489,15 +1549,12 @@ def test_00
[:peak_env_dir, ""],
[:tiny_font, Tiny_font_string],
[:transform_type, $fourier_transform],
- [:trap_segfault, true],
[:with_file_monitor, true],
- # FIXME
- # Ruby doesn't optimize
- [:optimization, 0],
[:clm_table_size, 512],
[:clm_default_frequency, 0.0],
[:with_verbose_cursor, false],
[:with_inset_graph, false],
+ [:with_interrupts, true],
[:remember_sound_state, false],
[:with_smpte_label, false],
[:with_toolbar, ($with_test_gtk ? true : false)],
@@ -1539,7 +1596,8 @@ def test_00
:peaks_font,
:bold_peaks_font].each do |sym|
req = snd_func(sym)
- snd_test_neq(set_snd_func(sym, "8x123"), req, "set_%s to bogus value", sym)
+ snd_test_neq(set_snd_func(sym, "8x123"), req,
+ "set_%s to bogus value", sym)
end
end
set_ask_about_unsaved_edits(false)
@@ -1581,7 +1639,6 @@ def test_01
["amp_control_bounds", amp_control_bounds()[1], 8.0],
["ask_about_unsaved_edits", ask_about_unsaved_edits(), false],
["ask_before_overwrite", ask_before_overwrite(), false],
- ["audio_output_device", audio_output_device(), 0],
["auto_resize", auto_resize(), true],
["auto_update", auto_update(), false],
["auto_update_interval", auto_update_interval(), 60.0],
@@ -1595,11 +1652,15 @@ def test_01
["color_inverted", color_inverted(), true],
["color_scale", color_scale(), 1.0],
["colormap", colormap(), $good_colormap],
- ["contrast_control", without_errors do contrast_control() end, :no_such_sound],
+ ["contrast_control", without_errors do
+ contrast_control()
+ end, :no_such_sound],
["contrast_control_amp", contrast_control_amp(), 1.0],
["contrast_control_bounds", contrast_control_bounds()[1], 10.0],
- ["contrast_control?", without_errors do contrast_control?() end, :no_such_sound],
- ["cursor_follows_play", cursor_follows_play(), false],
+ ["contrast_control?", without_errors do
+ contrast_control?()
+ end, :no_such_sound],
+ ["with_tracking_cursor", with_tracking_cursor(), false],
["cursor_location_offset", cursor_location_offset(), 0],
["cursor_size", cursor_size(), 15],
["cursor_style", cursor_style(), Cursor_cross],
@@ -1607,7 +1668,7 @@ def test_01
["dac_combines_channels", dac_combines_channels(), true],
["dac_size", dac_size(), 256],
["default_output_chans", default_output_chans(), 1],
- ["default_output_data_format", default_output_data_format(), Mus_lfloat],
+ ["default_output_sample_type", default_output_sample_type(), Mus_lfloat],
["default_output_header_type", default_output_header_type(), Mus_next],
["default_output_srate", default_output_srate(), 44100],
["dot_size", dot_size(), 1],
@@ -1625,25 +1686,35 @@ def test_01
["eps_file", eps_file(), "snd.eps"],
["eps_left_margin", eps_left_margin(), 0.0],
["eps_size", eps_size(), 1.0],
- ["expand_control", without_errors do expand_control() end, :no_such_sound],
+ ["expand_control", without_errors do
+ expand_control()
+ end, :no_such_sound],
["expand_control_bounds", expand_control_bounds()[1], 20.0],
["expand_control_hop", expand_control_hop(), 0.05],
["expand_control_jitter", expand_control_jitter(), 0.1],
["expand_control_length", expand_control_length(), 0.15],
["expand_control_ramp", expand_control_ramp(), 0.4],
- ["expand_control?", without_errors do expand_control?() end, :no_such_sound],
+ ["expand_control?", without_errors do
+ expand_control?()
+ end, :no_such_sound],
["fft_log_frequency", fft_log_frequency(), false],
["fft_log_magnitude", fft_log_magnitude(), false],
["fft_with_phases", fft_with_phases(), false],
["fft_window", fft_window(), 6],
["fft_window_alpha", fft_window_alpha(), 0.0],
["fft_window_beta", fft_window_beta(), 0.0],
- ["filter_control_coeffs", without_errors do filter_control_coeffs() end, :no_such_sound],
- ["filter_control_envelope", without_errors do filter_control_envelope() end, :no_such_sound],
+ ["filter_control_coeffs", without_errors do
+ filter_control_coeffs()
+ end, :no_such_sound],
+ ["filter_control_envelope", without_errors do
+ filter_control_envelope()
+ end, :no_such_sound],
["filter_control_in_dB", filter_control_in_dB(), false],
["filter_control_in_hz", filter_control_in_hz(), false],
["filter_control_order", filter_control_order(), 20],
- ["filter_control?", without_errors do filter_control?() end, :no_such_sound],
+ ["filter_control?", without_errors do
+ filter_control?()
+ end, :no_such_sound],
["graph_cursor", graph_cursor(), 34],
["graph_style", graph_style(), Graph_lines],
["graphs_horizontal", graphs_horizontal(), true],
@@ -1661,30 +1732,32 @@ def test_01
["mark_tag_height", mark_tag_height(), 4],
["mark_tag_width", mark_tag_width(), 10],
["max_regions", max_regions(), 16],
- ["max_virtual_ptrees", max_virtual_ptrees(), 32],
["max_transform_peaks", max_transform_peaks(), 100],
["min_dB", min_dB(), -60.0],
- ["minibuffer_history_length", minibuffer_history_length(), 8],
["mix_tag_height", mix_tag_height(), 14],
["mix_tag_width", mix_tag_width(), 6],
["mix_waveform_height", mix_waveform_height(), 20],
["mus_array_print_length", mus_array_print_length(), 8],
["mus_clipping", mus_clipping(), false],
["mus_float_equal_fudge_factor", mus_float_equal_fudge_factor(), 0.0000001],
- ["mus_prescaler", mus_prescaler(), 1.0],
- ["optimization", optimization(), 0], # Ruby doesn't optimize
["play_arrow_size", play_arrow_size(), 10],
["print_length", print_length(), 12],
["read_only", without_errors do read_only() end, :no_such_sound],
["region_graph_style", region_graph_style(), Graph_lines],
["remember_sound_state", remember_sound_state(), false],
["reverb_control_feedback", reverb_control_feedback(), 1.09],
- ["reverb_control_length", without_errors do reverb_control_length() end, :no_such_sound],
+ ["reverb_control_length", without_errors do
+ reverb_control_length()
+ end, :no_such_sound],
["reverb_control_length_bounds", reverb_control_length_bounds()[1], 5.0],
["reverb_control_lowpass", reverb_control_lowpass(), 0.7],
- ["reverb_control_scale", without_errors do reverb_control_scale() end, :no_such_sound],
+ ["reverb_control_scale", without_errors do
+ reverb_control_scale()
+ end, :no_such_sound],
["reverb_control_scale_bounds", reverb_control_scale_bounds()[1], 4.0],
- ["reverb_control?", without_errors do reverb_control?() end, :no_such_sound],
+ ["reverb_control?", without_errors do
+ reverb_control?()
+ end, :no_such_sound],
["save_as_dialog_auto_comment", save_as_dialog_auto_comment, false],
["save_as_dialog_src", save_as_dialog_src, false],
["save_state_file", save_state_file(), "saved-snd.rb"],
@@ -1692,6 +1765,7 @@ def test_01
["show_axes", show_axes(), 1],
["show_controls", show_controls(), false],
["show_full_duration", show_full_duration(), false],
+ ["show_full_range", show_full_range(), false],
["show_grid", show_grid(), false],
["show_indices", show_indices(), false],
["show_marks", show_marks(), true],
@@ -1718,13 +1792,14 @@ def test_01
["time_graph_type", time_graph_type(), Graph_once],
["time_graph?", without_errors do time_graph?() end, :no_such_sound],
["tiny_font", tiny_font(), Tiny_font_string],
- ["tracking_cursor_style", tracking_cursor_style(), Cursor_cross],
+ ["tracking_cursor_style", tracking_cursor_style(), Cursor_line],
["transform_graph_type", transform_graph_type(), Graph_once],
- ["transform_graph?", without_errors do transform_graph?() end, :no_such_sound],
+ ["transform_graph?", without_errors do
+ transform_graph?()
+ end, :no_such_sound],
["transform_normalization", transform_normalization(), Normalize_by_channel],
["transform_size", transform_size(), 512],
["transform_type", transform_type(), $fourier_transform],
- ["view_files_sort", view_files_sort(), 0],
["wavelet_type", wavelet_type(), 0],
["wavo_hop", wavo_hop(), 3],
["wavo_trace", wavo_trace(), 64],
@@ -1733,6 +1808,7 @@ def test_01
["with_tracking_cursor", with_tracking_cursor(), false],
["with_verbose_cursor", with_verbose_cursor(), false],
["with_inset_graph", with_inset_graph(), false],
+ ["with_interrupts", with_interrupts(), true],
["with_smpte_label", with_smpte_label, false],
["with_toolbar", with_toolbar, ($with_test_gtk ? true : false)],
["with_tooltips", with_tooltips, true],
@@ -1751,13 +1827,14 @@ end
# ---------------- test 02: headers ----------------
-def test_headers(name, chns, sr, dur, typ, frm, loop_start = false, loop_end = false)
- if File.exists?(name)
+def test_headers(name, chns, sr, dur, typ, frm,
+ loop_start = false, loop_end = false)
+ if File.exist?(name)
file = name
else
file = $sf_dir + name
end
- if File.exists?(file)
+ if File.exist?(file)
fchns = mus_sound_chans(file)
fsr = mus_sound_srate(file)
fdur = mus_sound_duration(file)
@@ -1770,22 +1847,22 @@ def test_headers(name, chns, sr, dur, typ, frm, loop_start = false, loop_end = f
if fneq(fdur, dur)
snd_display_prev_caller(snd_format_neq(fdur, dur, "%s duration", name))
end
- ffrm = mus_sound_data_format(file)
+ ffrm = mus_sound_sample_type(file)
ftyp = mus_sound_header_type(file)
req = mus_sound_length(file)
res = mus_sound_datum_size(file) * fdur * fsr * fchns
- if (ffrm != Mus_unknown) and
+ if (ffrm != Mus_unknown_sample) and
(ftyp != 27) and
(req + 1) < res
snd_display_prev_caller(snd_format_neq(res, req, "%s length", name))
end
- fframes = mus_sound_frames(file)
- res = fframes.to_f / fsr
+ fframples = mus_sound_framples(file)
+ res = fframples.to_f / fsr
if fneq(res, fdur)
- snd_display_prev_caller(snd_format_neq(res, fdur, "%s frames", name))
+ snd_display_prev_caller(snd_format_neq(res, fdur, "%s framples", name))
end
fsamps = mus_sound_samples(file)
- res = fframes - fsamps / fchns
+ res = fframples - fsamps / fchns
if res.abs > 1
snd_display_prev_caller(snd_format_neq(res, fsamps, "%s samples", name))
end
@@ -1793,7 +1870,7 @@ def test_headers(name, chns, sr, dur, typ, frm, loop_start = false, loop_end = f
if res != typ
snd_display_prev_caller(snd_format_neq(res, typ, "%s type", name))
end
- res = mus_data_format_name(ffrm)
+ res = mus_sample_type_name(ffrm)
if res != frm
snd_display_prev_caller(snd_format_neq(res, frm, "%s format", name))
end
@@ -1801,10 +1878,12 @@ def test_headers(name, chns, sr, dur, typ, frm, loop_start = false, loop_end = f
if loop_start and loop_end
if (not lst.nil?) and lst.length > 1
if lst[0] != loop_start
- snd_display_prev_caller(snd_format_neq(lst[0], loop_start, "%s loop start", name))
+ snd_display_prev_caller(snd_format_neq(lst[0],
+ loop_start, "%s loop start", name))
end
if lst[1] != loop_end
- snd_display_prev_caller(snd_format_neq(lst[1], loop_end, "%s loop end", name))
+ snd_display_prev_caller(snd_format_neq(lst[1],
+ loop_end, "%s loop end", name))
end
else
snd_display_prev_caller("%s loop info empty: %s?", name, lst.inspect)
@@ -1939,9 +2018,6 @@ def test_02
test_headers("o2_u8.avr", 1, 44100, 0.0367800444364548, "AVR", "unsigned byte (8 bits)")
test_headers("o2_u8.wave", 1, 44100, 0.0367800444364548, "RIFF", "unsigned byte (8 bits)")
test_headers("o28.mpc", 1, 44100, 0.036780, "AKAI 4", "little endian short (16 bits)")
- test_headers("oboe.g721", 1, 22050, 1.15287983417511, "Sun/Next", "unknown")
- test_headers("oboe.g723_24", 1, 22050, 0.864761888980865, "Sun/Next", "unknown")
- test_headers("oboe.g723_40", 1, 22050, 1.44126987457275, "Sun/Next", "unknown")
test_headers("oboe.kts", 1, 22050, 2.305125, "Korg", "big endian short (16 bits)")
test_headers("oboe.its", 1, 22050, 2.305125, "Impulse Tracker", "little endian short (16 bits)")
test_headers("oboe.sf2", 1, 22050, 2.305124759674, "SoundFont", "little endian short (16 bits)")
@@ -1954,7 +2030,6 @@ def test_02
test_headers("oboe-lf32.caf", 1, 22050, 2.305125, "caff", "little endian float (32 bits)")
test_headers("oboe-ulaw.caf", 1, 22050, 2.305125, "caff", "mulaw (8 bits)")
test_headers("oboe.nsp", 1, 22050, 2.305125, "CSL", "little endian short (16 bits)")
- test_headers("oboe.nvf", 1, 8000, 6.353500, "Creative NVF", "unknown")
test_headers("oboe-ulaw.voc", 1, 22050, 2.305669, "VOC", "mulaw (8 bits)")
test_headers("oboe-lf32.sf", 1, 22050, 2.305669, "IRCAM", "little endian float (32 bits)")
test_headers("oboe.wfp", 1, 22050, 2.305125, "Turtle Beach", "little endian short (16 bits)")
@@ -2056,16 +2131,16 @@ end
def test_03
ind = open_sound("oboe.snd")
test_dir = $HOME + "/test"
- if File.exists?(test_dir)
+ if File.exist?(test_dir)
old_val = temp_dir
snd_test_neq(set_temp_dir(test_dir), test_dir, "set_temp_dir")
set_temp_dir(old_val)
end
snd_test_neq(sample(1000), 0.0328, "sample 1000")
#
- [$output_name_hook,
- $output_comment_hook,
- $peak_env_hook,
+ $snd_error_hook.reset_hook!
+ $mus_error_hook.reset_hook!
+ [$output_comment_hook,
$help_hook,
$mark_drag_hook,
$mix_drag_hook,
@@ -2091,15 +2166,16 @@ def test_03
$after_graph_hook,
$graph_hook].each_with_index do |h, i|
if (not hook?(h)) or (not h.empty?)
- snd_display("%d: %s?", i, h.inspect)
+ snd_display("hook[%d]: %p?", i, h)
end
end
+ reset_almost_all_hooks
#
if $with_test_gui
old_ctrl = show_controls
set_show_controls(true)
req = enved_dialog
- snd_test_neq(dialog_widgets[2], req, "enved_dialog")
+ snd_test_neq(dialog_widgets[1], req, "enved_dialog")
req = [0.0, 0.0, 1.0, 1.0, 2.0, 0.0]
set_enved_envelope(req)
snd_test_neq(enved_envelope, req, "set_enved_envelope")
@@ -2139,8 +2215,6 @@ def test_03
[:amp_control_bounds, [0.0, 8.0], [1.0, 5.0]],
[:ask_about_unsaved_edits, false, true],
[:ask_before_overwrite, false, true],
- [:audio_input_device, 0, 1],
- [:audio_output_device, 0, 1],
[:auto_resize, true, false],
[:auto_update, false, true],
[:channel_style, 0, 1],
@@ -2154,13 +2228,12 @@ def test_03
[:with_tracking_cursor, false, true],
[:cursor_size, 15, 30],
[:cursor_style, Cursor_cross, Cursor_line],
- [:tracking_cursor_style, Cursor_cross, Cursor_line],
+ [:tracking_cursor_style, Cursor_line, Cursor_cross],
[:dac_combines_channels, true, false],
[:dac_size, 256, 512],
- [:minibuffer_history_length, 8, 16],
[:clipping, false, true],
[:default_output_chans, 1, 2],
- [:default_output_data_format, 1, 1],
+ [:default_output_sample_type, Mus_lfloat, Mus_bshort],
[:default_output_srate, 22050, 44100],
[:default_output_header_type, Mus_next, Mus_aifc],
[:dot_size, 1, 4],
@@ -2203,10 +2276,8 @@ def test_03
[:mix_tag_width, 6, 20],
[:mark_tag_height, 4, 20],
[:mark_tag_width, 10, 20],
- [:mus_prescaler, 1.0, 100.0],
[:mus_clipping, false, true],
[:selection_creates_region, true, false],
- [:view_files_sort, 0, 1],
[:play_arrow_size, 10, 16],
[:print_length, 12, 16],
[:region_graph_style, Graph_lines, Graph_lollipops],
@@ -2219,6 +2290,7 @@ def test_03
[:reverb_control_scale_bounds, [0.0, 4.0], [0.0, 0.2]],
[:show_axes, 1, 0],
[:show_full_duration, false, true],
+ [:show_full_range, false, true],
[:show_indices, false, true],
[:show_marks, true, false],
[:show_mix_waveforms, true, false],
@@ -2238,8 +2310,7 @@ def test_03
[:with_verbose_cursor, false, true],
[:wavelet_type, 0, 1],
[:time_graph?, false, true],
- # FIXME see below
- # [:time_graph_type, Graph_once, Graph_as_wavogram],
+ [:time_graph_type, Graph_once, Graph_as_wavogram],
[:wavo_hop, 3, 6],
[:wavo_trace, 64, 128],
[:with_mix_tags, true, false],
@@ -2253,12 +2324,6 @@ def test_03
if $with_test_gui
lst += gui_lst
end
- if $with_test_motif
- # FIXME
- # doesn't work with GTK
- # set_time_graph_type(Graph_as_wavogram) ==> segfault
- lst += [[:time_graph_type, Graph_once, Graph_as_wavogram]]
- end
lst.each do |sym, initval, newval|
next unless symbol?(sym)
2.times do |i|
@@ -2276,10 +2341,7 @@ def test_03
[:colormap, $good_colormap, [321, -123]],
[:color_cutoff, 0.003, [-1.0, 123.123]],
[:color_scale, 1.0, [-32.0, 2000.0]],
- if $with_test_motif
- # FIXME
- # doesn't work with GTK and ruby 1.9.2
- # set_contrast_control(xxx) ==> segfault
+ if $with_test_gui
[:contrast_control, 0.0, [-123.123, 123.123]]
end,
[:contrast_control_bounds, [0.0, 10.0], [false, [0.0], [1.0, 0.0], 2.0]],
@@ -2298,7 +2360,7 @@ def test_03
[:zero_pad, 0, [-1, -123]],
[:cursor_style, Cursor_cross, [-1]],
[:cursor_style, Cursor_line, [2, 123]],
- [:tracking_cursor_style, Cursor_cross, [-1]],
+ [:tracking_cursor_style, Cursor_line, [-1]],
[:tracking_cursor_style, Cursor_line, [2, 123]],
[:transform_graph_type, Graph_once, [-1, 123]],
[:fft_window, 6, [-1, 123]],
@@ -2306,7 +2368,6 @@ def test_03
[:filter_control_order, 20, [-10, -1, 0]],
[:max_transform_peaks, 100, [-1]],
[:max_regions, 16, [-1, -123]],
- [:view_files_sort, 0, [-1, 123]],
[:reverb_control_length, 1.0, [-1.0]],
[:show_axes, 1, [-1, 123]],
[:sinc_width, 10, [-10]],
@@ -2317,7 +2378,8 @@ def test_03
[:speed_control_bounds, [0.05, 20.0], [false, [0.0], [1.0, 0.0], 2.0]],
[:speed_control_style, 0, [-1, 10]],
[:sync_style, Sync_by_sound, [-1, 123]],
- [:transform_type, $fourier_transform, [integer2transform(-1), integer2transform(123)]],
+ [:transform_type, $fourier_transform,
+ [integer2transform(-1), integer2transform(123)]],
[:wavelet_type, 0, [-1, 123]],
[:wavo_hop, 1, [0, -123]],
[:wavo_trace, 1, [0, -123]],
@@ -2362,7 +2424,8 @@ def test_03
end
set_search_procedure(false)
if proc?(search_procedure)
- snd_display("global search procedure after reset: %s?", search_procedure.inspect)
+ snd_display("global search procedure after reset: %s?",
+ search_procedure.inspect)
end
set_search_procedure(lambda do |y| y > 0.1 end)
unless proc?(search_procedure)
@@ -2387,246 +2450,296 @@ def test_03
dismiss_all_dialogs
undefined = []
kernel_global_variables = Kernel.global_variables
- # FIXME
- # from original snd-test.scm list removed or changed:
+ # XXX: from original snd-test.scm list removed or changed:
#
- # :add_clm_field (run.c)
- # :run (macro in run.c)
# :file2string (Scheme specific in snd-utils.c)
# :redo (Ruby statement)
#
# :in replaced by :call_in
- #
- [:snd_opened_sound, :abort, :add_colormap, :add_directory_to_view_files_list, :add_file_filter,
- :add_file_sorter, :add_file_to_view_files_list, :add_mark, :add_player,
- :add_sound_file_extension, :add_source_file_extension, :add_to_main_menu, :add_to_menu,
- :add_transform, :after_apply_controls_hook, :after_edit_hook, :after_graph_hook,
- :after_lisp_graph_hook, :after_open_hook, :after_save_as_hook, :after_save_state_hook,
- :after_transform_hook, :all_pass, :all_pass?, :amp_control, :amp_control_bounds,
- :amplitude_modulate, :analyse_ladspa, :apply_controls, :apply_ladspa, :array2file,
- :array_interp, :as_one_edit, :ask_about_unsaved_edits, :ask_before_overwrite, :asymmetric_fm,
- :asymmetric_fm?, :audio_input_device, :audio_output_device, :auto_resize, :auto_update,
- :auto_update_interval, :autocorrelate, :autocorrelation, :moving_average, :moving_average?,
- :axis_color, :axis_info, :axis_label_font, :axis_numbers_font, :bad_header_hook,
- :bartlett_window, :bartlett_hann_window, :basic_color, :beats_per_measure, :beats_per_minute,
- :before_close_hook, :before_exit_hook, :before_save_as_hook, :before_save_state_hook,
- :before_transform_hook, :bind_key,
- :blackman2_window, :blackman3_window, :blackman4_window, :blackman5_window, :blackman6_window,
- :blackman7_window, :blackman8_window, :blackman9_window, :blackman10_window, :bohman_window,
- :bold_peaks_font, :bomb, :call_in, :cauchy_window, :mlt_sine_window, :cepstrum,
- :change_samples_with_origin, :channel2vct, :channel_amp_envs, :channel_data,
- :channel_properties, :channel_property, :channel_style, :channel_widgets, :channels,
- :channels_combined, :channels_separate, :channels_superimposed, :chans, :clear_array,
- :clear_listener, :clear_minibuffer, :clear_sincs, :clip_hook, :clipping, :clm_channel,
- :clm_print, :clm_table_size, :clm_default_frequency, :close_hook, :close_sound, :color2list,
- :color_cutoff, :color_orientation_dialog, :color_hook, :color_inverted, :color_scale,
- :color?, :colormap, :colormap_name, :colormap_ref, :colormap_size, :colormap?, :comb,
- :comb?, :comment, :connes_window, :continue_frame2file, :continue_sample2file,
- :contrast_control, :contrast_control_amp, :contrast_control_bounds, :contrast_control?,
- :contrast_enhancement, :controls2channel, :convolution, :convolve, :convolve_files,
- :convolve_selection_with, :convolve_with, :convolve?, :copy_context, :copy_sampler,
- :count_matches, :current_edit_position, :current_font, :cursor, :cursor_color,
- :cursor_context, :cursor_cross, :cursor_in_middle, :cursor_in_view, :cursor_line,
- :cursor_location_offset, :cursor_on_left, :cursor_on_right, :cursor_position, :cursor_size,
- :cursor_style, :cursor_update_interval, :dac_combines_channels, :dac_hook, :dac_size,
- :data_color, :data_format, :data_location, :data_size, :db2linear, :default_output_chans,
- :default_output_data_format, :default_output_header_type, :default_output_srate,
- :define_envelope, :degrees2radians, :delay, :delay_tick, :delay?, :delete_colormap,
- :delete_file_filter, :delete_file_sorter, :delete_mark, :delete_marks, :delete_sample,
- :delete_samples, :delete_samples_and_smooth, :delete_selection, :delete_selection_and_smooth,
- :delete_transform, :dialog_widgets, :disk_kspace,
- :display_edits, :dolph_chebyshev_window, :dont_normalize, :dot_product, :dot_size,
- :draw_axes, :draw_dot, :draw_dots, :draw_line, :draw_lines, :draw_mark_hook, :draw_mix_hook,
- :draw_string, :drop_hook, :during_open_hook, :edit_fragment, :edit_header_dialog,
- :edit_hook, :edit_list2function, :edit_position, :edit_tree, :edits, :edot_product,
- :env, :env_channel, :env_channel_with_base, :env_interp, :env_selection, :env_sound,
- :env?, :enved_add_point, :enved_amplitude, :enved_base, :enved_clip?, :enved_delete_point,
- :enved_dialog, :enved_envelope, :enved_filter, :enved_filter_order, :enved_hook, :enved_in_dB,
- :enved_move_point, :enved_power, :enved_spectrum, :enved_srate, :enved_style, :enved_target,
- :enved_wave?, :enved_waveform_color, :envelope_exponential, :envelope_linear,
- :eps_bottom_margin, :eps_file, :eps_left_margin, :eps_size, :exit, :exit_hook,
- :expand_control, :expand_control_bounds, :expand_control_hop, :expand_control_jitter,
- :expand_control_length, :expand_control_ramp, :expand_control?, :exponential_window,
- :fft, :fft_log_frequency, :fft_log_magnitude, :fft_window, :fft_window_alpha,
- :fft_window_beta, :fft_with_phases, :file2array, :file2frame, :file2frame?, :file2sample,
- :file2sample?, :file_name, :file_write_date, :fill_polygon, :fill_rectangle,
- :filter, :filtered_comb, :filtered_comb?, :filter_channel, :filter_control_coeffs,
- :filter_control_envelope, :filter_control_in_dB, :filter_control_in_hz, :filter_control_order,
- :filter_control_waveform_color, :filter_control?, :filter_selection, :filter_sound, :filter?,
- :find_channel, :find_dialog, :find_mark, :find_sound, :finish_progress_report, :fir_filter,
- :fir_filter?, :flat_top_window, :focus_widget, :foreground_color, :forget_region, :formant,
- :formant_bank, :formant?, :firmant, :firmant?, :fourier_transform, :frame, :frame_multiply,
- :frame_add, :frame2file, :frame2file?, :frame2frame, :frame2list, :frame2sample, :frame_ref,
- :frame_set!, :frame?, :frames, :free_player, :free_sampler, :gaussian_window, :gc_off,
- :gc_on, :gl_graph2ps, :glSpectrogram, :goto_listener_end, :granulate, :granulate?, :graph,
- :graph2ps, :graph_as_sonogram, :graph_as_spectrogram, :graph_as_wavogram, :graph_color,
- :graph_cursor, :graph_data, :graph_dots, :graph_dots_and_lines, :graph_filled, :graph_hook,
- :graph_lines, :graph_lollipops, :graph_once, :graph_style, :graphs_horizontal, :grid_density,
- :haar_transform, :hamming_window, :hann_poisson_window, :hann_window, :header_type,
- :help_dialog, :help_hook, :hide_widget, :highlight_color, :html_dir, :html_program,
- :hz2radians, :iir_filter, :iir_filter?, :in_any, :ina, :inb, :info_dialog, :init_ladspa,
- :initial_graph_hook, :insert_file_dialog, :insert_region, :insert_sample, :insert_samples,
- :insert_samples_with_origin, :insert_selection, :insert_silence, :insert_sound, :just_sounds,
- :kaiser_window, :key, :key_binding, :key_press_hook, :keyboard_no_action, :ladspa_activate,
- :ladspa_cleanup, :ladspa_connect_port, :ladspa_deactivate, :ladspa_descriptor, :ladspa_dir,
- :peak_env_dir, :ladspa_instantiate, :ladspa_run, :ladspa_run_adding,
- :ladspa_set_run_adding_gain, :left_sample, :linear2db, :lisp_graph, :lisp_graph_hook,
- :lisp_graph_style, :lisp_graph?, :list2vct, :list_ladspa, :listener_click_hook,
- :listener_color, :listener_font, :listener_prompt, :listener_selection,
- :listener_text_color, :little_endian?, :locsig, :locsig_ref, :locsig_reverb_ref,
- :locsig_reverb_set!, :locsig_set!, :locsig_type, :locsig?, :log_freq_start, :main_menu,
- :main_widgets, :make_all_pass, :make_asymmetric_fm, :make_moving_average, :make_bezier,
- :make_color, :make_comb, :make_filtered_comb, :make_convolve, :make_delay, :make_env,
- :make_fft_window, :make_file2frame, :make_file2sample, :make_filter, :make_fir_coeffs,
- :make_fir_filter, :make_formant, :make_firmant, :make_frame, :make_frame2file,
- :make_granulate, :make_graph_data, :make_iir_filter, :make_locsig, :make_mix_sampler,
- :make_mixer, :make_move_sound, :make_notch, :make_one_pole, :make_one_zero, :make_oscil,
- :make_phase_vocoder, :make_player, :make_polyshape, :make_polywave, :make_pulse_train,
- :make_rand, :make_rand_interp, :make_readin, :make_region, :make_region_sampler,
- :make_sample2file, :make_sampler, :make_sawtooth_wave, :make_scalar_mixer, :make_nrxysin,
- :make_nrxycos, :make_snd2sample, :make_sound_data, :make_square_wave, :make_src,
- :make_ssb_am, :make_ncos, :make_nsin, :make_table_lookup, :make_triangle_wave,
- :make_two_pole, :make_two_zero, :make_variable_graph, :make_vct, :make_wave_train,
- :map_chan, :map_channel, :mark_click_hook, :mark_color, :mark_context, :mark_drag_hook,
- :mark_home, :mark_hook, :mark_name, :mark_properties,
- :mark_property, :mark_sample, :mark_sync, :mark_sync_max, :mark_tag_height,
- :mark_tag_width, :mark?, :marks, :max_regions, :max_transform_peaks, :max_virtual_ptrees,
- :maxamp, :maxamp_position, :menu_widgets, :min_dB, :minibuffer_history_length, :mix,
- :mix_amp, :mix_amp_env, :mix_click_hook, :mix_color, :mix_dialog_mix, :mix_drag_hook,
- :mix_file_dialog, :mix_length, :mix_home, :mix_name, :mix_position, :mix_properties,
- :mix_property, :mix_region, :mix_release_hook, :mix_sync, :mix_sync_max, :mix_sampler?,
- :mix_selection, :mix_speed, :mix_tag_height, :mix_tag_width, :mix_tag_y, :mix_vct,
- :mix_waveform_height, :mix?, :mixer, :mixer_multiply, :mixer_add, :mixer_ref, :mixer_set!,
- :mixer?, :mixes, :mouse_click_hook, :mouse_drag_hook, :mouse_enter_graph_hook,
- :mouse_enter_label_hook, :mouse_enter_listener_hook, :mouse_enter_text_hook,
- :mouse_leave_graph_hook, :mouse_leave_label_hook, :mouse_leave_listener_hook,
- :mouse_leave_text_hook, :mouse_press_hook, :move_locsig, :move_sound, :move_sound?,
- :multiply_arrays, :mus_aifc, :mus_aiff, :mus_alaw, :mus_alsa_buffer_size,
- :mus_alsa_buffers, :mus_alsa_capture_device, :mus_alsa_device, :mus_alsa_playback_device,
- :mus_alsa_squelch_warning, :mus_apply, :mus_array_print_length, :mus_float_equal_fudge_factor,
- :mus_b24int, :mus_bdouble, :mus_bdouble_unscaled, :mus_bfloat, :mus_bfloat_unscaled,
- :mus_bicsf, :mus_bint, :mus_bintn, :mus_bshort, :mus_byte, :mus_bytes_per_sample,
- :mus_caff, :mus_channel, :mus_channels, :mus_chebyshev_first_kind, :mus_chebyshev_second_kind,
- :mus_clipping, :mus_close, :mus_data, :mus_data_format2string, :mus_data_format_name,
- :mus_describe, :mus_error_hook, :mus_error_type2string, :mus_expand_filename,
- :mus_feedback, :mus_feedforward, :mus_fft, :mus_file_buffer_size, :mus_file_clipping,
- :mus_file_name, :mus_file_prescaler, :mus_frequency, :mus_generator?,
- :mus_header_raw_defaults, :mus_header_type2string, :mus_header_type_name,
- :mus_hop, :mus_increment, :mus_input?, :mus_interp_all_pass, :mus_interp_bezier,
- :mus_interp_hermite, :mus_interp_lagrange, :mus_interp_linear, :mus_interp_none,
- :mus_interp_sinusoidal, :mus_interp_type, :mus_interpolate, :mus_ircam, :mus_l24int,
- :mus_ldouble, :mus_ldouble_unscaled, :mus_length, :mus_lfloat, :mus_lfloat_unscaled,
- :mus_lint, :mus_lintn, :mus_location, :mus_lshort, :mus_max_malloc, :mus_max_table_size,
- :mus_mix, :mus_mulaw, :mus_name, :mus_next, :mus_nist, :mus_offset, :mus_order,
- :mus_oss_set_buffers, :mus_out_format, :mus_output?, :mus_phase, :mus_prescaler,
- :mus_ramp, :mus_rand_seed, :mus_random, :mus_raw, :mus_reset, :mus_riff, :mus_run,
- :mus_scaler, :mus_set_formant_radius_and_frequency, :mus_sound_chans, :mus_sound_close_input,
- :mus_sound_close_output, :mus_sound_comment, :mus_sound_data_format, :mus_sound_data_location,
- :mus_sound_datum_size, :mus_sound_duration, :mus_sound_forget, :mus_sound_frames,
- :mus_sound_header_type, :mus_sound_length, :mus_sound_loop_info, :mus_sound_mark_info,
- :mus_sound_maxamp, :mus_sound_maxamp_exists?, :mus_sound_open_input, :mus_sound_open_output,
- :mus_sound_prune, :mus_sound_read, :mus_sound_reopen_output, :mus_sound_report_cache,
- :mus_sound_samples, :mus_sound_seek_frame, :mus_sound_srate, :mus_sound_type_specifier,
- :mus_sound_write, :mus_sound_write_date, :mus_soundfont, :mus_srate, :mus_svx, :mus_ubshort,
- :mus_ubyte, :mus_ulshort, :mus_unknown, :mus_unsupported, :mus_voc, :mus_width, :mus_xcoeff,
- :mus_xcoeffs, :mus_ycoeff, :mus_ycoeffs, :name_click_hook, :new_sound, :new_sound_dialog,
- :new_sound_hook, :new_widget_hook, :next_sample, :normalize_by_channel, :normalize_by_sound,
- :normalize_channel, :normalize_globally, :notch, :notch?, :one_pole, :one_pole?, :one_zero,
- :one_zero?, :open_file_dialog, :open_file_dialog_directory, :open_hook, :open_raw_sound,
- :open_raw_sound_hook, :open_sound, :optimization, :optimization_hook, :orientation_hook,
- :oscil, :oscil?, :out_any, :outa, :outb, :outc, :outd, :output_comment_hook,
- :output_name_hook, :override_samples_with_origin, :pad_channel, :partials2polynomial,
- :partials2wave, :parzen_window, :pausing, :peak_env_hook, :peaks, :peaks_font,
- :phase_partials2wave, :phase_vocoder, :phase_vocoder_amp_increments, :phase_vocoder_amps,
- :phase_vocoder_freqs, :phase_vocoder_phase_increments, :phase_vocoder_phases, :phase_vocoder?,
- :play, :play_arrow_size, :play_hook, :player_home, :player?, :players, :playing,
- :poisson_window, :polar2rectangular, :polynomial, :polyshape, :polywave, :polyshape?,
- :polywave?, :position2x, :position2y, :position_color, :preferences_dialog, :previous_sample,
- :print_dialog, :print_hook, :print_length, :progress_report, :prompt_in_minibuffer,
- :ptree_channel, :pulse_train, :pulse_train?, :radians2degrees, :radians2hz, :ramp_channel,
- :rand, :rand_interp, :rand_interp?, :rand?, :read_hook, :read_mix_sample, :read_only,
- :read_region_sample, :read_sample, :readin, :readin?, :rectangular2magnitudes,
- :rectangular2polar, :rectangular_window, :redo_edit, :region2vct, :region_chans,
- :region_home, :region_frames, :region_graph_style, :region_maxamp, :region_maxamp_position,
- :region_position, :region_sample, :region_sampler?, :region_srate, :region?, :regions,
- :remember_sound_state, :remove_from_menu, :report_in_minibuffer, :reset_controls,
- :reset_listener_cursor, :restore_controls, :restore_region, :reverb_control_decay,
- :reverb_control_feedback, :reverb_control_length, :reverb_control_length_bounds,
- :reverb_control_lowpass, :reverb_control_scale, :reverb_control_scale_bounds, :reverb_control?,
- :reverse_channel, :reverse_selection, :reverse_sound, :revert_sound, :riemann_window,
- :right_sample, :ring_modulate, :rv2_window, :rv3_window, :rv4_window, :samaraki_window,
- :sample, :sample2file, :sample2file?, :sample2frame, :sampler_at_end?, :sampler_home,
- :sampler_position, :sampler?, :samples, :samples2seconds, :sash_color, :save_controls,
- :save_dir, :save_edit_history, :save_envelopes, :save_hook, :save_listener, :save_macros,
- :save_marks, :save_region, :save_region_dialog, :save_selection, :save_selection_dialog,
- :save_sound, :save_sound_as, :save_sound_dialog, :save_state, :save_state_file,
- :save_state_hook, :sawtooth_wave, :sawtooth_wave?, :scale_by, :scale_channel,
- :scale_selection_by, :scale_selection_to, :scale_to, :scan_chan, :scan_channel,
- :script_arg, :script_args, :search_procedure, :seconds2samples, :select_all,
- :select_channel, :select_channel_hook, :select_sound, :select_sound_hook, :selected_channel,
- :selected_data_color, :selected_graph_color, :selected_sound, :selection_chans,
- :selection_color, :selection_context, :selection_creates_region, :selection_frames,
- :selection_maxamp, :selection_maxamp_position, :selection_member?, :selection_position,
- :selection_srate, :selection?, :short_file_name, :show_all_axes, :show_all_axes_unlabelled,
- :show_bare_x_axis, :show_axes, :show_controls, :show_grid, :show_indices,
- :show_full_duration, :initial_beg, :initial_dur, :show_listener,
- :show_marks, :show_mix_waveforms, :show_no_axes, :show_selection, :show_selection_transform,
- :show_sonogram_cursor, :show_transform_peaks, :show_widget, :show_x_axis,
- :show_x_axis_unlabelled, :show_y_zero, :sinc_width, :nrxysin, :nrxysin?, :nrxycos,
- :nrxycos?, :smooth_channel, :smooth_selection, :smooth_sound, :snd2sample, :snd2sample?,
- :snd_error, :snd_error_hook, :snd_gcs, :snd_help, :snd_font, :snd_color, :snd_print,
- :snd_simulate_keystroke, :snd_spectrum, :snd_tempnam, :snd_url, :snd_urls, :snd_version,
- :snd_warning, :snd_warning_hook, :sound_data2sound_data, :sound_data2vct, :sound_data_chans,
- :sound_data_length, :sound_data_maxamp, :sound_data_ref, :sound_data_peak, :sound_data_set!,
- :sound_data_scale!, :sound_data_fill!, :sound_data?, :sound_data_multiply!, :sound_data_add!,
- :sound_data_offset!, :sound_data_multiply, :sound_data_add, :sound_data_copy,
- :sound_data_reverse!, :sound_file_extensions, :sound_file?, :sound_files_in_directory,
- :sound_loop_info, :sound_properties, :sound_property, :sound_widgets, :sound?,
- :soundfont_info, :sounds, :spectrum_end, :spectro_hop, :spectrum_start, :spectro_x_angle,
- :spectro_x_scale, :spectro_y_angle, :spectro_y_scale, :spectro_z_angle, :spectro_z_scale,
- :spectrum, :speed_control, :speed_control_as_float, :speed_control_as_ratio,
- :speed_control_as_semitone, :speed_control_bounds, :speed_control_style,
- :speed_control_tones, :square_wave, :square_wave?, :squelch_update, :srate, :src,
- :src_channel, :src_selection, :src_sound, :src?, :ssb_am, :ssb_am?, :start_hook,
- :start_playing, :start_playing_hook, :start_playing_selection_hook, :start_progress_report,
- :stop_dac_hook, :stop_player, :stop_playing, :stop_playing_hook, :stop_playing_selection_hook,
- :ncos, :ncos?, :nsin, :nsin?, :swap_channels, :sync, :sync_style, :sync_none, :sync_all,
- :sync_by_sound, :sync_max, :syncd_marks, :table_lookup,
- :table_lookup?, :tap, :temp_dir, :text_focus_color, :time_graph,
- :time_graph_style, :time_graph_type, :time_graph?, :tiny_font, :tracking_cursor_style,
- :transform2vct, :transform_dialog, :transform_frames, :transform_graph,
- :transform_graph_style, :transform_graph_type, :transform_graph?, :transform_normalization,
- :transform_sample, :transform_size, :transform_type, :transform?, :trap_segfault,
- :triangle_wave, :triangle_wave?, :tukey_window, :two_pole, :two_pole?, :two_zero,
- :two_zero?, :ultraspherical_window, :unbind_key , :undo, :undo_edit, :undo_hook, :unselect_all,
+ [:snd_opened_sound, :abort, :add_colormap, :add_mark,
+ :add_player, :add_sound_file_extension, :add_source_file_extension,
+ :add_to_main_menu, :add_to_menu, :add_transform, :after_apply_controls_hook,
+ :after_edit_hook, :after_graph_hook, :after_lisp_graph_hook,
+ :after_open_hook, :after_save_as_hook, :after_save_state_hook,
+ :after_transform_hook, :all_pass, :all_pass?, :amp_control,
+ :amp_control_bounds, :amplitude_modulate, :analyse_ladspa, :apply_controls,
+ :apply_ladspa, :array2file, :array_interp, :as_one_edit,
+ :ask_about_unsaved_edits, :ask_before_overwrite, :asymmetric_fm,
+ :asymmetric_fm?, :auto_resize, :auto_update, :auto_update_interval,
+ :autocorrelate, :autocorrelation, :axis_color, :axis_info,
+ :axis_label_font, :axis_numbers_font, :bad_header_hook, :bartlett_window,
+ :bartlett_hann_window, :basic_color, :beats_per_measure, :beats_per_minute,
+ :before_close_hook, :before_exit_hook, :before_save_as_hook,
+ :before_save_state_hook, :before_transform_hook, :bind_key,
+ :blackman2_window, :blackman3_window, :blackman4_window, :blackman5_window,
+ :blackman6_window, :blackman7_window, :blackman8_window, :blackman9_window,
+ :blackman10_window, :bohman_window, :bold_peaks_font, :call_in,
+ :cauchy_window, :mlt_sine_window, :cepstrum, :change_samples_with_origin,
+ :channel2vct, :channel_amp_envs, :channel_data, :channel_properties,
+ :channel_property, :channel_style, :channel_widgets, :channels,
+ :channels_combined, :channels_separate, :channels_superimposed,
+ :chans, :clear_listener, :clip_hook,
+ :clipping, :clm_channel, :clm_table_size,
+ :clm_default_frequency, :close_hook, :close_sound,
+ :color_cutoff, :color_orientation_dialog, :color_hook, :color_inverted,
+ :color_scale, :color?, :colormap, :colormap_name, :colormap_ref,
+ :colormap_size, :colormap?, :comb, :comb?, :combined_data_color,
+ :comment, :connes_window, :continue_frample2file, :continue_sample2file,
+ :contrast_control, :contrast_control_amp, :contrast_control_bounds,
+ :contrast_control?, :contrast_enhancement, :controls2channel, :convolution,
+ :convolve, :convolve_files, :convolve_selection_with, :convolve_with,
+ :convolve?, :copy_context, :copy_sampler,
+ :current_edit_position, :current_font, :cursor, :cursor_color,
+ :cursor_context, :cursor_cross, :cursor_in_middle, :cursor_in_view,
+ :cursor_line, :cursor_location_offset, :cursor_on_left, :cursor_on_right,
+ :cursor_position, :cursor_size, :cursor_style, :cursor_update_interval,
+ :dac_combines_channels, :dac_size, :data_color, :sample_type,
+ :data_location, :data_size, :db2linear, :default_output_chans,
+ :default_output_sample_type, :default_output_header_type,
+ :default_output_srate, :define_envelope, :degrees2radians, :delay,
+ :delay_tick, :delay?, :delete_colormap, :delete_mark, :delete_marks,
+ :delete_sample, :delete_samples, :delete_samples_and_smooth,
+ :delete_selection, :delete_selection_and_smooth, :delete_transform,
+ :dialog_widgets, :disk_kspace, :display_edits, :dolph_chebyshev_window,
+ :dont_normalize,
+ :dot_product, :dot_size, :draw_axes, :draw_dot, :draw_dots, :draw_line,
+ :draw_lines, :draw_mark_hook, :draw_mix_hook, :draw_string, :drop_hook,
+ :during_open_hook, :edit_fragment, :edit_header_dialog, :edit_hook,
+ :edit_list2function, :edit_position, :edit_tree, :edits, :edot_product,
+ :env, :env_channel, :env_channel_with_base, :env_interp, :env_selection,
+ :env_sound, :env?, :enved_add_point, :enved_amplitude, :enved_base,
+ :enved_clip?, :enved_delete_point, :enved_dialog, :enved_envelope,
+ :enved_filter, :enved_filter_order, :enved_hook, :enved_in_dB,
+ :enved_move_point, :enved_power, :enved_spectrum, :enved_srate,
+ :enved_style, :enved_target, :enved_wave?, :enved_waveform_color,
+ :envelope_exponential, :envelope_linear, :eps_bottom_margin, :eps_file,
+ :eps_left_margin, :eps_size, :exit, :exit_hook, :expand_control,
+ :expand_control_bounds, :expand_control_hop, :expand_control_jitter,
+ :expand_control_length, :expand_control_ramp, :expand_control?,
+ :exponential_window, :fft, :fft_log_frequency, :fft_log_magnitude,
+ :fft_window, :fft_window_alpha, :fft_window_beta, :fft_with_phases,
+ :file2array, :file2frample, :file2frample?, :file2sample, :file2sample?,
+ :file_name, :file_write_date, :fill_polygon, :fill_rectangle,
+ :filter, :filtered_comb, :filtered_comb?, :filter_channel,
+ :filter_control_coeffs, :filter_control_envelope, :filter_control_in_dB,
+ :filter_control_in_hz, :filter_control_order,
+ :filter_control_waveform_color, :filter_control?, :filter_selection,
+ :filter_sound, :filter?, :find_dialog, :find_mark,
+ :find_sound, :finish_progress_report, :fir_filter, :fir_filter?,
+ :flat_top_window, :focus_widget, :foreground_color, :forget_region,
+ :formant, :formant_bank, :formant_bank?, :formant?, :firmant, :firmant?,
+ :comb_bank, :comb_bank?, :all_pass_bank, :all_pass_bank?,
+ :filtered_comb_bank, :filtered_comb_bank?, :make_comb_bank,
+ :make_all_pass_bank, :make_filtered_comb_bank,
+ :fourier_transform, :frample2file, :frample2file?, :frample2frample,
+ :framples, :free_player, :free_sampler,
+ :gaussian_window, :gc_off, :gc_on, :gl_graph2ps, :glSpectrogram,
+ :goto_listener_end, :granulate, :granulate?, :graph, :graph2ps,
+ :graph_as_sonogram, :graph_as_spectrogram, :graph_as_wavogram,
+ :graph_color, :graph_cursor, :graph_data, :graph_dots,
+ :graph_dots_and_lines, :graph_filled, :graph_hook, :graph_lines,
+ :graph_lollipops, :graph_once, :graph_style, :graphs_horizontal,
+ :grid_density, :haar_transform, :hamming_window, :hann_poisson_window,
+ :hann_window, :header_type, :help_dialog, :help_hook, :hide_widget,
+ :highlight_color, :html_dir, :html_program, :hz2radians, :iir_filter,
+ :iir_filter?, :in_any, :ina, :inb, :info_dialog,
+ :init_ladspa, :initial_graph_hook, :insert_file_dialog, :insert_region,
+ :insert_sample, :insert_samples, :insert_samples_with_origin,
+ :insert_selection, :insert_silence, :insert_sound, :just_sounds,
+ :kaiser_window, :key, :key_binding, :key_press_hook, :keyboard_no_action,
+ :ladspa_activate, :ladspa_cleanup, :ladspa_connect_port,
+ :ladspa_deactivate, :ladspa_descriptor, :ladspa_dir, :peak_env_dir,
+ :ladspa_instantiate, :ladspa_run, :ladspa_run_adding,
+ :ladspa_set_run_adding_gain, :left_sample, :linear2db, :lisp_graph,
+ :lisp_graph_hook, :lisp_graph_style, :lisp_graph?, :list2vct,
+ :list_ladspa, :listener_click_hook, :listener_color, :listener_font,
+ :listener_prompt, :listener_selection, :listener_text_color,
+ :little_endian?, :locsig, :locsig_ref, :locsig_reverb_ref,
+ :locsig_reverb_set!, :locsig_set!, :locsig_type, :locsig?,
+ :log_freq_start, :main_menu, :main_widgets, :make_all_pass,
+ :make_asymmetric_fm, :make_moving_average, :make_moving_max,
+ :make_bezier, :make_color, :make_comb, :make_filtered_comb, :make_convolve,
+ :make_delay, :make_env, :make_fft_window, :make_file2frample,
+ :make_file2sample, :make_filter, :make_fir_coeffs, :make_fir_filter,
+ :make_formant, :make_firmant, :make_formant_bank,
+ :make_frample2file, :make_granulate, :make_graph_data, :make_iir_filter,
+ :make_locsig, :make_mix_sampler, :make_move_sound,
+ :make_notch, :make_one_pole, :make_one_pole_all_pass, :make_one_zero,
+ :make_oscil, :make_phase_vocoder, :make_player, :make_polyshape,
+ :make_polywave, :make_pulse_train, :make_rand, :make_rand_interp,
+ :make_readin, :make_region, :make_region_sampler, :make_sample2file,
+ :make_sampler, :make_sawtooth_wave, :make_nrxysin,
+ :make_nrxycos, "make_rxyk!cos".intern, "make_rxyk!sin".intern,
+ :make_snd2sample, :make_square_wave,
+ :make_src, :make_ssb_am, :make_ncos, :make_nsin, :make_table_lookup,
+ :make_triangle_wave, :make_two_pole, :make_two_zero, :make_variable_graph,
+ :make_vct, :make_wave_train, :map_chan, :map_channel, :mark_click_hook,
+ :mark_color, :mark_context, :mark_drag_hook, :mark_home, :mark_hook,
+ :mark_name, :mark_properties, :mark_property, :mark_sample, :mark_sync,
+ :mark_sync_max, :mark_tag_height, :mark_tag_width, :mark?, :marks,
+ :max_regions, :max_transform_peaks, :maxamp, :maxamp_position,
+ :menu_widgets, :min_dB, :mix, :mix_amp, :mix_amp_env, :mix_click_hook,
+ :mix_color, :mix_dialog_mix, :mix_drag_hook, :mix_file_dialog,
+ :mix_length, :mix_home, :mix_name, :mix_position, :mix_properties,
+ :mix_property, :mix_region, :mix_release_hook, :mix_sync, :mix_sync_max,
+ :mix_sampler?, :mix_selection, :mix_speed, :mix_tag_height,
+ :mix_tag_width, :mix_tag_y, :mix_vct, :mix_waveform_height, :mix?,
+ :mixes, :mouse_click_hook, :mouse_drag_hook, :mouse_enter_graph_hook,
+ :mouse_enter_label_hook, :mouse_enter_listener_hook,
+ :mouse_enter_text_hook, :mouse_leave_graph_hook, :mouse_leave_label_hook,
+ :mouse_leave_listener_hook, :mouse_leave_text_hook, :mouse_press_hook,
+ :move_locsig, :move_sound, :move_sound?, :moving_average, :moving_average?,
+ :moving_max, :moving_max?, :mus_aifc,
+ :mus_aiff, :mus_alaw, :mus_alsa_buffer_size, :mus_alsa_buffers,
+ :mus_alsa_capture_device, :mus_alsa_device, :mus_alsa_playback_device,
+ :mus_alsa_squelch_warning, :mus_apply, :mus_array_print_length,
+ :mus_float_equal_fudge_factor, :mus_b24int, :mus_bdouble,
+ :mus_bdouble_unscaled, :mus_bfloat, :mus_bfloat_unscaled, :mus_bicsf,
+ :mus_bint, :mus_bintn, :mus_bshort, :mus_byte, :mus_bytes_per_sample,
+ :mus_caff, :mus_channel, :mus_channels, :mus_chebyshev_first_kind,
+ :mus_chebyshev_second_kind,:mus_clipping, :mus_close, :mus_data,
+ :mus_sample_type2string, :mus_sample_type_name, :mus_describe,
+ :mus_error_hook, :mus_error_type2string, :mus_expand_filename,
+ :mus_feedback, :mus_feedforward, :mus_fft, :mus_file_buffer_size,
+ :mus_file_clipping, :mus_file_name, :mus_frequency,
+ :mus_generator?, :mus_header_raw_defaults, :mus_header_type2string,
+ :mus_header_type_name, :mus_hop, :mus_increment, :mus_input?,
+ :mus_interp_all_pass, :mus_interp_bezier, :mus_interp_hermite,
+ :mus_interp_lagrange, :mus_interp_linear, :mus_interp_none,
+ :mus_interp_sinusoidal, :mus_interp_type, :mus_interpolate,
+ :mus_ircam, :mus_l24int, :mus_ldouble, :mus_ldouble_unscaled,
+ :mus_length, :mus_lfloat, :mus_lfloat_unscaled, :mus_lint,
+ :mus_lintn, :mus_location, :mus_lshort, :mus_max_malloc,
+ :mus_max_table_size, :mus_mulaw, :mus_name, :mus_next,
+ :mus_nist, :mus_offset, :mus_order, :mus_oss_set_buffers,
+ :mus_out_format, :mus_output?, :mus_phase, :mus_ramp,
+ :mus_rand_seed, :mus_random, :mus_raw, :mus_reset, :mus_riff, :mus_run,
+ :mus_scaler, :mus_set_formant_radius_and_frequency, :mus_sound_chans,
+ :mus_sound_comment, :mus_sound_sample_type, :mus_sound_data_location,
+ :mus_sound_datum_size, :mus_sound_duration, :mus_sound_forget,
+ :mus_sound_framples, :mus_sound_header_type, :mus_sound_length,
+ :mus_sound_loop_info, :mus_sound_mark_info, :mus_sound_maxamp,
+ :mus_sound_maxamp_exists?, :mus_sound_prune, :mus_sound_report_cache,
+ :mus_sound_samples, :mus_sound_srate, :mus_sound_type_specifier,
+ :mus_sound_write_date, :mus_soundfont, :mus_srate, :mus_svx,
+ :mus_ubshort, :mus_ubyte, :mus_ulshort, :mus_unknown_sample,
+ :mus_unknown_header, :mus_voc, :mus_width, :mus_xcoeff,
+ :mus_xcoeffs, :mus_ycoeff, :mus_ycoeffs, :name_click_hook,
+ :new_sound, :new_sound_dialog, :new_sound_hook, :new_widget_hook,
+ :next_sample, :normalize_by_channel, :normalize_by_sound,
+ :normalize_channel, :normalize_globally, :notch, :notch?,
+ :one_pole, :one_pole?, :one_pole_all_pass, :one_pole_all_pass?,
+ :one_zero, :one_zero?,
+ :open_file_dialog, :open_file_dialog_directory, :open_hook,
+ :open_raw_sound, :open_raw_sound_hook, :open_sound, :orientation_hook,
+ :oscil, :oscil?, :out_any, :outa, :outb, :outc, :outd,
+ :output_comment_hook, :override_samples_with_origin,
+ :pad_channel, :partials2polynomial, :partials2wave, :parzen_window,
+ :pausing, :peaks, :peaks_font, :phase_partials2wave,
+ :phase_vocoder, :phase_vocoder_amp_increments, :phase_vocoder_amps,
+ :phase_vocoder_freqs, :phase_vocoder_phase_increments,
+ :phase_vocoder_phases, :phase_vocoder?, :play, :play_arrow_size,
+ :play_hook, :player_home, :player?, :players, :playing, :poisson_window,
+ :polar2rectangular, :polynomial, :polyshape, :polywave, :polyshape?,
+ :polywave?, :position2x, :position2y, :position_color, :preferences_dialog,
+ :previous_sample, :print_dialog, :print_length, :progress_report,
+ :pulse_train, :pulse_train?, :radians2degrees, :radians2hz, :ramp_channel,
+ :rand, :rand_interp, :rand_interp?, :rand?, :read_mix_sample,
+ :read_only, :read_region_sample, :read_sample, :readin, :readin?,
+ :rectangular2magnitudes, :rectangular2polar, :rectangular_window,
+ :redo_edit, :region2vct, :region_chans, :region_home, :region_framples,
+ :region_graph_style, :region_maxamp, :region_maxamp_position,
+ :region_position, :region_sample, :region_sampler?, :region_srate,
+ :region?, :regions, :remember_sound_state, :remove_from_menu,
+ :reset_controls, :reset_listener_cursor, :restore_controls,
+ :restore_region, :reverb_control_decay, :reverb_control_feedback,
+ :reverb_control_length, :reverb_control_length_bounds,
+ :reverb_control_lowpass, :reverb_control_scale,
+ :reverb_control_scale_bounds, :reverb_control?, :reverse_channel,
+ :reverse_selection, :reverse_sound, :revert_sound, :riemann_window,
+ :right_sample, :ring_modulate, :rv2_window, :rv3_window, :rv4_window,
+ :samaraki_window, :sample, :sample2file, :sample2file?,
+ :sampler_at_end?, :sampler_home, :sampler_position, :sampler?, :samples,
+ :samples2seconds, :sash_color, :save_controls, :save_dir,
+ :save_edit_history, :save_envelopes, :save_hook, :save_listener,
+ :save_marks, :save_region, :save_region_dialog, :save_selection,
+ :save_selection_dialog, :save_sound, :save_sound_as, :save_sound_dialog,
+ :save_state, :save_state_file, :save_state_hook, :sawtooth_wave,
+ :sawtooth_wave?, :scale_by, :scale_channel, :scale_selection_by,
+ :scale_selection_to, :scale_to, :scan_channel, :script_arg,
+ :script_args, :search_procedure, :seconds2samples, :select_all,
+ :select_channel, :select_channel_hook, :select_sound, :select_sound_hook,
+ :selected_channel, :selected_data_color, :selected_graph_color,
+ :selected_sound, :selection_chans, :selection_color,
+ :selection_context, :selection_creates_region, :selection_framples,
+ :selection_maxamp, :selection_maxamp_position, :selection_member?,
+ :selection_position, :selection_srate, :selection?, :short_file_name,
+ :show_all_axes, :show_all_axes_unlabelled, :show_bare_x_axis,
+ :show_axes, :show_controls, :show_grid, :show_indices,
+ :show_full_duration, :show_full_range, :initial_beg, :initial_dur,
+ :show_listener, :show_marks, :show_mix_waveforms, :show_no_axes,
+ :show_selection, :show_selection_transform, :show_sonogram_cursor,
+ :show_transform_peaks, :show_widget, :show_x_axis,
+ :show_x_axis_unlabelled, :show_y_zero, :sinc_width, :nrxysin,
+ :nrxysin?, :nrxycos, :nrxycos?, "rxyk!cos".intern, "rxyk!cos?".intern,
+ "rxyk!sin".intern, "rxyk!sin?".intern, :smooth_channel, :smooth_selection,
+ :smooth_sound, :snd2sample, :snd2sample?, :snd_error, :snd_error_hook,
+ :snd_gcs, :snd_help, :snd_font, :snd_color, :snd_print, :snd_spectrum,
+ :snd_tempnam, :snd_url, :snd_urls, :snd_version, :snd_warning,
+ :snd_warning_hook, :sound_file_extensions, :sound_file?,
+ :sound_files_in_directory, :sound_loop_info, :sound_properties,
+ :sound_property, :sound_widgets, :sound?, :soundfont_info, :sounds,
+ :spectrum_end, :spectro_hop, :spectrum_start, :spectro_x_angle,
+ :spectro_x_scale, :spectro_y_angle, :spectro_y_scale, :spectro_z_angle,
+ :spectro_z_scale, :spectrum, :speed_control, :speed_control_as_float,
+ :speed_control_as_ratio, :speed_control_as_semitone,
+ :speed_control_bounds, :speed_control_style, :speed_control_tones,
+ :square_wave, :square_wave?, :squelch_update, :srate, :src,
+ :src_channel, :src_selection, :src_sound, :src?, :ssb_am, :ssb_am?,
+ :start_playing, :start_playing_hook,
+ :start_playing_selection_hook, :start_progress_report,
+ :status_report, :stop_player, :stop_playing,
+ :stop_playing_hook, :stop_playing_selection_hook, :ncos, :ncos?,
+ :nsin, :nsin?, :swap_channels, :sync, :sync_style, :sync_none,
+ :sync_all, :sync_by_sound, :sync_max, :syncd_marks, :table_lookup,
+ :table_lookup?, :tap, :tap?, :temp_dir, :text_focus_color, :time_graph,
+ :time_graph_style, :time_graph_type, :time_graph?, :tiny_font,
+ :tracking_cursor_style, :transform2vct, :transform_dialog,
+ :transform_framples, :transform_graph, :transform_graph_style,
+ :transform_graph_type, :transform_graph?, :transform_normalization,
+ :transform_sample, :transform_size, :transform_type, :transform?,
+ :triangle_wave, :triangle_wave?, :tukey_window,
+ :two_pole, :two_pole?, :two_zero, :two_zero?, :ultraspherical_window,
+ :unbind_key, :undo, :undo_edit, :undo_hook, :unselect_all,
:update_hook, :update_lisp_graph, :update_sound, :update_time_graph,
- :update_transform_graph, :variable_graph?, :vct, :vct_multiply, :vct_add, :vct2channel,
- :vct2list, :vct2sound_data, :vct2string, :vct2vector, :vct_add!, :vct_copy, :vct_fill!,
- :vct_length, :vct_map!, :vct_move!, :vct_multiply!, :vct_offset!, :vct_peak, :vct_ref,
- :vct_reverse!, :vct_scale!, :vct_set!, :vct_subseq, :vct_subtract!, :vct?, :vector2vct,
- :view_files_amp, :view_files_amp_env, :view_files_dialog, :view_files_files,
- :view_files_select_hook, :view_files_selected_files, :view_files_sort, :view_files_speed,
- :view_files_speed_style, :view_mixes_dialog, :view_regions_dialog, :view_sound,
- :walsh_transform, :wave_train, :wave_train?, :wavelet_transform, :wavelet_type,
- :wavo_hop, :wavo_trace, :welch_window, :widget_position, :widget_size, :widget_text,
- :window_height, :window_width, :window_x, :window_y, :with_background_processes,
- :with_file_monitor, :with_gl, :with_mix_tags, :with_relative_panes, :with_tracking_cursor,
- :with_verbose_cursor, :with_inset_graph, :with_pointer_focus,
- :with_smpte_label, :with_toolbar, :with_tooltips, :with_menu_icons,
- :save_as_dialog_src, :save_as_dialog_auto_comment, :x2position,
- :x_axis_as_clock, :x_axis_as_percentage, :x_axis_in_beats, :x_axis_in_measures,
- :x_axis_in_samples, :x_axis_in_seconds, :x_axis_label, :x_axis_style, :x_bounds,
- :x_position_slider, :x_zoom_slider, :xramp_channel, :y2position, :y_axis_label,
- :y_bounds, :y_position_slider, :y_zoom_slider, :zero_pad, :zoom_color, :zoom_focus_active,
- :zoom_focus_left, :zoom_focus_middle, :zoom_focus_right, :zoom_focus_style].each do |n|
+ :update_transform_graph, :variable_graph?, :vct, :vct_multiply,
+ :vct_add, :vct2channel, :vct2list, :vct2string,
+ :vct2vector, :vct_add!, :vct_length,
+ :vct_max, :vct_min, :vct_move!, :vct_multiply!, :vct_offset!,
+ :vct_peak, :vct_ref, :vct_reverse!, :vct_scale!, :vct_set!, :vct_subseq,
+ :vct_subtract!, :vct?, :vector2vct, :view_sound, :walsh_transform,
+ :wave_train, :wave_train?, :wavelet_transform, :wavelet_type, :wavo_hop,
+ :wavo_trace, :welch_window, :widget_position, :widget_size, :widget_text,
+ :window_height, :window_width, :window_x, :window_y,
+ :with_background_processes, :with_file_monitor, :with_gl,
+ :with_mix_tags, :with_relative_panes, :with_tracking_cursor,
+ :with_verbose_cursor, :with_inset_graph, :with_interrupts,
+ :with_pointer_focus, :with_smpte_label, :with_toolbar, :with_tooltips,
+ :with_menu_icons, :save_as_dialog_src, :save_as_dialog_auto_comment,
+ :x2position, :x_axis_as_clock, :x_axis_as_percentage, :x_axis_in_beats,
+ :x_axis_in_measures, :x_axis_in_samples, :x_axis_in_seconds,
+ :x_axis_label, :x_axis_style, :x_bounds, :x_position_slider,
+ :x_zoom_slider, :xramp_channel, :y2position, :y_axis_label,
+ :y_bounds, :y_position_slider, :y_zoom_slider, :zero_pad,
+ :zoom_color, :zoom_focus_active, :zoom_focus_left, :zoom_focus_middle,
+ :zoom_focus_right, :zoom_focus_style].each do |n|
next if Module.function?(n)
str = n.to_s
next if Object.const_defined?("#{str.capitalize}".intern)
str = "$" + str
- # FIXME
- # ruby18 likes a String
+ # XXX: ruby18 likes a String
next if kernel_global_variables.member?(str)
- # ruby19 likes a Symbol
+ # XXX: ruby19+ likes a Symbol
next if kernel_global_variables.member?(str.intern)
undefined << n
end
@@ -2640,49 +2753,22 @@ def test_03
undefined.delete_if do |s| s == :gl_graph2ps end
end
unless undefined.empty?
- snd_display("undefined: %s", undefined)
+ snd_display("undefined[%d]: %s", undefined.length, undefined)
end
end
# ---------------- test 04: sndlib ----------------
-def play_sound_1(file)
- sound_fd = mus_sound_open_input(file)
- chans = mus_sound_chans(file)
- frames = mus_sound_frames(file)
- srate = mus_sound_srate(file)
- bufsize = 256
- data = SoundData.new(chans, bufsize)
- bytes = bufsize * chans * 2
- audio_fd = mus_audio_open_output(0, srate, chans, Mus_lshort, bytes)
- if audio_fd == -1
- audio_fd = mus_audio_open_output(0, srate, chans, Mus_bshort, bytes)
- end
- if audio_fd == -1
- snd_display("cannot play %s", file)
- else
- 0.step(frames, bufsize) do
- mus_sound_read(sound_fd, 0, bufsize - 1, chans, data)
- mus_audio_write(audio_fd, data, bufsize)
- end
- mus_audio_close(audio_fd)
- end
-rescue
- snd_display("cannot open audio (%s)", file)
-ensure
- data = nil
- mus_sound_close_input(sound_fd)
-end
-
def frame2byte(file, frame)
- mus_sound_data_location(file) + mus_sound_chans(file) * mus_sound_datum_size(file) * frame
+ mus_sound_data_location(file) + mus_sound_chans(file) *
+ mus_sound_datum_size(file) * frame
end
def test_04_00
oboe_snd = "oboe.snd"
chns = mus_sound_chans(oboe_snd)
dl = mus_sound_data_location(oboe_snd)
- fr = mus_sound_frames(oboe_snd)
+ fr = mus_sound_framples(oboe_snd)
smps = mus_sound_samples(oboe_snd)
len = mus_sound_length(oboe_snd)
size = mus_sound_datum_size(oboe_snd)
@@ -2691,7 +2777,7 @@ def test_04_00
m1 = mus_sound_maxamp_exists?(oboe_snd)
mal = mus_sound_maxamp(oboe_snd)
mz = mus_sound_maxamp "z.snd"
- bytes = mus_bytes_per_sample(mus_sound_data_format(oboe_snd))
+ bytes = mus_bytes_per_sample(mus_sound_sample_type(oboe_snd))
snd_test_neq(mz[0], 0, "mus_sound_maxamp z.snd")
snd_test_neq(mz[1], 0.0, "mus_sound_maxamp z.snd")
[[Mus_bshort, 2],
@@ -2718,8 +2804,10 @@ def test_04_00
[Mus_lfloat_unscaled, 4]].each do |frm, siz|
snd_test_neq(mus_bytes_per_sample(frm), siz, "mus_bytes_per_sample")
end
- snd_test_neq(mus_data_format2string(Mus_bshort), "Mus_bshort", "mus_data_format2string")
- snd_test_neq(mus_header_type2string(Mus_aifc), "Mus_aifc", "mus_header_type2string")
+ snd_test_neq(mus_sample_type2string(Mus_bshort), "Mus_bshort",
+ "mus_sample_type2string")
+ snd_test_neq(mus_header_type2string(Mus_aifc), "Mus_aifc",
+ "mus_header_type2string")
hiho = "hiho.tmp"
mus_sound_report_cache(hiho)
fp = File.open(hiho)
@@ -2727,13 +2815,9 @@ def test_04_00
fp.close
delete_file(hiho)
req = 10
- res = mus_audio_describe.length
- if res < req
- snd_display(snd_format(res, req, "<", "mus_audio_describe: %s?", mus_audio_describe))
- end
snd_test_neq(chns, 1, "oboe: mus_sound_chans")
snd_test_neq(dl, 28, "oboe: mus_sound_data_location")
- snd_test_neq(fr, 50828, "oboe: mus_sound_frames")
+ snd_test_neq(fr, 50828, "oboe: mus_sound_framples")
snd_test_neq(smps, 50828, "oboe: mus_sound_samples")
snd_test_neq(len, 50828 * 2 + 28, "oboe: mus_sound_length")
snd_test_neq(size, 2, "oboe: mus_sound_datum_size")
@@ -2768,12 +2852,12 @@ def test_04_00
snd_test_neq(frm, Mus_bdouble_unscaled, "mus_header_raw_defaults format")
set_mus_header_raw_defaults(old_val)
#
- snd_test_neq(Time.at(mus_sound_write_date(oboe_snd)).localtime.strftime("%d-%b %H:%M"),
- "15-Oct 04:34",
- "mus_sound_write_date oboe.snd")
- snd_test_neq(Time.at(mus_sound_write_date("pistol.snd")).localtime.strftime("%d-%b %H:%M"),
- "01-Jul 13:06",
- "mus_sound_write_date pistol.snd")
+ tm = mus_sound_write_date(oboe_snd)
+ snd_test_neq(Time.at(tm).localtime.strftime("%d-%b %H:%M"), "15-Oct 04:34",
+ "mus_sound_write_date oboe.snd")
+ tm = mus_sound_write_date("pistol.snd")
+ snd_test_neq(Time.at(tm).localtime.strftime("%d-%b %H:%M"), "01-Jul 22:06",
+ "mus_sound_write_date pistol.snd")
#
ind = open_sound(oboe_snd)
lfname = "test" + "-test" * 10 + ".snd"
@@ -2800,10 +2884,7 @@ def test_04_00
snd_display("cannot find test...snd")
end
req = lfname.length
- res = file_name(ind).length
- if res < req
- snd_display(snd_format(res, req, "<", "file_name length"))
- end
+ snd_test_lt(file_name(ind).length, req, "file_name length")
snd_test_neq(short_file_name(ind).length, req, "short_file_name length")
close_sound(ind)
mus_sound_forget(lfname)
@@ -2814,47 +2895,58 @@ def test_04_00
ind = open_sound("fmv.snd")
snd_test_neq(sound_loop_info(ind), mus_sound_loop_info(fsnd), "loop_info")
set_sound_loop_info(ind, [12000, 14000, 1, 2, 3, 4])
- snd_test_neq(sound_loop_info(ind), [12000, 14000, 1, 2, 3, 4, 1, 1], "set_loop_info")
- save_sound_as("fmv1.snd", ind, Mus_aifc)
+ snd_test_neq(sound_loop_info(ind),
+ [12000, 14000, 1, 2, 3, 4, 1, 1], "set_loop_info")
+ save_sound_as("fmv1.snd", ind, :header_type, Mus_aifc)
close_sound(ind)
- snd_test_neq(mus_sound_loop_info("fmv1.snd"), [12000, 14000, 1, 2, 3, 4, 1, 1], "saved loop_info")
+ snd_test_neq(mus_sound_loop_info("fmv1.snd"),
+ [12000, 14000, 1, 2, 3, 4, 1, 1], "saved loop_info")
end
#
ind = open_sound(oboe_snd)
- save_sound_as("fmv.snd", ind, Mus_aifc)
+ save_sound_as("fmv.snd", ind, :header_type, Mus_aifc)
close_sound(ind)
ind = open_sound("fmv.snd")
snd_test_neq(sound_loop_info(ind), nil, "null loop_info")
set_sound_loop_info(ind, [1200, 1400, 4, 3, 2, 1])
- snd_test_neq(sound_loop_info(ind), [1200, 1400, 4, 3, 2, 1, 1, 1], "set null loop_info")
+ snd_test_neq(sound_loop_info(ind),
+ [1200, 1400, 4, 3, 2, 1, 1, 1], "set null loop_info")
save_sound_as("fmv1.snd", :sound, ind, :header_type, Mus_aifc)
close_sound(ind)
- snd_test_neq(mus_sound_loop_info("fmv1.snd"), [1200, 1400, 4, 3, 2, 1, 1, 1], "saved null loop_info")
+ snd_test_neq(mus_sound_loop_info("fmv1.snd"),
+ [1200, 1400, 4, 3, 2, 1, 1, 1], "saved null loop_info")
ind = open_sound("fmv.snd")
set_sound_loop_info(ind, [1200, 1400, 4, 3, 2, 1, 1, 0])
- snd_test_neq(sound_loop_info(ind), [1200, 1400, 0, 0, 2, 1, 1, 0], "set null loop_info (no mode1)")
- save_sound_as("fmv1.snd", ind, Mus_aifc)
+ snd_test_neq(sound_loop_info(ind),
+ [1200, 1400, 0, 0, 2, 1, 1, 0], "set null loop_info (no mode1)")
+ save_sound_as("fmv1.snd", ind, :header_type, Mus_aifc)
close_sound(ind)
- snd_test_neq(mus_sound_loop_info("fmv1.snd"), [1200, 1400, 0, 0, 2, 1, 1, 0], "saved null loop_info (no mode1)")
+ snd_test_neq(mus_sound_loop_info("fmv1.snd"),
+ [1200, 1400, 0, 0, 2, 1, 1, 0], "saved null loop_info (no mode1)")
#
unless com.empty?
snd_display("oboe: mus_sound_comment: %s", com.inspect)
end
- [["nasahal8.wav", "ICRD: 1997-02-22\nIENG: Paul R. Roger\nISFT: Sound Forge 4.0\n"],
+ [["nasahal8.wav",
+ "ICRD: 1997-02-22\nIENG: Paul R. Roger\nISFT: Sound Forge 4.0\n"],
["8svx-8.snd", "File created by Sound Exchange "],
["sun-16-afsp.snd", "AFspdate:1981/02/11 23:03:34 UTC"],
["smp-16.snd", "Converted using Sox. "],
["d40130.au", "1994 Jesus Villena"],
["wood.maud", "file written by SOX MAUD-export "],
- ["addf8.sf_mipseb", "date=\"Feb 11 18:03:34 1981\" info=\"Original recorded at 20 kHz, 15-bit D/A, digitally filtered and resampled\" speaker=\"AMK female\" text=\"Add the sum to the product of these three.\" "],
+ ["addf8.sf_mipseb",
+ "date=\"Feb 11 18:03:34 1981\" info=\"Original recorded at 20 kHz, 15-bit D/A, digitally filtered and resampled\" speaker=\"AMK female\" text=\"Add the sum to the product of these three.\" "],
["mary-sun4.sig", "MARY HAD A LITTLE LAMB\n"],
["nasahal.pat", "This patch saved with Sound Forge 3.0."],
- ["next-16.snd", ";Written on Mon 1-Jul-91 at 12:10 PDT at localhost (NeXT) using Allegro CL and clm of 25-June-91"],
+ ["next-16.snd",
+ ";Written on Mon 1-Jul-91 at 12:10 PDT at localhost (NeXT) using Allegro CL and clm of 25-June-91"],
["wood16.nsp", "Created by Snack "],
["wood.sdx", "1994 Jesus Villena"],
["clmcom.aif", "this is a comment"],
["anno.aif", "1994 Jesus Villena\n"],
- ["telephone.wav", "sample_byte_format -s2 01\nchannel_count -i 1\nsample_count -i 36461\nsample_rate -i 16000\nsample_n_bytes -i 2\nsample_sig_bits -i 16\n"]].each do |f, req|
+ ["telephone.wav",
+ "sample_byte_format -s2 01\nchannel_count -i 1\nsample_count -i 36461\nsample_rate -i 16000\nsample_n_bytes -i 2\nsample_sig_bits -i 16\n"]
+ ].each do |f, req|
with_file(f) do |fsnd|
snd_test_neq(mus_sound_comment(fsnd), req, "mus_sound_comment %s", fsnd)
end
@@ -2869,117 +2961,101 @@ def test_04_00
snd_test_neq(mal[1], 0.14724, "oboe: mus_sound_maxamp")
snd_test_neq(mal[0], 24971, "oboe: mus_sound_maxamp at %d", mal[0])
end
- set_mus_sound_maxamp(oboe_snd, [1234, 0.5])
- mal = mus_sound_maxamp(oboe_snd)
- snd_test_neq(mal[1], 0.5, "oboe: set_mus_sound_maxamp")
- snd_test_neq(mal[0], 1234, "oboe: set_mus_sound_maxamp at %d", mal[0])
- #
- mal = mus_sound_maxamp("4.aiff")
- if $clmtest.zero?
- snd_test_neq(mal,
- vct(810071, 0.245, 810071, 0.490, 810071, 0.735, 810071, 0.980),
- "mus_sound_maxamp 4.aiff")
- end
- set_mus_sound_maxamp("4.aiff", [12345, 0.5, 54321, 0.2, 0, 0.1, 9999, 0.01])
- snd_test_neq(mus_sound_maxamp("4.aiff"),
- vct(12345, 0.5, 54321, 0.2, 0, 0.1, 9999, 0.01),
- "set_mus_sound_maxamp 4.aiff")
- #
- if (res = Snd.catch do set_mus_sound_maxamp(oboe_snd, [1234]) end).first != :wrong_type_arg
- snd_display("set_mus_sound_maxamp bad arg: %s?", res.inspect)
- end
res = mus_sound_type_specifier(oboe_snd)
if res != 0x646e732e and # little endian reader
res != 0x2e736e64 # big endian reader
snd_display("oboe: mus_sound_type_specifier: 0x%x?", res)
end
#
- snd_test_neq(Time.at(file_write_date(oboe_snd)).localtime.strftime("%d-%b-%Y %H:%M"),
- "15-Oct-2006 04:34",
- "file_write_date oboe.snd")
- play_sound_1(oboe_snd)
- mus_sound_forget(oboe_snd)
+ tm = file_write_date(oboe_snd)
+ snd_test_neq(Time.at(tm).localtime.strftime("%d-%b-%Y %H:%M"),
+ "15-Oct-2006 04:34", "file_write_date oboe.snd")
#
lasth = 1
- until mus_header_type_name(lasth) == "unsupported"
+ until mus_header_type_name(lasth) == "unknown"
lasth += 1
end
if lasth < 50
snd_display("header_type[%d] == %s?", lasth, mus_header_type_name(lasth))
end
lasth = 1
- until mus_data_format_name(lasth) == "unknown"
+ until mus_sample_type_name(lasth) == "unknown"
lasth += 1
end
if lasth < 10
- snd_display("data_format[%d] == %s?", lasth, mus_data_format_name(lasth))
+ snd_display("sample_type[%d] == %s?", lasth, mus_sample_type_name(lasth))
end
[:Dont_normalize,
:Normalize_globally,
:Normalize_by_channel].each do |val_sym|
req = Module.const_get(val_sym)
set_transform_normalization(req)
- snd_test_neq(transform_normalization, req, "set_transform_normalization(%s)", val_sym)
+ snd_test_neq(transform_normalization, req,
+ "set_transform_normalization(%s)", val_sym)
end
#
- ind = new_sound("fmv.snd", Mus_next, Mus_bshort, 22050, 1, "set_samples test", 100)
+ ind = new_sound("fmv.snd", 1, 22050, Mus_bshort, Mus_next,
+ "set_samples test", 100)
set_samples(10, 3, Vct.new(3, 0.1))
snd_test_neq(channel2vct(0, 20, ind, 0),
- vct(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
- "1 set samples 0 for 0.1")
+ vct(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
+ "1 set samples 0 for 0.1")
set_samples(20, 3, Vct.new(3, 0.1), ind, 0)
snd_test_neq(channel2vct(10, 20, ind, 0),
- vct(0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
- "2 set samples 10 for 0.1")
+ vct(0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
+ "2 set samples 10 for 0.1")
set_samples(30, 3, Vct.new(3, 0.1), ind, 0, false, "a name")
snd_test_neq(channel2vct(20, 20, ind, 0),
- vct(0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
- "3 set samples 20 for 0.1")
+ vct(0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
+ "3 set samples 20 for 0.1")
set_samples(0, 3, Vct.new(3, 0.2), ind, 0, false, "a name", 0, 1)
snd_test_neq(channel2vct(0, 20, ind, 0),
- vct(0.2, 0.2, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
- "4 set samples 0 at 1 for 0.1")
+ vct(0.2, 0.2, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
+ "4 set samples 0 at 1 for 0.1")
snd_test_neq(channel2vct(20, 20, ind, 0),
- Vct.new(20, 0.0),
- "5 set samples 20 at 1 for 0.1")
+ Vct.new(20, 0.0),
+ "5 set samples 20 at 1 for 0.1")
nd = new_sound("fmv1.snd", :channels, 2)
vct2channel(Vct.new(10, 0.5), 0, 10, nd, 0)
vct2channel(Vct.new(10, 0.3), 0, 10, nd, 1)
save_sound_as("fmv1.snd", nd)
close_sound(nd)
- unless File.exists?("fmv1.snd")
+ unless File.exist?("fmv1.snd")
snd_display("fmv1.snd not saved?")
end
set_samples(0, 10, "fmv1.snd", ind, 0, false, "another name", 1)
snd_test_neq(channel2vct(0, 20, ind, 0),
- vct(0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
- 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
+ vct(0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
+ 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
"6 set samples 0 at 1 for 0.1")
set_samples(5, 6, "fmv1.snd", ind, 0, false, "another name 7", 0)
snd_test_neq(channel2vct(0, 20, ind, 0),
- vct(0.3, 0.3, 0.3, 0.3, 0.3, 0.5, 0.5, 0.5, 0.5, 0.5,
- 0.5, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
- "7 set samples 0 at 1 for 0.1")
+ vct(0.3, 0.3, 0.3, 0.3, 0.3, 0.5, 0.5, 0.5, 0.5, 0.5,
+ 0.5, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0),
+ "7 set samples 0 at 1 for 0.1")
revert_sound(ind)
set_samples(0, 10, "fmv1.snd", ind, 0, false, "another name 8", 1, 0, false)
snd_test_neq(channel2vct(0, 20, ind, 0),
- vct(0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- "8 set samples 0 at 1 for 0.1")
+ vct(0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
+ 0.3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ "8 set samples 0 at 1 for 0.1")
set_samples(10, 10, "fmv1.snd", ind, 0, false, "another name 9", 0, 0)
snd_test_neq(channel2vct(0, 20, ind, 0),
- vct(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5),
- "9 set samples 0 at 1 for 0.1")
+ vct(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0.5,
+ 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5),
+ "9 set samples 0 at 1 for 0.1")
set_samples(20, 10, "fmv1.snd")
snd_test_neq(channel2vct(10, 20, ind, 0),
- Vct.new(20, 0.5),
- "10 set samples 0 at 1 for 0.1")
+ Vct.new(20, 0.5),
+ "10 set samples 0 at 1 for 0.1")
revert_sound(ind)
set_samples(0, 10, "fmv1.snd", ind, 0, true, "another name", 1, 0, false)
- snd_test_neq(frames(ind, 0), 10, "11 set samples truncate")
+ snd_test_neq(framples(ind, 0), 10, "11 set samples truncate")
revert_sound(ind)
delete_file("fmv1.snd")
#
- if (res = Snd.catch do set_samples(0, 10, "fmv1.snd", ind, 0) end).first != :no_such_file
+ res = Snd.catch do set_samples(0, 10, "fmv1.snd", ind, 0) end
+ if res.first != :no_such_file
snd_display("set samples, no such file: %s", res.inspect)
end
nd = new_sound("fmv1.snd", :channels, 1)
@@ -2996,10 +3072,12 @@ def test_04_00
end).first != :no_such_channel
snd_display("set samples no such channel (-1): %s", res.inspect)
end
- if (res = Snd.catch do set_samples(0, -10, "fmv1.snd") end).first != :wrong_type_arg
+ res = Snd.catch do set_samples(0, -10, "fmv1.snd") end
+ if res.first != :wrong_type_arg
snd_display("set samples (-10): %s", res.inspect)
end
- if (res = Snd.catch do set_samples(-10, 10, "fmv1.snd") end).first != :no_such_sample
+ res = Snd.catch do set_samples(-10, 10, "fmv1.snd") end
+ if res.first != :no_such_sample
snd_display("set samples (beg -10): %s", res.inspect)
end
close_sound(ind)
@@ -3021,7 +3099,7 @@ def test_04_00
[Mus_bfloat, 2 ** -23],
[Mus_bdouble, 2 ** -23],
[Mus_ldouble, 2 ** -23]].each do |type, allowed_diff|
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next)
v = make_vct(len)
maxdiff = 0.0
maxpos = false
@@ -3042,7 +3120,7 @@ def test_04_00
v[i] = 1.0 - val
end
vct2channel(v, 0, len, ind, 0)
- save_sound_as("test1.snd", ind, Mus_next, :data_format, type)
+ save_sound_as("test1.snd", ind, :header_type, Mus_next, :sample_type, type)
close_sound(ind)
ind = open_sound("test1.snd")
v1 = channel2vct(0, len, ind, 0)
@@ -3054,10 +3132,11 @@ def test_04_00
end
end
if maxdiff > allowed_diff
- snd_display(snd_format_neq(v1[maxpos], v[maxpos], "type %s: maxdiff %1.4f, maxpos %d",
- mus_data_format_name(type),
- maxdiff,
- maxpos))
+ snd_display(snd_format_neq(v1[maxpos], v[maxpos],
+ "type %s: maxdiff %1.4f, maxpos %d",
+ mus_sample_type_name(type),
+ maxdiff,
+ maxpos))
end
close_sound(ind)
end
@@ -3065,30 +3144,36 @@ def test_04_00
ob = view_sound(oboe_snd)
samp = sample(1000, ob)
old_comment = mus_sound_comment(oboe_snd)
- str = format("written %s", Time.now.localtime.strftime("%a %d-%b-%Y %H:%M %Z"))
+ str = format("written %s",
+ Time.now.localtime.strftime("%a %d-%b-%Y %H:%M"))
set_comment(ob, str)
#
check_it = lambda do |snd, type, fmt|
- snd_test_neq(header_type(snd), type, "save_as %s", mus_header_type_name(type))
+ snd_test_neq(header_type(snd), type,
+ "save_as %s", mus_header_type_name(type))
ntyp = mus_sound_header_type("test.snd")
snd_test_neq(ntyp,
type,
"saved_as %s -> %s",
mus_header_type_name(type),
mus_header_type_name(ntyp))
- snd_test_neq(data_format(snd), fmt, "save_as %s", mus_data_format_name(fmt))
- nfmt = mus_sound_data_format("test.snd")
+ snd_test_neq(sample_type(snd), fmt,
+ "save_as %s", mus_sample_type_name(fmt))
+ nfmt = mus_sound_sample_type("test.snd")
snd_test_neq(nfmt,
fmt,
"saved_as %s -> %s",
- mus_data_format_name(fmt),
- mus_data_format_name(nfmt))
- snd_test_neq(sample(1000, snd), samp, "%s[1000]", mus_header_type_name(type))
+ mus_sample_type_name(fmt),
+ mus_sample_type_name(nfmt))
+ snd_test_neq(sample(1000, snd), samp,
+ "%s[1000]", mus_header_type_name(type))
end
#
- if (tag = Snd.catch do
- save_sound_as("test.snd", ob, Mus_aifc, Mus_bdouble)
- end).first == :cannot_save
+ tag = Snd.catch do
+ save_sound_as("test.snd", ob,
+ :header_type, Mus_aifc, :sample_type, Mus_bdouble)
+ end
+ if tag.first == :cannot_save
snd_display("save_sound_as test.snd write trouble: %s", tag)
end
#
@@ -3098,15 +3183,16 @@ def test_04_00
snd_test_neq(mus_sound_comment("test.snd"), str, "output_comment")
snd_test_neq(comment(ab), str, "output_comment (comment)")
close_sound(ab)
- snd_test_neq(mus_sound_comment(oboe_snd), old_comment, "set_comment overwrote current")
+ snd_test_neq(mus_sound_comment(oboe_snd), old_comment,
+ "set_comment overwrote current")
set_filter_control_in_hz(false)
#
- save_sound_as("test.snd", ob, Mus_raw)
+ save_sound_as("test.snd", ob, :header_type, Mus_raw)
ab = open_raw_sound("test.snd", 1, 22050, Mus_bshort)
check_it.call(ab, Mus_raw, Mus_bshort)
close_sound(ab)
#
- save_sound_as("test.snd", ob, Mus_nist, Mus_bint)
+ save_sound_as("test.snd", ob, :header_type, Mus_nist, :sample_type, Mus_bint)
ab = open_sound("test.snd")
check_it.call(ab, Mus_nist, Mus_bint)
close_sound(ab)
@@ -3115,7 +3201,10 @@ def test_04_00
$output_comment_hook.add_hook!("snd-test-4") do |string|
string + " [written by me]"
end
- save_sound_as(:file, "test.snd", :sound, ob, :header_type, Mus_riff, :data_format, Mus_lfloat)
+ save_sound_as(:file, "test.snd",
+ :sound, ob,
+ :header_type, Mus_riff,
+ :sample_type, Mus_lfloat)
$output_comment_hook.reset_hook!
ab = open_sound("test.snd")
check_it.call(ab, Mus_riff, Mus_lfloat)
@@ -3124,24 +3213,25 @@ def test_04_00
[[Mus_aiff, Mus_b24int],
[Mus_ircam, Mus_mulaw],
[Mus_next, Mus_alaw],
- [Mus_next, Mus_bdouble]].each do |type, fmt|
- save_sound_as("test.snd", ob, type, fmt)
+ [Mus_next, Mus_ldouble]].each do |type, fmt|
+ save_sound_as("test.snd", ob, :header_type, type, :sample_type, fmt)
ab = open_sound("test.snd")
check_it.call(ab, type, fmt)
close_sound(ab)
end
- save_sound_as("test.snd", ob, Mus_next, Mus_bshort)
+ save_sound_as("test.snd", ob,
+ :header_type, Mus_next, :sample_type, Mus_bshort)
ab = open_sound("test.snd")
check_it.call(ab, Mus_next, Mus_bshort)
$update_hook.reset_hook!
set_y_bounds([-3.0, 3.0], ab, 0)
- set_data_format(ab, Mus_lshort)
+ set_sample_type(ab, Mus_lshort)
# ; these set!'s can change the index via update-sound
if find_sound("test.snd") != ab
ab = find_sound("test.snd")
end
- frm = data_format(ab)
- snd_test_neq(frm, Mus_lshort, "set_data_format %s", mus_data_format_name(frm))
+ frm = sample_type(ab)
+ snd_test_neq(frm, Mus_lshort, "set_sample_type %s", mus_sample_type_name(frm))
snd_test_neq(y_bounds(ab, 0), [-3.0, 3.0], "set data format y_bounds")
set_y_bounds([2.0], ab, 0)
snd_test_neq(y_bounds(ab, 0), [-2.0, 2.0], "set data format y_bounds 1")
@@ -3177,20 +3267,22 @@ def test_04_00
snd_test_neq(srate(ab), 12345, "set_srate")
close_sound(ab)
#
- save_sound_as("test.snd", ob, Mus_next, Mus_bfloat)
+ save_sound_as("test.snd", ob,
+ :header_type, Mus_next, :sample_type, Mus_bfloat)
ab = open_sound("test.snd")
check_it.call(ab, Mus_next, Mus_bfloat)
close_sound(ab)
#
- save_sound_as("test.snd", ob, Mus_next, Mus_bshort)
+ save_sound_as("test.snd", ob,
+ :header_type, Mus_next, :sample_type, Mus_bshort)
close_sound(ob)
ab = open_sound("test.snd")
- set_data_format(Mus_lshort)
+ set_sample_type(Mus_lshort)
if find_sound("test.snd") != ab
ab = find_sound("test.snd")
end
- frm = data_format(ab)
- snd_test_neq(frm, Mus_lshort, "set_data_format %s", mus_data_format_name(frm))
+ frm = sample_type(ab)
+ snd_test_neq(frm, Mus_lshort, "set_sample_type %s", mus_sample_type_name(frm))
set_header_type(Mus_aifc)
if find_sound("test.snd") != ab
ab = find_sound("test.snd")
@@ -3216,13 +3308,16 @@ def test_04_00
#
ind = open_sound("2a.snd")
[[lambda do
- save_sound_as("test.snd", :header_type, Mus_riff, :data_format, Mus_l24int, :channel, 0)
+ save_sound_as("test.snd",
+ :header_type, Mus_riff, :sample_type, Mus_l24int, :channel, 0)
end,
Mus_riff,
Mus_l24int,
srate(ind)],
[lambda do
- save_sound_as("test.snd", :header_type, Mus_aifc, :data_format, Mus_bfloat, :channel, 1, :srate, 12345)
+ save_sound_as("test.snd",
+ :header_type, Mus_aifc, :sample_type, Mus_bfloat, :channel, 1,
+ :srate, 12345)
end,
Mus_aifc,
Mus_bfloat,
@@ -3231,7 +3326,7 @@ def test_04_00
save_sound_as("test.snd", :channel, 1, :comment, "this is a test")
end,
header_type(ind),
- data_format(ind),
+ sample_type(ind),
srate(ind)]].each_with_index do |args, i|
prc, type, fmt, sr = args
prc.call
@@ -3239,16 +3334,17 @@ def test_04_00
info = format("save_sound_as :channel %d", i)
snd_test_neq(channels(snd), 1, "%s channels", info)
snd_test_neq(header_type(snd), type, "%s header_type", info)
- snd_test_neq(data_format(snd), fmt, "%s data_format", info)
+ snd_test_neq(sample_type(snd), fmt, "%s sample_type", info)
snd_test_neq(srate(snd), sr, "%s srate", info)
- snd_test_neq(frames(snd), frames(ind, 0), "%s frames", info)
+ snd_test_neq(framples(snd), framples(ind, 0), "%s framples", info)
snd_test_neq(maxamp(snd, 0), maxamp(ind, 0), "%s maxamp", info)
close_sound(snd)
end
close_sound(ind)
#
[["t15.aiff", [[132300, 0.148], [132300, 0.126]]],
- ["M1F1-float64C-AFsp.aif", [[8000, -0.024], [8000, 0.021]]]].each do |f, vals|
+ ["M1F1-float64C-AFsp.aif",
+ [[8000, -0.024], [8000, 0.021]]]].each do |f, vals|
with_file(f) do |fsnd|
ind = open_sound(fsnd)
chn = -1
@@ -3256,12 +3352,8 @@ def test_04_00
chn += 1
fneq(sample(val[0], ind, chn), val[1])
end
- snd_display("%s trouble[%s]: %s",
- fsnd,
- chn,
- vals.map_with_index do |val, i|
- sample(val[0], ind, i)
- end)
+ snd_display("%s trouble[%s]: %s", fsnd, chn,
+ vals.map_with_index do |val, i| sample(val[0], ind, i) end)
end
close_sound(ind)
end
@@ -3269,7 +3361,7 @@ def test_04_00
#
[["bad_chans.snd", [0, 22050, 0]],
["bad_srate.snd", [1, 0, 0]],
- ["bad_data_format.snd", [1, 22050, 4411]],
+ ["bad_sample_type.snd", [1, 22050, 4411]],
["bad_chans.aifc", [0, 22050, 0]],
["bad_srate.aifc", [1, 0, 0]],
["bad_length.aifc", [1, 22050, -10]],
@@ -3282,7 +3374,7 @@ def test_04_00
res = Snd.catch do
[mus_sound_chans(fsnd),
mus_sound_srate(fsnd),
- mus_sound_frames(fsnd)]
+ mus_sound_framples(fsnd)]
end.first
if res != vals and res != :mus_error
snd_display(snd_format_neq(res, vals, fsnd))
@@ -3321,40 +3413,6 @@ def test_04_00
close_sound(ind)
Snd.sounds.apply(:close_sound)
#
- ob = open_sound(oboe_snd)
- sd = vct2sound_data(channel2vct())
- mx = sound_data_maxamp(sd)
- snd_test_neq(sound_data_length(sd), 50828, "oboe->sd: len")
- snd_test_neq(sd[0, 1000], 0.0328369, "oboe->sd[1000]")
- snd_test_neq(mx.length, 1, "sound_data_maxamp oboe.snd len")
- snd_test_neq(maxamp(ob, 0), mx[0], "sound_data_maxamp oboe.snd")
- snd_test_neq(sound_data_peak(sd), mx[0], "sound_data_peak oboe.snd")
- if (res = Snd.catch do set_selected_channel(1) end).first != :no_such_channel
- snd_display("set_selected_channel bad chan: %s?", res)
- end
- if (res = Snd.catch do set_selected_channel(123456, 1) end).first != :no_such_sound
- snd_display("set_selected_channel bad snd: %s?", res)
- end
- [[2, 1000],
- [-1, 1000],
- [0, -1],
- [0, 10000000]].each do |chn, frm|
- if (res = Snd.catch do sd[chn, frm] end).first != :out_of_range
- snd_display("sound_data_ref bad chan or frame: %s %s %s?", chn, frm, res)
- end
- end
- [[2, 1000],
- [0, 10000000]].each do |chn, frm|
- if (res = Snd.catch do sd[chn, frm] = 1 end).first != :out_of_range
- snd_display("sound_data_set! bad chan or frame: %s %s %s?", chn, frm, res)
- end
- end
- v = make_vct(3)
- if (res = Snd.catch do vct2sound_data(v, sd, 2) end).first != :out_of_range
- snd_display("vct2sound_data set bad chan: %s?", res.inspect)
- end
- close_sound(ob)
- #
if selected_sound
snd_display("selected_sound %s %s?", selected_sound, sounds.inspect)
end
@@ -3370,122 +3428,6 @@ def test_04_00
end
def test_04_01
- fmv5_snd = "fmv5.snd"
- delete_file(fmv5_snd)
- fd = mus_sound_open_output(fmv5_snd, 22050, 1, Mus_bshort, Mus_aiff, "no comment")
- sdata = SoundData.new(1, 100)
- 100.times do |i| sdata[0, i] = i * 0.01 end
- snd_test_neq(sdata.to_s,
- "#<sound-data[chans=1, length=100]:
- (0.000 0.010 0.020 0.030 0.040 0.050 0.060 0.070 0.080 0.090 0.100 0.110 ...)>",
- "print sound_data")
- edat = sdata
- edat1 = SoundData.new(1, 100)
- edat2 = SoundData.new(2, 100)
- snd_test_neq(edat, sdata, "sound_data")
- snd_test_eq(edat1, sdata, "sound_data 1")
- snd_test_eq(edat1, edat2, "sound_data 2")
- 100.times do |i| edat1[0, i] = sdata[0, i] end
- snd_test_neq(edat1, sdata, "sound_data 3")
- v0 = make_vct(100)
- v1 = make_vct(3)
- sound_data2vct(sdata, 0, v0)
- snd_test_neq(v0[10], 0.1, "sound_data2vct")
- sound_data2vct(sdata, 0, v1)
- snd_test_neq(v1[1], 0.01, "sound_data2(small)vct")
- vct2sound_data(v0, sdata, 0)
- snd_test_neq(sound_data_ref(sdata, 0, 10), 0.1, "vct2sound_data")
- snd_test_neq(sdata[0, 10], 0.1, "vct2sound_data applied")
- if (res = Snd.catch do sound_data2vct(sdata, 2, v0) end).first != :out_of_range
- snd_display("sound_data2vct bad chan: %s?", res.inspect)
- end
- if (res = Snd.catch do mus_audio_write(1, make_sound_data(3, 3), 123) end).first != :out_of_range
- snd_display("mus_audio_write bad frames: %s?", res.inspect)
- end
- #
- v0 = make_vct(10)
- vx = make_vct(3)
- sdata2 = SoundData.new(2, 10)
- 10.times do |i|
- sdata2[0, i] = 0.1
- sdata2[1, i] = 0.2
- end
- sound_data2vct(sdata2, 0, v0)
- sound_data2vct(sdata2, 0, vx)
- snd_test_neq(v0[1], 0.1, "sound_data2vct[1]")
- sound_data2vct(sdata2, 1, v0)
- snd_test_neq(v0[1], 0.2, "sound_data2vct[2]")
- vct2sound_data(v0, sdata2, 0)
- snd_test_neq(sdata2[0, 1], 0.2, "vct2sound_data[2]")
- vct_fill!(v0, 0.3)
- vct2sound_data(v0, sdata2, 1)
- snd_test_neq(sdata2[1, 1], 0.3, "vct2sound_data[3]")
- vct2sound_data(vx, sdata2, 0)
- mus_sound_write(fd, 0, 99, 1, sdata)
- mus_sound_close_output(fd, 100 * mus_bytes_per_sample(Mus_bshort))
- fd = mus_sound_reopen_output(fmv5_snd, 1, Mus_bshort, Mus_aiff, mus_sound_data_location(fmv5_snd))
- mus_sound_close_output(fd, 100 * mus_bytes_per_sample(Mus_bshort))
- fd = mus_sound_open_input(fmv5_snd)
- mus_sound_read(fd, 0, 99, 1, sdata)
- snd_test_neq(sdata[0, 10], 0.1, "mus_sound_write")
- pos = mus_sound_seek_frame(fd, 20)
- # FIXME
- # IO.open(fd).pos doesn't work
- # snd_test_neq(IO.open(fd).pos, pos, "1 mus_sound_seek_frame")
- snd_test_neq(frame2byte(fmv5_snd, 20), pos, "2 mus_sound_seek_frame")
- mus_sound_read(fd, 0, 10, 1, sdata)
- snd_test_neq(sdata[0, 0], 0.2, "2 mus_sound_seek")
- mus_sound_close_input(fd)
- #
- sd = make_sound_data(2, 10)
- vct2sound_data(Vct.new(10, 0.25), sd, 0)
- vct2sound_data(Vct.new(10, 0.50), sd, 1)
- sound_data_scale!(sd, 2.0)
- snd_test_neq(sound_data2vct(sd, 0), Vct.new(10, 0.5), "sound_data_scale! chan 0")
- snd_test_neq(sound_data2vct(sd, 1), Vct.new(10, 1.0), "sound_data_scale! chan 1")
- sd = make_sound_data(2, 10)
- sound_data_fill!(sd, 2.0)
- snd_test_neq(sound_data2vct(sd, 0), Vct.new(10, 2.0), "sound_data_fill! chan 0")
- snd_test_neq(sound_data2vct(sd, 1), Vct.new(10, 2.0), "sound_data_fill! chan 1")
- #
- if (res = Snd.catch do
- mus_sound_open_output("fmv.snd", 22050, -1, Mus_bshort, Mus_aiff, "no comment")
- end).first != :out_of_range
- snd_display("mus_sound_open_output bad chans: %s?", res)
- end
- if (res = Snd.catch do
- mus_sound_open_output("fmv.snd", 22050, 1, -1, Mus_aiff, "no comment")
- end).first != :out_of_range
- snd_display("mus_sound_open_output bad format: %s?", res)
- end
- if (res = Snd.catch do
- mus_sound_open_output("fmv.snd", 22050, 1, Mus_bshort, -1, "no comment")
- end).first != :out_of_range
- snd_display("mus_sound_open_output bad type: %s?", res)
- end
- if (res = Snd.catch do
- mus_sound_reopen_output("fmv.snd", -1, Mus_bshort, Mus_aiff, false)
- end).first != :out_of_range
- snd_display("mus_sound_reopen_output bad chans: %s?", res)
- end
- if (res = Snd.catch do
- mus_sound_reopen_output("fmv.snd", 1, -1, Mus_aiff, false)
- end).first != :out_of_range
- snd_display("mus_sound_reopen_output bad format: %s?", res)
- end
- if (res = Snd.catch do
- mus_sound_reopen_output("fmv.snd", 1, Mus_bshort, -1, false)
- end).first != :out_of_range
- snd_display("mus_sound_reopen_output bad type: %s?", res)
- end
- #
- sd = SoundData.new(2, 10)
- sd.fill!(1.0)
- snd_test_neq(sound_data2vct(sd, 0), Vct.new(10, 1.0), "sd.fill! chan 0")
- snd_test_neq(sound_data2vct(sd, 1), Vct.new(10, 1.0), "sd.fill! chan 1")
- sd1 = sd.dup
- snd_test_neq(sd1, sd, "sd.dup (copy)")
- #
["trunc.snd",
"trunc.aiff",
"trunc.wav",
@@ -3500,232 +3442,37 @@ def test_04_01
snd_test_neq(res.first, :mus_error, "open_sound %s", file)
end
end
- $open_raw_sound_hook.add_hook!("snd-test-044") do |file, choice| [1, 22050, Mus_bshort] end
+ $open_raw_sound_hook.add_hook!("snd-test-044") do |file, choice|
+ [1, 22050, Mus_bshort]
+ end
with_file("empty.snd") do |fsnd|
ind = open_sound(fsnd)
- if data_format(ind) != Mus_bshort or
+ if sample_type(ind) != Mus_bshort or
channels(ind) != 1 or
srate(ind) != 22050 or
data_location(ind) != 0 or
- frames(ind) != 0
+ framples(ind) != 0
snd_display("open raw: %s %s %s %s %s?",
- data_format(ind),
+ sample_type(ind),
channels(ind),
srate(ind),
data_location(ind),
- frames(ind))
+ framples(ind))
end
close_sound(ind)
end
$open_raw_sound_hook.reset_hook!
- #
- sd1 = SoundData.new(1, 32)
- sd2 = SoundData.new(2, 64)
- 32.times do |i|
- sd1[0, i] = i * 0.01
- end
- 64.times do |i|
- sd2[0, i] = i * 0.1
- sd2[1, i] = i * 0.2
- end
- sound_data2sound_data(sd2, sd1, 3, 6, 32)
- [[0, 0.00],
- [2, 0.02],
- [3, 0.00],
- [6, 0.30],
- [10, 0.1]].each do |idx, val|
- snd_test_neq(sd1[0, idx], val, "sound_data2sound_data %d", idx)
- end
- sound_data2sound_data(sd1, sd2, 0, 10, 32)
- snd_test_neq(sd2[0, 5], 0.2, "sound_data2sound_data 2 5")
- #
- sdi = SoundData.new(1, 32)
- sdo = SoundData.new(1, 32)
- snd_test_neq(sound_data2sound_data(sdi, sdo, 10, 32, 10), 2, "sound_data2sound_data wrap around")
- snd_test_neq(sound_data2sound_data(sdi, sdo, 10, 32, 32), 10, "sound_data2sound_data wrap around")
- if (res = Snd.catch do
- sound_data2sound_data(sdi, sdo, -1, 10, 10)
- end).first != :out_of_range
- snd_display("sound_data2sound_data start: %s", res)
- end
- if (res = Snd.catch do
- sound_data2sound_data(sdi, sdo, 0, -1, 10)
- end).first != :out_of_range
- snd_display("sound_data2sound_data frames: %s", res)
- end
- if (res = Snd.catch do
- sound_data2sound_data(sdi, sdo, 0, 128, 10)
- end).first != :out_of_range
- snd_display("sound_data2sound_data frames: %s", res)
- end
- #
- sd = SoundData.new(1, 1)
- snd_test_neq(sd[0, 0], 0.0, "sound_data_ref")
- sd[0, 0] = 1.0
- snd_test_neq(sd[0, 0], 1.0, "sound_data_set")
- sd1 = make_sound_data(1, 1)
- sound_data_set!(sd1, 0, 0, 1.0)
- snd_test_neq(sd, sd1, "sound_data_set")
- #
- sd = SoundData.new(2, 3)
- snd_test_neq(sd[0, 0], 0.0, "sound_data_ref (1)")
- sd[1, 0] = 1.0
- snd_test_neq(sd[1, 0], 1.0, "sound_data_set (1 0)")
- sd[1, 2] = 2.0
- snd_test_neq(sd[1, 2], 2.0, "sound_data_set (1 2)")
- sd1 = make_sound_data(2, 3)
- sound_data_set!(sd1, 1, 0, 1.0)
- sound_data_set!(sd1, 1, 2, 2.0)
- snd_test_neq(sd, sd1, "sound_data_set (3)")
- #
-end
-
-def test_04_02
- [1, 2, 4, 8].each do |chans|
- [[Mus_bshort, Mus_next],
- [Mus_bfloat, Mus_aifc],
- [Mus_lshort, Mus_aifc],
- [Mus_lfloat, Mus_riff],
- [Mus_lshort, Mus_nist],
- [Mus_bint, Mus_aiff],
- [Mus_lint, Mus_next],
- [Mus_bintn, Mus_next],
- [Mus_lintn, Mus_next],
- [Mus_b24int, Mus_aifc],
- [Mus_l24int, Mus_riff],
- [Mus_bfloat, Mus_ircam],
- [Mus_bfloat_unscaled, Mus_next],
- [Mus_lfloat_unscaled, Mus_next],
- [Mus_bdouble_unscaled, Mus_next],
- [Mus_ldouble_unscaled, Mus_next],
- [Mus_bdouble, Mus_next],
- [Mus_ldouble, Mus_next],
- [Mus_ulshort, Mus_next],
- [Mus_ubshort, Mus_next]].each do |df, ht|
- samps = case chans
- when 1
- 100000
- when 2
- 50000
- else
- 1000
- end
- delete_file("fmv5.snd")
- fd = mus_sound_open_output("fmv5.snd", 22050, chans, df, ht, "no, comment")
- sdata = SoundData.new(chans, samps)
- ndata = SoundData.new(chans, samps)
- chans.times do |chn|
- samps.times do |i|
- # FIXME
- # This leads to v0 = 1.0 != v1 = -1.0 at some places:
- # sdata[chn, i] = random(2.0) - 1.0
- sdata[chn, i] = random(1.9999) - 1.0
- end
- end
- mus_sound_write(fd, 0, samps - 1, chans, sdata)
- mus_sound_close_output(fd, samps * chans * mus_bytes_per_sample(df))
- fd = mus_sound_open_input("fmv5.snd")
- mus_sound_read(fd, 0, samps - 1, chans, ndata)
- pos = mus_sound_seek_frame(fd, 100)
- # FIXME
- # IO.open(fd).pos doesn't work
- # snd_test_neq(IO.open(fd).pos,
- # pos,
- # "mus_sound_seek_frame(%d) chans %d, (%s %s)",
- # pos,
- # chans,
- # mus_header_type_name(ht),
- # mus_data_format_name(df))
- snd_test_neq(frame2byte("fmv5.snd", 100),
- pos,
- "mus_sound_seek_frame(100) chans %d, (%s %s)",
- chans,
- mus_header_type_name(ht),
- mus_data_format_name(df))
- mus_sound_close_input(fd)
- Snd.catch(:read_write_error, lambda do |*args|
- snd_display("read_write trouble: %s %s (%s != %s at [%s, %s])?",
- *args.first[2..-1])
- end) do
- chans.times do |chn|
- samps.times do |i|
- v0 = sdata[chn, i]
- v1 = ndata[chn, i]
- if fneq(v0, v1)
- Snd.throw(:read_write_error,
- mus_data_format_name(df), mus_header_type_name(ht), v0, v1, chn, i)
- end
- end
- end
- end
- end
- end
end
def test_04_03
- ind = open_sound("oboe.snd")
- our_short = little_endian? ? Mus_lshort : Mus_bshort
- our_srate = 22050
- our_dac_buffer_size_in_bytes = 512
- our_dac_buffer_size_in_shorts = 256
- our_chans = 1
- our_chan = 0
- in_sys = 0
- in_port = Snd.catch(:mus_error, -1) do
- mus_audio_open_input(0, our_srate, our_chans, our_short, our_dac_buffer_size_in_bytes)
- end.first
- data = make_sound_data(our_chans, our_dac_buffer_size_in_shorts)
- vobj = make_vct(our_dac_buffer_size_in_shorts)
- if in_port == -1
- snd_display("cannot open audio input port!")
- else
- 10.times do
- mus_audio_read(in_port, data, our_dac_buffer_size_in_shorts)
- graph(sound_data2vct(data, our_chan, vobj))
- end
- mus_audio_close(in_port)
- end
- close_sound(ind)
- #
- fmv = "fmv.snd"
- fd = mus_sound_open_output(fmv, 22050, 1, Mus_bshort, Mus_next, "no comment")
- sdata = SoundData.new(1, 10)
- sdata[0, 1] = 0.1
- mus_sound_write(fd, 0, 9, 1, sdata)
- mus_sound_close_output(fd, 20)
- fd = mus_sound_open_input(fmv)
- mus_sound_read(fd, 0, 9, 1, sdata)
- if fneq(sdata[0, 0], 0.0) or
- fneq(sdata[0, 1], 0.1) or
- fneq(sdata[0, 2], 0.0) or
- fneq(sdata[0, 6], 0.0)
- snd_display("read/write: %s?", sdata.to_a)
- end
- mus_sound_close_input(fd)
- fd = mus_sound_reopen_output(fmv, 1, Mus_bshort, Mus_next, mus_sound_data_location(fmv))
- mus_sound_seek_frame(fd, 0)
- sdata[0, 2] = 0.1
- sdata[0, 3] = 0.1
- mus_sound_write(fd, 0, 9, 1, sdata)
- mus_sound_close_output(fd, 20)
- fd = mus_sound_open_input(fmv)
- sdata1 = SoundData.new(1, 10)
- mus_sound_read(fd, 0, 9, 1, sdata1)
- if fneq(sdata1[0, 0], 0.0) or
- fneq(sdata1[0, 1], 0.1) or
- fneq(sdata1[0, 2], 0.1) or
- fneq(sdata1[0, 3], 0.1) or
- fneq(sdata1[0, 6], 0.0)
- snd_display(snd_format_neq(sdata1.to_a, sdata.to_a, "re-read/write"))
- end
- mus_sound_close_input(fd)
#
# check clipping choices
#
ind = view_sound("oboe.snd")
set_clipping(false)
- map_channel(lambda do |y| y * 10.0 end, 0, frames(), ind, 0)
- save_sound_as("test.snd", ind, Mus_next, Mus_bfloat)
+ scale_channel(10.0)
+ save_sound_as("test.snd", ind,
+ :header_type, Mus_next, :sample_type, Mus_bfloat)
undo_edit(1, ind, 0)
ind1 = open_sound("test.snd")
snd_test_neq(maxamp(ind1, 0), 10.0 * maxamp(ind, 0), "clipping 0")
@@ -3733,8 +3480,9 @@ def test_04_03
delete_file("test.snd")
#
set_clipping(true)
- map_channel(lambda do |y| y * 10.0 end, 0, frames(), ind, 0)
- save_sound_as("test.snd", ind, Mus_next, Mus_bfloat)
+ map_channel(lambda do |y| y * 10.0 end, 0, framples(), ind, 0)
+ save_sound_as("test.snd", ind,
+ :header_type, Mus_next, :sample_type, Mus_bfloat)
undo_edit(1, ind, 0)
ind1 = open_sound("test.snd")
snd_test_neq(maxamp(ind1, 0), 1.0, "clipping 1")
@@ -3743,17 +3491,19 @@ def test_04_03
#
set_clipping(false)
mx = maxamp(ind)
- map_channel(lambda do |y| y + (1.001 - mx) end, 0, frames(), ind, 0)
- save_sound_as("test.snd", ind, Mus_next, Mus_bshort)
+ map_channel(lambda do |y| y + (1.001 - mx) end, 0, framples(), ind, 0)
+ save_sound_as("test.snd", ind,
+ :header_type, Mus_next, :sample_type, Mus_bfloat)
ind1 = open_sound("test.snd")
- unless res = scan_channel(lambda do |y| y < 0.0 end)
+ if res = scan_channel(lambda do |y| y < 0.0 end)
snd_display("clipping 2: %s?", res)
end
close_sound(ind1)
delete_file("test.snd")
#
set_clipping(true)
- save_sound_as("test.snd", ind, Mus_next, Mus_bshort)
+ save_sound_as("test.snd", ind,
+ :header_type, Mus_next, :sample_type, Mus_bshort)
ind1 = open_sound("test.snd")
if res = scan_channel(lambda do |y| y < 0.0 end)
snd_display("clipping 3: %s?", res)
@@ -3763,10 +3513,9 @@ def test_04_03
#
set_clipping(false)
close_sound(ind)
- delete_file(fmv)
#
set_clipping(false)
- snd = new_sound("test.snd", :data_format, Mus_lshort)
+ snd = new_sound("test.snd", :sample_type, Mus_lshort)
pad_channel(0, 10)
set_sample(1, 1.0)
set_sample(2, -1.0)
@@ -3781,13 +3530,13 @@ def test_04_03
close_sound(snd)
snd = open_sound("test.snd")
snd_test_neq(channel2vct(0, 10),
- vct(0.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0),
+ vct(0.0, 1.0, -1.0, 1.0, 0.0, 0.0, -0.7, 0.7, -0.2, 0.2),
"unclipped 1")
close_sound(snd)
mus_sound_forget("test.snd")
#
set_clipping(true)
- snd = new_sound("test.snd", :data_format, Mus_lshort)
+ snd = new_sound("test.snd", :sample_type, Mus_lshort)
pad_channel(0, 10)
set_sample(1, 1.0)
set_sample(2, -1.0)
@@ -3806,113 +3555,6 @@ def test_04_03
"clipped")
close_sound(snd)
#
- data = vct(0.0, 1.0, -1.0, 0.9999, 2.0, -2.0, 1.3, -1.3, 1.8, -1.8)
- sdata = vct2sound_data(data)
- snd = mus_sound_open_output("test.snd", 22050, 1, Mus_lshort, Mus_riff, "a comment")
- set_mus_file_clipping(snd, false)
- mus_sound_write(snd, 0, 9, 1, sdata)
- mus_sound_close_output(snd, 40)
- snd = open_sound("test.snd")
- snd_test_neq(channel2vct(0, 10),
- vct(0.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0),
- "unclipped 2")
- close_sound(snd)
- mus_sound_forget("test.snd")
- #
- data = vct(0.0, 1.0, -1.0, 0.9999, 2.0, -2.0, 1.3, -1.3, 1.8, -1.8)
- sdata = vct2sound_data(data)
- snd = mus_sound_open_output("test.snd", 22050, 1, Mus_lshort, Mus_riff, "a comment")
- set_mus_file_clipping(snd, true)
- mus_sound_write(snd, 0, 9, 1, sdata)
- set_mus_file_clipping(snd, false)
- mus_sound_close_output(snd, 40)
- snd = open_sound("test.snd")
- snd_test_neq(channel2vct(0, 10),
- vct(0.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0),
- "clipped 1")
- close_sound(snd)
- #
- set_mus_clipping(false)
- data = vct(0.0, 1.0, -1.0, 0.9999, 2.0, -2.0, 1.3, -1.3, 1.8, -1.8)
- sdata = vct2sound_data(data)
- snd = mus_sound_open_output("test.snd", 22050, 1, Mus_lshort, Mus_riff, "a comment")
- mus_sound_write(snd, 0, 9, 1, sdata)
- mus_sound_close_output(snd, 40)
- snd = open_sound("test.snd")
- snd_test_neq(channel2vct(0, 10),
- vct(0.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0),
- "unclipped 3")
- close_sound(snd)
- mus_sound_forget("test.snd")
- #
- set_mus_clipping(true)
- data = vct(0.0, 1.0, -1.0, 0.9999, 2.0, -2.0, 1.3, -1.3, 1.8, -1.8)
- sdata = vct2sound_data(data)
- snd = mus_sound_open_output("test.snd", 22050, 1, Mus_lshort, Mus_riff, "a comment")
- mus_sound_write(snd, 0, 9, 1, sdata)
- mus_sound_close_output(snd, 40)
- snd = open_sound("test.snd")
- snd_test_neq(channel2vct(0, 10),
- vct(0.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0),
- "clipped 2")
- close_sound(snd)
- #
- set_mus_clipping(true)
- data = vct(0.0, 1.0, -1.0, 0.9999, 2.0, -2.0, 1.3, -1.3, 1.8, -1.8)
- sdata = vct2sound_data(data)
- snd = mus_sound_open_output("test.snd", 22050, 1, Mus_lshort, Mus_riff, "a comment")
- if (res = Snd.catch do mus_sound_write(snd, 0, 10, 1, sdata) end).first != :out_of_range
- snd_display("mus_sound_write too many bytes: %s", res.inspect)
- end
- if (res = Snd.catch do mus_sound_read(snd, 0, 10, 1, sdata) end).first != :out_of_range
- snd_display("mus_sound_read too many bytes: %s", res.inspect)
- end
- mus_sound_close_output(snd, 0)
- delete_file("test.snd")
- mus_sound_forget("test.snd")
- set_mus_clipping(false) # default
- set_clipping(false)
- #
- com = "this is a comment which we'll repeat enough times to trigger an internal loop" * 3
- fd = mus_sound_open_output(fmv, 22050, 4, Mus_lshort, Mus_riff, com)
- sdata = SoundData.new(4, 10)
- 4.times do |i| sdata[i, 1] = 0.1 end
- mus_sound_write(fd, 0, 9, 4, sdata)
- mus_sound_close_output(fd, 80)
- fd = mus_sound_open_input(fmv)
- mus_sound_read(fd, 0, 9, 4, sdata)
- 4.times do |i|
- if fneq(sdata[i, 0], 0.0) or
- fneq(sdata[i, 1], 0.1) or
- fneq(sdata[i, 2], 0.0) or
- fneq(sdata[i, 6], 0.0)
- snd_display("1 read/write[%d]: %s?", i, sdata.to_vct(i).to_a)
- end
- end
- mus_sound_close_input(fd)
- fd = mus_sound_reopen_output(fmv, 4, Mus_lshort, Mus_riff, mus_sound_data_location(fmv))
- mus_sound_seek_frame(fd, 0)
- 4.times do |i|
- sdata[i, 2] = 0.1
- sdata[i, 3] = 0.1
- end
- mus_sound_write(fd, 0, 9, 4, sdata)
- mus_sound_close_output(fd, 80)
- fd = mus_sound_open_input(fmv)
- sdata1 = SoundData.new(4, 10)
- mus_sound_read(fd, 0, 9, 4, sdata1)
- 4.times do |i|
- if fneq(sdata1[i, 0], 0.0) or
- fneq(sdata1[i, 1], 0.1) or
- fneq(sdata1[i, 2], 0.1) or
- fneq(sdata1[i, 3], 0.1) or
- fneq(sdata1[i, 6], 0.0)
- snd_display(snd_format_neq(sdata1.to_vct(i).to_a, sdata.to_vct(i).to_a,
- "2 re-read/write[%d]", i))
- end
- end
- mus_sound_close_input(fd)
- #
with_file("32bit.sf") do |fsnd|
ind = open_sound(fsnd)
snd_test_neq(maxamp(ind, 0), 0.228, "32bit max")
@@ -3958,10 +3600,6 @@ def test_04_03
vct(0.021, 0.018, 0.014, 0.009, 0.004, -0.001, -0.004, -0.006, -0.007, -0.008)],
["wood.sds", 1000, 10,
vct(-0.160, -0.216, -0.254, -0.239, -0.175, -0.102, -0.042, 0.005, 0.041, 0.059)],
- ["oboe.g721", 1000, 10,
- vct(-0.037, -0.040, -0.040, -0.041, -0.042, -0.038, -0.028, -0.015, -0.005, 0.002)],
- ["oboe.g723_40", 1000, 10,
- vct(-0.037, -0.040, -0.041, -0.041, -0.041, -0.038, -0.028, -0.015, -0.005, 0.003)],
["mus10.snd", 10000, 10,
vct(0.004, 0.001, 0.005, 0.009, 0.017, 0.015, 0.008, 0.011, 0.009, 0.012)],
["ieee-text-16.snd", 1000, 10,
@@ -3993,12 +3631,10 @@ def test_04_04
"no phase method",
"null gen arg to method",
"no length method",
- "no free method",
"no describe method",
"no data method",
"no scaler method",
"memory allocation failed",
- "unstable two pole error",
"can't open file",
"no sample input",
"no sample output",
@@ -4007,9 +3643,9 @@ def test_04_04
"no location method",
"no channel method",
"no such fft window",
- "unsupported data format",
+ "unknown sample type",
"header read failed",
- "unsupported header type",
+ "unknown header type",
"file descriptors not initialized",
"not a sound file",
"file closed",
@@ -4020,7 +3656,7 @@ def test_04_04
"bad envelope",
"audio channels not available",
"audio srate not available",
- "audio format not available",
+ "audio sample type not available",
"no audio input available",
"audio configuration not available",
"audio write error",
@@ -4034,7 +3670,6 @@ def test_04_04
"no audio read permission",
"can't close file",
"arg out of range",
- "wrong type arg",
"no channels method",
"no hop method",
"no width method",
@@ -4051,68 +3686,85 @@ def test_04_04
"bad size",
"can't convert",
"read error",
- "no safety method",
+ "no feedforward method",
+ "no feedback method",
+ "no interp-type method",
+ "no position method",
+ "no order method",
+ "no copy method",
"can't translate"].each_with_index do |err, i|
snd_test_neq(err, mus_error_type2string(i), "mus_error_type2string %d", i)
end
oboe_snd = "oboe.snd"
cur_srate = mus_sound_srate(oboe_snd)
cur_chans = mus_sound_chans(oboe_snd)
- cur_format = mus_sound_data_format(oboe_snd)
+ cur_format = mus_sound_sample_type(oboe_snd)
cur_type = mus_sound_header_type(oboe_snd)
cur_loc = mus_sound_data_location(oboe_snd)
cur_samps = mus_sound_samples(oboe_snd)
set_mus_sound_srate(oboe_snd, cur_srate * 2)
- snd_test_neq(mus_sound_srate(oboe_snd), cur_srate * 2, "set_mus_sound_srate")
+ snd_test_neq(mus_sound_srate(oboe_snd), cur_srate * 2,
+ "set_mus_sound_srate")
set_mus_sound_samples(oboe_snd, cur_samps * 2)
- snd_test_neq(mus_sound_samples(oboe_snd), cur_samps * 2, "set_mus_sound_samples")
+ snd_test_neq(mus_sound_samples(oboe_snd), cur_samps * 2,
+ "set_mus_sound_samples")
set_mus_sound_chans(oboe_snd, cur_chans * 2)
- snd_test_neq(mus_sound_chans(oboe_snd), cur_chans * 2, "set_mus_sound_chans")
+ snd_test_neq(mus_sound_chans(oboe_snd), cur_chans * 2,
+ "set_mus_sound_chans")
set_mus_sound_data_location(oboe_snd, cur_loc * 2)
- snd_test_neq(mus_sound_data_location(oboe_snd), cur_loc * 2, "set_mus_sound_data_location")
+ snd_test_neq(mus_sound_data_location(oboe_snd), cur_loc * 2,
+ "set_mus_sound_data_location")
set_mus_sound_header_type(oboe_snd, Mus_nist)
- snd_test_neq(mus_sound_header_type(oboe_snd), Mus_nist, "set_mus_sound_header_type")
- set_mus_sound_data_format(oboe_snd, Mus_lintn)
- snd_test_neq(mus_sound_data_format(oboe_snd), Mus_lintn, "set_mus_sound_data_format")
+ snd_test_neq(mus_sound_header_type(oboe_snd), Mus_nist,
+ "set_mus_sound_header_type")
+ set_mus_sound_sample_type(oboe_snd, Mus_lintn)
+ snd_test_neq(mus_sound_sample_type(oboe_snd), Mus_lintn,
+ "set_mus_sound_sample_type")
set_mus_sound_srate(oboe_snd, cur_srate)
set_mus_sound_samples(oboe_snd, cur_samps)
set_mus_sound_chans(oboe_snd, cur_chans)
set_mus_sound_data_location(oboe_snd, cur_loc)
set_mus_sound_header_type(oboe_snd, cur_type)
- set_mus_sound_data_format(oboe_snd, cur_format)
+ set_mus_sound_sample_type(oboe_snd, cur_format)
#
ind = open_sound("oboe.snd")
- save_sound_as("test.wave", ind, Mus_riff)
- save_sound_as("test.rf64", ind, Mus_rf64)
- save_sound_as("test.aifc", ind, Mus_aifc)
+ save_sound_as("test.wave", ind, :header_type, Mus_riff)
+ save_sound_as("test.rf64", ind, :header_type, Mus_rf64)
+ save_sound_as("test.aifc", ind, :header_type, Mus_aifc)
close_sound(ind)
["test.wave",
"test.rf64",
"test.aifc"].each do |file|
cur_srate = mus_sound_srate(file)
cur_chans = mus_sound_chans(file)
- cur_format = mus_sound_data_format(file)
+ cur_format = mus_sound_sample_type(file)
cur_type = mus_sound_header_type(file)
cur_loc = mus_sound_data_location(file)
cur_samps = mus_sound_samples(file)
set_mus_sound_srate(file, cur_srate * 2)
- snd_test_neq(mus_sound_srate(file), cur_srate * 2, "%s set_mus_sound_srate", file)
+ snd_test_neq(mus_sound_srate(file), cur_srate * 2,
+ "%s set_mus_sound_srate", file)
set_mus_sound_samples(file, cur_samps * 2)
- snd_test_neq(mus_sound_samples(file), cur_samps * 2, "%s set_mus_sound_samples", file)
+ snd_test_neq(mus_sound_samples(file), cur_samps * 2,
+ "%s set_mus_sound_samples", file)
set_mus_sound_chans(file, cur_chans * 2)
- snd_test_neq(mus_sound_chans(file), cur_chans * 2, "%s set_mus_sound_chans", file)
+ snd_test_neq(mus_sound_chans(file), cur_chans * 2,
+ "%s set_mus_sound_chans", file)
set_mus_sound_data_location(file, cur_loc * 2)
- snd_test_neq(mus_sound_data_location(file), cur_loc * 2, "%s set_mus_sound_data_location", file)
+ snd_test_neq(mus_sound_data_location(file), cur_loc * 2,
+ "%s set_mus_sound_data_location", file)
set_mus_sound_header_type(file, Mus_nist)
- snd_test_neq(mus_sound_header_type(file), Mus_nist, "%s set_mus_sound_header_type", file)
- set_mus_sound_data_format(file, Mus_lintn)
- snd_test_neq(mus_sound_data_format(file), Mus_lintn, "%s set_mus_sound_data_format", file)
+ snd_test_neq(mus_sound_header_type(file), Mus_nist,
+ "%s set_mus_sound_header_type", file)
+ set_mus_sound_sample_type(file, Mus_lintn)
+ snd_test_neq(mus_sound_sample_type(file), Mus_lintn,
+ "%s set_mus_sound_sample_type", file)
set_mus_sound_srate(file, cur_srate)
set_mus_sound_samples(file, cur_samps)
set_mus_sound_chans(file, cur_chans)
set_mus_sound_data_location(file, cur_loc)
set_mus_sound_header_type(file, cur_type)
- set_mus_sound_data_format(file, cur_format)
+ set_mus_sound_sample_type(file, cur_format)
end
["test.wave",
"test.rf64",
@@ -4120,14 +3772,14 @@ def test_04_04
ind = open_sound(file)
cur_srate = srate(ind)
cur_chans = chans(ind)
- cur_format = data_format(ind)
+ cur_format = sample_type(ind)
cur_type = header_type(ind)
cur_loc = data_location(ind)
- cur_samps = frames(ind)
+ cur_samps = framples(ind)
set_srate(ind, cur_srate * 2)
snd_test_neq(srate(ind), cur_srate * 2, "%s set_srate", file)
- set_frames(cur_samps * 2, ind)
- snd_test_neq(frames(ind), cur_samps * 2, "%s set_frames", file)
+ set_framples(cur_samps * 2, ind)
+ snd_test_neq(framples(ind), cur_samps * 2, "%s set_framples", file)
set_chans(ind, cur_chans * 2) # this can change the index
xind = find_sound(file)
if ind != xind
@@ -4138,21 +3790,20 @@ def test_04_04
snd_test_neq(data_location(ind), cur_loc * 2, "%s set_location", file)
set_header_type(ind, Mus_nist)
snd_test_neq(header_type(ind), Mus_nist, "%s set_header_type", file)
- set_data_format(ind, Mus_lintn)
- snd_test_neq(data_format(ind), Mus_lintn, "%s set_data_format", file)
+ set_sample_type(ind, Mus_lintn)
+ snd_test_neq(sample_type(ind), Mus_lintn, "%s set_sample_type", file)
set_srate(ind, cur_srate)
- set_frames(cur_samps, ind)
+ set_framples(cur_samps, ind)
set_channels(ind, cur_chans)
set_data_location(ind, cur_loc)
set_header_type(ind, cur_type)
- set_data_format(ind, cur_format)
+ set_sample_type(ind, cur_format)
close_sound(ind)
delete_file(file)
- end
+ end unless $with_test_motif
end
-# FIXME
-# with big file
+# XXX: with big file
#
# with_sound(:output, $bigger_snd, :srate, 44100, :play, false) do
# 72000.times do |i|
@@ -4160,22 +3811,23 @@ end
# end
# end
-$big_file_frames = 0
+$big_file_framples = 0
def test_04_05
- if File.exists?($bigger_snd)
+ if File.exist?($bigger_snd)
# ; silence as last .9 secs, so it probably wasn't written
- probable_frames = (44100 * 71999.1).floor
+ probable_framples = (44100 * 71999.1).floor
snd_test_neq(mus_sound_samples($bigger_snd), 3175160310, "bigger samples")
- snd_test_neq(mus_sound_frames($bigger_snd), 3175160310, "bigger frames")
- snd_test_neq(mus_sound_frames($bigger_snd), probable_frames, "bigger frames (probable)")
+ snd_test_neq(mus_sound_framples($bigger_snd), 3175160310, "bigger framples")
+ snd_test_neq(mus_sound_framples($bigger_snd), probable_framples,
+ "bigger framples (probable)")
snd_test_neq(mus_sound_length($bigger_snd), 6350320648, "bigger length")
snd_test_neq(mus_sound_duration($bigger_snd), 71999.1015, "bigger dur")
ind = open_sound($bigger_snd)
- snd_test_neq(frames(ind), 3175160310, "bigger frames")
- $big_file_frames = frames(ind)
- snd_test_neq(frames(ind), probable_frames, "bigger frames (probable)")
- snd_test_neq(frames(ind, 0, 0), $big_file_frames, "bigger edpos-frames")
+ snd_test_neq(framples(ind), 3175160310, "bigger framples")
+ $big_file_framples = framples(ind)
+ snd_test_neq(framples(ind), probable_framples, "bigger framples (probable)")
+ snd_test_neq(framples(ind, 0, 0), $big_file_framples, "bigger edpos-framples")
m1 = add_mark(44100 * 50000, ind)
snd_test_neq(mark_sample(m1), 44100 * 50000, "bigger mark at")
set_mark_sample(m1, 44100 * 66000)
@@ -4195,12 +3847,12 @@ def test_04_05
old_select = selection_creates_region
set_selection_creates_region(false)
select_all(ind)
- snd_test_neq(selection_frames(), frames(ind), "bigger select all")
+ snd_test_neq(selection_framples(), framples(ind), "bigger select all")
set_selection_position(44100 * 50000)
snd_test_neq(selection_position(), 44100 * 50000, "bigger select pos")
set_selection_position(0)
- set_selection_frames(44100 * 65000)
- snd_test_neq(selection_frames(), 44100 * 65000, "bigger select len")
+ set_selection_framples(44100 * 65000)
+ snd_test_neq(selection_framples(), 44100 * 65000, "bigger select len")
set_selection_creates_region(old_select)
set_cursor(44100 * 50000, ind)
snd_test_neq(cursor(ind), 44100 * 50000, "bigger cursor")
@@ -4218,11 +3870,11 @@ def test_04_05
end
def test_04_06
- ind = new_sound("tmp.snd", Mus_riff, Mus_l24int, 22050, 1, :size, 100000)
+ ind = new_sound("tmp.snd", 1, 22050, Mus_l24int, Mus_riff, :size, 100000)
old_selection_creates_region = selection_creates_region()
set_selection_creates_region(true)
x = -0.5
- incr = 1.0 / frames()
+ incr = 1.0 / framples()
map_channel(lambda do |n|
val = x
x += incr
@@ -4234,10 +3886,12 @@ def test_04_06
reg = select_all
[[:Mus_next, :Mus_l24int],
[:Mus_aifc, :Mus_l24int]].each do |ht, df|
- save_selection("tmp1.snd", Module.const_get(ht), Module.const_get(df))
+ save_selection("tmp1.snd", 44100,
+ Module.const_get(df),
+ Module.const_get(ht))
ind1 = open_sound("tmp1.snd")
x = -0.5
- incr = 1.0 / frames()
+ incr = 1.0 / framples()
err = scan_channel(lambda do |n|
val = x
x += incr
@@ -4248,10 +3902,10 @@ def test_04_06
end
close_sound(ind1)
end
- save_region(reg, "tmp1.snd", Mus_next, Mus_l24int)
+ save_region(reg, "tmp1.snd", Mus_l24int, Mus_next)
ind1 = open_sound("tmp1.snd")
x = -0.5
- incr = 1.0 / frames()
+ incr = 1.0 / framples()
err = scan_channel(lambda do |n|
val = x
x += incr
@@ -4266,12 +3920,14 @@ def test_04_06
delete_file("tmp.snd")
set_selection_creates_region(old_selection_creates_region)
#
- ind = new_sound("tmp.snd", Mus_next, Mus_bfloat, 22050, 1, :size, 10, :comment, false)
+ ind = new_sound("tmp.snd", 1, 22050, Mus_bfloat, Mus_next,
+ :size, 10, :comment, false)
map_channel($init_channel)
env_channel([0.0, 0.0, 0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4,
0.5, 0.5, 0.6, 0.6, 0.7, 0.7, 0.8, 0.8, 0.9, 0.9])
snd_test_neq(channel2vct(),
- vct(0.000, 0.100, 0.200, 0.300, 0.400, 0.500, 0.600, 0.700, 0.800, 0.900),
+ vct(0.000, 0.100, 0.200, 0.300, 0.400,
+ 0.500, 0.600, 0.700, 0.800, 0.900),
"ramp env by 0.1")
close_sound(ind)
end
@@ -4361,7 +4017,7 @@ def test_04_07
mus_sound_forget("test.snd")
end
-def make_aifc_file(frames, auth_lo, bits)
+def make_aifc_file(framples, auth_lo, bits)
File.open("test.aif", "w") do |fp|
fp.write "FORM"
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0146); # len
@@ -4371,7 +4027,7 @@ def make_aifc_file(frames, auth_lo, bits)
fp.write "COMM"
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0046); # COMM chunk size
fp.putc(0000); fp.putc(0001); # 1 chan
- fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(frames); # frames
+ fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(framples); # framples
fp.putc(0000); fp.putc(bits); # bits
fp.putc(0100); fp.putc(0016); fp.putc(0254); fp.putc(0104); fp.putc(0000);
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000);
@@ -4399,7 +4055,7 @@ def read_ascii(in_filename,
out_format = Mus_bshort,
out_srate = 44100)
in_buffer = IO.readlines(in_filename) # array of strings
- out_snd = new_sound(out_filename, out_type, out_format, out_srate, 1,
+ out_snd = new_sound(out_filename, 1, out_srate, out_format, out_type,
format("created by %s: %s", get_func_name, in_filename))
bufsize = 512
data = make_vct(bufsize)
@@ -4437,7 +4093,7 @@ def test_04_08
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000); # comment
fp.putc(0000); fp.putc(0001); # samp 1
end
- snd_test_neq(mus_sound_data_format("test.snd"), Mus_bshort, "next 18")
+ snd_test_neq(mus_sound_sample_type("test.snd"), Mus_bshort, "next 18")
delete_file("test.snd")
mus_sound_forget("test.snd")
File.open("test.snd", "w") do |fp|
@@ -4469,7 +4125,7 @@ def test_04_08
end
res = Snd.catch do open_sound("test.snd") end.first
if number?(res) and sound?(res)
- snd_display("open_sound next bad format %s: %s?", data_format(res), res)
+ snd_display("open_sound next bad format %s: %s?", sample_type(res), res)
close_sound(res)
end
delete_file("test.snd")
@@ -4482,7 +4138,7 @@ def test_04_08
make_aifc_file(0102, 004, 020)
Snd.catch do
ind = open_sound("test.aif")
- snd_test_neq(frames(ind), 2, "bad frames in header")
+ snd_test_neq(framples(ind), 2, "bad framples in header")
close_sound(ind)
end
delete_file("test.aif")
@@ -4490,7 +4146,8 @@ def test_04_08
make_aifc_file(002, 150, 020)
res = Snd.catch do open_sound("test.aif") end.first
if number?(res) and sound?(res)
- snd_display("open_sound aifc no ssnd chunk %s: %s?", data_location(res), res)
+ snd_display("open_sound aifc no ssnd chunk %s: %s?",
+ data_location(res), res)
close_sound(res)
end
delete_file("test.aif")
@@ -4506,7 +4163,7 @@ def test_04_08
make_aifc_file(002, 150, 120)
res = Snd.catch do open_sound("test.aif") end.first
if number?(res) and sound?(res)
- snd_display("open_sound aifc bits 80 %s: %s?", data_format(res), res)
+ snd_display("open_sound aifc bits 80 %s: %s?", sample_type(res), res)
close_sound(res)
end
delete_file("test.aif")
@@ -4520,7 +4177,7 @@ def test_04_08
fp.write "COMM"
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0046); # COMM chunk size
fp.putc(0000); fp.putc(0001); # 1 chan
- fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0002); # frames
+ fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0002); # framples
fp.putc(0000); fp.putc(0020); # bits
fp.putc(0100); fp.putc(0016); fp.putc(0254); fp.putc(0104); fp.putc(0000);
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000);
@@ -4550,7 +4207,8 @@ def test_04_08
fp.putc(0000); fp.putc(0101); fp.putc(0000); fp.putc(0100); # two samples
end
Snd.catch do
- snd_test_neq(mus_sound_comment("test.aif").length, 15, "aifc 3 aux comments")
+ snd_test_neq(mus_sound_comment("test.aif").length, 15,
+ "aifc 3 aux comments")
end
delete_file("test.aif")
mus_sound_forget("test.aif")
@@ -4566,7 +4224,7 @@ def test_04_08
fp.write "COMM"
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0046); # COMM chunk size
fp.putc(0000); fp.putc(0001); # 1 chan
- fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0002); # frames
+ fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0002); # framples
fp.putc(0000); fp.putc(0020); # bits
fp.putc(0100); fp.putc(0016); fp.putc(0254); fp.putc(0104); fp.putc(0000);
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000);
@@ -4583,9 +4241,10 @@ def test_04_08
fp.putc(0000);
end
Snd.catch do
- snd_test_neq(mus_sound_comment("test.aif")[0..2], "bil", "aifc trailing comt comments")
+ snd_test_neq(mus_sound_comment("test.aif")[0..2], "bil",
+ "aifc trailing comt comments")
end
- snd_test_neq(mus_sound_frames("test.aif"), 2, "aifc trailing comt frames")
+ snd_test_neq(mus_sound_framples("test.aif"), 2, "aifc trailing comt framples")
Snd.catch do
ind = open_sound("test.aif")
if fneq(sample(0), 0.00198) or
@@ -4611,7 +4270,7 @@ def test_04_08
fp.write "COMM"
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0046); # COMM chunk size
fp.putc(0000); fp.putc(0001); # 1 chan
- fp.putc(0000); fp.putc(0000); fp.putc(0100); fp.putc(0102); # frames
+ fp.putc(0000); fp.putc(0000); fp.putc(0100); fp.putc(0102); # framples
fp.putc(0000); fp.putc(0020); # bits
fp.putc(0100); fp.putc(0016); fp.putc(0254); fp.putc(0104); fp.putc(0000);
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000);
@@ -4627,8 +4286,10 @@ def test_04_08
fp.write "bil"
fp.putc(0000);
end
- snd_test_neq(mus_sound_comment("test.aif")[0..2], "bil", "aifc trailing comt comment")
- snd_test_neq(mus_sound_frames("test.aif"), 2, "aifc trailing comt (bogus) frames")
+ snd_test_neq(mus_sound_comment("test.aif")[0..2], "bil",
+ "aifc trailing comt comment")
+ snd_test_neq(mus_sound_framples("test.aif"), 2,
+ "aifc trailing comt (bogus) framples")
Snd.catch do
ind = open_sound("test.aif")
if fneq(sample(0), 0.00198) or
@@ -4654,7 +4315,7 @@ def test_04_08
fp.write "COMM"
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0046); # COMM chunk size
fp.putc(0000); fp.putc(0001); # 1 chan
- fp.putc(0000); fp.putc(0000); fp.putc(0100); fp.putc(0102); # frames
+ fp.putc(0000); fp.putc(0000); fp.putc(0100); fp.putc(0102); # framples
fp.putc(0000); fp.putc(0020); # bits
fp.putc(0100); fp.putc(0016); fp.putc(0254); fp.putc(0104); fp.putc(0000);
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000);
@@ -4670,7 +4331,8 @@ def test_04_08
end
res = Snd.catch do open_sound("test.aif") end.first
if number?(res) and sound?(res)
- snd_display("open_sound aifc 2 ssnd chunks %s: %s?", data_location(res), res)
+ snd_display("open_sound aifc 2 ssnd chunks %s: %s?",
+ data_location(res), res)
close_sound(res)
end
delete_file("test.aif")
@@ -4705,7 +4367,7 @@ def test_04_08
fp.write "COMM"
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0046); # COMM chunk size
fp.putc(0000); fp.putc(0001); # 1 chan
- fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0002); # frames
+ fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0002); # framples
fp.putc(0000); fp.putc(0020); # bits
fp.putc(0100); fp.putc(0016); fp.putc(0254); fp.putc(0104); fp.putc(0000);
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000);
@@ -4739,7 +4401,7 @@ def test_04_08
snd_test_neq(gen.call(2), 0.00000, "file2sample chunked eof")
snd_test_neq(gen.call(3), 0.00000, "file2sample chunked eof+1")
res = open_sound("test.aif")
- snd_test_neq(frames(res), 2, "chunked frames")
+ snd_test_neq(framples(res), 2, "chunked framples")
snd_test_neq(sample(0), 0.93948, "file chunked 0")
snd_test_neq(sample(1), 0.50195, "file chunked 1")
snd_test_neq(sample(2), 0.00000, "file chunked eof")
@@ -4747,7 +4409,7 @@ def test_04_08
close_sound(res)
end
Snd.catch do
- snd_test_neq(mus_sound_frames("test.aif"), 2, "chunked mus_sound_frames")
+ snd_test_neq(mus_sound_framples("test.aif"), 2, "chunked mus_sound_framples")
end
delete_file("test.aif")
mus_sound_forget("test.aif")
@@ -4767,7 +4429,7 @@ def test_04_08
fp.write "COMM"
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0046); # COMM chunk size
fp.putc(0000); fp.putc(0001); # 1 chan
- fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0002); # frames
+ fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0002); # framples
fp.putc(0000); fp.putc(0020); # bits
fp.putc(0100); fp.putc(0016); fp.putc(0254); fp.putc(0104); fp.putc(0000);
fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(0000);
@@ -4777,7 +4439,7 @@ def test_04_08
fp.write "not compressed"
fp.putc(0000);
fp.write "APPL"
- fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(?h);
+ fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(key_to_int(?h));
fp.write "CLM ;Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98"
fp.putc(0000);
end
@@ -4788,7 +4450,7 @@ def test_04_08
snd_test_neq(gen.call(2), 0.00000, "file2sample chunked eof")
snd_test_neq(gen.call(3), 0.00000, "file2sample chunked eof+1")
res = open_sound("test.aif")
- snd_test_neq(frames(res), 2, "chunked frames")
+ snd_test_neq(framples(res), 2, "chunked framples")
snd_test_neq(sample(0), 0.93948, "file chunked 0")
snd_test_neq(sample(1), 0.50195, "file chunked 1")
snd_test_neq(sample(2), 0.00000, "file chunked eof")
@@ -4826,7 +4488,7 @@ def test_04_08
fp.write "not compressed"
fp.putc(0000);
fp.write "APPL"
- fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(?h);
+ fp.putc(0000); fp.putc(0000); fp.putc(0000); fp.putc(key_to_int(?h));
fp.write "CLM ;Written Mon 02-Nov-98 01:44 CST by root at ockeghem (Linux/X86) using Allegro CL, clm of 20-Oct-98"
fp.putc(0000);
end
@@ -4837,7 +4499,7 @@ def test_04_08
snd_test_neq(gen.call(1, 0), 0.00000, "file2sample chunked eof (stereo)")
snd_test_neq(gen.call(1, 1), 0.00000, "file2sample chunked eof+1 (stereo)")
res = open_sound("test.aif")
- snd_test_neq(frames(res), 1, "chunked frames (1)")
+ snd_test_neq(framples(res), 1, "chunked framples (1)")
snd_test_neq(sample(0, res, 0), 0.93948, "file chunked 0 0")
snd_test_neq(sample(0, res, 1), 0.50195, "file chunked 0 1")
snd_test_neq(sample(1, res, 0), 0.00000, "file chunked eof (stereo)")
@@ -4855,7 +4517,8 @@ def test_04_08
snd_display("no sound files in %s?", Dir.pwd)
end
files1 = sound_files_in_directory()
- snd_test_neq(files1, files, "different sound files in %s and default?", Dir.pwd)
+ snd_test_neq(files1, files,
+ "different sound files in %s and default?", Dir.pwd)
files2 = sound_files_in_directory(".")
if files1 != files2 or files != files2
snd_display("sound_files_in_directory dot: %s but %s?:", files2, files)
@@ -4865,13 +4528,13 @@ def test_04_08
Snd.sounds.apply(:close_sound)
#
ind = new_sound(:size, 0)
- snd_test_neq(frames(ind), 0, "new_sound :size 0")
+ snd_test_neq(framples(ind), 0, "new_sound :size 0")
snd_test_neq(sample(0), 0.0, "new_sound :size 0 sample 0")
new_file_name = file_name(ind)
close_sound(ind)
delete_file(new_file_name)
ind = new_sound(:size, 1)
- snd_test_neq(frames(ind), 1, "new_sound :size 1")
+ snd_test_neq(framples(ind), 1, "new_sound :size 1")
snd_test_neq(sample(0), 0.0, "new_sound :size 1 sample 0")
new_file_name = file_name(ind)
close_sound(ind)
@@ -4886,10 +4549,10 @@ def test_04_08
snd_display("read_ascii cannot find %s (%s)?", file, ind.inspect)
end
snd_test_neq(maxamp(ind, 0), 0.723, "read_ascii maxamp")
- snd_test_neq(frames(ind, 0), 50000, "read_ascii frames")
+ snd_test_neq(framples(ind, 0), 50000, "read_ascii framples")
snd_test_neq(srate(ind), 44100, "read_ascii srate")
set_srate(ind, 8000)
- snd_test_neq(frames(ind, 0), 50000, "set srate clobbered new sound frames")
+ snd_test_neq(framples(ind, 0), 50000, "set srate clobbered new sound framples")
snd_test_neq(maxamp(ind, 0), 0.723, "set srate clobbered new sound maxamp")
close_sound(ind)
end
@@ -4899,7 +4562,8 @@ def test_04_08
close_sound(ind)
ind = open_sound("test space.snd")
snd_test_neq(short_file_name(ind), "test space.snd", "file name with space")
- snd_test_neq(mus_sound_frames("test space.snd"), frames(ind), "spaced filename frames")
+ snd_test_neq(mus_sound_framples("test space.snd"), framples(ind),
+ "spaced filename framples")
add_mark(1234, ind, 0)
save_marks(ind)
close_sound(ind)
@@ -4909,13 +4573,10 @@ def test_04_08
snd_display("space file name save marks: %s", marks(ind).inspect)
end
rd = make_readin(:file, "test space.snd")
- snd_test_neq(mus_file_name(rd), "test space.snd", "file name with space readin")
+ snd_test_neq(mus_file_name(rd), "test space.snd",
+ "file name with space readin")
close_sound(ind)
delete_files("test space.snd", "test space.marks")
- #
- # FIXME
- # S7 specific tests skipped
- #
end
def test_04
@@ -4927,7 +4588,6 @@ def test_04
clear_listener()
test_04_00
test_04_01
- test_04_02
test_04_03
test_04_04
test_04_05 if $with_big_file
@@ -4940,49 +4600,24 @@ end
# ---------------- test 05: simple overall checks ----------------
def test_edpos(ind1, func_sym, func_body = nil, &change_thunk)
- if proc?(func_body)
- fr1 = func_body.call(ind1, 0, false)
- fr2 = func_body.call(ind1, 0, 0)
- fr3 = func_body.call(ind1, 0, Current_edit_position)
- fr4 = func_body.call(ind1, 0, lambda do |snd, chn| 0 end)
- unless fr1 == fr2 and fr1 == fr3 and fr1 == fr4
- snd_display_prev_caller("initial %s: %s %s %s %s?", func_sym, fr1, fr2, fr3, fr4)
- end
- change_thunk.call
- fr5 = func_body.call(ind1, 0, false)
- fr6 = func_body.call(ind1, 0, 1)
- fr7 = func_body.call(ind1, 0, Current_edit_position)
- fr8 = func_body.call(ind1, 0, lambda do |snd, chn| edit_position(snd, chn) end)
- unless fr5 == fr6 and fr5 == fr7 and fr5 == fr8
- snd_display_prev_caller("%s (edpos 1): %s %s %s %s?", func_sym, fr5, fr6, fr7, fr8)
- end
- fr5 = func_body.call(ind1, 0, 0)
- fr6 = func_body.call(ind1, 0, lambda do |snd, chn| 0 end)
- unless fr1 == fr5 and fr1 == fr6
- snd_display_prev_caller("%s (edpos -1): %s %s %s?", func_sym, fr1, fr5, fr6)
- end
- else
- fr1 = snd_func(func_sym, ind1, 0, false)
- fr2 = snd_func(func_sym, ind1, 0, 0)
- fr3 = snd_func(func_sym, ind1, 0, Current_edit_position)
- fr4 = snd_func(func_sym, ind1, 0, lambda do |snd, chn| 0 end)
- unless fr1 == fr2 and fr1 == fr3 and fr1 == fr4
- snd_display_prev_caller("initial %s: %s %s %s %s?", func_sym, fr1, fr2, fr3, fr4)
- end
- change_thunk.call
- fr5 = snd_func(func_sym, ind1, 0, false)
- fr6 = snd_func(func_sym, ind1, 0, 1)
- fr7 = snd_func(func_sym, ind1, 0, Current_edit_position)
- fr8 = snd_func(func_sym, ind1, 0, lambda do |snd, chn| edit_position(snd, chn) end)
- unless fr5 == fr6 and fr5 == fr7 and fr5 == fr8
- snd_display_prev_caller("%s (edpos 1): %s %s %s %s?", func_sym, fr5, fr6, fr7, fr8)
- end
- fr5 = snd_func(func_sym, ind1, 0, 0)
- fr6 = snd_func(func_sym, ind1, 0, lambda do |snd, chn| 0 end)
- unless fr1 == fr5 and fr1 == fr6
- snd_display_prev_caller("%s (edpos -1): %s %s %s?", func_sym, fr1, fr5, fr6)
+ unless func_body
+ func_body = lambda do |snd, chn, val|
+ snd_func(func_sym, snd, chn, val)
end
end
+ fr1 = func_body.call(ind1, 0, false)
+ fr2 = func_body.call(ind1, 0, 0)
+ fr3 = func_body.call(ind1, 0, Current_edit_position)
+ if fr1 != fr2 or fr1 != fr3
+ snd_display_prev_caller("initial %s: %s %s %s?", func_sym, fr1, fr2, fr3)
+ end
+ change_thunk.call
+ fr5 = func_body.call(ind1, 0, false)
+ fr6 = func_body.call(ind1, 0, 1)
+ fr7 = func_body.call(ind1, 0, Current_edit_position)
+ if fr5 != fr6 or fr5 != fr7
+ snd_display_prev_caller("%s (edpos 1): %s %s %s?", func_sym, fr5, fr6, fr7)
+ end
revert_sound(ind1)
end
@@ -4991,18 +4626,14 @@ def test_edpos_1(func_sym, ind1, &body)
body.call(ind1, 0)
v1 = channel2vct(12000, 10, ind1, 0)
if vequal(v0, v1)
- snd_display_prev_caller(snd_format(v1, v0, "==", "%s (0) no change!", func_sym))
+ s = snd_format(v1, v0, "==", "%s (0) no change!", func_sym)
+ snd_display_prev_caller(s)
end
body.call(ind1, 0)
v2 = channel2vct(12000, 10, ind1, 0)
unless vequal(v1, v2)
snd_display_prev_caller(snd_format(v2, v1, "!=", "%s (1)", func_sym))
end
- body.call(ind1, lambda do |snd, chn| 0 end)
- v2 = channel2vct(12000, 10, ind1, 0)
- unless vequal(v1, v2)
- snd_display_prev_caller(snd_format(v2, v1, "!=", "%s (2)", func_sym))
- end
revert_sound(ind1)
end
@@ -5010,12 +4641,13 @@ def test_orig(func0, func1, name, ind1)
v0 = channel2vct(12000, 10, ind1, 0)
func0.call(ind1)
v1 = channel2vct(12000, 10, ind1, 0)
- if vfequal(v0, v1) # okay
- snd_display_prev_caller(snd_format(v1, v0, "==", "%s (orig 0) no change!", name))
+ if vfequal(v0, v1)
+ snd_display_prev_caller(snd_format(v1, v0, "==",
+ "%s (orig 0) no change!", name))
end
func1.call(ind1)
v2 = channel2vct(12000, 10, ind1, 0)
- unless vfequal(v0, v2) # okay
+ unless vfequal(v0, v2)
snd_display_prev_caller(snd_format(v2, v0, "!=", "%s (orig 1)", name))
end
revert_sound(ind1)
@@ -5034,30 +4666,27 @@ end
def check_maxamp(ind, val, name)
if fneq(maxamp(ind, 0), val)
- snd_display_prev_caller("maxamp amp_env %s: %s should be %s", name, maxamp(ind), val)
+ snd_display_prev_caller("maxamp amp_env %s: %s should be %s",
+ name, maxamp(ind), val)
end
- unless pos = find_channel(lambda do |y| y.abs >= (val - 0.0001) end)
+ pos = find_channel(lambda do |y| y.abs >= (val - 0.0001) end)
+ unless pos
snd_display_prev_caller("actual maxamp %s vals not right", name)
end
maxpos = maxamp_position(ind, 0)
if maxpos != pos
- snd_display_prev_caller("%s: find and maxamp_position disagree: %s (%s) %s (%s)?",
- name, pos, sample(pos, ind, 0), maxpos, sample(maxpos, ind, 0))
+ snd_display_prev_caller("%s: \
+find and maxamp_position disagree: %s (%s) %s (%s)?",
+ name, pos, sample(pos, ind, 0), maxpos, sample(maxpos, ind, 0))
end
- mx = 0.0
- ctr = 0
- mpos = 0
- scan_chan(lambda do |y|
- if fneq(y.abs, mx) and y.abs > mx
- mpos = ctr
- mx = y.abs
- end
- ctr += 1
- false
- end)
+ reader = make_sampler(0, ind, 0)
+ data = Vct.new(framples(ind, 0)) do |i|
+ next_sample(reader)
+ end
+ mx, mpos = vct_peak_and_location(data)
if mpos != maxpos
- snd_display_prev_caller("%s: scan_chan and maxamp_position disagree: %s %s?",
- name, mpos, maxpos)
+ snd_display_prev_caller("%s: scan and maxamp_position disagree: %s %s?",
+ name, mpos, maxpos)
end
if fneq(mx, val)
snd_display_prev_caller("actual %s max: %s (correct: %s)", name, mx, val)
@@ -5065,23 +4694,22 @@ def check_maxamp(ind, val, name)
end
def check_env_vals(name, gen)
- ctr = -1
- scan_chan(lambda do |y|
- ctr += 1
- if fneq(val = env(gen), y)
- snd_display_prev_caller(snd_format_neq(val, y,
- "%s %s at %d",
- get_func_name, name, ctr))
- true
- else
- false
- end
- end)
+ reader = make_sampler()
+ framples().times do |i|
+ val = env(gen)
+ y = next_sample(reader)
+ if fneq(val, y)
+ snd_display_prev_caller(snd_format_neq(val, y,
+ "%s %s at %d", get_func_name, name, i))
+ return
+ end
+ end
end
def our_x2position(ind, x)
ax = axis_info(ind, 0)
- [ax[10].to_f + ((x - ax[2]) * (ax[12].to_f - ax[10])) / (ax[4] - ax[2]), x2position(x, ind)]
+ [ax[10].to_f + ((x - ax[2]) * (ax[12].to_f - ax[10])) / (ax[4] - ax[2]),
+ x2position(x, ind)]
end
def region2vct_1(reg, chn, len)
@@ -5747,7 +5375,7 @@ def test_05_02
(at 10, end_mark)
")
ctr = 0
- if res = scan_chan(lambda do |y|
+ if res = scan_channel(lambda do |y|
if fneq(y, 0.5 * vals[ctr])
true
else
@@ -5765,7 +5393,7 @@ def test_05_02
(at 9, end_mark)
")
ctr = 1
- if res = scan_chan(lambda do |y|
+ if res = scan_channel(lambda do |y|
if fneq(y, vals[ctr])
true
else
@@ -5783,7 +5411,7 @@ def test_05_02
(at 8, end_mark)
")
ctr = 2
- if res = scan_chan(lambda do |y|
+ if res = scan_channel(lambda do |y|
if fneq(y, vals[ctr])
true
else
@@ -5827,7 +5455,7 @@ def test_05_02
(at 10, end_mark)
")
ctr = 0
- if res = scan_chan(lambda do |y|
+ if res = scan_channel(lambda do |y|
if (ctr > 5 and fneq(y, vals[ctr])) or
(ctr < 4 and fneq(y, vals[ctr])) or
((ctr == 4 or ctr == 5) and fneq(y, 0.5 * vals[ctr]))
@@ -6965,8 +6593,10 @@ def test_05_08
check1.call(data)
func2.call
check2.call(data)
- snd_test_neq(channel2vct, data, "3 case %s (%s (%s))", name2, name1, name)
- snd_test_neq(rev_channel2vct.call, data, "3 rev case %s (%s (%s))", name2, name1, name)
+ snd_test_neq(channel2vct, data, "3 case %s (%s (%s))",
+ name2, name1, name)
+ snd_test_neq(rev_channel2vct.call, data, "3 rev case %s (%s (%s))",
+ name2, name1, name)
end
end
end
@@ -7214,9 +6844,9 @@ def test_05_10
xz = x_zoom_slider
yz = y_zoom_slider
snd_test_neq(snd_completion(" open-so"), " open-sound", "completion (1)")
- # FIXME
- # Zoom_focus_right (constant) replaced by zoom_focus_style
- snd_test_neq(snd_completion(" zoom_focus_s"), " zoom_focus_style", "completion (2)")
+ # XXX: Zoom_focus_right (constant) replaced with zoom_focus_style
+ snd_test_neq(snd_completion(" zoom_focus_s"), " zoom_focus_style",
+ "completion (2)")
play("oboe.snd", :wait, true)
play("oboe.snd", :start, 12000, :wait, true)
play("oboe.snd", :start, 12000, :end, 15000, :wait, true)
@@ -7234,54 +6864,54 @@ def test_05_10
set_speed_control(old_speed, ind)
set_speed_control_style(old_style)
set_show_controls(old_open, ind)
- bomb(ind, true)
k = disk_kspace("oboe.snd")
if (not number?(k)) or k <= 0
snd_display("disk_kspace = %s", k)
end
k = disk_kspace("/baddy/hiho")
- # FIXME
- # #if !USE_STATFS in snd-file.c
- # disk_kspace returns 1234567
- if k != 1234567 and k != -1
- snd_display("disk_kspace of bogus file = %s", k)
- end
- snd_test_neq(transform_frames, 0, "transform_frames")
+ snd_test_neq(k, -1, "disk_kspace of bogus file")
+ snd_test_neq(transform_framples, 0, "transform_framples")
set_transform_size(512)
set_transform_graph?(true)
- unless (res = fft_peak(ind, 0, 1.0))
- snd_display("fft_peak %s?", res.inspect)
- end
set_time_graph?(true)
#
- Snd.catch(:all, lambda do |*args| snd_display("axis label error: %s", args) end) do
+ Snd.catch(:all, lambda do |*args|
+ snd_display("axis label error: %s", args)
+ end) do
snd_test_neq(x_axis_label(), "time", "def time x_axis_label")
set_x_axis_label("no time", ind, 0, Time_graph)
snd_test_neq(x_axis_label(), "no time", "set time x_axis_label")
update_transform_graph
- snd_test_neq(x_axis_label(ind, 0, Transform_graph), "frequency", "get fft x_axis_label")
+ snd_test_neq(x_axis_label(ind, 0, Transform_graph), "frequency",
+ "get fft x_axis_label")
set_x_axis_label("hiho", ind, 0, Transform_graph)
update_transform_graph
- snd_test_neq(x_axis_label(ind, 0, Transform_graph), "hiho", "set fft x_axis_label")
+ snd_test_neq(x_axis_label(ind, 0, Transform_graph), "hiho",
+ "set fft x_axis_label")
set_x_axis_label("frequency", ind, 0, Transform_graph) # for later test
#
graph([0, 0, 1, 1, 2, 0], "lisp")
update_lisp_graph
- snd_test_neq(x_axis_label(ind, 0, Lisp_graph), "lisp", "def lisp x_axis_label")
+ snd_test_neq(x_axis_label(ind, 0, Lisp_graph), "lisp",
+ "def lisp x_axis_label")
set_x_axis_label("no lisp", ind, 0, Lisp_graph)
- snd_test_neq(x_axis_label(ind, 0, Lisp_graph), "no lisp", "lisp x_axis_label")
+ snd_test_neq(x_axis_label(ind, 0, Lisp_graph), "no lisp",
+ "lisp x_axis_label")
#
set_y_axis_label("no amp", ind, 0, Time_graph)
snd_test_neq(y_axis_label(), "no amp", "time y_axis_label")
set_y_axis_label("no lamp", ind, 0, Lisp_graph)
- snd_test_neq(y_axis_label(ind, 0, Lisp_graph), "no lamp", "lisp y_axis_label")
+ snd_test_neq(y_axis_label(ind, 0, Lisp_graph), "no lamp",
+ "lisp y_axis_label")
set_y_axis_label(false)
set_y_axis_label("no amp", ind, 0)
snd_test_neq(y_axis_label(), "no amp", "time y_axis_label")
set_y_axis_label(false, ind)
end
- #
- graph_data(make_vct(4))
+ #
+ cr = make_cairo(channel_widgets(ind, 0)[0])
+ graph_data(make_vct(4), ind, 0, Copy_context, false, false, Graph_lines, cr)
+ free_cairo(cr)
update_lisp_graph
graph(vct(0, 0, 1, 1, 2, 0))
32.times do
@@ -7298,28 +6928,34 @@ def test_05_10
left_sample,
right_sample)
mid = (0.5 * data.length).round
- snd_test_neq(sample(left_sample + mid), data[mid], "make_graph_data[%d]", mid)
+ snd_test_neq(sample(left_sample + mid), data[mid],
+ "make_graph_data[%d]", mid)
end
data = make_graph_data(ind, 0, 0, 100, 199)
if vct?(data)
snd_test_neq(data.length, 100, "make_graph_data 100:199")
- snd_test_neq(sample(50), data[50], "make_graph_data")
+ snd_test_neq(sample(50), data[50], "make_graph_data 50")
end
set_x_bounds([0.0, 0.1])
update_transform_graph
- Snd.catch(:no_such_axis, lambda do |*args| snd_display("transform axis not displayed?") end) do
- snd_test_neq(x_axis_label(ind, 0, Transform_graph), "frequency", "def fft x_axis_label")
+ Snd.catch(:no_such_axis, lambda do |*args|
+ snd_display("transform axis not displayed?")
+ end) do
+ snd_test_neq(x_axis_label(ind, 0, Transform_graph), "frequency",
+ "def fft x_axis_label")
set_x_axis_label("fourier", ind, 0, Transform_graph)
- snd_test_neq(x_axis_label(ind, 0, Transform_graph), "fourier", "fft x_axis_label")
+ snd_test_neq(x_axis_label(ind, 0, Transform_graph), "fourier",
+ "fft x_axis_label")
set_x_axis_label("hiho")
#
set_y_axis_label("spectra", ind, 0, Transform_graph)
- snd_test_neq(y_axis_label(ind, 0, Transform_graph), "spectra", "fft y_axis_label")
+ snd_test_neq(y_axis_label(ind, 0, Transform_graph), "spectra",
+ "fft y_axis_label")
set_y_axis_label("hiho")
end
#
- if number?(transform_frames) and transform_frames.zero?
- snd_display("transform_graph? transform-frames: %s?", trandform_frames)
+ if number?(transform_framples) and transform_framples.zero?
+ snd_display("transform_graph? transform-framples: %s?", trandform_framples)
end
update_transform_graph
if (tag = Snd.catch do peaks("/baddy/hiho") end).first != :cant_open_file
@@ -7335,8 +6971,10 @@ def test_05_10
end
delete_file("tmp.peaks")
peaks()
- if $with_test_motif and (!dialog_widgets[20] or !RXtIsManaged(dialog_widgets[20]))
- snd_display("peaks but no help?")
+ if $with_test_motif
+ if (not dialog_widgets[15]) or (not RXtIsManaged(dialog_widgets[15]))
+ snd_display("peaks but no help?")
+ end
end
dismiss_all_dialogs
num_transforms = 6
@@ -7381,19 +7019,22 @@ def test_05_10
delete_file(psf)
set_graph_style(i)
graph2ps
- unless File.exists?(psf)
+ unless File.exist?(psf)
snd_display("graph2ps: %s?", psf)
end
delete_file(psf)
end
end
set_graph_style(old_gstyle)
- if (err = Snd.catch(:cannot_print, 12345) do graph2ps("/bad/bad.eps") end).first != 12345
+ err = Snd.catch(:cannot_print, 12345) do graph2ps("/bad/bad.eps") end
+ if err.first != 12345
snd_display("graph2ps err: %s?", err.inspect)
end
n2 = open_sound("2.snd") or open_sound("4.aiff")
set_transform_graph?(true, n2)
- [Channels_superimposed, Channels_combined, Channels_separate].each do |style|
+ [Channels_superimposed,
+ Channels_combined,
+ Channels_separate].each do |style|
set_channel_style(style, n2)
snd_test_neq(channel_style(n2), style, "channel_style")
graph2ps("aaa.eps")
@@ -7427,19 +7068,21 @@ def test_05_10
[[:sound?, true],
[:chans, 1],
[:channels, 1],
- [:frames, 50828],
+ [:framples, 50828],
[:srate, 22050],
[:data_location, 28],
[:data_size, 50828 * 2],
- [:data_format, Mus_bshort],
+ [:sample_type, Mus_bshort],
[:maxamp, 0.14724],
[:maxamp_position, 24971],
[:comment, ""]].each do |func, val|
snd_test_neq(snd_func(func, ind), val, "oboe")
end
snd_test_neq(short_file_name(ind), "oboe.snd", "oboe: short name")
- snd_test_neq(count_matches(lambda do |y| y > 0.125 end), 1314, "oboe: count_matches")
- snd_test_neq(count_matches(lambda do |y| y > 0.1 end), 2852, "oboe: unopt count_matches")
+ snd_test_neq(count_matches(lambda do |y| y > 0.125 end), 1314,
+ "oboe: count_matches")
+ snd_test_neq(count_matches(lambda do |y| y > 0.1 end), 2852,
+ "oboe: unopt count_matches")
spot = find_channel(lambda do |y| y > 0.13 end)
if spot.kind_of?(FalseClass) or spot != 8862
snd_display("find: %s?", spot)
@@ -7460,7 +7103,6 @@ def test_05_10
snd_display("edit_position: %s %s?", edit_position, eds)
end
play(ind, :channel, 0, :wait, true)
- bomb(ind, false)
select_all(ind, 0)
r0 = regions.first
unless selection?
@@ -7472,11 +7114,13 @@ def test_05_10
snd_test_neq(selection_chans, 1, "selection_chans (1)")
snd_test_neq(selection_srate, srate(ind), "selection_srate")
snd_test_neq(region_maxamp(r0), maxamp(ind), "region_maxamp (1)")
- snd_test_neq(region_maxamp_position(r0), maxamp_position(ind), "region_maxamp_position (1)")
+ snd_test_neq(region_maxamp_position(r0), maxamp_position(ind),
+ "region_maxamp_position (1)")
snd_test_neq(selection_maxamp(ind, 0), maxamp(ind), "selection_maxamp (1)")
- snd_test_neq(selection_maxamp_position(ind, 0), maxamp_position(ind), "selection_maxamp_position (1)")
+ snd_test_neq(selection_maxamp_position(ind, 0), maxamp_position(ind),
+ "selection_maxamp_position (1)")
save_region(r0, "temp.dat")
- if File.exists?("temp.dat")
+ if File.exist?("temp.dat")
File.unlink("temp.dat")
else
snd_display("save_region file disappeared?")
@@ -7490,18 +7134,18 @@ def test_05_10
end
[[:region_srate, 22050],
[:region_chans, 1],
- [:region_frames, 50828],
+ [:region_framples, 50828],
[:region_home, ["oboe.snd", 0, 50827]]].each do |func, req|
snd_test_neq(snd_func(func, r0), req, "%s", func)
end
- snd_test_neq(selection_frames, 50828, "selection_frames")
+ snd_test_neq(selection_framples, 50828, "selection_framples")
snd_test_neq(selection_position, 0, "selection_position")
snd_test_neq(region_position(r0, 0), 0, "region_position")
snd_test_neq(region_maxamp(r0), maxamp(ind), "region_maxamp (2)")
snd_test_neq(selection_maxamp(ind, 0), maxamp(ind), "selection_maxamp (2)")
[[:region_srate, 22050],
[:region_chans, 1],
- [:region_frames, 50828],
+ [:region_framples, 50828],
[:region_maxamp, maxamp(ind)]].each do |func, req|
snd_test_neq(snd_func(func, r0), req, "%s", func)
end
@@ -7530,7 +7174,8 @@ def test_05_10
50827.times do |i|
val = (i % 2).nonzero? ? next_sample(rd) : read_sample(rd)
if val != samps1[i] or val != samps2[i]
- snd_display("readers disagree at %s (%s %s %s)", i, val, samps1[i], samps2[i])
+ snd_display("readers disagree at %s (%s %s %s)",
+ i, val, samps1[i], samps2[i])
break
end
end
@@ -7568,7 +7213,8 @@ def test_05_10
end
revert_sound(ind)
insert_sample(100, 0.5, ind)
- if (res = Snd.catch do insert_sound("oboe.snd", 0, 1) end).first != :no_such_channel
+ res = Snd.catch do insert_sound("oboe.snd", 0, 1) end
+ if res.first != :no_such_channel
snd_display("insert_sound bad chan (1): %s", res.inspect)
end
if (res = Snd.catch do insert_sample(-12, 1.0) end).first != :no_such_sample
@@ -7578,22 +7224,23 @@ def test_05_10
update_transform_graph(ind)
update_time_graph(ind)
snd_test_neq(sample(100), 0.5, "insert_sample (100)")
- snd_test_neq(frames(ind), 50829, "insert_sample (frames)")
+ snd_test_neq(framples(ind), 50829, "insert_sample (framples)")
v0 = Array.new(3, 0.25)
v1 = make_vct(3, 0.75)
insert_samples(200, 3, v0, ind)
insert_samples(300, 3, v1, ind)
snd_test_neq(sample(201), 0.25, "insert_samples (201)")
snd_test_neq(sample(301), 0.75, "insert_samples (301)")
- snd_test_neq(frames(ind), 50835, "insert_samples (frames)")
- save_sound_as("hiho.snd", ind, Mus_next, Mus_bshort, :srate, 22050)
+ snd_test_neq(framples(ind), 50835, "insert_samples (framples)")
+ save_sound_as("hiho.snd", ind, 22050, Mus_bshort, Mus_next)
nind = view_sound("hiho.snd")
snd_test_neq(sample(101, nind), sample(101, ind), "save_sound_as")
unless read_only(nind)
snd_display("read_only view_sound: %s?", read_only(nind))
end
set_speed_control_style(Speed_control_as_semitone, nind)
- snd_test_neq(speed_control_style(nind), Speed_control_as_semitone, "speed_control_style set semi")
+ snd_test_neq(speed_control_style(nind), Speed_control_as_semitone,
+ "speed_control_style set semi")
set_speed_control_tones(-8, nind)
snd_test_neq(speed_control_tones(nind), 12, "speed_control_tones -8")
set_speed_control_tones(18, nind)
@@ -7608,17 +7255,19 @@ def test_05_10
snd_test_neq(sample(60), 0.25, "set_samples (60)")
snd_test_neq(sample(61), 0.25, "set_samples (61)")
set_samples(10, 3, [0.1, 0.2, 0.3], ind)
- snd_test_neq(channel2vct(10, 3, ind), vct(0.1, 0.2, 0.3), "set_samples via list")
+ snd_test_neq(channel2vct(10, 3, ind), vct(0.1, 0.2, 0.3),
+ "set_samples via list")
revert_sound(ind)
save_sound_as("temporary.snd", ind)
set_samples(100000, 20000, "temporary.snd", ind)
- snd_test_neq(channel2vct(110000, 10), channel2vct(10000, 10), "set_samples to self")
+ snd_test_neq(channel2vct(110000, 10), channel2vct(10000, 10),
+ "set_samples to self")
revert_sound(ind)
delete_file("temporary.snd")
delete_sample(100, ind)
- snd_test_neq(frames(ind), 50827, "delete_sample")
+ snd_test_neq(framples(ind), 50827, "delete_sample")
delete_samples(0, 100, ind)
- snd_test_neq(frames(ind), 50727, "delete_samples")
+ snd_test_neq(framples(ind), 50727, "delete_samples")
revert_sound(ind)
maxa = maxamp(ind)
scale_to(0.5, ind)
@@ -7671,8 +7320,8 @@ def test_05_10
revert_sound(ind)
s100 = sample(100)
s40 = sample(40)
- len = frames
- addlen = mus_sound_frames("fyow.snd")
+ len = framples
+ addlen = mus_sound_framples("fyow.snd")
old_csize = cursor_size
old_cstyle = cursor_style
set_cursor_style(Cursor_line)
@@ -7688,16 +7337,20 @@ def test_05_10
set_cursor(20, ind, 0)
if $with_test_gui
set_cursor_style(lambda do |snd, chn, ax|
- x, y = cursor_position
- size = (cursor_size / 2.0).round
- draw_line(x - size, y - size, x + size, y + size, snd, chn, Cursor_context)
- draw_line(x - size, y + size, x + size, y - size, snd, chn, Cursor_context)
- end,
- ind, 0)
+ x, y = cursor_position
+ size = (cursor_size / 2.0).round
+ cr = make_cairo(channel_widgets(snd, chn)[0])
+ draw_line(x - size, y - size, x + size, y + size,
+ snd, chn, Cursor_context, cr)
+ draw_line(x - size, y + size, x + size, y - size,
+ snd, chn, Cursor_context, cr)
+ free_cairo(cr)
+ end, ind, 0)
unless proc?(res = cursor_style(ind, 0))
snd_display("set_cursor_style to Proc: %s", res)
end
end
+
set_cursor_size(old_csize)
set_cursor_style(old_cstyle)
set_cursor(50, ind)
@@ -7706,16 +7359,17 @@ def test_05_10
snd_test_neq(sample(40), s40, "insert_sound s40")
snd_test_eq(ss100, s100, "insert_sound s100")
snd_test_neq(ss100, 0.001831, "insert_sound")
- snd_test_neq(frames, addlen + len, "insert_sound len")
+ snd_test_neq(framples, addlen + len, "insert_sound len")
save_sound_as("not-temporary.snd")
insert_samples(0, 100, "not-temporary.snd")
- set_cursor(frames(ind, 0, 0) - 2, ind, 0, 0)
+ set_cursor(framples(ind, 0, 0) - 2, ind, 0, 0)
revert_sound
- snd_test_neq(cursor(ind, 0), frames(ind, 0, 0) - 2, "set edpos cursor %s", cursor)
+ snd_test_neq(cursor(ind, 0), framples(ind, 0, 0) - 2,
+ "set edpos cursor %s", cursor)
delete_file("not-temporary.snd")
id = make_region(0, 99)
insert_region(id, 60, ind)
- snd_test_neq(frames, len + 100, "insert_region len")
+ snd_test_neq(framples, len + 100, "insert_region len")
snd_test_neq(sample(100), s40, "insert_region")
if (res = Snd.catch do
regmax = if regions
@@ -7730,76 +7384,83 @@ def test_05_10
save_region(id, "fmv.snd")
region_srate(id)
region_chans(id)
- region_frames(id)
+ region_framples(id)
[[:mus_sound_header_type, Mus_next],
- [:mus_sound_data_format, Mus_out_format],
+ [:mus_sound_sample_type, Mus_out_format],
[:mus_sound_srate, region_srate(id)],
[:mus_sound_chans, region_chans(id)],
- [:mus_sound_frames, region_frames(id)]].each do |func, req|
+ [:mus_sound_framples, region_framples(id)]].each do |func, req|
snd_test_neq(snd_func(func, "fmv.snd"), req, "save_region (1) %s", func)
end
if region_position(id, 0).nonzero?
snd_display("save_region position: %s", region_position(id, 0))
end
delete_file("fmv.snd")
- save_region(id, "fmv.snd", Mus_riff, Mus_lshort, "this is a comment")
+ save_region(id, "fmv.snd", Mus_lshort, Mus_riff, "this is a comment")
[[:mus_sound_header_type, Mus_riff],
- [:mus_sound_data_format, Mus_lshort],
+ [:mus_sound_sample_type, Mus_lshort],
[:mus_sound_comment, "this is a comment"],
- [:mus_sound_frames, region_frames(id)]].each do |func, req|
+ [:mus_sound_framples, region_framples(id)]].each do |func, req|
snd_test_neq(snd_func(func, "fmv.snd"), req, "save_region (2) %s", func)
end
delete_file("fmv.snd")
save_region(id,
:file, "fmv.snd",
:header_type, Mus_riff,
- :data_format, Mus_lshort,
+ :sample_type, Mus_lshort,
:comment, "this is a comment")
[[:mus_sound_header_type, Mus_riff],
- [:mus_sound_data_format, Mus_lshort],
+ [:mus_sound_sample_type, Mus_lshort],
[:mus_sound_comment, "this is a comment"],
- [:mus_sound_frames, region_frames(id)]].each do |func, req|
- snd_test_neq(snd_func(func, "fmv.snd"), req, "save_region opt (3) %s", func)
+ [:mus_sound_framples, region_framples(id)]].each do |func, req|
+ snd_test_neq(snd_func(func, "fmv.snd"), req,
+ "save_region opt (3) %s", func)
end
delete_file("fmv.snd")
save_region(id,
:comment, "this is a comment",
:file, "fmv.snd",
- :data_format, Mus_lshort,
+ :sample_type, Mus_lshort,
:header_type, Mus_riff)
[[:mus_sound_header_type, Mus_riff],
- [:mus_sound_data_format, Mus_lshort],
+ [:mus_sound_sample_type, Mus_lshort],
[:mus_sound_comment, "this is a comment"],
- [:mus_sound_frames, region_frames(id)]].each do |func, req|
- snd_test_neq(snd_func(func, "fmv.snd"), req, "save_region opt1 (4) %s", func)
+ [:mus_sound_framples, region_framples(id)]].each do |func, req|
+ snd_test_neq(snd_func(func, "fmv.snd"), req,
+ "save_region opt1 (4) %s", func)
end
delete_file("fmv.snd")
- save_region(id, "fmv.snd", :data_format, Mus_bshort)
+ save_region(id, "fmv.snd", :sample_type, Mus_bshort)
[[:mus_sound_header_type, Mus_next],
- [:mus_sound_data_format, Mus_bshort],
- [:mus_sound_frames, region_frames(id)]].each do |func, req|
- snd_test_neq(snd_func(func, "fmv.snd"), req, "save_region opt2 (5) %s", func)
+ [:mus_sound_sample_type, Mus_bshort],
+ [:mus_sound_framples, region_framples(id)]].each do |func, req|
+ snd_test_neq(snd_func(func, "fmv.snd"), req,
+ "save_region opt2 (5) %s", func)
end
delete_files("fmv.snd", "aaa.eps")
close_sound(ind)
end
def test_05_11
- if (res = Snd.catch do new_sound("hi.snd", 0, 1, 100, 0) end).first != :out_of_range
+ res = Snd.catch do new_sound("hi.snd", :channels, 0) end
+ if res.first != :out_of_range
snd_display("new_sound bad chan: %s?", res)
end
#
- ind = new_sound("fmv.snd", Mus_next, Mus_bshort, 22050, 2, "unequal lens")
+ ind = new_sound("fmv.snd", 2, 22050, Mus_ldouble, Mus_next, "unequal lens")
insert_silence(0, 1000, ind, 1)
- if (res1 = frames(ind, 0)) != 1 or (res2 = frames(ind, 1)) != 1001
- snd_display("silence 1: %s %s?", res1, res2)
+ res1 = framples(ind, 0)
+ res2 = framples(ind, 1)
+ if res1 != 1 or res2 != 1001
+ snd_test_neq(res1, 1, "silence 1")
+ snd_test_neq(res2, 1001, "silence 1 (1001")
end
save_sound(ind)
- if (res1 = frames(ind, 0)) != 1001 or (res2 = frames(ind, 1)) != 1001
+ if (res1 = framples(ind, 0)) != 1001 or (res2 = framples(ind, 1)) != 1001
snd_display("saved silence 1: %s %s?", res1, res2)
end
- if (res = mus_sound_frames("fmv.snd")) != 1001
- snd_display("saved frames silence 1: %s?", res)
+ if (res = mus_sound_framples("fmv.snd")) != 1001
+ snd_display("saved framples silence 1: %s?", res)
end
v0 = channel2vct(0, 1000, ind, 0)
v1 = channel2vct(0, 1000, ind, 1)
@@ -7812,9 +7473,9 @@ def test_05_11
close_sound(ind)
delete_file("fmv.snd")
#
- ind = new_sound("fmv.snd", Mus_next, Mus_bshort, 22050, 2, "unequal lens")
+ ind = new_sound("fmv.snd", 2, 22050, Mus_bshort, Mus_next, "unequal lens")
pad_channel(0, 1000, ind, 1)
- if (res1 = frames(ind, 0)) != 1 or (res2 = frames(ind, 1)) != 1001
+ if (res1 = framples(ind, 0)) != 1 or (res2 = framples(ind, 1)) != 1001
snd_display("silence: %s %s?", res1, res2)
end
v0 = channel2vct(0, 1000, ind, 0)
@@ -7828,13 +7489,14 @@ def test_05_11
map_channel($init_channel, 0, 2, ind, 0)
map_channel($init_channel, 0, 1002, ind, 1)
pad_channel(0, 1000, ind, 0, 1)
- if (res = frames(ind, 1)) != 1002
+ if (res = framples(ind, 1)) != 1002
snd_display("pad_channel ed 1: %s?", res)
end
close_sound(ind)
delete_file("fmv.snd")
#
- ind = new_sound("fmv.snd", Mus_ircam, Mus_bshort, 22050, 1, "this is a comment")
+ ind = new_sound("fmv.snd", 1, 22050, Mus_bshort, Mus_ircam,
+ "this is a comment")
v0 = make_vct(128)
v0[64] = 0.5
v0[127] = 0.5
@@ -7855,7 +7517,9 @@ def test_05_11
set_sinc_width(40)
src_selection(0.5)
v0 = channel2vct(0, 128, ind, 0)
- if fneq(sample(20), 0.5) or fneq(sample(30), 0.0) or fneq(sample(17), -0.1057)
+ if fneq(sample(20), 0.5) or
+ fneq(sample(30), 0.0) or
+ fneq(sample(17), -0.1057)
snd_display("src_selection: %s?", v0)
end
unselect_all
@@ -7871,7 +7535,9 @@ def test_05_11
select_all
filter_selection([0, 0, 0.1, 1, 1, 0], 40)
v0 = channel2vct(0, 128, ind, 0)
- if fneq(sample(29), 0.1945) or fneq(sample(39), -0.0137) or fneq(sample(24), -0.01986)
+ if fneq(sample(29), 0.1945) or
+ fneq(sample(39), -0.0137) or
+ fneq(sample(24), -0.01986)
snd_display("filter_selection: %s?", v0)
end
revert_sound(ind)
@@ -7880,7 +7546,9 @@ def test_05_11
select_all
filter_selection(make_one_zero(:a0, 0.5, :a1, 0.0))
v0 = channel2vct(0, 128, ind, 0)
- if fneq(sample(29), 0.5) or fneq(sample(39), 0.5) or fneq(sample(24), 0.5)
+ if fneq(sample(29), 0.5) or
+ fneq(sample(39), 0.5) or
+ fneq(sample(24), 0.5)
snd_display("filter_selection one_zero: %s?", v0)
end
revert_sound(ind)
@@ -7890,24 +7558,28 @@ def test_05_11
select_all
env_selection([0, 0, 1, 1, 2, 0], 1.0)
v0 = channel2vct(0, 128, ind, 0)
- if fneq(sample(64), 1.0) or fneq(sample(20), 0.3125) or fneq(sample(119), 0.127)
+ if fneq(sample(64), 1.0) or
+ fneq(sample(20), 0.3125) or
+ fneq(sample(119), 0.127)
snd_display("env_selection: %s?", v0)
end
- save_selection("fmv5.snd", Mus_next, Mus_bint, 22050, "")
+ save_selection("fmv5.snd", 22050, Mus_bint, Mus_next, "")
revert_sound(ind)
#
- if (res = Snd.catch do file2array("/baddy/hiho", 0, 0, 128, v0) end).first != :no_such_file
+ res = Snd.catch do file2array("/baddy/hiho", 0, 0, 128, v0) end
+ if res.first != :no_such_file
snd_display("file2array w/o file: %s", res.inspect)
end
- if (res = Snd.catch do file2array("fmv5.snd", 123, 0, 128, v0) end).first != :no_such_channel
+ res = Snd.catch do file2array("fmv5.snd", 123, 0, 128, v0) end
+ if res.first != :no_such_channel
snd_display("file2array w/o channel: %s", res.inspect)
end
file2array("fmv5.snd", 0, 0, 128, v0)
if fneq(v0[64], 1.0) or fneq(v0[20], 0.3125) or fneq(v0[119], 0.127)
snd_display("save_selection: %s %s %s %s?", v0[64], v0[20], v0[119], v0)
end
- if (res = mus_sound_data_format("fmv5.snd")) != Mus_bint
- snd_display("save_selection type: %s?", mus_data_format_name(res))
+ if (res = mus_sound_sample_type("fmv5.snd")) != Mus_bint
+ snd_display("save_selection type: %s?", mus_sample_type_name(res))
end
if (res = mus_sound_header_type("fmv5.snd")) != Mus_next
snd_display("save_selection format: %s?", mus_header_type_name(res))
@@ -7921,7 +7593,7 @@ def test_05_11
vct2channel(v0)
select_all
Snd.catch do reverse_selection end
- save_selection("fmv4.snd", Mus_riff, Mus_lfloat, 44100, "this is a comment")
+ save_selection("fmv4.snd", 44100, Mus_lfloat, Mus_riff, "this is a comment")
v0 = channel2vct(0, 128, ind, 0)
if fneq(sample(27), 0.5) or fneq(sample(125), -0.5)
snd_display("reverse_selection: %s?", v0)
@@ -7933,8 +7605,8 @@ def test_05_11
if (res = mus_sound_header_type("fmv4.snd")) != Mus_riff
snd_display("save_selection type 1: %s", mus_header_type_name(res))
end
- if (res = mus_sound_data_format("fmv4.snd")) != Mus_lfloat
- snd_display("save_selection format 1: %s", mus_data_format_name(res))
+ if (res = mus_sound_sample_type("fmv4.snd")) != Mus_lfloat
+ snd_display("save_selection format 1: %s", mus_sample_type_name(res))
end
if (res = mus_sound_srate("fmv4.snd")) != 44100
snd_display("save_selection srate 1: %s", res)
@@ -7946,14 +7618,14 @@ def test_05_11
#
save_selection(:file, "fmv4.snd",
:header_type, Mus_riff,
- :data_format, Mus_lfloat,
+ :sample_type, Mus_lfloat,
:srate, 44100,
:comment, "this is a comment")
if (res = mus_sound_header_type("fmv4.snd")) != Mus_riff
snd_display("save_selection opt type 1: %s", mus_header_type_name(res))
end
- if (res = mus_sound_data_format("fmv4.snd")) != Mus_lfloat
- snd_display("save_selection opt format 1: %s", mus_data_format_name(res))
+ if (res = mus_sound_sample_type("fmv4.snd")) != Mus_lfloat
+ snd_display("save_selection opt format 1: %s", mus_sample_type_name(res))
end
if (res = mus_sound_srate("fmv4.snd")) != 44100
snd_display("save_selection opt srate 1: %s", res)
@@ -7963,13 +7635,13 @@ def test_05_11
end
delete_file("fmv4.snd")
#
- save_selection(:file, "fmv4.snd", :data_format, Mus_bfloat, :channel, 0)
+ save_selection(:file, "fmv4.snd", :sample_type, Mus_bfloat, :channel, 0)
res = mus_sound_header_type("fmv4.snd")
if res != Mus_next and res != Mus_ircam
snd_display("save_selection opt1 type 1: %s", mus_header_type_name(res))
end
- if (res = mus_sound_data_format("fmv4.snd")) != Mus_bfloat
- snd_display("save_selection opt1 format 1: %s", mus_data_format_name(res))
+ if (res = mus_sound_sample_type("fmv4.snd")) != Mus_bfloat
+ snd_display("save_selection opt1 format 1: %s", mus_sample_type_name(res))
end
if (res = mus_sound_chans("fmv4.snd")) != 1
snd_display("save_selection opt1 chans: %s", res)
@@ -8000,7 +7672,7 @@ end
def test_05_12
obind = open_sound("oboe.snd")
vol = maxamp(obind)
- dur = frames
+ dur = framples
set_amp_control(2.0, obind)
snd_test_neq(amp_control(obind), 2.0, "set_amp_control")
reset_controls(obind)
@@ -8022,44 +7694,49 @@ def test_05_12
set_speed_control_bounds([0.05, 20.0], obind)
add_mark(1234)
apply_controls(obind)
- newdur = frames(obind)
+ newdur = framples(obind)
set_speed_control(1.0, obind)
unless newdur - 2.0 * dur < 256
snd_display("apply speed: %s -> %s?", dur, newdur)
end
set_contrast_control?(true, obind)
set_contrast_control_bounds([0.5, 2.5], obind)
- snd_test_neq(contrast_control_bounds(obind), [0.5, 2.5], "contrast_control_bounds")
+ snd_test_neq(contrast_control_bounds(obind), [0.5, 2.5],
+ "contrast_control_bounds")
set_contrast_control(1.0, obind)
apply_controls(obind)
set_contrast_control_bounds([0.0, 10.0], obind)
- snd_test_neq(contrast_control_bounds(obind), [0.0, 10.0], "contrast_control_bounds (2)")
+ snd_test_neq(contrast_control_bounds(obind), [0.0, 10.0],
+ "contrast_control_bounds (2)")
secamp = maxamp(obind)
- secdur = frames(obind)
+ secdur = framples(obind)
snd_test_neq(secamp, 0.989, "apply contrast")
snd_test_neq(secdur, newdur, "apply contrast length")
undo_edit(3, obind)
set_reverb_control?(true, obind)
set_reverb_control_scale_bounds([0.0, 1.0], obind)
- snd_test_neq(reverb_control_scale_bounds(obind), [0.0, 1.0], "reverb_control_scale_bounds")
+ snd_test_neq(reverb_control_scale_bounds(obind), [0.0, 1.0],
+ "reverb_control_scale_bounds")
set_reverb_control_length_bounds([0.0, 2.0], obind)
- snd_test_neq(reverb_control_length_bounds(obind), [0.0, 2.0], "reverb_control_length_bounds")
+ snd_test_neq(reverb_control_length_bounds(obind), [0.0, 2.0],
+ "reverb_control_length_bounds")
set_reverb_control_scale(0.2, obind)
apply_controls(obind)
revamp = maxamp(obind)
- revdur = frames(obind)
- snd_test_any_neq(revamp, 0.214, :ffequal?, "apply reverb scale") # okay
+ revdur = framples(obind)
+ snd_test_any_neq(revamp, 0.214, :ffequal?, "apply reverb scale")
unless revdur - ((reverb_control_decay * 22050.0).round + 50828) < 256
snd_display("apply reverb length: %s?", revdur)
end
undo_edit(1, obind)
set_expand_control?(true, obind)
set_expand_control_bounds([1.0, 3.0], obind)
- snd_test_neq(expand_control_bounds(obind), [1.0, 3.0], "expand_control_bounds")
+ snd_test_neq(expand_control_bounds(obind), [1.0, 3.0],
+ "expand_control_bounds")
set_expand_control(1.5, obind)
apply_controls(obind)
expamp = maxamp(obind)
- expdur = frames(obind)
+ expdur = framples(obind)
if fneq_err(expamp, 0.152, 0.05)
snd_display("apply expand_control scale: %s?", expamp)
end
@@ -8073,17 +7750,9 @@ def test_05_12
set_filter_control_envelope([0.0, 0.0, 1.0, 0.5, 2.0, 0.0], obind)
apply_controls(obind)
fltamp = maxamp(obind)
- fltdur = frames(obind)
- # FIXME
- # from command line: => 0.054348257295914 (snd-s7|ruby|forth)
- # from listener: => less than 0.025
- if (fltamp - 0.02).abs > 0.005
- snd_display(snd_format(fltamp, 0.025, ">", "apply filter scale"))
- end
- req = 40 + 50828 + 256
- if fltdur - (40 + 50828) > 256
- snd_display(snd_format(fltdur, req, ">", "apply filter length"))
- end
+ fltdur = framples(obind)
+ snd_test_gt((fltamp - 0.02).abs, 0.005, "apply filter scale")
+ snd_test_gt(fltdur - (40 + 50828), 256, "apply filter length")
undo_edit(1, obind)
#
revert_sound(obind)
@@ -8116,13 +7785,13 @@ def test_05_12
[2002, 0, 2002, 2002, 0.999969720840454, 0.0, 0.0, 0],
[2003, 0, 2003, 50827, 1.0, 0.0, 0.0, 0],
[50828, -2, 0, 0, 0.0, 0.0, 0.0, 0]]
- if tree.length != tr_tree.length
- snd_display(snd_format_neq(tree.length, tr_tree.length, "edit trees are not same length"))
- else
+ unless snd_test_neq(tree.length, tr_tree.length,
+ "edit trees are not same length")
tree.each_with_index do |branch, i|
tr_branch = tr_tree[i]
5.times do |j|
- snd_test_neq(branch[j], tr_branch[j], "edit trees disagree at [%d][%d]", i, j)
+ snd_test_neq(branch[j], tr_branch[j],
+ "edit trees disagree at [%d][%d]", i, j)
end
end
end
@@ -8148,14 +7817,13 @@ def test_05_12
[2063, 0, 2002, 2002, 0.999969720840454, 0.0, 0.0, 0],
[2064, 0, 2003, 50827, 1.0, 0.0, 0.0, 0],
[50889, -2, 0, 0, 0.0, 0.0, 0.0, 0]]
- if tree.length != tr_tree.length
- snd_display(snd_format_neq(tree.length, tr_tree.length,
- "silenced edit trees are not same length"))
- else
+ unless snd_test_neq(tree.length, tr_tree.length,
+ "silenced edit trees are not same length")
tree.each_with_index do |branch, i|
tr_branch = tr_tree[i]
5.times do |j|
- snd_test_neq(branch[j], tr_branch[j], "silenced edit trees disagree at [%d][%d]", i, j)
+ snd_test_neq(branch[j], tr_branch[j],
+ "silenced edit trees disagree at [%d][%d]", i, j)
end
end
end
@@ -8172,7 +7840,7 @@ def test_05_12
mark_now = marks(obind, 0).length
snd_test_neq(mark_num, mark_now, "mark lost after scaling")
set_selection_position(0)
- set_selection_frames(100)
+ set_selection_framples(100)
scale_selection_to(0.5)
mark_now = marks(obind, 0).length
snd_test_neq(mark_num, mark_now, "mark lost after scaling scaling")
@@ -8197,29 +7865,31 @@ def test_05_12
key(key_to_int(?j), 4, obind)
snd_test_neq(cursor(obind), 100, "C-- C-j")
revert_sound(obind)
- frs = frames(obind)
+ frs = framples(obind)
make_region(0, 999, obind, 0)
unless selection?
snd_display("make_region but no selection? %s", selection?)
end
delete_selection
- snd_test_neq(frames(obind), frs - 1000, "delete_selection")
+ snd_test_neq(framples(obind), frs - 1000, "delete_selection")
val = sample(0, obind, 0)
undo_edit
snd_test_neq(sample(1000), val, "delete_selection val")
insert_selection
- if (res = Snd.catch do insert_selection(0, obind, 123) end).first != :no_such_channel
+ res = Snd.catch do insert_selection(0, obind, 123) end
+ if res.first != :no_such_channel
snd_display("insert_selection bad chan: %s?", res.inspect)
end
- if (res = Snd.catch do mix_selection(0, obind, 123) end).first != :no_such_channel
+ res = Snd.catch do mix_selection(0, obind, 123) end
+ if res.first != :no_such_channel
snd_display("mix_selection bad chan: %s?", res.inspect)
end
- snd_test_neq(frames(obind), frs + 1000, "insert_selection")
+ snd_test_neq(framples(obind), frs + 1000, "insert_selection")
snd_test_neq(sample(2000), val, "insert_selection val")
val = sample(900)
mix_selection
snd_test_neq(sample(900), val * 2.0, "mix_selection val")
- snd_test_neq(frames(obind), frs + 1000, "mix_selection len")
+ snd_test_neq(framples(obind), frs + 1000, "mix_selection len")
close_sound(obind)
end
@@ -8227,43 +7897,36 @@ Apply_to_sound, Apply_to_channel, Apply_to_selection = [0, 1, 2]
def test_05_13
ind = open_sound("2.snd")
- len = frames(ind)
+ len = framples(ind)
+ len2 = len * 2
+ len4 = len * 4
set_sync(1, ind)
set_speed_control(0.5, ind)
apply_controls(ind, Apply_to_sound) # temp 1
- if (frames - 2 * len).abs > 256
- snd_display("apply srate 0.5: %s %s?", frames, len * 2)
- end
- make_selection(0, frames)
+ snd_test_gt((framples() - len2).abs, 256, "apply srate 0.5")
+ make_selection(0, framples())
set_speed_control(0.5, ind)
apply_controls(ind, Apply_to_selection) # temp 2
- if (frames - 4 * len).abs > 256
- snd_display("apply srate 0.5 to selection: %s %s?", frames, len * 4)
- end
- env_sound([0, 0, 1, 1], 0, frames, 32.0) # temp 3
- reg = select_all # make multi_channel region
+ snd_test_gt((framples() - len4).abs, 256, "apply srate 0.5 to selection")
+ env_sound([0, 0, 1, 1], 0, framples(), 32.0) # temp 3
+ reg = select_all() # make multi_channel region
insert_region(reg, 0) # temp 4
insert_selection(0) # temp 5
revert_sound(ind)
+ #
set_speed_control(0.5)
set_sync(0, ind)
set_selected_channel(ind, 1)
apply_controls(ind, Apply_to_channel)
- if (frames(ind, 1) - 2 * len).abs > 256
- snd_display("apply srate 0.5 to chan 1: %s %s?", frames(ind, 1), len * 2)
- end
- if frames(ind, 0) != len
- snd_display("apply srate 0.5 but chan 0: %s %s?", frames(ind, 0), len)
- end
+ snd_test_gt((framples(ind, 1) - len2).abs, 256, "apply srate 0.5 to chan 1")
+ snd_test_neq(framples(ind, 0), len, "apply srate 0.5 but chan 0")
set_speed_control(0.5, ind)
apply_controls(ind, Apply_to_sound, 1000)
make_selection(2000, 4000)
set_speed_control(0.5, ind)
apply_controls(ind, Apply_to_selection)
set_selected_channel(ind, false)
- if selected_channel(ind)
- snd_display("selected_channel false: %s?", selected_channel(ind))
- end
+ snd_test_neq(selected_channel(ind), false, "selected_channel false")
close_sound(ind)
#
ind1 = open_sound("oboe.snd")
@@ -8273,109 +7936,66 @@ def test_05_13
mx21 = maxamp(ind2, 1)
select_sound(ind1)
scale_sound_by(2.0)
- if fneq(res = maxamp(ind1, 0), 2.0 * mx1)
- snd_display("scale_sound_by 2.0: %s %s?", mx1, res)
- end
- if (res1 = edit_fragment(1, ind1, 0)) !=
- (res2 = ["scale_channel(2.000, 0, false", "scale", 0, 50828])
- snd_display("scale_sound_by:\n# %s\n# %s", res1, res2)
- end
+ snd_test_neq(maxamp(ind1, 0), 2.0 * mx1, "scale_sound_by 2.0")
+ res = edit_fragment(1, ind1, 0)
+ req = ["scale_channel(2.000, 0, false", "scale", 0, 50828]
+ snd_test_neq(res, req, "scale_sound_by")
scale_sound_to(0.5)
- if fneq(res = maxamp(ind1, 0), 0.5)
- snd_display("scale_sound_to 0.5: %s?", res)
- end
- if (res1 = edit_fragment(2, ind1, 0)) !=
- (res2 = ["scale_channel(1.698, 0, false", "scale", 0, 50828])
- snd_display("scale_sound_to:\n# %s\n# %s", res1, res2)
- end
+ snd_test_neq(maxamp(ind1, 0), 0.5, "scale_sound_to 0.5")
+ res = edit_fragment(2, ind1, 0)
+ req = ["scale_channel(1.698, 0, false", "scale", 0, 50828]
+ snd_test_neq(res, req, "scale_sound_to")
scale_sound_by(0.0, 0, 1000, ind1, 0)
- if fneq(res = maxamp(ind1, 0), 0.5)
- snd_display("scale_sound_by 0.0: %s?", res)
- end
- if (res1 = edit_fragment(3, ind1, 0)) !=
- (res2 = ["scale_channel(0.000, 0, 1000", "scale", 0, 1000])
- snd_display("scale_sound_by 0.0:\n# %s\n# %s", res1, res2)
- end
- v = channel2vct(0, 1000, ind1, 0)
- if fneq(res = vct_peak(v), 0.0)
- snd_display("scale_sound_by 0.0 [0:1000]: %s", res)
- end
+ snd_test_neq(maxamp(ind1, 0), 0.5, "scale_sound_by 0.0")
+ res = edit_fragment(3, ind1, 0)
+ req = ["scale_channel(0.000, 0, 1000", "scale", 0, 1000]
+ snd_test_neq(res, req, "scale_sound_by 0.0")
+ res = channel2vct(0, 1000, ind1, 0).peak
+ snd_test_neq(res, 0.0, "0:0 scale_sound_by 0.0 [0:1000]")
revert_sound(ind1)
oldv = channel2vct(12000, 10, ind1, 0)
scale_sound_by(2.0, 12000, 10, ind1, 0)
newv = channel2vct(12000, 10, ind1, 0)
10.times do |i|
- if fneq(res1 = oldv[i] * 2.0, res2 = newv[i])
- snd_display("scale %s: %s %s?", i, res1, res2)
- end
- end
- if (res1 = edit_fragment(1, ind1, 0)) !=
- (res2 = ["scale_channel(2.000, 12000, 10", "scale", 12000, 10])
- snd_display("scale_sound_by 2.0 [12000:10]:\n# %s\n# %s", res1, res2)
+ snd_test_neq(oldv[i] * 2.0, newv[i], "scale %d", i)
end
+ res = edit_fragment(1, ind1, 0)
+ req = ["scale_channel(2.000, 12000, 10", "scale", 12000, 10]
+ snd_test_neq(res, req, "scale_sound_by 2.0 [12000:10]")
revert_sound(ind1)
#
select_sound(ind2)
scale_sound_by(2.0)
- if fneq(res = maxamp(ind2, 0), 2.0 * mx20)
- snd_display("2:0 scale_sound_by 2.0: %s %s?", mx20, res)
- end
- if fneq(res = maxamp(ind2, 1), 2.0 * mx21)
- snd_display("2:1 scale_sound_by 2.0: %s %s?", mx21, res)
- end
- if (res1 = edit_fragment(1, ind2, 0)) !=
- (res2 = ["scale_channel(2.000, 0, false", "scale", 0, 50828])
- snd_display("2 scale_sound_by:\n# %s\n# %s", res1, res2)
- end
+ snd_test_neq(maxamp(ind2, 0), 2.0 * mx20, "2:0 scale_sound_by 2.0")
+ snd_test_neq(maxamp(ind2, 1), 2.0 * mx21, "2:1 scale_sound_by 2.0")
scale_sound_to(0.5)
- if fneq(res = [maxamp(ind2, 0), maxamp(ind2, 1)].max, 0.5)
- snd_display("2 scale_sound_to 0.5: %s %s?", res, maxamp(ind2))
- end
+ res = [maxamp(ind2, 0), maxamp(ind2, 1)].max
+ snd_test_neq(res, 0.5, "2 scale_sound_to 0.5")
scale_sound_by(0.0, 0, 1000, ind2, 1)
- if fneq(res = maxamp(ind2, 0), 0.5)
- snd_display("2 scale_sound_by 0.0: %s?", res)
- end
- if (res1 = edit_fragment(3, ind2, 1)) !=
- (res2 = ["scale_channel(0.000, 0, 1000", "scale", 0, 1000])
- snd_display("2:1 scale_sound_by 0.0:\n# %s\n# %s", res1, res2)
- end
- v = channel2vct(0, 1000, ind2, 1)
- if fneq(res = vct_peak(v), 0.0)
- snd_display("2:1 scale_sound_by 0.0 [0:1000]: %s", res)
- end
+ res = edit_fragment(3, ind2, 1)
+ req = ["scale_channel(0.000, 0, 1000", "scale", 0, 1000]
+ snd_test_neq(res, req, "2:1 scale_sound_by 0.0")
+ res = channel2vct(0, 1000, ind2, 1).peak
+ snd_test_neq(res, 0.0, "2:1 scale_sound_by 0.0 [0:1000]")
revert_sound(ind2)
oldv = channel2vct(12000, 10, ind2, 0)
scale_sound_by(2.0, 12000, 10, ind2, 0)
newv = channel2vct(12000, 10, ind2, 0)
10.times do |i|
- if fneq(res1 = oldv[i] * 2.0, res2 = newv[i])
- snd_display("2 scale %s: %s %s?", i, res1, res2)
- end
+ snd_test_neq(oldv[i] * 2.0, newv[i], "2 scale %d", i)
end
revert_sound(ind2)
#
set_sync(3, ind2)
set_sync(3, ind1)
scale_sound_by(2.0)
- if fneq(res = maxamp(ind1, 0), mx1)
- snd_display("sync scale_sound_by 2.0: %s %s?", mx1, res)
- end
- if fneq(res = maxamp(ind2, 0), 2.0 * mx20)
- snd_display("2:0 sync scale_sound_by 2.0: %s %s?", mx20, res)
- end
- if fneq(res = maxamp(ind2, 1), 2.0 * mx21)
- snd_display("2:1 sync scale_sound_by 2.0: %s %s?", mx21, res)
- end
+ snd_test_neq(maxamp(ind1, 0), mx1, "sync scale_sound_by 2.0")
+ snd_test_neq(maxamp(ind2, 0), 2.0 * mx20, "2:0 sync scale_sound_by 2.0")
+ snd_test_neq(maxamp(ind2, 1), 2.0 * mx21, "2:1 sync scale_sound_by 2.0")
scale_sound_to(1.0, 20000, 40000, ind2, 1)
- if fneq(res = maxamp(ind1, 0), mx1)
- snd_display("sync scale_sound_to 1.0: %s %s?", mx1, res)
- end
- if fneq(res = maxamp(ind2, 0), 2.0 * mx20)
- snd_display("2:0 sync scale_sound_to 1.0: %s %s?", mx20, res)
- end
- if fneq(res = maxamp(ind2, 1), 1.0)
- snd_display("2:1 sync scale_sound_to 1.0: %s?", res)
- end
+ snd_test_neq(maxamp(ind1, 0), mx1, "sync scale_sound_to 1.0")
+ snd_test_neq(maxamp(ind2, 0), 2.0 * mx20, "2:0 sync scale_sound_to 1.0")
+ snd_test_neq(maxamp(ind2, 1), 1.0, "2:1 sync scale_sound_to 1.0")
close_sound(ind1)
close_sound(ind2)
end
@@ -8407,9 +8027,12 @@ def test_05_14
set_transform_graph?(true, ind, 0)
set_transform_graph_type(Graph_as_sonogram, ind, 0)
update_transform_graph(ind, 0)
- res = transform_frames(ind, 0)
- if (not list?(res)) or fneq(res.car, 1.0) or res.caddr != 256
- snd_display("transform_frames: %s (%s)?", res.inspect, transform_size(ind, 0))
+ res = transform_framples(ind, 0)
+ if (not list?(res)) or
+ fneq(res.car, 1.0) or
+ res.caddr != 256
+ snd_display("transform_framples: %s (%s)?",
+ res.inspect, transform_size(ind, 0))
end
close_sound(ind)
#
@@ -8430,7 +8053,9 @@ def test_05_14
end
after_ran = false
$after_apply_controls_hook.reset_hook!
- $after_apply_controls_hook.add_hook!("snd-test") do |snd| after_ran = snd end
+ $after_apply_controls_hook.add_hook!("snd-test") do |snd|
+ after_ran = snd
+ end
apply_controls(ind)
unless ind.eql?(after_ran)
snd_display("$after_apply_controls_hook: %s?", after_ran)
@@ -8440,27 +8065,34 @@ def test_05_14
set_sync(1, ind)
scale_to(vct(0.1, 0.2))
mx = maxamp(ind, true)
- if fneq(mx[0], 0.1) or fneq(mx[1], 0.2) or fneq(mx[2], 0.2) or fneq(mx[3], 0.2)
+ if fneq(mx[0], 0.1) or
+ fneq(mx[1], 0.2) or
+ fneq(mx[2], 0.2) or
+ fneq(mx[3], 0.2)
snd_display("scale_to with vector: %s?", mx)
end
set_filter_control_envelope([0, 0, 1, 1], ind)
if [0.0, 0.0, 1.0, 1.0] != filter_control_envelope(ind)
- snd_display("set_filter_control_envelope: %s?", filter_control_envelope(ind))
+ snd_display("set_filter_control_envelope: %s?",
+ filter_control_envelope(ind))
end
set_filter_control_order(20, ind)
unless vequal(res = filter_control_coeffs(ind),
- vct(-0.007, 0.010, -0.025, 0.029, -0.050, 0.055, -0.096, 0.109, -0.268, 0.241,
- 0.241, -0.268, 0.109, -0.096, 0.055, -0.050, 0.029, -0.025, 0.010, -0.007))
+ vct(-0.007, 0.010, -0.025, 0.029, -0.050, 0.055, -0.096,
+ 0.109, -0.268, 0.241, 0.241, -0.268, 0.109, -0.096,
+ 0.055, -0.050, 0.029, -0.025, 0.010, -0.007))
snd_display("highpass coeffs: %s?", res)
end
set_filter_control_envelope(filter_control_envelope(ind), ind)
if [0.0, 0.0, 1.0, 1.0] != filter_control_envelope(ind)
- snd_display("set_filter_control_envelope to self: %s?", filter_control_envelope(ind))
+ snd_display("set_filter_control_envelope to self: %s?",
+ filter_control_envelope(ind))
end
set_filter_control_envelope([0, 1, 1, 0], ind)
unless vequal(res = filter_control_coeffs(ind),
- vct(0.003, 0.002, 0.004, 0.002, 0.007, 0.003, 0.014, 0.012, 0.059, 0.394,
- 0.394, 0.059, 0.012, 0.014, 0.003, 0.007, 0.002, 0.004, 0.002, 0.003))
+ vct(0.003, 0.002, 0.004, 0.002, 0.007, 0.003, 0.014, 0.012,
+ 0.059, 0.394, 0.394, 0.059, 0.012, 0.014, 0.003, 0.007,
+ 0.002, 0.004, 0.002, 0.003))
snd_display("lowpass coeffs: %s?", res)
end
close_sound(ind)
@@ -8469,7 +8101,8 @@ end
def test_05_15
obind = open_sound("4.aiff")
amps = maxamp(obind, true)
- snd_test_neq(maxamp_position(obind, true), [810071, 810071, 810071, 810071], "4.aiff times")
+ snd_test_neq(maxamp_position(obind, true), [810071, 810071, 810071, 810071],
+ "4.aiff times")
if window_width < 600
set_window_width(600)
end
@@ -8481,7 +8114,8 @@ def test_05_15
update_time_graph
set_amp_control(0.1, obind)
select_channel(2)
- if (res = Snd.catch do apply_controls(obind, 1) end).first == :no_such_sound
+ res = Snd.catch do apply_controls(obind, 1) end
+ if res.first == :no_such_sound
snd_display("apply_controls cannot find 4.aiff: %s?", res.inspect)
end
newamps = maxamp(obind, true)
@@ -8493,7 +8127,7 @@ def test_05_15
end
undo_edit(1, obind, 2)
set_amp_control(0.1, obind)
- make_region(0, frames(obind), obind, 1)
+ make_region(0, framples(obind), obind, 1)
Snd.catch do apply_controls(obind, 2) end
newamps = maxamp(obind, true)
if fneq(amps[0], newamps[0]) or
@@ -8511,7 +8145,8 @@ def test_05_15
select_channel(0)
set_cursor(100, obind)
xy = cursor_position(obind)
- snd_test_neq(position2x(xy[0]), cursor(obind).to_f / srate(obind), "cursor_position %s", xy[0])
+ snd_test_neq(position2x(xy[0]), cursor(obind).to_f / srate(obind),
+ "cursor_position %s", xy[0])
snd_test_neq(position2x(x2position(xpos)), xpos, "x<->position")
if ((res = position2y(y2position(ypos))) - ypos).abs > 0.5
snd_display(snd_format(res, ypos, "y<->position"))
@@ -8535,10 +8170,14 @@ def test_05_15
end
if $clmtest.zero?
cp_x = lambda do |x|
- (axinfo[10] + ((x - x0.to_f) * ((axinfo[12] - axinfo[10].to_f) / (x1 - x0.to_f)))).floor
+ (axinfo[10] +
+ ((x - x0.to_f) *
+ ((axinfo[12] - axinfo[10].to_f) / (x1 - x0.to_f)))).floor
end
cp_y = lambda do |y|
- (axinfo[13] + ((y1.to_f - y) * ((axinfo[11] - axinfo[13].to_f) / (y1 - y0.to_f)))).floor
+ (axinfo[13] +
+ ((y1.to_f - y) *
+ ((axinfo[11] - axinfo[13].to_f) / (y1 - y0.to_f)))).floor
end
if ((res1 = x2position(xpos)) - (res2 = cp_x.call(xpos))).abs > 1
snd_display(snd_format_neq(res2, res1, "cp_x 0.5"))
@@ -8555,9 +8194,10 @@ def test_05_15
if ((res1 = y2position(yypos)) - (res2 = cp_y.call(yypos))).abs > 1
snd_display(snd_format_neq(res2, res1, "cp_y[%d] %1.4f", i, yypos))
end
- snd_test_neq(position2x(cp_x.call(xxpos)), xxpos, "x2position cp_x[%d]", i)
- # okay
- snd_test_any_neq(position2y(cp_y.call(yypos)), yypos, :fffequal?, "y2position cp_y[%d]", i)
+ snd_test_neq(position2x(cp_x.call(xxpos)), xxpos,
+ "x2position cp_x[%d]", i)
+ snd_test_any_neq(position2y(cp_y.call(yypos)), yypos, :fffequal?,
+ "y2position cp_y[%d]", i)
end
end
old_samp = left_sample(obind, 0)
@@ -8621,19 +8261,23 @@ def test_05_16
lambda { |snd| env_sound([0, 1.0, 1, 0.5, 2, 1.0]) },
"env_sound([0, 1.0, 1, 2.0, 2, 1.0])",
ind1)
- test_orig(lambda { |snd| env_channel(make_env([0, 1.0, 1, 2.0], :length, frames(snd))) },
- lambda { |snd| env_channel(make_env([[0, 1.0], [1, 0.5]], :length, frames(snd))) },
- "env_channel(make_env([0, 1.0, 1, 2.0]))",
- ind1)
+ test_orig(lambda { |snd|
+ env_channel(make_env([0, 1.0, 1, 2.0], :length, framples(snd)))
+ },
+ lambda { |snd|
+ env_channel(make_env([[0, 1.0], [1, 0.5]], :length, framples(snd)))
+ }, "env_channel(make_env([0, 1.0, 1, 2.0]))", ind1)
test_orig(lambda { |snd| env_channel([0, 1.0, 1, 2.0]) },
lambda { |snd| env_channel([0, 1.0, 1, 0.5]) },
"env_channel([0, 1.0, 1, 2.0])",
ind1)
test_orig(lambda { |snd|
- env_channel(make_env([0, 2, 1, 2, 2, 0.5, 3, 0.5], :base, 0, :length, frames(snd)))
+ env_channel(make_env([0, 2, 1, 2, 2, 0.5, 3, 0.5],
+ :base, 0, :length, framples(snd)))
},
lambda { |snd|
- env_channel(make_env([0, 0.5, 1, 0.5, 2, 2, 3, 2], :base, 0, :length, frames(snd)))
+ env_channel(make_env([0, 0.5, 1, 0.5, 2, 2, 3, 2],
+ :base, 0, :length, framples(snd)))
},
"env_channel(make_env([0, 2, 1, 2, 2, 0.5, 3, 0.5]))",
ind1)
@@ -8651,7 +8295,9 @@ def test_05_16
ind1)
outp = false
test_orig(lambda { |snd| map_channel(lambda { |y| vct(y * 2.0, y * 2.0) }) },
- lambda { |snd| map_channel(lambda { |y| outp = (outp ? false : y * 0.5) }) },
+ lambda { |snd| map_channel(lambda { |y|
+ outp = (outp ? false : y * 0.5)
+ }) },
"map_channel(lambda { |y| vct(y * 2.0, y * 2.0) })",
ind1)
test_orig(lambda { |snd| map_chan(lambda { |y| y * 2.0 }) },
@@ -8670,8 +8316,10 @@ def test_05_16
lambda { |snd| clm_channel(make_one_pole(:a0, 0.5, :b1, 0.0)) },
"clm_channel(make_one_pole)",
ind1)
- test_orig(lambda { |snd| filter_sound(make_one_zero(:a0, 2.0, :a1, 0.0), 2, snd, 0) },
- lambda { |snd| filter_sound(make_one_zero(:a0, 0.5, :a1, 0.0), 2, snd, 0) },
+ test_orig(lambda { |snd| filter_sound(make_one_zero(:a0, 2.0, :a1, 0.0),
+ 2, snd, 0) },
+ lambda { |snd| filter_sound(make_one_zero(:a0, 0.5, :a1, 0.0),
+ 2, snd, 0) },
"filter_sound(make_one_zero)",
ind1)
if (res = Snd.catch do src_sound([0, 0, 1, 1]) end).first != :out_of_range
@@ -8690,20 +8338,19 @@ def test_05_16
convolve_with("fmv3.snd", 1.0, ind1)
convolve_files("fmv4.snd", "fmv3.snd", 1.0, "fmv5.snd")
v2 = channel2vct(12000, 10, ind1, 0)
- snd_test_any_neq(v2, v1, :vfequal?, "convolve_with (orig 0)") # okay
+ snd_test_any_neq(v2, v1, :vfequal?, "convolve_with (orig 0)")
file2array("fmv5.snd", 0, 12000, 10, v2)
- snd_test_any_neq(v2, v1, :vfequal?, "convolve_files (orig 0)") # okay
+ snd_test_any_neq(v2, v1, :vfequal?, "convolve_files (orig 0)")
delete_files("fmv3.snd", "fmv5.snd")
convolve_files("2.snd", "oboe.snd", 0.5, "fmv5.snd")
res = mus_sound_maxamp("fmv5.snd")
- unless (fneq(res[1], 0.25) or fneq(res[3], 0.5))
- snd_display("convolve_files stereo: %s", res)
- end
+ snd_test_neq(res[1], 0.25, "convolve_files stereo (1)")
+ snd_test_neq(res[3], 0.50, "convolve_files stereo (2)")
delete_file("fmv5.snd")
scale_to(0.25, ind1)
set_y_bounds([], ind1)
- if $with_test_gui and (res = y_bounds(ind1)) != [-0.25, 0.25]
- snd_display("y_bounds []: %s", res)
+ if $with_test_gui
+ snd_test_neq(y_bounds(ind1), [-0.25, 0.25], "y_bounds []")
end
revert_sound(ind1)
#
@@ -8715,9 +8362,9 @@ def test_05_16
convolve_with("fmv3.snd", 1.0, ind1)
convolve_files("fmv4.snd", "fmv3.snd", 1.0, "fmv5.snd")
v2 = channel2vct(12005, 10, ind1, 0)
- snd_test_any_neq(v2, v1, :vfequal?, "convolve_with (orig 2)") # okay
+ snd_test_any_neq(v2, v1, :vfequal?, "convolve_with (orig 2)")
file2array("fmv5.snd", 0, 12005, 10, v2)
- snd_test_any_neq(v2, v1, :vfequal?, "convolve_files (orig 2)") # okay
+ snd_test_any_neq(v2, v1, :vfequal?, "convolve_files (orig 2)")
delete_files("fmv3.snd", "fmv4.snd", "fmv5.snd")
revert_sound(ind1)
#
@@ -8733,7 +8380,7 @@ def test_05_16
data = channel2vct(12000, 10, ind1, 0)
convolve_with("pistol.snd", maxamp(ind1, 0, 0), ind1, 0, 0)
new_data = channel2vct(12000, 10, ind1, 0)
- snd_test_any_neq(new_data, data, :vfequal?, "convolve_selection_with") # okay
+ snd_test_any_neq(new_data, data, :vfequal?, "convolve_selection_with")
revert_sound(ind1)
#
make_selection(1000, 2000, ind1)
@@ -8747,8 +8394,9 @@ def test_05_16
unless region?(id)
snd_display("make_region argless: %s?", id)
end
- if (res1 = region_frames(id, 0)) != (res2 = selection_frames)
- snd_display("region/selection_frames: %s %s (%s)?", res1, res2, region_frames(id))
+ if (res1 = region_framples(id, 0)) != (res2 = selection_framples)
+ snd_display("region/selection_framples: %s %s (%s)?",
+ res1, res2, region_framples(id))
end
if (res1 = region_sample(id, 0)) != (res2 = sample(1000, ind1))
snd_display("region_sample from make_region: %s %s?", res1, res2)
@@ -8774,17 +8422,20 @@ def test_05_17
v2 = channel2vct(12000, 10, ind, 0)
v3 = channel2vct(12000, 10, ind, 1)
if vequal(v0, v2) or vequal(v1, v3)
- snd_display("swap_channels 0: no change!\n# %s\n# %s\n# %s\n# %s", v0, v2, v1, v3)
+ snd_display("swap_channels 0: no change!\n# %s\n# %s\n# %s\n# %s",
+ v0, v2, v1, v3)
end
swap_channels(ind)
v2 = channel2vct(12000, 10, ind, 0)
v3 = channel2vct(12000, 10, ind, 1)
unless vequal(v0, v2) or vequal(v1, v3)
- snd_display("swap_channels 1: \n# %s\n# %s\n# %s\n# %s", v0, v2, v1, v3)
+ snd_display("swap_channels 1: \n# %s\n# %s\n# %s\n# %s",
+ v0, v2, v1, v3)
end
set_cursor(100, ind, 0)
set_cursor(200, ind, 1)
- if (res0 = cursor(ind, 0)) != 100 or (res1 = cursor(ind, 1)) != 200
+ if (res0 = cursor(ind, 0)) != 100 or
+ (res1 = cursor(ind, 1)) != 200
snd_display("cursor: %s %s?", res0, res1)
end
set_sync(1, ind)
@@ -8794,12 +8445,14 @@ def test_05_17
amps = maxamp(ind, true)
swap_channels(ind, 0, ind)
newamps = maxamp(ind, true)
- if fneq(amps[0], newamps[1]) or fneq(amps[1], newamps[0])
+ if fneq(amps[0], newamps[1]) or
+ fneq(amps[1], newamps[0])
snd_display("swap_channels with cp def: %s %s?", amps, newamps)
end
swap_channels(ind, 1)
newamps = maxamp(ind, true)
- if fneq(amps[0], newamps[0]) or fneq(amps[1], newamps[1])
+ if fneq(amps[0], newamps[0]) or
+ fneq(amps[1], newamps[1])
snd_display("swap_channels with cp def 0: %s %s?", amps, newamps)
end
close_sound(ind)
@@ -8810,12 +8463,12 @@ def test_05_18
ind2 = open_sound("2.snd")
ups1 = count_matches(lambda do |n| n > 0.1 end, 0, ind1, 0)
count = 0
- scan_chan(lambda do |n|
- if n > 0.1
- count += 1
- end
- false
- end, 0, frames(ind1), ind1, 0)
+ reader = make_sampler(0, ind1)
+ framples(ind1).times do |i|
+ if next_sample(reader) > 0.1
+ count += 1
+ end
+ end
ups2 = count
if ups1 != ups2
snd_display("scan_chan: %s %s?", ups1, ups2)
@@ -8823,20 +8476,20 @@ def test_05_18
ups1 = count_matches(lambda do |n| n > 0.03 end, 0, ind2, 0)
ups2 = count_matches(lambda do |n| n > 0.03 end, 0, ind2, 1)
count = 0
- scan_chan(lambda do |n|
- if n > 0.03
- count += 1
- end
- false
- end, 0, frames(ind2), ind2, 0)
+ reader = make_sampler(0, ind2, 0)
+ framples(ind2).times do |i|
+ if next_sample(reader) > 0.03
+ count += 1
+ end
+ end
ups3 = count
count = 0
- scan_chan(lambda do |n|
- if n > 0.03
- count += 1
- end
- false
- end, 0, frames(ind2), ind2, 1)
+ reader = make_sampler(0, ind2, 1)
+ framples(ind2).times do |i|
+ if next_sample(reader) > 0.03
+ count += 1
+ end
+ end
ups4 = count
if ups1 != ups3
snd_display("2[0] scan_chan: %s %s?", ups1, ups3)
@@ -8858,7 +8511,7 @@ def test_05_18
end
set_sync(false, ind2)
count = 0
- scan_sound_chans(0, frames(ind2), ind2) do |n|
+ scan_sound_chans(0, framples(ind2), ind2) do |n|
if n > 0.03
count += 1
end
@@ -8904,21 +8557,21 @@ end
def test_05_20
ind1 = open_sound("oboe.snd")
- len = frames(ind1)
+ len = framples(ind1)
ctr = 0
map_chan(lambda do |n|
ctr = (ctr == 1) ? 0 : 1
ctr.zero? ? n * 2.0 : false
- end, 0, frames(ind1), "ignore: cut 2", ind1, 0)
- if frames(ind1) > (len * 2 + 1)
- snd_display("map_chan cut: %s %s?", len, frames(ind1))
+ end, 0, framples(ind1), "ignore: cut 2", ind1, 0)
+ if framples(ind1) > (len * 2 + 1)
+ snd_display("map_chan cut: %s %s?", len, framples(ind1))
end
revert_sound(ind1)
ctr = 0
map_chan(lambda do |n|
ctr += 1
ctr > 3 ? true : n
- end, 0, frames(ind1), "ignore: cut none", ind1, 0)
+ end, 0, framples(ind1), "ignore: cut none", ind1, 0)
if ctr > 4
snd_display("map_chan no-edit count: %s?", ctr)
end
@@ -8928,9 +8581,9 @@ def test_05_20
v1[0] = n
v1[1] = n * 3.0
v1
- end, 0, frames(ind1), "ignore: cut 2", ind1, 0)
- if (frames(ind1) - len * 2).abs > 3
- snd_display("map_chan double: %s %s?", len, frames(ind1))
+ end, 0, framples(ind1), "ignore: cut 2", ind1, 0)
+ if (framples(ind1) - len * 2).abs > 3
+ snd_display("map_chan double: %s %s?", len, framples(ind1))
end
revert_sound(ind1)
otime = maxamp_position(ind1)
@@ -8954,86 +8607,66 @@ def test_05_20
end
set_sample(1234, 0.0)
env_channel([0, 0, 1, 1])
- if (res = maxamp_position) != 35062
- snd_display("env_channel maxamp_position: %s (35062)?", res)
- end
+ snd_test_neq(maxamp_position(), 35062, "env_channel maxamp_position")
ootime = maxamp_position(ind1, 0, 0)
- if ootime != otime
- snd_display("maxamp_position edpos 0 (1): %s %s?", otime, ootime)
- end
+ snd_test_neq(ootime, otime, "maxamp_position edpos 0 (1)")
nntime = maxamp_position(ind1, 0, 1)
- if nntime != 1234
- snd_display("maxamp_position edpos 1 (1): %s (1234)?", nntime)
- end
+ snd_test_neq(nntime, 1234, "maxamp_position edpos 1 (1)")
nntime = maxamp_position(ind1, 0, Current_edit_position)
- if nntime != 35062
- snd_display("maxamp_position edpos current: %s (35062)?", nntime)
- end
+ snd_test_neq(nntime, 35062, "maxamp_position edpos current")
revert_sound(ind1)
make_selection(24000, 25000)
- if (res = selection_maxamp_position) != 971
- snd_display("selection_maxamp_position: %s (971)?", res)
- end
+ snd_test_neq(selection_maxamp_position(), 971, "selection_maxamp_position")
make_region(24000, 25000)
- if (res = region_maxamp_position(regions.first)) != 971
- snd_display("region_maxamp_position: %s (971)?", res)
- end
+ res = region_maxamp_position(regions.first)
+ snd_test_neq(res, 971, "region_maxamp_position")
close_sound(ind1)
ind1 = open_sound("oboe.snd")
test_edpos(ind1, :maxamp) do | | scale_by(2.0, ind1, 0) end
- test_edpos(ind1, :frames) do | | src_sound(2.0, 1.0, ind1, 0) end
+ test_edpos(ind1, :framples) do | | src_sound(2.0, 1.0, ind1, 0) end
test_edpos(ind1, :count_matches, lambda do |*args|
- snd, chn, edpos = get_test_args(args, 0, 0, Current_edit_position)
- count_matches(lambda do |n1| n1 > 0.1 end, 0, snd, chn, edpos)
- end) do | |
+ snd, chn, edpos = get_test_args(args, 0, 0, Current_edit_position)
+ count_matches(lambda do |n1| n1 > 0.1 end, 0, snd, chn, edpos)
+ end) do | |
scale_by(2.0, ind1, 0)
end
test_edpos(ind1, :find, lambda do |*args|
- snd, chn, edpos = get_test_args(args, 0, 0, Current_edit_position)
- find_channel(lambda do |n2| n2 > 0.1 end, 0, snd, chn, edpos)
- end) do | |
+ snd, chn, edpos = get_test_args(args, 0, 0, Current_edit_position)
+ find_channel(lambda do |n2| n2 > 0.1 end, 0, snd, chn, edpos)
+ end) do | |
delete_samples(0, 100, ind1, 0)
end
- test_edpos(ind1, :scan_chan, lambda do |*args|
- snd, chn, edpos = get_test_args(args, 0, 0, Current_edit_position)
- samp = 0
- scan_chan(lambda do |n3|
- if n3 > 0.1
- samp
- else
- samp += 1
- false
- end
- end, 0, frames(snd, chn), snd, chn, edpos)
- samp
- end) do | |
+ test_edpos(ind1, :scan_channel, lambda do |*args|
+ snd, chn, edpos = get_test_args(args, 0, 0, Current_edit_position)
+ samp = 0
+ scan_channel(lambda do |n3|
+ if n3 > 0.1
+ samp
+ else
+ samp += 1
+ false
+ end
+ end, 0, framples(snd, chn), snd, chn, edpos)
+ samp
+ end) do | |
delete_samples(0, 100, ind1, 0)
end
#
- src_sound(2.0, 1.0, ind1, 0)
- play(ind1, :channel, 0, :edit_position, 0, :wait, true)
- play(ind1, :channel, 0, :edit_position, 1, :wait, true)
- play(ind1, :channel, 0, :edit_position, lambda do |snd, chn|
- edit_position(snd, chn)
- end, :wait, true)
- undo_edit(1, ind1, 0)
- play(ind1, :channel, 0, :edit_position, 1, :wait, true)
- #
delete_samples(0, 10000, ind1, 0)
save_sound_as("fmv.snd", ind1, :edit_position, 0)
- save_sound_as("fmv1.snd", ind1, :edit_position, lambda do |snd, chn| 1 end)
+ save_sound_as("fmv1.snd", ind1, :edit_position, 1)
if (res = Snd.catch do
- save_sound_as("fmv2.snd", ind1, :channel, 1234)
- end).first != :no_such_channel
- snd_display("save_sound_as bad chan: %s", res)
+ save_sound_as("fmv2.snd", ind1, :channel, 1234)
+ end).first != :no_such_channel
+ snd_display("save_sound_as bad chan: %s", res)
end
- if (res0 = mus_sound_frames("fmv.snd")) != (res1 = frames(ind1, 0, 0))
+ if (res0 = mus_sound_framples("fmv.snd")) != (res1 = framples(ind1, 0, 0))
snd_display("save_sound_as (edpos): %s %s?", res0, res1)
end
- if (res0 = mus_sound_frames("fmv1.snd")) != (res1 = frames(ind1, 0, 1))
+ if (res0 = mus_sound_framples("fmv1.snd")) != (res1 = framples(ind1, 0, 1))
snd_display("save_sound_as (edpos 1): %s %s?", res0, res1)
end
- if (res0 = mus_sound_frames("fmv.snd")) == (res1 = frames(ind1, 0, 1))
+ if (res0 = mus_sound_framples("fmv.snd")) == (res1 = framples(ind1, 0, 1))
snd_display("save_sound_as (edpos 1)(2): %s %s?", res0, res1)
end
ind2 = open_sound("fmv.snd")
@@ -9046,7 +8679,8 @@ def test_05_20
res1 = channel2vct(12000, 10, ind3, 0))
snd_display("save_sound_as (edpos 4): %s %s?", res0, res1)
end
- if vequal(res0 = channel2vct(12000, 10, ind2), res1 = channel2vct(12000, 10, ind3, 0))
+ if vequal(res0 = channel2vct(12000, 10, ind2),
+ res1 = channel2vct(12000, 10, ind3, 0))
snd_display("save_sound_as (edpos 5): %s %s?", res0, res1)
end
select_sound(ind3)
@@ -9068,14 +8702,18 @@ def test_05_20
src_sound(0.5, 1.0, snd, 0, pos)
end
test_edpos_1(:filter_sound, ind1) do |snd, pos|
- filter_sound(make_fir_filter(6, vct(0.1, 0.2, 0.3, 0.3, 0.2, 0.1)), 6, snd, 0, pos)
+ filter_sound(make_fir_filter(6, vct(0.1, 0.2, 0.3, 0.3, 0.2, 0.1)),
+ 6, snd, 0, pos)
end
test_edpos_1(:convolve_with, ind1) do |snd, pos|
convolve_with("pistol.snd", 0.5, snd, 0, pos)
end
#
ind = new_sound("fmv.snd")
- v = make_vct!(2000) do |i| sin(i * (PI / 5.0)) end
+ e = make_env([0.0, 0.0, 1.0, 2000 * 0.2 * PI], :length, 2001)
+ v = make_vct!(2000) do |i|
+ sin(env(e))
+ end
vct2channel(v, 0, 2000, ind, 0)
filter_sound([0, 0, 0.09, 0, 0.1, 1, 0.11, 0, 1, 0], 1024)
if maxamp > 0.025
@@ -9094,7 +8732,8 @@ def test_05_20
old_ssc = show_sonogram_cursor
old_tgt = transform_graph_type
set_show_sonogram_cursor(true)
- set_cursor_follows_play(true)
+ set_with_tracking_cursor(true)
+ snd_test_neq(with_tracking_cursor(), true, "with_tracking_cursor set to true")
set_transform_graph_type(Graph_as_sonogram)
play(selected_sound, :wait, true)
set_transform_graph?(true)
@@ -9107,7 +8746,7 @@ end
def peak_env_equal?(name, index, e, diff)
rd = make_sampler(0, index, 0)
e_size = e.first.length
- samps_per_bin = (frames(index) / e_size.to_f).ceil
+ samps_per_bin = (framples(index) / e_size.to_f).ceil
mins, maxs = e[0, 2]
max_diff = 0.0
e_bin = 0
@@ -9175,16 +8814,18 @@ def test_05_22
set_selection_member?(false, true)
set_selection_member?(true, ind, 0)
set_selection_position(20000, ind, 0)
- set_selection_frames(12000, ind, 0)
+ set_selection_framples(12000, ind, 0)
scale_selection_by(3.0)
e1 = channel_amp_envs(ind, 0, 1)
mx3 = vct_peak(e1[0])
mx4 = vct_peak(e1[1])
if fneq(3.0 * mx1, mx3) or fneq(3.0 * mx2, mx4)
- snd_display("selection 3.0 amp env max: %s %s %s %s?", mx1, mx2, mx3, mx4)
+ snd_display("selection 3.0 amp env max: %s %s %s %s?",
+ mx1, mx2, mx3, mx4)
end
if fneq(maxamp(ind, 0), 3.0 * mx)
- snd_display("maxamp after selection scale: %s %s?", mx, maxamp(ind, 0))
+ snd_display("maxamp after selection scale: %s %s?",
+ mx, maxamp(ind, 0))
end
peak_env_equal?("selection peak", ind, e1, 0.0001)
#
@@ -9193,10 +8834,12 @@ def test_05_22
mx3 = vct_peak(e1[0])
mx4 = vct_peak(e1[1])
if fneq(3.0 * mx2, mx4)
- snd_display("abs selection 3.0 amp env max: %s %s %s %s?", mx1, mx2, mx3, mx4)
+ snd_display("abs selection 3.0 amp env max: %s %s %s %s?",
+ mx1, mx2, mx3, mx4)
end
if fneq(maxamp(ind, 0), 3.0 * mx)
- snd_display("maxamp after abs selection scale: %s %s?", mx, maxamp(ind, 0))
+ snd_display("maxamp after abs selection scale: %s %s?",
+ mx, maxamp(ind, 0))
end
peak_env_equal?("map_chan peak", ind, e1, 0.0001)
#
@@ -9205,10 +8848,12 @@ def test_05_22
mx3 = vct_peak(e1[0])
mx4 = vct_peak(e1[1])
if fneq(3.0 * mx2, mx4)
- snd_display("abs selection 3.0 amp env max: %s %s %s %s?", mx1, mx2, mx3, mx4)
+ snd_display("abs selection 3.0 amp env max: %s %s %s %s?",
+ mx1, mx2, mx3, mx4)
end
if fneq(maxamp(ind, 0), 3.0 * mx)
- snd_display("maxamp after abs selection scale: %s %s?", mx, maxamp(ind, 0))
+ snd_display("maxamp after abs selection scale: %s %s?",
+ mx, maxamp(ind, 0))
end
peak_env_equal?("delete peak", ind, e1, 0.0001)
#
@@ -9216,7 +8861,8 @@ def test_05_22
e1 = channel_amp_envs(ind, 0, 4)
mx3 = vct_peak(e1[0])
if fneq(maxamp(ind, 0), mx)
- snd_display("maxamp after minus selection scale: %s %s?", mx, maxamp(ind, 0))
+ snd_display("maxamp after minus selection scale: %s %s?",
+ mx, maxamp(ind, 0))
end
if fneq(maxamp(ind, 0), mx3)
snd_display("mx3 maxamp after minus abs selection scale: %s %s?", mx, mx3)
@@ -9230,87 +8876,117 @@ def test_05_22
env_channel([0, 0, 1, 1, 2, 0])
peak_env_equal?("env_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.002)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0], :scaler, 0.5, :length, frames))
- peak_env_equal?("scaled env_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.002)
+ env_channel(make_env([0, 0, 1, 1, 2, 0], :scaler, 0.5, :length, framples))
+ peak_env_equal?("scaled env_channel peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.002)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0], 0.5, :length, frames))
- peak_env_equal?("scaled nokey env_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.001)
+ env_channel(make_env([0, 0, 1, 1, 2, 0], 0.5, :length, framples))
+ peak_env_equal?("scaled nokey env_channel peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.001)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0], :scaler, 0.5, :offset, 0.5, :length, frames))
- peak_env_equal?("scaled and offset env_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.001)
+ env_channel(make_env([0, 0, 1, 1, 2, 0],
+ :scaler, 0.5, :offset, 0.5, :length, framples))
+ peak_env_equal?("scaled and offset env_channel peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.001)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0.5, 3, 0], :base, 0.0, :length, frames))
- peak_env_equal?("env_channel base 0.0 peak", ind, channel_amp_envs(ind, 0, 1), 0.001)
+ env_channel(make_env([0, 0, 1, 1, 2, 0.5, 3, 0],
+ :base, 0.0, :length, framples))
+ peak_env_equal?("env_channel base 0.0 peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.001)
undo_edit
xramp_channel(0.0, 1.0, 32.0)
- peak_env_equal?("xramp_channel 32.0 peak", ind, channel_amp_envs(ind, 0, 1), 0.008)
+ peak_env_equal?("xramp_channel 32.0 peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.008)
undo_edit
xramp_channel(0.0, 1.0, 0.032)
- peak_env_equal?("xramp_channel 0.032 peak", ind, channel_amp_envs(ind, 0, 1), 0.004)
+ peak_env_equal?("xramp_channel 0.032 peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.004)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0.5, 3, 0], :base, 10.0, :length, frames))
- peak_env_equal?("env_channel base 10.0 peak", ind, channel_amp_envs(ind, 0, 1), 0.01)
+ env_channel(make_env([0, 0, 1, 1, 2, 0.5, 3, 0],
+ :base, 10.0, :length, framples))
+ peak_env_equal?("env_channel base 10.0 peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.01)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0], :base, 0.1, :length, frames))
- peak_env_equal?("env_channel base 0.1 peak", ind, channel_amp_envs(ind, 0, 1), 0.003)
+ env_channel(make_env([0, 0, 1, 1, 2, 0], :base, 0.1, :length, framples))
+ peak_env_equal?("env_channel base 0.1 peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.003)
undo_edit
insert_samples(1000, 5000, make_vct(5000, 0.5))
- peak_env_equal?("insert_samples peak", ind, channel_amp_envs(ind, 0, 1), 0.0001)
+ peak_env_equal?("insert_samples peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.0001)
undo_edit
set_samples(500, 100, make_vct(100, 0.1))
- peak_env_equal?("set_samples peak", ind, channel_amp_envs(ind, 0, 1), 0.0001)
+ peak_env_equal?("set_samples peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.0001)
undo_edit
#
revert_sound(ind)
ramp_channel(0.0, 1.0)
ramp_channel(1.0, 0.0)
- peak_env_equal?("2 ramp_channel peak", ind, channel_amp_envs(ind, 0, 2), 0.002)
+ peak_env_equal?("2 ramp_channel peak",
+ ind, channel_amp_envs(ind, 0, 2), 0.002)
#
revert_sound(ind)
env_channel([0, 0, 1, 1])
env_channel([0, 0, 1, 1, 2, 0])
- peak_env_equal?("2 env_channel peak", ind, channel_amp_envs(ind, 0, 2), 0.002)
+ peak_env_equal?("2 env_channel peak",
+ ind, channel_amp_envs(ind, 0, 2), 0.002)
revert_sound(ind)
ramp_channel(0.0, 1.0, 12000, 5000)
- peak_env_equal?("ramp_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.002)
+ peak_env_equal?("ramp_channel peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.002)
undo_edit
env_channel([0, 0, 1, 1, 2, 0], 12000, 5000)
- peak_env_equal?("env_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.003)
+ peak_env_equal?("env_channel peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.003)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0], :scaler, 0.5, :length, 5000), 12000, 5000)
- peak_env_equal?("scaled env_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.004)
+ env_channel(make_env([0, 0, 1, 1, 2, 0],
+ :scaler, 0.5, :length, 5000), 12000, 5000)
+ peak_env_equal?("scaled env_channel peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.004)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0], 0.5, :length, 5000), 12000, 5000)
- peak_env_equal?("scaled nokey env_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.004)
+ env_channel(make_env([0, 0, 1, 1, 2, 0],
+ 0.5, :length, 5000), 12000, 5000)
+ peak_env_equal?("scaled nokey env_channel peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.004)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0], :scaler, 0.5, :offset, 0.5, :length, 5000), 12000, 5000)
- peak_env_equal?("scaled and offset env_channel peak", ind, channel_amp_envs(ind, 0, 1), 0.002)
+ env_channel(make_env([0, 0, 1, 1, 2, 0],
+ :scaler, 0.5, :offset, 0.5, :length, 5000), 12000, 5000)
+ peak_env_equal?("scaled and offset env_channel peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.002)
undo_edit
xramp_channel(0.0, 1.0, 32.0, 2000, 1000)
- peak_env_equal?("xramp_channel 32.0 peak (1)", ind, channel_amp_envs(ind, 0, 1), 0.009)
+ peak_env_equal?("xramp_channel 32.0 peak (1)",
+ ind, channel_amp_envs(ind, 0, 1), 0.009)
undo_edit
xramp_channel(0.0, 1.0, 0.032, 2000, 1000)
- peak_env_equal?("xramp_channel 0.032 peak (1)", ind, channel_amp_envs(ind, 0, 1), 0.01)
+ peak_env_equal?("xramp_channel 0.032 peak (1)",
+ ind, channel_amp_envs(ind, 0, 1), 0.01)
undo_edit
- env_channel(make_env([0, 0, 1, 1, 2, 0.5, 3, 0], :base, 10.0, :length, 5000), 12000, 5000)
- peak_env_equal?("env_channel base 10.0 peak", ind, channel_amp_envs(ind, 0, 1), 0.1)
+ env_channel(make_env([0, 0, 1, 1, 2, 0.5, 3, 0],
+ :base, 10.0, :length, 5000), 12000, 5000)
+ peak_env_equal?("env_channel base 10.0 peak",
+ ind, channel_amp_envs(ind, 0, 1), 0.1)
undo_edit
#
revert_sound(ind)
ramp_channel(0.0, 1.0)
ramp_channel(1.0, 0.0, 2000, 1000)
- peak_env_equal?("2 ramp_channel peak", ind, channel_amp_envs(ind, 0, 2), 0.002)
+ peak_env_equal?("2 ramp_channel peak",
+ ind, channel_amp_envs(ind, 0, 2), 0.002)
#
revert_sound(ind)
env_channel([0, 0, 1, 1])
env_channel([0, 0, 1, 1, 2, 0], 2000, 1000)
- peak_env_equal?("2 env_channel peak", ind, channel_amp_envs(ind, 0, 2), 0.002)
+ peak_env_equal?("2 env_channel peak",
+ ind, channel_amp_envs(ind, 0, 2), 0.002)
#
revert_sound(ind)
env_channel([0, 0, 1, 1])
env_channel([0, 0, 1, 1, 2, 0])
env_channel([0, 0, 1, 1], 12000, 5000)
- peak_env_equal?("3 env_channel peak", ind, channel_amp_envs(ind, 0, 3), 0.01)
+ peak_env_equal?("3 env_channel peak",
+ ind, channel_amp_envs(ind, 0, 3), 0.01)
revert_sound(ind)
close_sound(ind)
#
@@ -9348,7 +9024,7 @@ end
$g_init_val = 0
def test_channel_func(name, index, init_val, func, &val_func)
- len = frames(index)
+ len = framples(index)
chns = chans(index)
$g_init_val = init_val
2.times do |k|
@@ -9356,7 +9032,8 @@ def test_channel_func(name, index, init_val, func, &val_func)
set_sync(k, index)
chns.times do |i|
map_channel(lambda do |n| 0.0 end, 0, len, index, i)
- if res = scan_channel(lambda do |n| n.abs > 0.001 end, 0, len, index, i)
+ res = scan_channel(lambda do |n| n.abs > 0.001 end, 0, len, index, i)
+ if res
snd_display("%s init scan: %s?", name, res)
end
end
@@ -9370,7 +9047,8 @@ def test_channel_func(name, index, init_val, func, &val_func)
snd_display("%s chan func: %s %s?", name, vi, val)
end
else
- if res = scan_channel(lambda do |n| n.abs > 0.001 end, 0, len, index, j)
+ res = scan_channel(lambda do |n| n.abs > 0.001 end, 0, len, index, j)
+ if res
snd_display("%s chan func leaks? %s %s: %s", name, i, j, res)
end
end
@@ -9389,8 +9067,10 @@ def test_channel_func(name, index, init_val, func, &val_func)
snd_display("%s ed chan func: %s %s?", name, vi, val)
end
else
- if res = scan_channel(lambda do |n| n.abs > 0.001 end, 0, len, index, j)
- snd_display("%s ed chan func leaks? %s %s %s: %s", name, i, j, ed, res)
+ res = scan_channel(lambda do |n| n.abs > 0.001 end, 0, len, index, j)
+ if res
+ snd_display("%s ed chan func leaks? %s %s %s: %s",
+ name, i, j, ed, res)
end
end
end
@@ -9415,7 +9095,8 @@ def test_channel_func(name, index, init_val, func, &val_func)
snd_display("%s chan func n: %s %s?", name, vi, val)
end
else
- if res = scan_channel(lambda do |n| n.abs > 0.001 end, 0, len, index, j)
+ res = scan_channel(lambda do |n| n.abs > 0.001 end, 0, len, index, j)
+ if res
snd_display("%s dur chan func leaks? %s %s: %s", name, i, j, res)
end
end
@@ -9426,12 +9107,13 @@ def test_channel_func(name, index, init_val, func, &val_func)
end
def test_05_23
- index = new_sound("fmv.snd", Mus_next, Mus_bshort, 22050, 2, "channel tests")
+ index = new_sound("fmv.snd", 2, 22050, Mus_bshort, Mus_next, "channel tests")
insert_silence(0, 10, index, 0)
insert_silence(0, 10, index, 1)
test_channel_func(:env, index, 0.0,
lambda do |beg, dur, index, chan, edpos|
- clm_channel(make_env(:envelope, [0, 0, 1, 1], :length, dur),
+ clm_channel(make_env(:envelope, [0, 0, 1, 1],
+ :length, dur),
beg, dur, index, chan, edpos)
end) do |dur|
e = make_env(:envelope, [0, 0, 1, 1], :length, dur)
@@ -9439,7 +9121,8 @@ def test_05_23
end
test_channel_func(:oscil, index, 0.0,
lambda do |beg, dur, index, chan, edpos|
- clm_channel(make_oscil(:frequency, 0.0, :initial_phase, PI / 2.0),
+ clm_channel(make_oscil(:frequency, 0.0,
+ :initial_phase, PI / 2.0),
beg, dur, index, chan, edpos)
end) do |dur| make_vct!(dur) do 1.0 end end
test_channel_func(:scale_channel, index, 1.0,
@@ -9448,7 +9131,8 @@ def test_05_23
end) do |dur| make_vct!(dur) do 0.5 end end
test_channel_func(:env_channel, index, 1.0,
lambda do |beg, dur, index, chan, edpos|
- env_channel(make_env(:envelope, [0, 0, 1, 1], :length, dur),
+ env_channel(make_env(:envelope, [0, 0, 1, 1],
+ :length, dur),
beg, dur, index, chan, edpos)
end) do |dur|
e = make_env(:envelope, [0, 0, 1, 1], :length, dur)
@@ -9463,18 +9147,26 @@ def test_05_23
end
test_channel_func(:vct2channel, index, 1.0,
lambda do |beg, dur, index, chan, edpos|
- vct2channel(make_vct!(dur) do -1.0 end, beg, dur, index, chan)
- end) do |dur| make_vct!(dur) do -1.0 end end
+ vct2channel(make_vct!(dur) do -1.0 end,
+ beg, dur, index, chan)
+ end) do |dur|
+ make_vct!(dur) do -1.0 end
+ end
test_channel_func(:pad_channel, index, 1.0,
lambda do |beg, dur, index, chan, edpos|
delete_samples(beg, dur, index, chan, edpos)
pad_channel(beg, dur, index, chan, edpos)
- end) do |dur| make_vct(dur) end
+ end) do |dur|
+ make_vct(dur)
+ end
test_channel_func(:insert_samples, index, 1.0,
lambda do |beg, dur, index, chan, edpos|
delete_samples(beg, dur, index, chan, edpos)
- insert_samples(beg, dur, make_vct!(dur) do -1.0 end, index, chan, edpos)
- end) do |dur| make_vct!(dur) do -1.0 end end
+ insert_samples(beg, dur, make_vct!(dur) do -1.0 end,
+ index, chan, edpos)
+ end) do |dur|
+ make_vct!(dur) do -1.0 end
+ end
test_channel_func(:set_samples, index, 1.0,
lambda do |beg, dur, index, chan, edpos|
set_samples(beg, dur, make_vct!(dur) do -1.0 end,
@@ -9482,7 +9174,8 @@ def test_05_23
end) do |dur| make_vct!(dur) do -1.0 end end
test_channel_func(:reverse_channel, index, 1.0,
lambda do |beg, dur, index, chan, edpos|
- env_channel(make_env(:envelope, [0, 0, 1, 1], :length, dur),
+ env_channel(make_env(:envelope, [0, 0, 1, 1],
+ :length, dur),
beg, dur, index, chan, edpos)
reverse_channel(beg, dur, index, chan)
end) do |dur|
@@ -9491,7 +9184,8 @@ def test_05_23
end
test_channel_func(:smooth_channel, index, 1.0,
lambda do |beg, dur, index, chan, edpos|
- env_channel(make_env(:envelope, [0, 0, 1, 1], :length, dur),
+ env_channel(make_env(:envelope, [0, 0, 1, 1],
+ :length, dur),
beg, dur, index, chan, edpos)
set_sample(beg + dur, 1.0, index, chan)
smooth_channel(beg, dur, index, chan)
@@ -9504,7 +9198,7 @@ def test_05_23
#
old_max = maxamp(index, true)
regdata = Snd.regions.map do |n| region2vct(n, 0, 10) end
- old_reglen = Snd.regions.map do |n| region_frames(n) end
+ old_reglen = Snd.regions.map do |n| region_framples(n) end
s61_files = []
$save_state_hook.add_hook!("snd-test") do |file|
s61_files.push(file)
@@ -9515,12 +9209,16 @@ def test_05_23
close_sound(index)
Snd.regions.apply(:forget_region)
load("s61.rb")
- if (res = Snd.regions.map do |n| region_frames(n) end) != old_reglen
- snd_display("region_frames after save: %s %s?", old_reglen, res)
+ if (res = Snd.regions.map do |n| region_framples(n) end) != old_reglen
+ snd_display("region_framples after save: %s %s?", old_reglen, res)
end
- Snd.regions.zip(regdata) do |n, data|
- unless vequal(res = region2vct(n, 0, 10), data)
- snd_display("region after save %s: %s %s?", n, data, res)
+ Snd.catch(:all, lambda do |*args|
+ snd_display("region2vct: %s", args.inspect)
+ end) do
+ Snd.regions.zip(regdata) do |n, data|
+ unless vequal(res = region2vct(n, 0, 10), data)
+ snd_display("region after save %s: %s %s?", n, data, res)
+ end
end
end
index = find_sound("fmv.snd")
@@ -9532,7 +9230,7 @@ def test_05_23
end
10.times do |i|
pos = random(edits(index).first)
- scale_channel(random(2.0).abs, random(5.0), random(5.0), index, 0, pos)
+ scale_channel(random(2.0), random(5), random(5), index, 0, pos)
set_edit_position((edits(index).first * 0.7).floor, index)
end
close_sound(index)
@@ -9543,7 +9241,7 @@ def test_05_23
end
def test_05_24
- index = new_sound("fmv.snd", Mus_next, Mus_bshort, 22050, 2, "channel tests")
+ index = new_sound("fmv.snd", 2, 22050, Mus_bshort, Mus_next, "channel tests")
sw = sinc_width
set_sinc_width(10)
v0 = make_vct(10)
@@ -9563,21 +9261,22 @@ def test_05_24
unless vequal(res = channel2vct(0, 10, index, 1), make_vct(10))
snd_display("src_channel leaks: %s?", res)
end
- if (res = Snd.catch do src(s, 1.0, lambda do |a, b| a end) end).first != :bad_arity
- snd_display("src bad func: %s?", res.inspect)
- end
- if (res = Snd.catch do src_channel(120000.0) end).first != :mus_error
+ res = Snd.catch do src_channel(120000.0) end
+ if res.first != :mus_error
snd_display("src_channel crazy srate: %s?", res.inspect)
end
- if (res = Snd.catch do filter_sound(make_snd2sample()) end).first != :mus_error
- snd_display("filter_sound + un-run gen: %s?", res.inspect) # not relevant in Ruby?
+ res = Snd.catch do filter_sound(make_snd2sample()) end
+ if res.first != :mus_error
+ # not relevant in Ruby?
+ snd_display("filter_sound + un-run gen: %s?", res.inspect)
end
revert_sound(index)
vct2channel(v0, 0, 10, index, 1)
vct2channel(v0, 10, 10, index, 1)
src_channel(make_env(:envelope, [1, 1, 2, 2], :length, 21), 0, 20, index, 1)
unless vequal(res = channel2vct(0, 10, index, 1),
- vct(1.000, 0.000, -0.048, 0.068, -0.059, 0.022, 0.030, -0.100, 0.273, 0.606))
+ vct(1.000, 0.000, -0.048, 0.068, -0.059,
+ 0.022, 0.030, -0.100, 0.273, 0.606))
snd_display("src_channel env: %s?", res)
end
unless vequal(res = channel2vct(0, 10, index, 0), make_vct(10))
@@ -9589,7 +9288,8 @@ def test_05_24
vct2channel(v0, 10, 10, index, 1)
src_channel(make_env(:envelope, [1, 1, 2, 2], :length, 21), 0, 20, index, 1)
unless vequal(res = channel2vct(0, 10, index, 1),
- vct(1.000, 0.000, -0.048, 0.068, -0.059, 0.022, 0.030, -0.100, 0.273, 0.606))
+ vct(1.000, 0.000, -0.048, 0.068, -0.059,
+ 0.022, 0.030, -0.100, 0.273, 0.606))
snd_display("src_channel env: %s?", res)
end
unless vequal(res = channel2vct(0, 10, index, 0), make_vct(10))
@@ -9601,7 +9301,8 @@ def test_05_24
vct2channel(v0, 10, 10, index, 1)
src_channel([1, 1, 2, 2], 0, 20, index, 1)
unless vequal(res = channel2vct(0, 10, index, 1),
- vct(1.000, 0.000, -0.051, 0.069, -0.056, 0.015, 0.042, -0.117, 0.320, 0.568))
+ vct(1.000, 0.000, -0.051, 0.069, -0.056,
+ 0.015, 0.042, -0.117, 0.320, 0.568))
snd_display("src_channel lst: %s?", res)
end
unless vequal(res = channel2vct(0, 10, index, 0), make_vct(10))
@@ -9621,7 +9322,8 @@ def test_05_25
snd_display("deferred region after scaling:\n# %s\n# %s", rid0_data, res)
end
unless vequal(res = region_to_vct(rid0, 0, 20), rid0_data)
- snd_display("deferred region after scaling (rs):\n# %s\n# %s", rid0_data, res)
+ snd_display("deferred region after scaling (rs):\n# %s\n# %s",
+ rid0_data, res)
end
undo_edit
scale_by(4.0)
@@ -9658,10 +9360,10 @@ def test_05_25
set_selection_member?(false, true)
set_selection_member?(true, ind, 0)
set_selection_position(s1, ind, 0)
- set_selection_frames(l1, ind, 0)
+ set_selection_framples(l1, ind, 0)
set_selection_member?(true, ind, 1)
set_selection_position(s2, ind, 1)
- set_selection_frames(l2, ind, 1)
+ set_selection_framples(l2, ind, 1)
rid2 = make_region
rid20_data = region2vct_1(rid2, 0, l1)
rid21_data = region2vct_1(rid2, 1, l2)
@@ -9670,26 +9372,33 @@ def test_05_25
end
swap_channels(ind, 0, ind, 1)
unless vequal(res = region2vct_1(rid2, 0, l1), rid20_data)
- snd_display("deferred region after scaling (20):\n# %s\n# %s", rid20_data, res)
+ snd_display("deferred region after scaling (20):\n# %s\n# %s",
+ rid20_data, res)
end
unless vequal(res = region_to_vct(rid2, 0, l1), rid20_data)
- snd_display("deferred region after scaling (20 rs):\n# %s\n# %s", rid20_data, res)
+ snd_display("deferred region after scaling (20 rs):\n# %s\n# %s",
+ rid20_data, res)
end
unless vequal(res = region2vct_1(rid2, 1, l2), rid21_data)
- snd_display("deferred region after scaling (21):\n# %s\n# %s", rid21_data, res)
+ snd_display("deferred region after scaling (21):\n# %s\n# %s",
+ rid21_data, res)
end
unless vequal(res = region_to_vct(rid2, 1, l2), rid21_data)
- snd_display("deferred region after scaling (21 rs):\n# %s\n# %s", rid21_data, res)
+ snd_display("deferred region after scaling (21 rs):\n# %s\n# %s",
+ rid21_data, res)
end
close_sound(ind)
unless vequal(res = region2vct_1(rid2, 0, l1), rid20_data)
- snd_display("deferred region after scaling (20):\n# %s\n# %s", rid20_data, res)
+ snd_display("deferred region after scaling (20):\n# %s\n# %s",
+ rid20_data, res)
end
unless vequal(res = region_to_vct(rid2, 0, l1), rid20_data)
- snd_display("deferred region after scaling (20 rs):\n# %s\n# %s", rid20_data, res)
+ snd_display("deferred region after scaling (20 rs):\n# %s\n# %s",
+ rid20_data, res)
end
unless vequal(res = region2vct_1(rid2, 1, l2), rid21_data)
- snd_display("deferred region after scaling (21):\n# %s\n# %s", rid21_data, res)
+ snd_display("deferred region after scaling (21):\n# %s\n# %s",
+ rid21_data, res)
end
unless vequal(res = region_to_vct(rid2, 1, l2), rid21_data)
snd_display("deferred region after scaling (21 rs):\n# %s\n# %s",
@@ -9699,58 +9408,31 @@ def test_05_25
ind = open_sound("obtest.snd")
set_read_only(true, ind)
delete_samples(0, 1000, ind, 0)
- if integer?((res = Snd.catch do save_sound(ind) end).first)
+ res = Snd.catch do save_sound(ind) end
+ if sound?(res.first)
snd_display("save_sound read_only: %s", res)
end
- if (res = edits(ind)) != [1, 0]
- snd_display("read_only ignored: %s?", res)
- end
+ snd_test_neq(edits(ind), [1, 0], "read_only ignored")
set_read_only(false, ind)
revert_sound(ind)
- unless sound?((res = Snd.catch do save_sound(ind) end).first)
+ res = Snd.catch do save_sound(ind) end
+ unless sound?(res.first)
snd_display("save_sound read_write: %s", res)
end
key(key_to_int(?j), 4)
- if $with_test_gui
- if (res = widget_text(sound_widgets(ind)[3])) != "no marks" and res != "no such mark"
- snd_display("C-j w/o marks: %s?", res)
- end
- end
key(key_to_int(?-), 4)
key(key_to_int(?j), 4)
key(key_to_int(?j), 4)
key(key_to_int(?x), 4)
key(key_to_int(?c), 0)
- if $with_test_gui
- if (res = widget_text(main_widgets[1]))
- snd_display("widget_text of non-text widget: %s", res)
- end
- set_widget_text(channel_widgets(ind, 0)[2], "F")
- if (res = widget_text(channel_widgets(ind, 0)[2])) != "F"
- snd_display("set button label to F: %s?", res)
- end
- if (res = widget_text(sound_widgets(ind)[3])) != "no marks" and res != "no such mark"
- snd_display("C-x c w/o marks: %s?", res)
- end
- end
- add_mark(123)
+ Snd.catch do add_mark(123) end
key(key_to_int(?u), 4)
key(key_to_int(?6), 4)
key(key_to_int(?j), 4)
- if $with_test_gui
- if (res = widget_text(sound_widgets(ind)[3])) != "no such mark"
- snd_display("C-u 6 C-j: %s?", res)
- end
- end
key(key_to_int(?u), 4)
key(key_to_int(?6), 4)
key(key_to_int(?x), 4)
key(key_to_int(?c), 0)
- if $with_test_gui
- if (res = widget_text(sound_widgets(ind)[3])) != "no such mark"
- snd_display("C-u 6 C-x c: %s?", res)
- end
- end
close_sound(ind)
#
ns = new_sound
@@ -9762,9 +9444,9 @@ def test_05_25
vct2channel(v, 0, 1000, ns, 0)
set_selection_member?(true, ns, 0)
set_selection_position(200, ns, 0)
- set_selection_frames(300, ns, 0)
+ set_selection_framples(300, ns, 0)
delete_selection_and_smooth
- snd_test_neq(frames(ns, 0), 700, "delete_selection_and_smooth frames")
+ snd_test_neq(framples(ns, 0), 700, "delete_selection_and_smooth framples")
snd_test_neq(sample(167, ns, 0), 0.167, "delete_selection_and_smooth 167")
snd_test_neq(sample(234, ns, 0), 0.534, "delete_selection_and_smooth 234")
snd_test_neq(sample(210, ns, 0), 0.406, "delete_selection_and_smooth 210")
@@ -9782,12 +9464,8 @@ def test_05_25
mindiff = diff
end
end
- if mindiff < 0.0009
- snd_display(snd_format(mindiff, 0.0009, "<", "delete_selection_and_smooth min diff"))
- end
- if maxdiff > 0.007
- snd_display(snd_format(maxdiff, 0.007, ">", "delete_selection_and_smooth max diff"))
- end
+ snd_test_lt(mindiff, 0.0009, "delete_selection_and_smooth min diff")
+ snd_test_gt(maxdiff, 0.007, "delete_selection_and_smooth max diff")
close_sound(ns)
#
ns = new_sound
@@ -9798,7 +9476,7 @@ def test_05_25
end
vct2channel(v, 0, 1000, ns, 0)
delete_samples_and_smooth(200, 300, ns, 0)
- snd_test_neq(frames(ns, 0), 700, "delete_samples_and_smooth frames")
+ snd_test_neq(framples(ns, 0), 700, "delete_samples_and_smooth framples")
snd_test_neq(sample(167, ns, 0), 0.167, "delete_samples_and_smooth 167")
snd_test_neq(sample(234, ns, 0), 0.534, "delete_samples_and_smooth 234")
snd_test_neq(sample(210, ns, 0), 0.406, "delete_samples_and_smooth 210")
@@ -9816,23 +9494,37 @@ def test_05_25
mindiff = diff
end
end
- if mindiff < 0.0009
- snd_display(snd_format(mindiff, 0.0009, "<", "delete_samples_and_smooth min diff"))
- end
- if maxdiff > 0.007
- snd_display(snd_format(maxdiff, 0.007, ">", "delete_samples_and_smooth max diff"))
- end
+ snd_test_lt(mindiff, 0.0009, "delete_samples_and_smooth min diff")
+ snd_test_gt(maxdiff, 0.007, "delete_samples_and_smooth max diff")
close_sound(ns)
#
old_beg = initial_beg
old_dur = initial_dur
old_show = show_full_duration
$initial_graph_hook.reset_hook!
+ #
+ set_show_full_range(true)
+ ns = open_sound("1a.snd")
+ snd_test_neq(y_bounds(ns, 0), [-1.0, 1.0], "show_full_range 1.0 test")
+ close_sound(ns)
+ with_sound(:output, "test.snd", :clipped, false) do
+ fm_violin(0, 1, 440, 3.5)
+ end
+ ns = open_sound("test.snd")
+ snd_test_neq(y_bounds(ns, 0), [-3.5, 3.5], "show_full_range 3.5 test")
+ with_sound(:output, "test.snd", :clipped, false) do
+ fm_violin(0, 1, 440, 1.5)
+ end
+ update_sound(ns = find_sound("test.snd"))
+ snd_test_neq(y_bounds(ns, 0), [-1.5, 1.5], "show_full_range 1.5 test")
+ close_sound(ns)
+ set_show_full_range(false)
+ #
set_show_full_duration(true)
ns = open_sound("1.snd")
ls = left_sample(ns, 0)
rs = right_sample(ns, 0)
- fr = frames(ns, 0)
+ fr = framples(ns, 0)
snd_test_neq([fr, ls, rs], [220501, 0, 220501], "show_full_duration 1")
close_sound(ns)
set_show_full_duration(true)
@@ -9841,7 +9533,7 @@ def test_05_25
ns = open_sound("1.snd")
ls = left_sample(ns, 0)
rs = right_sample(ns, 0)
- fr = frames(ns, 0)
+ fr = framples(ns, 0)
snd_test_neq([fr, ls, rs], [220501, 0, 220501], "show_full_duration 2")
close_sound(ns)
set_show_full_duration(false)
@@ -9850,7 +9542,7 @@ def test_05_25
ns = open_sound("1.snd")
ls = left_sample(ns, 0)
rs = right_sample(ns, 0)
- fr = frames(ns, 0)
+ fr = framples(ns, 0)
snd_test_neq([fr, ls, rs], [220501, 0, 4410], "show_full_duration 3")
close_sound(ns)
set_initial_beg(2.0)
@@ -9858,7 +9550,7 @@ def test_05_25
ns = open_sound("1.snd")
ls = left_sample(ns, 0)
rs = right_sample(ns, 0)
- fr = frames(ns, 0)
+ fr = framples(ns, 0)
snd_test_neq([fr, ls, rs], [220501, 44100, 66150], "show_full_duration 4")
close_sound(ns)
set_initial_beg(old_beg)
@@ -9871,36 +9563,22 @@ def test_05_25
set_sync(1, ns)
set_sync_style(Sync_by_sound)
ns1 = open_sound("1a.snd")
- snd_test_eq(sync(ns1), 0, "Sync_by_sound open")
snd_test_eq(sync(ns1), 1, "Sync_by_sound open")
snd_test_neq(sync(ns), 1, "Sync_by_sound open")
close_sound(ns1)
close_sound(ns)
- set_sync_style(Sync_all)
- ns = open_sound("2.snd")
- ns1 = open_sound("1a.snd")
- snd_test_neq(sync(ns), sync(ns1), "Sync_all open")
- snd_test_eq(sync(ns), 0, "Sync_all open")
- set_sync_style(Sync_none)
- ns2 = open_sound("oboe.snd")
- snd_test_neq(sync(ns), sync(ns1), "back to Sync_none open")
- snd_test_neq(sync(ns2), 0, "back to Sync_none open")
- close_sound(ns2)
- close_sound(ns1)
- close_sound(ns)
set_sync_style(old_sync)
#
- view_sound("obtest.snd")
+ ind = view_sound("obtest.snd")
delete_samples(0, 1000, ind, 0)
- if integer?((res = Snd.catch do save_sound(ind) end).first)
+ res = Snd.catch do save_sound(ind) end
+ if sound?(res.first)
snd_display("save_viewed_sound: %s", res)
end
- if (res = edits(ind)) != [1, 0]
- snd_display("view read_only ignored: %s?", res)
- end
+ snd_test_neq(edits(ind), [1, 0], "view read_only ignored")
close_sound(ind)
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next)
insert_silence(0, 150000)
map_channel(lambda do |y| 0.5 end)
env_sound([0, 0, 1, 1, 2, 0])
@@ -9911,54 +9589,54 @@ def test_05_25
set_with_tracking_cursor(old_cursor)
close_sound(ind)
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next)
[150, 1500, 150000].each do |dur|
insert_silence(0, dur)
map_channel($init_channel)
env_sound([0, 0, 1, 1, 2, 0])
- rd = make_sampler(frames - 1, ind, 0, -1)
- if (res = sampler_position(rd)) != (frames - 1)
+ rd = make_sampler(framples - 1, ind, 0, -1)
+ if (res = sampler_position(rd)) != (framples - 1)
snd_display("sampler_position: %s?", res)
end
map_channel(lambda do |y| rd.call end)
pos = 0
e = make_env([0, 0, 1, 1, 2, 0], :length, dur + 1)
scan_channel(lambda do |y|
- if fneq(val = env(e), y)
- snd_display("trouble in reverse read at %s %s %s", pos, val, y)
- true
- else
- pos += 1
- false
- end
- end)
+ if fneq(val = env(e), y)
+ snd_display("trouble in reverse read at %s %s %s", pos, val, y)
+ true
+ else
+ pos += 1
+ false
+ end
+ end)
revert_sound
end
close_sound(ind)
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next)
insert_silence(0, 1000)
map_channel($init_channel)
env_sound([0, 0, 1, 1, 2, 0])
scale_channel(0.0, 100, 200)
- rd = make_sampler(frames - 1, ind, 0, -1)
+ rd = make_sampler(framples - 1, ind, 0, -1)
map_channel(lambda do |y| rd.call end)
pos = 0
e = make_env([0, 0, 1, 1, 2, 0], :length, 1001)
scan_channel(lambda do |y|
- val = env(e)
- if ((pos > 900 or pos <= 700) and fneq(val, y)) or
- (pos > 700 and pos <= 900 and fneq(y, 0.0))
- snd_display("trouble in reverse read 2 at %s %s %s", pos, val, y)
- true
- else
- pos += 1
- false
- end
- end)
+ val = env(e)
+ if ((pos > 900 or pos <= 700) and fneq(val, y)) or
+ (pos > 700 and pos <= 900 and fneq(y, 0.0))
+ snd_display("trouble in reverse read 2 at %s %s %s", pos, val, y)
+ true
+ else
+ pos += 1
+ false
+ end
+ end)
close_sound(ind)
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next)
insert_silence(0, 150000)
map_channel($init_channel)
edpos = edit_position
@@ -9979,21 +9657,21 @@ def test_05_25
when 6
env_sound([0, 1, 1, 0], 10000, 2000)
end
- rd = make_sampler(frames - 1, ind, 0, -1)
+ rd = make_sampler(framples - 1, ind, 0, -1)
map_channel(lambda do |y| rd.call end)
- rd = make_sampler(frames - 1, ind, 0, -1)
+ rd = make_sampler(framples - 1, ind, 0, -1)
map_channel(lambda do |y| rd.call end)
old_rd = make_sampler(0, ind, 0, 1, edit_position(ind, 0) - 2)
pos = 0
scan_channel(lambda do |y|
- if fneq(val = old_rd.call, y)
- snd_display("trouble in reverse (%s) read at %s %s %s", i, pos, val, y)
- true
- else
- pos += 1
- false
- end
- end)
+ if fneq(val = old_rd.call, y)
+ snd_display("trouble in reverse (%s) read at %s %s %s", i, pos, val, y)
+ true
+ else
+ pos += 1
+ false
+ end
+ end)
end
set_edit_position(edpos, ind, 0)
close_sound(ind)
@@ -10033,8 +9711,8 @@ def test_05_25
snd_display("scan_again: res %s != req %s?", res, req)
end
set_cursor(1000)
- # FIXME
- # set_sample(0.5) isn't possible
+ # XXX: set_sample(0.5) isn't possible
+ # Wrong_type_arg in set_sample: argument 1, 0.5, should be an integer
set_sample(:undefined, 0.5)
if fneq(res = sample(1000), 0.5)
snd_display("set sample no arg: %s %s?", res, sample(0))
@@ -10047,83 +9725,88 @@ def test_05_26
map_chan(lambda do |y| 1.0 end, 0, 1000)
env_channel(make_env([0, 1, 1, 1], :scaler, 0.5, :length, 1001))
check_maxamp(ind, 0.5, "simple scaler")
- check_env_vals("simple scaler", make_env([0, 1, 1, 1], :scaler, 0.5, :length, 1001))
+ check_env_vals("simple scaler",
+ make_env([0, 1, 1, 1], :scaler, 0.5, :length, 1001))
if edit_position == 2
undo_edit
else
snd_display("env+scl was no-op")
end
env_channel(make_env([0, 1, 1, 1], :offset, 0.5, :length, 1001))
- check_maxamp(ind, 1.5, "simple scaler")
- check_env_vals("simple scaler", make_env([0, 1, 1, 1], :offset, 0.5, :length, 1001))
+ check_maxamp(ind, 1.5, "simple offset")
+ check_env_vals("simple offset",
+ make_env([0, 1, 1, 1], :offset, 0.5, :length, 1001))
if edit_position == 2
undo_edit
else
snd_display("env+offset was no-op")
end
- env_channel(make_env([0, 0, 1, 1, 2, 0], :offset, 0.5, :scaler, 2.0, :length, 1001))
+ env_channel(make_env([0, 0, 1, 1, 2, 0],
+ :offset, 0.5, :scaler, 2.0, :length, 1001))
check_maxamp(ind, 2.5, "off+scl")
- check_env_vals("off+scl", make_env([0, 0, 1, 1, 2, 0], :offset, 0.5, :scaler, 2.0, :length, 1001))
+ check_env_vals("off+scl",
+ make_env([0, 0, 1, 1, 2, 0],
+ :offset, 0.5, :scaler, 2.0, :length, 1001))
undo_edit
- env_channel(make_env([0, -0.5, 1, 0, 2, -1], :offset, 0.5, :scaler, 2.0, :length, 1001))
+ env_channel(make_env([0, -0.5, 1, 0, 2, -1],
+ :offset, 0.5, :scaler, 2.0, :length, 1001))
check_maxamp(ind, 1.5, "off+scl #2")
mx = -12.0
- scan_chan(lambda do |y|
- if y > mx
- mx = y
- end
- false
- end)
- snd_test_neq(mx, 0.5, "non abs max")
+ scan_channel(lambda do |y|
+ if y > mx
+ mx = y
+ end
+ false
+ end)
+ snd_test_neq(mx, 0.5, "non abs max (correct 0.5)")
check_env_vals("off+scl #2",
- make_env([0, -0.5, 1, 0, 2, -1], :offset, 0.5, :scaler, 2.0, :length, 1001))
+ make_env([0, -0.5, 1, 0, 2, -1],
+ :offset, 0.5, :scaler, 2.0, :length, 1001))
undo_edit
- env_sound([0, 0.5, 1, 0.75, 2, 0.25], 0, frames, 32.0)
+ env_sound([0, 0.5, 1, 0.75, 2, 0.25], 0, framples(), 32.0)
check_maxamp(ind, 0.75, "xramp")
- check_env_vals("xramp", make_env([0, 0.5, 1, 0.75, 2, 0.25], :base, 32.0, :length, 1001))
+ check_env_vals("xramp",
+ make_env([0, 0.5, 1, 0.75, 2, 0.25],
+ :base, 32.0, :length, 1001))
undo_edit
env_channel_with_base([0, 0.5, 1, 0.75, 2, 0.25], 32.0)
check_maxamp(ind, 0.75, "xramp1")
- check_env_vals("xramp1", make_env([0, 0.5, 1, 0.75, 2, 0.25], :base, 32.0, :length, 1001))
+ check_env_vals("xramp1",
+ make_env([0, 0.5, 1, 0.75, 2, 0.25],
+ :base, 32.0, :length, 1001))
close_sound(ind)
#
hlb = make_hilbert_transform(8)
- snd_test_neq(make_vct!(20) do |i| hilbert_transform(hlb, (i == 0 ? 1.0 : 0.0)) end,
- vct(0, -0.01, 0, -0.046, 0, -0.152, 0, -0.614, 0, 0.614,
- 0, 0.152, 0, 0.046, 0, 0.01, 0, 0, 0, 0),
- "hilbert_transform 8 impulse response")
+ snd_test_neq(make_vct!(20) do |i|
+ hilbert_transform(hlb, (i == 0 ? 1.0 : 0.0))
+ end, vct(0, -0.01, 0, -0.046, 0, -0.152, 0, -0.614, 0,
+ 0.614, 0, 0.152, 0, 0.046, 0, 0.01, 0, 0, 0, 0),
+ "hilbert_transform 8 impulse response")
hlb = make_hilbert_transform(7)
- snd_test_neq(make_vct!(20) do |i| hilbert_transform(hlb, (i == 0 ? 1.0 : 0.0)) end,
- vct(-0.007, 0.0, -0.032, 0.0, -0.136, 0.0, -0.608, 0.0, 0.608, 0.0,
- 0.136, 0.0, 0.032, 0.0, 0.007, 0.0, 0.0, 0.0, 0.0, 0.0),
- "hilbert_transform 7 impulse response")
+ snd_test_neq(make_vct!(20) do |i|
+ hilbert_transform(hlb, (i == 0 ? 1.0 : 0.0))
+ end, vct(-0.007, 0.0, -0.032, 0.0, -0.136, 0.0, -0.608,
+ 0.0, 0.608, 0.0, 0.136, 0.0, 0.032, 0.0, 0.007,
+ 0.0, 0.0, 0.0, 0.0, 0.0), "hilbert_transform 7 impulse response")
ind = new_sound("test.snd")
pad_channel(0, 1000)
set_sample(100, 1.0)
h = make_hilbert_transform(100)
- 4.times do map_channel(lambda do |y| hilbert_transform(h, y) end) end
- res = sample(500)
- if (res - 0.98).abs > 0.01
- snd_display(snd_format(res, 0.01, ">", "hilbert impulse"))
+ 4.times do
+ map_channel(lambda do |y| hilbert_transform(h, y) end)
end
+ snd_test_gt((sample(500) - 0.98).abs, 0.01, "hilbert impulse")
set_sample(500, 0.0)
- res = maxamp(ind, 0)
- if res > 0.02
- snd_display(snd_format(res, 0.02, ">", "hilbert sidelobes"))
- end
+ snd_test_gt(maxamp(ind, 0), 0.02, "hilbert sidelobes")
scale_channel(0.0)
set_sample(100, 1.0)
h = make_hilbert_transform(101)
- 4.times do map_channel(lambda do |y| hilbert_transform(h, y) end) end
- res = sample(504)
- if (res - 0.98).abs > 0.01
- snd_display(snd_format(res, 0.01, ">", "hilbert 101 impulse"))
+ 4.times do
+ map_channel(lambda do |y| hilbert_transform(h, y) end)
end
+ snd_test_gt((sample(504) - 0.98).abs, 0.01, "hilbert 101 impulse")
set_sample(504, 0.0)
- res = maxamp(ind, 0)
- if res > 0.02
- snd_display(snd_format(res, 0.02, ">", "hilbert 101 sidelobes"))
- end
+ snd_test_gt(maxamp(ind, 0), 0.02, "hilbert 101 sidelobes")
revert_sound
pad_channel(0, 1000)
set_sample(100, 1.0)
@@ -10143,7 +9826,7 @@ def test_05_26
close_sound(ind)
#
ind = new_sound("test.snd")
- map_channel(lambda do |y| 1.0 - random(2.0) end, 0, 10000)
+ map_channel(lambda do |y| mus_random(1.0) end, 0, 10000)
f2 = make_bandpass_2(0.12 * PI, 0.15 * PI, 0.22 * PI, 0.25 * PI, 100)
map_channel(lambda do |y| bandpass_2(f2, y) end)
data = channel2vct
@@ -10160,7 +9843,8 @@ def test_05_26
undo_edit
close_sound(ind)
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1, "ramp re-order tests", 100)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next,
+ "ramp re-order tests", 100)
map_channel(lambda do |y| 1.0 end)
[["ramp-xramp", true,
lambda do
@@ -10259,7 +9943,8 @@ def test_05_26
end
close_sound(ind)
# offset channel
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1, "offset tests", 10)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next,
+ "offset tests", 10)
offset_channel(0.1)
snd_test_neq(channel2vct(0, 10), Vct.new(10, 0.1), "offset_channel (0.1)")
offset_channel(-0.2, 5, 5)
@@ -10274,34 +9959,35 @@ def test_05_26
map_channel($init_channel)
sine_ramp(0.0, 1.0)
snd_test_neq(channel2vct,
- vct(0.000, 0.024, 0.095, 0.206, 0.345, 0.500, 0.655, 0.794, 0.905, 0.976),
- "sine_ramp 0 1")
+ vct(0.000, 0.024, 0.095, 0.206, 0.345, 0.500,
+ 0.655, 0.794, 0.905, 0.976), "sine_ramp 0 1")
revert_sound(ind)
offset_channel(1.0)
sine_ramp(1.0, 0.0)
snd_test_neq(channel2vct,
- vct(1.000, 0.976, 0.905, 0.794, 0.655, 0.500, 0.345, 0.206, 0.095, 0.024),
- "sine_ramp 1 0")
+ vct(1.000, 0.976, 0.905, 0.794, 0.655, 0.500,
+ 0.345, 0.206, 0.095, 0.024), "sine_ramp 1 0")
close_sound(ind)
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1, "sine_env tests", 100)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next,
+ "sine_env tests", 100)
# map_channel($init_channel)
map_channel(lambda do |y| 1.0 end)
sine_env_channel([0, 0, 1, 1, 2, -0.5, 3, 1])
snd_test_neq(channel2vct(20, 10),
- vct(0.664, 0.708, 0.750, 0.790, 0.827, 0.862, 0.893, 0.921, 0.944, 0.964),
- "sine_env_channel 0a")
+ vct(0.664, 0.708, 0.750, 0.790, 0.827, 0.862,
+ 0.893, 0.921, 0.944, 0.964), "sine_env_channel 0a")
snd_test_neq(channel2vct(60, 10),
- vct(-0.381, -0.417, -0.446, -0.47, -0.486, -0.497, -0.5, -0.497, -0.486, -0.47),
- "sine_env_channel 0b")
+ vct(-0.381, -0.417, -0.446, -0.47, -0.486, -0.497,
+ -0.5, -0.497, -0.486, -0.47), "sine_env_channel 0b")
snd_test_neq(edit_position(ind, 0), 2, "as_one_edit sine_env_channel")
revert_sound(ind)
offset_channel(-1.0)
sine_env_channel([0, 0, 1, 1, 2, 1, 3, 0], 40, 20)
snd_test_neq(channel2vct(40, 20),
- vct(0, -0.05, -0.188, -0.389, -0.611, -0.812, -0.95, -1, -1, -1,
- -1, -1, -1, -1, -1, -0.95, -0.812, -0.611, -0.389, -0.188),
- "off+sine_env a")
+ vct(0, -0.05, -0.188, -0.389, -0.611, -0.812, -0.95,
+ -1, -1, -1, -1, -1, -1, -1, -1, -0.95, -0.812,
+ -0.611, -0.389, -0.188), "off+sine_env a")
snd_test_neq(channel2vct(30, 10), make_vct(10, -1.0), "off+sine_env b")
revert_sound(ind)
scale_by(0.0)
@@ -10338,7 +10024,8 @@ def test_05_26
end
def test_05_27
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1, "special env tests", 100)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next,
+ "special env tests", 100)
map_channel($init_channel)
blackman4_ramp(0.0, 1.0)
vals = channel2vct
@@ -10358,38 +10045,33 @@ def test_05_27
undo_edit
blackman4_env_channel([0, 0, 1, 1, 2, -0.5, 3, 0])
unless vequal(res = channel2vct(60, 10),
- vct(-0.109, -0.217, -0.313, -0.392, -0.451, -0.488, -0.499, -0.499, -0.499, -0.499))
+ vct(-0.109, -0.217, -0.313, -0.392, -0.451,
+ -0.488, -0.499, -0.499, -0.499, -0.499))
snd_display("blackman4_env_channel to -0.5: %s", res)
end
undo_edit
#
ramp_squared(0.0, 1.0)
- vals = channel2vct
+ vals = channel2vct()
undo_edit
env_squared_channel([0, 0, 1, 1])
- unless vequal(res = channel2vct, vals)
- snd_display("env_squared/ramp:\n# %s\n# %s", vals, res)
- end
+ snd_test_neq(channel2vct(), vals, "env_squared/ramp")
undo_edit
ramp_squared(0.0, 1.0, true, 0, 50)
vals = channel2vct
undo_edit
env_squared_channel([0, 0, 1, 1, 2, 1])
- unless vequal(res = channel2vct, vals)
- snd_display("env_squared/ramp 1:\n# %s\n# %s", vals, res)
- end
+ snd_test_neq(channel2vct(), vals, "env_squared/ramp 1")
undo_edit
env_squared_channel([0, 0, 1, 1, 2, -0.5, 3, 0])
- unless vequal(res = channel2vct(60, 10),
- vct(-0.450, -0.466, -0.478, -0.488, -0.494, -0.499, -0.500, -0.500, -0.498, -0.496))
- snd_display("env_squared to -0.5: %s", res)
- end
+ req = vct(-0.450, -0.466, -0.478, -0.488, -0.494,
+ -0.499, -0.500, -0.500, -0.498, -0.496)
+ snd_test_neq(channel2vct(60, 10), req, "env_squared to -0.5")
undo_edit
env_squared_channel([0, 0, 1, 1, 2, -0.5, 3, 0], false)
- unless vequal(res = channel2vct(60, 10),
- vct(-0.004, -0.080, -0.158, -0.240, -0.324, -0.410, -0.500, -0.500, -0.498, -0.496))
- snd_display("env_squared unsymmetric to -0.5: %s", res)
- end
+ req = vct(-0.004, -0.080, -0.158, -0.240, -0.324,
+ -0.410, -0.500, -0.500, -0.498, -0.496)
+ snd_test_neq(channel2vct(60, 10), req, "env_squared unsymmetric to -0.5")
undo_edit
#
ramp_squared(0.0, 1.0)
@@ -10418,40 +10100,32 @@ def test_05_27
undo_edit
#
ramp_expt(0.0, 1.0, 32.0)
- vals = channel2vct
+ vals = channel2vct()
undo_edit
env_expt_channel([0, 0, 1, 1], 32.0)
- unless vequal(res = channel2vct, vals)
- snd_display("env_expt/ramp 32:\n# %s\n# %s", vals, res)
- end
+ snd_test_neq(channel2vct(), vals, "env_expt/ramp 32")
undo_edit
ramp_expt(0.0, 1.0, 32.0, false, 0, 50)
- vals = channel2vct
+ vals = channel2vct()
undo_edit
env_expt_channel([0, 0, 1, 1, 2, 1], 32.0)
- unless vequal(res = channel2vct, vals)
- snd_display("env_expt/ramp 1 32.0:\n# %s\n# %s", vals, res)
- end
+ snd_test_neq(channel2vct(), vals, "env_expt/ramp 1 32")
undo_edit
ramp_expt(0.0, 1.0, 0.1)
- vals = channel2vct
+ vals = channel2vct()
undo_edit
env_expt_channel([0, 0, 1, 1], 0.1)
- unless vequal(res = channel2vct, vals)
- snd_display("env_expt/ramp 0.1:\n# %s\n# %s", vals, res)
- end
+ snd_test_neq(channel2vct(), vals, "env_expt/ramp 0.1")
undo_edit
env_expt_channel([0, 0, 1, 1, 2, -0.5, 3, 0], 12.0)
- unless vequal(res = channel2vct(30, 10),
- vct(0.319, 0.472, 0.691, 1.000, 0.537, 0.208, -0.022, -0.182, -0.291, -0.365))
- snd_display("env_expt to -0.5 12.0\n# %s\n# %s", vals, res)
- end
+ req = vct(0.319, 0.472, 0.691, 1.000, 0.537,
+ 0.208, -0.022, -0.182, -0.291, -0.365)
+ snd_test_neq(channel2vct(30, 10), req, "env_expt to -0.5 12.0")
undo_edit
env_expt_channel([0, 0, 1, 1, 2, -0.5, 3, 0], 12.0, false)
- unless vequal(res = channel2vct(30, 10),
- vct(0.319, 0.472, 0.691, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000))
- snd_display("env_expt ot -0.5 12.0 unsymmetric:\n# %s\n# %s", vals, res)
- end
+ req = vct(0.319, 0.472, 0.691, 1.000, 1.000,
+ 1.000, 1.000, 1.000, 1.000, 1.000)
+ snd_test_neq(channel2vct(30, 10), req, "env_expt ot -0.5 12.0 unsymmetric")
undo_edit
close_sound(ind)
#
@@ -10472,11 +10146,13 @@ def test_05_27
set_sync(1, ind0)
set_selected_sound(ind0)
env_selection([0, 0, 1, 1])
- if (res0 = edit_position(ind0, 0)) != 0 or (res1 = edit_position(ind1)) != 5
+ if (res0 = edit_position(ind0, 0)) != 0 or
+ (res1 = edit_position(ind1)) != 5
snd_display("selection override of sync field: %s %s?", res0, res1)
end
env_sound([0, 0, 1, 1, 2, 0])
- if (res0 = edit_position(ind0, 0)) != 1 or (res1 = edit_position(ind1)) != 5
+ if (res0 = edit_position(ind0, 0)) != 1 or
+ (res1 = edit_position(ind1)) != 5
snd_display("sync field over selection: %s %s?", res0, res1)
end
close_sound(ind0)
@@ -10522,369 +10198,215 @@ def test_06
v0 = make_vct(10)
v1 = Vct.new(10)
vlst = make_vct(3)
- unless vct?(v0)
- snd_display("v0 is not a vct?")
- end
- unless v0.kind_of?(Vct)
- snd_display("v0 is not kind_of? Vct?")
- end
- if v0 == 10
- snd_display("v0 is 10!?")
- end
- if vct?(10)
- snd_display("10 is a vct?")
- end
- if v0.length != 10
- snd_display("v0 length = %s?", v0.length)
- end
+ snd_test_neq(vct?(v0), true, "v0 is not a vct?")
+ snd_test_neq(v0.kind_of?(Vct), true, "v0 is not kind_of? Vct?")
+ snd_test_eq(v0, 10, "v0 is 10")
+ snd_test_neq(vct?(10), false, "10 is a vct?")
+ snd_test_neq(v0.length, 10, "Vct#length")
vct_fill!(v0, 1.0)
v1.fill(0.5)
if v0.eql?(v1)
- snd_display("vct %s.eql?(%s)?", v0, v1)
+ snd_format_eq(v0, v1, "Vct#eql?")
end
if v0 == v1
- snd_display("vct %s == %s?", v0, v1)
+ snd_format_eq(v0, v1, "Vct#==")
end
v2 = v1
v3 = Vct.new(10)
v4 = make_vct(3)
unless v1.eql?(v2)
- snd_display("vct not %s.eql?(%s)?", v1, v2)
+ snd_format_neq(v1, v2, "not Vct#eql? (1)")
end
vct_fill!(v3, 0.5)
unless v2.eql?(v1)
- snd_display("vct not %s.eql?(%s)?", v2, v1)
+ snd_format_neq(v2, v1, "not Vct#eql? (2)")
end
if v4.eql?(v1)
- snd_display("len diff vct %s.eql?(%s)?", v4, v1)
+ snd_format_eq(v4, v1, "len diff Vct#eql?")
end
+ vct_set!(v3, 0, 1.0)
+ snd_test_neq(vct_ref(v3, 0), 1.0, "vct_set!")
v3[0] = 1.0
- if fneq(v3[0], 1.0)
- snd_display("vct_set!: %s", v3[0])
- end
+ snd_test_neq(v3[0], 1.0, "Vct#[]=")
vlst[1] = 0.1
- unless vequal(res = vct2list(vlst), [0.0, 0.1, 0.0])
- snd_display("vct2list: %s?", res)
- end
+ snd_test_neq(vct2list(vlst), [0.0, 0.1, 0.0], "vct2list")
vect = [0.0, 1.0, 2.0, 3.0]
v123 = vct(0.0, 1.0, 2.0, 3.0)
v2 = vect.to_vct
v3 = v2
str = format("%s", v2.to_s)
str1 = format("%s", make_vct(32).to_s)
- unless vct?(res = vector2vct(make_array(0)))
- snd_display("vector2vct empty vect: %s", res)
- end
- unless vct?(res = make_array(0).to_vct)
- snd_display("make_array(0).to_vct empty vect: %s", res)
- end
- if str != "#<vct[len=4]: 0.000 1.000 2.000 3.000>"
- snd_display("vct print:\n# %s\n# %s?", str, v2.to_s)
- end
- if print_length == 12 and
- str1 != "#<vct[len=32]: 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ...>"
- snd_display("vct(32) print: %s?", str1)
- end
- unless vequal(v123, v2)
- snd_display("vector2vct: %s", v2)
- end
- unless (res = vct2vector(v123)) == vect
- snd_display("vct2vector:\n# %s\n# %s", vect, res)
- end
- unless (res = v123.to_a) == vect
- snd_display("v123.to_a:\n# %s\n# %s", vect, res)
- end
+ snd_test_neq(vct?(vector2vct(make_array(0))), true, "vector2vct empty vect")
+ snd_test_neq(vct?(make_array(0).to_vct), true,
+ "make_array(0).to_vct empty vect")
+ snd_test_neq(str, "#<vct[len=4]: 0.000 1.000 2.000 3.000>", "Vct#to_s")
+ snd_test_neq(v123, v2, "vector2vct")
+ snd_test_neq(vct2vector(v123), vect, "vct2vector")
+ snd_test_neq(v123.to_a, vect, "Vct#to_a")
unless v3.eql?(v2)
- snd_display("vct=? %s %s", v2, v3)
- end
- if v2.length != 4
- snd_display("vector2vct length: %s?", v2.lenght)
- end
- if fneq(v2[2], 2.0)
- snd_display("vector2vct: %s?", v2)
+ snd_format_neq(v3, v2, "Vct#eql?")
end
+ snd_test_neq(v2.length, 4, "vector2vct#length")
+ snd_test_neq(v2[2], 2.0, "vector2vct[2]")
vct_move!(v2, 0, 2)
- if fneq(v2[0], 2.0)
- snd_display("vct_move!: %s?", v2)
- end
+ snd_test_neq(v2[0], 2.0, "vct_move!")
v2 = Vct.new(4) do |i| i end
v2.move!(3, 2, true)
- if fneq(v2[3], 2.0) or fneq(v2[2], 1.0)
- snd_display("vct_move! back: %s?", v2)
- end
- unless vequal(vct(4, 3, 2, 1), res = vct_reverse!(vct(1, 2, 3, 4)))
- snd_display("vct_reverse: %s?", res)
- end
- unless vequal(vct(3, 2, 1), res = vct(1, 2, 3).reverse)
- snd_display("vct_reverse: %s?", res)
- end
- unless vequal(vct(2, 1), res = vct_reverse!(vct(1, 2)))
- snd_display("vct_reverse: %s?", res)
- end
- unless vequal(vct(1), res = vct(1).reverse)
- snd_display("vct_reverse: %s?", res)
- end
- unless vequal(vct(4, 3, 2, 1), res = vct(1, 2, 3, 4).reverse(4))
- snd_display("vct_reverse: %s?", res)
- end
- unless vequal(vct(3, 2, 1), res = vct_reverse!(vct(1, 2, 3), 3))
- snd_display("vct_reverse: %s?", res)
- end
- unless vequal(vct(2, 1), res = vct(1, 2).reverse(2))
- snd_display("vct_reverse: %s?", res)
- end
- unless vequal(vct(1), res = vct_reverse!(vct(1), 1))
- snd_display("vct_reverse: %s?", res)
- end
+ snd_test_neq(v2[2], 1.0, "Vct#move! back (1)")
+ snd_test_neq(v2[3], 2.0, "Vct#move! back (2)")
+ snd_test_neq(vct(3, 2, 1), vct_reverse!(vct(1, 2, 3)), "vct_reverse!")
+ snd_test_neq(vct(3, 2, 1), vct(1, 2, 3).reverse, "Vct#reverse")
+ snd_test_neq(vct(2, 1), vct_reverse!(vct(1, 2)), "vct_reverse!")
+ snd_test_neq(vct(1), vct(1).reverse, "vct(1)#reverse")
+ snd_test_neq(vct(4, 3, 2, 1), vct(1, 2, 3, 4).reverse(4), "Vct#reverse(4)")
+ snd_test_neq(vct(3, 2, 1), vct_reverse!(vct(1, 2, 3), 3), "vct_reverse(3)")
+ snd_test_neq(vct(2, 1), vct(1, 2).reverse(2), "Vct#reverse(2)")
+ snd_test_neq(vct(1), vct_reverse!(vct(1), 1), "vct_reverse!(1)")
#
vv0 = Vct.new(3)
- if (res = Snd.catch do vct_ref(vv0, 10) end).first != :out_of_range
- snd_display("vct_ref high index: %s", res)
- end
- if (res = Snd.catch do vv0[-4] end).first != :out_of_range
- snd_display("[] low index: %s", res)
- end
- if (res = Snd.catch do vct_set!(vv0, 10, 1.0) end).first != :out_of_range
- snd_display("vct_set! high index: %s", res)
- end
- if (res = Snd.catch do vv0[-1] = 1.0 end).first != :out_of_range
- snd_display("[]= low index: %s", res)
- end
- if (res = Snd.catch do vct_move!(vv0, 10, 0, true) end).first != :out_of_range
- snd_display("vct_move! high index: %s", res)
- end
- if (res = Snd.catch do vv0.move(0, 10, true) end).first != :out_of_range
- snd_display("v.move high 2 index: %s", res)
- end
- if (res = Snd.catch do vct_move!(vv0, -10, 0, false) end).first != :out_of_range
- snd_display("vct_move! back high index: %s", res)
- end
- if (res = Snd.catch do vv0.move!(0, -10, false) end).first != :out_of_range
- snd_display("v.move! back high 2 index: %s", res)
- end
+ snd_test_neq(Snd.catch do vct_ref(vv0, 10) end.first,
+ :out_of_range, "vct_ref high index")
+ snd_test_neq(Snd.catch do vv0[-4] end.first,
+ :out_of_range, "Vct#[] low index")
+ snd_test_neq(Snd.catch do vct_set!(vv0, 10, 1.0) end.first,
+ :out_of_range, "vct_set! high index")
+ snd_test_neq(Snd.catch do vv0[-1] = 1.0 end.first,
+ :out_of_range, "Vct#[]= low index")
+ snd_test_neq(Snd.catch do vct_move!(vv0, 10, 0, true) end.first,
+ :out_of_range, "vct_move! high index")
+ snd_test_neq(Snd.catch do vv0.move(0, 10, true) end.first,
+ :out_of_range, "Vct#move high 2 index")
+ snd_test_neq(Snd.catch do vct_move!(vv0, -10, 0, false) end.first,
+ :out_of_range, "vct_move! back high index")
+ snd_test_neq(Snd.catch do vv0.move!(0, -10, false) end.first,
+ :out_of_range, "Vct#move! back high 2 index")
10.times do |i|
- if fneq(v0[i], 1.0)
- snd_display("fill v0[%s] = %s?", i, v0[i])
- end
- if fneq(v1[i], 0.5)
- snd_display("preset v1[%s] = %s?", i, v1[i])
- end
+ snd_test_neq(v0[i], 1.0, "fill v0[%d]", i)
+ snd_test_neq(v1[i], 0.5, "preset v1[%d]", i)
end
# add
v0.add(v1).each_with_index do |x, i|
- if fneq(x, 1.5)
- snd_display("v0.add[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.5, "Vct#add[%d]", i)
end
(v0 + v1).each_with_index do |x, i|
- if fneq(x, 1.5)
- snd_display("v0 + v1[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.5, "Vct#+[%d]", i)
end
vct_add!(v0, v1)
v0.each_with_index do |x, i|
- if fneq(x, 1.5)
- snd_display("add v0[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.5, "vct_add![%d]", i)
end
# subtract
v0.subtract(v1).each_with_index do |x, i|
- if fneq(x, 1.0)
- snd_display("v0.subtract[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.0, "Vct#subtract[%d]", i)
end
(v0 - v1).each_with_index do |x, i|
- if fneq(x, 1.0)
- snd_display("v0 - v1 [%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.0, "Vct#-[%d]", i)
end
vct_subtract!(v0, v1)
v0.each_with_index do |x, i|
- if fneq(x, 1.0)
- snd_display("subtract v0[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.0, "vct_subtract![%d]", i)
end
# dup, vct_copy
v0.dup.each_with_index do |x, i|
- if fneq(x, 1.0)
- snd_display("v0.dup[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.0, "Vct#dup[%d]", i)
end
v2 = vct_copy(v0)
v2.each_with_index do |x, i|
- if fneq(x, 1.0)
- snd_display("copy v2[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.0, "vct_copy[%d]", i)
end
# scale
v2.scale(5.0).each_with_index do |x, i|
- if fneq(x, 5.0)
- snd_display("v2.scale[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 5.0, "Vct#scale[%d]", i)
end
(v2 * 5.0).each_with_index do |x, i|
- if fneq(x, 5.0)
- snd_display("v2 * 5.0 [%s] = %s?", i, x)
- end
+ snd_test_neq(x, 5.0, "Vct#*[%d]", i)
end
vct_scale!(v2, 5.0)
v2.each_with_index do |x, i|
- if fneq(x, 5.0)
- snd_display("scale v2[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 5.0, "vct_scale![%d]", i)
end
# offset
v0.offset(-1.0).each_with_index do |x, i|
- if fneq(x, 0.0)
- snd_display("v0.offset[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 0.0, "Vct#offset[%d]", i)
end
(v0 + -1.0).each_with_index do |x, i|
- if fneq(x, 0.0)
- snd_display("v0 + -1.0 [%s] = %s?", i, x)
- end
+ snd_test_neq(x, 0.0, "Vct#+[%d]", i)
end
vct_offset!(v0, -1.0)
v0.each_with_index do |x, i|
- if fneq(x, 0.0)
- snd_display("offset v0[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 0.0, "vct_offset![%d]", i)
end
# multiply
v2.multiply(v1).each_with_index do |x, i|
- if fneq(x, 2.5)
- snd_display("v2.multiply[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 2.5, "Vct#multiply[%d]", i)
end
(v2 * v1).each_with_index do |x, i|
- if fneq(x, 2.5)
- snd_display("v2 * v1 [%s] = %s?", i, x)
- end
+ snd_test_neq(x, 2.5, "Vct#*[%d]", i)
end
vct_multiply!(v2, v1)
v2.each_with_index do |x, i|
- if fneq(x, 2.5)
- snd_display("multiply v2[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 2.5, "vct_multiply![%d]", i)
end
#
- if fneq(vct_peak(v2), 2.5)
- snd_display("peak of v2 is %s?", vct_peak(v2))
- end
- if fneq(v2.peak, 2.5)
- snd_display("v2.peak is %s?", vct_peak(v2))
- end
+ snd_test_neq(vct_peak(v2), 2.5, "vct_peak (1)")
+ snd_test_neq(v2.peak, 2.5, "Vct#peak (1)")
v2[5] = 123.0
- if fneq(vct_peak(v2), 123.0)
- snd_display("set peak of v2 is %s?", vct_peak(v2))
- end
- if fneq(v2.peak, 123.0)
- snd_display("v2.peak is %s?", vct_peak(v2))
- end
+ snd_test_neq(vct_peak(v2), 123.0, "vct_peak (2)")
+ snd_test_neq(v2.peak, 123.0, "Vct#peak (2)")
vn = Vct.new(32) do |i| i end
vb = make_vct(64)
vs = make_vct(3)
vss = Vct.new(1)
vnew = vct_subseq(vn, 3)
- if fneq(vnew[0], 3.0)
- snd_display("vct_subseq[3:] %s?", vneq[0])
- end
- if vnew.length != 29
- snd_display("vct_subseq[3:] length %s?", vnew.length)
- end
+ snd_test_neq(vnew[0], 3.0, "vct_subseq[3:]")
+ snd_test_neq(vnew.length, 29, "vct_subseq[3:] length")
vnew = vn.subseq(3, 8)
- if fneq(vnew[0], 3.0)
- snd_display("v.subseq[3:8] %s?", vneq[0])
- end
- if vnew.length != 6
- snd_display("v.subseq[3:8] length %s?", vnew.length)
- end
+ snd_test_neq(vnew[0], 3.0, "Vct#subseq[3:8]")
+ snd_test_neq(vnew.length, 6, "Vct#subseq[3:8] length")
vct_subseq(vn, 3, 3, vs)
- if fneq(vs[0], 3.0) or fneq(vs[1], 0.0) or fneq(vs[2], 0.0)
- snd_display("vct_subseq[3:3->vs] %s?", vs)
- end
+ snd_test_neq(vs[0], 3.0, "vct_subseq[3:3->vs] (1)")
+ snd_test_neq(vs[1], 0.0, "vct_subseq[3:3->vs] (2)")
+ snd_test_neq(vs[2], 0.0, "vct_subseq[3:3->vs] (3)")
vn.subseq(0, 32, vs)
- if vs.length != 3
- snd_display("v.subseq[:32->vs] length %s?", vs.length)
- end
+ snd_test_neq(vs.length, 3, "Vct#subseq[:32->vs] length")
vn.subseq(2, 3, vss)
- if fneq(vss[0], 2.0)
- snd_display("v.subseq[2:3->vss] %s?", vss[0])
- end
+ snd_test_neq(vss[0], 2.0, "Vct#subseq[2:3->vss]")
vb[8] = 123.0
vct_subseq(vn, 1, 8, vb)
- if fneq(vb[0], 1.0)
- snd_display("vct_subseq[1:8->vb] %s?", vb[0])
- end
- if fneq(vb[8], 123.0)
- snd_display("vct_subseq[1:8->vb][8] %s?", vb[8])
- end
+ snd_test_neq(vb[0], 1.0, "vct_subseq[1:8->vb][0]")
+ snd_test_neq(vb[8], 123.0, "vct_subseq[1:8->vb][8]")
# vct_add, vct_multiply (vct+, vct*)
v1 = Vct.new(3, 0.1)
v2 = make_vct(4, 0.2)
- unless vequal(res = vct_add(v1.dup, v2), vct(0.3, 0.3, 0.3))
- snd_display("vct_add 0.1 0.2: %s?", res)
- end
- unless vequal(res = v1 + v2, vct(0.3, 0.3, 0.3))
- snd_display("v1 + v2 0.1 0.2: %s?", res)
- end
+ snd_test_neq(vct_add(v1.dup, v2), vct(0.3, 0.3, 0.3), "vct_add 0.1 0.2")
+ snd_test_neq(v1 + v2, vct(0.3, 0.3, 0.3), "Vct#+ 0.1 0.2")
v1[1] = 0.3
- unless vequal(res = vct_add(v1.dup, v2), vct(0.3, 0.5, 0.3))
- snd_display("vct_add 0.1 0.2 (1): %s?", res)
- end
- unless vequal(res = v1 + v2, vct(0.3, 0.5, 0.3))
- snd_display("v1 + v2 0.1 0.2 (1): %s?", res)
- end
- unless vequal(res = vct_add(v1.dup, 2.0), vct(2.1, 2.3, 2.1))
- snd_display("vct_add 0.1 2.0: %s?", res)
- end
- unless vequal(res = v1 + 2.0, vct(2.1, 2.3, 2.1))
- snd_display("v1 + 2.0 0.1 2.0: %s?", res)
- end
- unless vequal(res = vct_add(2.0, v1.dup), vct(2.1, 2.3, 2.1))
- snd_display("vct_add 0.1 2.0 (1): %s?", res)
- end
- unless vequal(res = 2.0 + v1, vct(2.1, 2.3, 2.1))
- snd_display("2.0 + v1 0.1 2.0 (1): %s?", res)
- end
- unless vequal(res = vct_multiply(2.0, v1.dup), vct(0.2, 0.6, 0.2))
- snd_display("vct_multiply 2.0: %s?", res)
- end
- unless vequal(res = 2.0 * v1, vct(0.2, 0.6, 0.2))
- snd_display("2.0 * v1 2.0: %s?", res)
- end
- unless vequal(res = vct_multiply(v1.dup, 2.0), vct(0.2, 0.6, 0.2))
- snd_display("vct_multiply 2.0 (1): %s?", res)
- end
- unless vequal(res = v1 * 2.0, vct(0.2, 0.6, 0.2))
- snd_display("v1 * 2.0 2.0 (1): %s?", res)
- end
- unless vequal(res = vct_multiply(v1.dup, v2), vct(0.02, 0.06, 0.02))
- snd_display("vct_multiply v1 v2: %s?", res)
- end
- unless vequal(res = v1 * v2, vct(0.02, 0.06, 0.02))
- snd_display("v1 * v2 v1 v2: %s?", res)
- end
+ snd_test_neq(vct_add(v1.dup, v2), vct(0.3, 0.5, 0.3), "vct_add 0.1 0.2 (1)")
+ snd_test_neq(v1 + v2, vct(0.3, 0.5, 0.3), "Vct#+ 0.1 0.2 (1)")
+ snd_test_neq(vct_add(v1.dup, 2.0), vct(2.1, 2.3, 2.1), "vct_add 0.1 2.0")
+ snd_test_neq(v1 + 2.0, vct(2.1, 2.3, 2.1), "Vct#+ 0.1 2.0")
+ snd_test_neq(vct_add(2.0, v1.dup), vct(2.1, 2.3, 2.1), "vct_add 0.1 2.0 (1)")
+ snd_test_neq(2.0 + v1, vct(2.1, 2.3, 2.1), "2.0#+(v1) 0.1 2.0 (1)")
+ snd_test_neq(vct_multiply(2.0, v1.dup), vct(0.2, 0.6, 0.2), "vct_multiply 2")
+ snd_test_neq(2.0 * v1, vct(0.2, 0.6, 0.2), "2.0#*(v1)")
+ snd_test_neq(vct_multiply(v1.dup, 2.0), vct(0.2, 0.6, 0.2),
+ "vct_multiply 2 (1)")
+ snd_test_neq(v1 * 2.0, vct(0.2, 0.6, 0.2), "Vct#* 2 (1)")
+ snd_test_neq(vct_multiply(v1.dup, v2), vct(0.02, 0.06, 0.02),
+ "vct_multiply v1 v2")
+ snd_test_neq(v1 * v2, vct(0.02, 0.06, 0.02), "Vct#*(v2)")
#
v0.map do |val| PI end.each_with_index do |x, i|
- if fneq(x, PI)
- snd_display("v0.map[%s] = %s?", i, x)
- end
+ snd_test_neq(x, PI, "Vct#map[%d]", i)
end
- vct_map!(v0, lambda do | | 1.0 end)
+ v0.map! do |x| 1.0 end
v0.each_with_index do |x, i|
- if fneq(x, 1.0)
- snd_display("map v0[%s] = %s?", i, x)
- end
+ snd_test_neq(x, 1.0, "Vct#map[%d] 1.0", i)
end
#
- if fneq(vct(1.0, 2.0, 3.0)[1], 2.0)
- snd_display("vct(...) = %s?", vct(1.0, 2.0, 3.0)[1])
- end
+ snd_test_neq(vct(1.0, 2.0, 3.0)[1], 2.0, "vct(...)[1]")
v1 = [1, 2, 3, 4].to_vct
- if fneq(v1[1], 2.0)
- snd_display("v1[1] = %s?", v1[1])
- end
+ snd_test_neq(v1[1], 2.0, "Vct#[1]")
#
ind = open_sound("oboe.snd")
set_speed_control(0.5, ind)
@@ -10896,72 +10418,35 @@ def test_06
# try some special cases
#
apply_controls
- if edit_position(ind) != 0
- snd_display("apply_controls with no change: %s: %s", edits(ind), edit_tree(ind))
- end
+ snd_test_neq(edit_position(ind), 0, "apply_controls with no change")
set_speed_control(-1.0, ind)
apply_controls
- if $with_test_gui and edit_position(ind) != 1
- snd_display("apply_controls with srate -1.0: %s: %s", edits(ind), edit_tree(ind))
+ if $with_test_gui
+ snd_test_neq(edit_position(ind), 1, "apply_controls with srate -1.0")
end
- if ((res0 = frames(ind, 0)) - (res1 = frames(ind, 0, 0))).abs > 2
+ if ((res0 = framples(ind, 0)) - (res1 = framples(ind, 0, 0))).abs > 2
snd_display("apply_controls srate -1.0 lengths: %s %s", res0, res1)
end
res1 = sample(9327)
if fneq(res0 = maxamp, 0.147) or res1.abs < 0.01
snd_display("apply_controls srate -1.0 samples: %s %s?", res0, res1)
end
- if fneq(res = speed_control(ind), 1.0)
- snd_display("apply_controls -1.0 -> %s?", res)
- end
- ctr = 0
- $dac_hook.add_hook!("snd-test") do |data|
- ctr += 1
- if ctr >= 3
- set_playing(false)
- end
- end
- play(selected_sound, :wait, true)
- if ctr != 3
- snd_display("ctr after dac_hook: %s", ctr)
- end
+ snd_test_neq(speed_control(ind), 1.0, "apply_controls -1.0")
set_speed_control(1.5)
apply_controls
- $dac_hook.reset_hook!
- revert_sound
- set_speed_control(1.5)
- ctr = 0
- $dac_hook.add_hook!("snd-test") do |data|
- ctr += 1
- if ctr == 3
- apply_controls
- end
- end
- play(selected_sound, :wait, true)
- if edit_position(ind, 0) != 1
- snd_display("apply_controls from hook: %s %s", edits(ind), edit_tree(ind))
- end
- $dac_hook.reset_hook!
revert_sound
set_speed_control(1.5)
- stop_playing
$after_apply_controls_hook.add_hook!("snd-test") do |s|
- if (res = Snd.catch do apply_controls end).first != :cannot_apply_controls
- snd_display("after_apply_controls_hook: recursive attempt apply_controls: %s", res)
- end
+ snd_test_neq(Snd.catch do apply_controls() end.first,
+ :cannot_apply_controls,
+ "after_apply_controls_hook: recursive attempt apply_controls")
end
apply_controls
$after_apply_controls_hook.reset_hook!
- $dac_hook.add_hook!("snd-test") do |s|
- if (res = Snd.catch do apply_controls end).first != :cannot_apply_controls
- snd_display("dac_hook: recursive attempt apply_controls: %s", res)
- end
- end
- $dac_hook.reset_hook!
revert_sound
close_sound(ind)
#
- # Vct.new.map twice, Vct.new twice, and vct_map! twice
+ # Vct.new.map twice, and Vct.new twice
#
v1 = Vct.new(32)
v1.map! do
@@ -10969,176 +10454,93 @@ def test_06
v2.map! do 0.1 end
v2.first
end
- if fneq(v1[12], 0.1)
- snd_display("v.map! twice: %s?", v1[12])
- end
+ snd_test_neq(v1[12], 0.1, "v.map! twice")
Vct.new(32) do Vct.new(3) do 0.1 end.first end
- if fneq(v1[12], 0.1)
- snd_display("Vct.new twice: %s?", v1[12])
- end
- v1 = make_vct(32)
- vct_map!(v1, lambda do | |
- v2 = make_vct(3)
- vct_map!(v2, lambda do | | 0.1 end)
- vct_ref(v2, 0)
- end)
- if fneq(v1[12], 0.1)
- snd_display("vct_map! twice: %s?", v1[12])
- end
+ snd_test_neq(v1[12], 0.1, "v.new twice")
hi = make_vct(3)
- if (res = Snd.catch do vct_subseq(hi, 1, 0) end).first != :out_of_range
- snd_display("vct_subseq 1 0: %s", res.inspect)
- end
- unless vct?(vct())
- snd_display("vct -> %s?", vct().inspect)
- end
- unless vct?(res = make_vct(0))
- snd_display("make_vct(0) -> %s?", res.inspect)
- end
- ho = make_vct(3)
- vct_add!(hi, ho, 4)
+ snd_test_neq(Snd.catch do vct_subseq(hi, 1, 0) end.first,
+ :out_of_range, "vct_subseq 1 0")
+ snd_test_neq(vct?(vct()), true, "vct() not a vct")
+ snd_test_neq(vct?(make_vct(0)), true, "make_vct(0) not a vct")
v0 = make_vct(5, 0.1)
v1 = make_vct(6, 0.2)
v0.add!(v1, 2)
- unless vequal(v0, [0.1, 0.1, 0.3, 0.3, 0.3].to_vct)
- snd_display("v.add! + offset: %s?", v0)
- end
+ snd_test_neq(v0, [0.1, 0.1, 0.3, 0.3, 0.3].to_vct, "v.add! + offset")
#
# vct methods
#
- if (v1 = Vct.new(10)) != (v2 = make_vct(10))
- snd_display("Vct.new 0.000: %s %s?", v1, v2)
- end
- if (v1 = Vct.new(10, 3.14)) != (v2 = make_vct(10, 3.14))
- snd_display("Vct.new 3.140: %s %s?", v1, v2)
- end
+ snd_test_neq(Vct.new(10), make_vct(10), "Vct#new 0.000")
+ snd_test_neq(Vct.new(10, 3.14), make_vct(10, 3.14), "Vct#new 3.140")
v1 = Vct.new(10) do |i| i * 0.01 end
v2 = make_vct(10)
ctr = -1
- vct_map!(v2, lambda do | | (ctr += 1) * 0.01 end)
- if v1 != v2
- snd_display("Vct.new 0.000...0.090: %s %s?", v1, v2)
- end
- if vct_ref(v1, 8) != v2[8] or v2[8] != 0.08
- snd_display("Vct#[]: %s %s?", vct_ref(v1, 8), v2[8])
- end
+ v2.map! do |x| (ctr += 1) * 0.01 end
+ snd_test_neq(v1, v2, "Vct#new 0.000 0.010 0.020...")
+ snd_test_neq(vct_ref(v1, 8), v2[8], "Vct#[] (1)")
+ snd_test_neq(v2[8], 0.08, "Vct#[] (2)")
vct_set!(v1, 8, 0.5)
v2[8] = 0.5
- if vct_ref(v1, 8) != v2[8] or v2[8] != 0.5
- snd_display("Vct#[]=: %s %s?", vct_ref(v1, 8), v2[8])
- end
- if v1.length != vct_length(v2) or v2.length != vct_length(v1) or v2.length != 10
- snd_display("Vct#length: %s %s %s %s?", v1.length, vct_length(v1), v2.length, vct_length(v2))
- end
+ snd_test_neq(vct_ref(v1, 8), v2[8], "Vct#[]= (1)")
+ snd_test_neq(v2[8], 0.5, "Vct#[]= (2)")
+ snd_test_neq(v1.length, vct_length(v2), "Vct#length (1)")
+ snd_test_neq(v2.length, vct_length(v1), "Vct#length (2)")
+ snd_test_neq(v2.length, 10, "Vct#length (3)")
v1.each_with_index do |val, i|
- if val != vct_ref(v2, i)
- snd_display("Vct#each: %s %s?", val, vct_ref(v2, i))
- end
- end
- if (v1 <=> v2).nonzero?
- snd_display("Vct#<=> (0): %s?", (v1 <=> v2))
- end
- if (v3 = Vct.new(10) do |i| i * 0.001 end <=> v1) != -1
- snd_display("Vct#<=> (-1): %s?", (v3 <=> v1))
- end
- if (v2 <=> (v3 = Vct.new(10) do |i| i * 0.001 end)) != 1
- snd_display("Vct#<=> (1): %s?", (v2 <=> v3))
+ snd_test_neq(val, v2[i], "Vct#each (%d)", i)
end
+ snd_test_neq(v1 <=> v2, 0, "Vct#<=> (0)")
+ snd_test_neq(Vct.new(10) do |i| i * 0.001 end <=> v1, -1, "Vct#<=> (-1)")
+ snd_test_neq(v2 <=> Vct.new(10) do |i| i * 0.001 end, 1, "Vct#<=> (1)")
v2.map! do |val| val + 0.5 end
v3 = v1.map do |val| val + 0.5 end
- if v2 != v3
- snd_display("Vct#map(!): %s %s?", v2, v3)
- end
+ snd_test_neq(v2, v3, "Vct#map(!)")
v2 = v1.dup
- if (v1 <=> v2).nonzero?
- snd_display("Vct#dup: %s?", v1, v2)
- end
+ snd_test_neq(v1 <=> v2, 0, "Vct#dup")
vec1 = make_array(10) do |i| i * 0.01 end
vec1[8] = 0.5
vec2 = v2.to_a
- if vec1 != vec2
- snd_display("Vct#to_a: %s %s?", vec1, vec2)
- end
- if vec1.to_vct != v1
- snd_display("Array#to_vct: %s %s?", vec1.to_vct, v1)
- end
- if vct2string(v1) != v2.to_str or
- v2.to_str != "vct(0.000, 0.010, 0.020, 0.030, 0.040, 0.050, 0.060, 0.070, 0.500, 0.090)"
- snd_display("Vct#to_str:\n# %s\n# %s?", vct2string(v1), v2.to_str)
- end
- if v1.peak != vct_peak(v2)
- snd_display("Vct#peak: %s %s?", v1.peak, vct_peak(v2))
- end
+ snd_test_neq(vec1, vec2, "Vct#to_a")
+ snd_test_neq(vec1.to_vct, v1, "Array#to_vct")
+ snd_test_neq(vct2string(v1), v2.to_str, "Vct#to_str")
+ snd_test_neq(v2.to_str, "\
+vct(0.000, 0.010, 0.020, 0.030, 0.040, 0.050, 0.060, 0.070, 0.500, 0.090)",
+ "Vct#to_str")
+ snd_test_neq(v1.peak, vct_peak(v2), "Vct#peak")
v3 = v1.dup
v3.add!(v2)
v4 = v1.add(v2)
- if v3 != v4
- snd_display("Vct#add(!): %s %s?", v3, v4)
- end
+ snd_test_neq(v3, v4, "Vct#add(!)")
v3 = v1.dup
v3.subtract!(v2)
v4 = v1.subtract(v2)
- if v3 != v4
- snd_display("Vct#subtract(!): %s %s?", v3, v4)
- end
+ snd_test_neq(v3, v4, "Vct#subtract(!)")
v3 = v1.dup
v3.multiply!(v2)
v4 = v1.multiply(v2)
- if v3 != v4
- snd_display("Vct#multiply(!): %s %s?", v3, v4)
- end
+ snd_test_neq(v3, v4, "Vct#multiply(!)")
v3 = v1.dup
v3.offset!(0.5)
v4 = v1.offset(0.5)
- if v3 != v4
- snd_display("Vct#offset(!): %s %s?", v3, v4)
- end
+ snd_test_neq(v3, v4, "Vct#offset(!)")
v3 = v1.dup
v3.scale!(2.0)
v4 = v1.scale(2.0)
- if v3 != v4
- snd_display("Vct#scale(!): %s %s?", v3, v4)
- end
+ snd_test_neq(v3, v4, "Vct#scale(!)")
v3 = Vct.new(10)
v4 = Vct.new(10)
v3.fill(0.5)
vct_fill!(v4, 0.5)
- if v3 != v4
- snd_display("Vct#fill: %s %s?", v3, v4)
- end
- if v1.first != vct_ref(v2, 0)
- snd_display("Vct#first: %s %s?", v1.first, vct_ref(v2, 0))
- end
- if v1.last != vct_ref(v2, vct_length(v2) - 1)
- snd_display("Vct#last: %s %s?", v1.last, vct_ref(v2, vct_length(v2) - 1))
- end
+ snd_test_neq(v3, v4, "Vct#fill(!)")
+ snd_test_neq(v1.first, vct_ref(v2, 0), "Vct#first")
+ snd_test_neq(v1.last, vct_ref(v2, vct_length(v2) - 1), "Vct#last")
v1.first = 0.2
vct_set!(v2, 0, 0.2)
- if v1.first != vct_ref(v2, 0) or v1.first != 0.2
- snd_display("Vct#first: %s %s?", v1.first, vct_ref(v2, 0))
- end
+ snd_test_neq(v1.first, vct_ref(v2, 0), "Vct#first (2)")
+ snd_test_neq(v1.first, 0.2, "Vct#first (3)")
v1.last = 0.3
vct_set!(v2, vct_length(v2) - 1, 0.3)
- if v1.last != vct_ref(v2, vct_length(v2) - 1) or v1.last != 0.3
- snd_display("Vct#last: %s %s?", v1.last, vct_ref(v2, vct_length(v2) - 1))
- end
- #
- # make_fm_violin (v.rb)
- #
- samps = 1000
- ind = new_sound(:file, "fmv.snd", :srate, 22050, :channels, 2, :size, samps)
- dur = samples2seconds(samps)
- # thunk
- fmv1 = make_fm_violin(0, dur, 440, 0.5, :thunk?, true)
- v3 = make_vct(samps)
- vct_map!(v3, fmv1)
- vct2channel(v3, 0, samps, ind, 0)
- # proc with one arg
- fmv2 = make_fm_violin(0, dur, 440, 0.5, :thunk?, false)
- map_channel(fmv2, 0, samps, ind, 1)
- snd_test_neq(channel2vct(100, 100, ind, 0), channel2vct(100, 100, ind, 1), "make_fm_violin")
- close_sound(ind)
- delete_file("fmv.snd")
+ snd_test_neq(v1.last, vct_ref(v2, vct_length(v2) - 1), "Vct#last (2)")
+ snd_test_neq(v1.last, 0.3, "Vct#last (3)")
end
# ---------------- test 07: colors ----------------
@@ -11236,9 +10638,9 @@ end
def check_colormap(name, colmap, x, r, g, b, n, err)
r1, g1, b1 = colormap_ref(colmap, x)
if x < (1.0 - (1.0 / n)) and
- (fneq_err(r, r1, err) or # okay
- fneq_err(g, g1, err) or # okay
- fneq_err(b, b1, err)) # okay
+ (fneq_err(r, r1, err) or
+ fneq_err(g, g1, err) or
+ fneq_err(b, b1, err))
snd_display_prev_caller("%s %1.4f (%1.4f): %s %s",
name,
x,
@@ -11428,54 +10830,54 @@ def test_07_02(old_colormap_size)
if (res = colormap_name($rainbow_colormap)) != "rainbow"
snd_display("rainbow: %s?", res)
end
- purple_cmap = add_colormap("purple",
- lambda do |size|
- r = make_vct(size)
- g = make_vct(size)
- b = make_vct(size)
- er = [0, 60, 60, 116, 128, 252, 192, 252, 256, 60]
- eg = [0, 0, 64, 0, 128, 252, 192, 252, 256, 0]
- eb = [0, 80, 128, 252, 192, 0, 256, 80]
- incr = 256.0 / size
- x = 0.0
- size.times do |i|
- r[i] = envelope_interp(x, er) / 256.0
- g[i] = envelope_interp(x, eg) / 256.0
- b[i] = envelope_interp(x, eb) / 256.0
- x += incr
- end
- [r, g, b]
- end)
- sin_cmap = add_colormap("sin",
- lambda do |size|
- r = make_vct(size)
- g = make_vct(size)
- b = make_vct(size)
- incr = (2.0 * PI) / size
- x = 0.0
- size.times do |i|
- r[i] = sin(1.5 * x).abs
- g[i] = sin(3.5 * x).abs
- b[i] = sin(2.5 * x).abs
- x += incr
- end
- [r, g, b]
- end)
- another_sin_cmap = add_colormap("another-sin",
- lambda do |size|
- r = make_vct(size)
- g = make_vct(size)
- b = make_vct(size)
- incr = (2.0 * PI) / size
- x = 0.0
- size.times do |i|
- r[i] = sin(2.5 * x).abs
- g[i] = sin(3.5 * x).abs
- b[i] = sin(4.5 * x).abs
- x += incr
- end
- [r, g, b]
- end)
+ add_colormap("purple",
+ lambda do |size|
+ r = make_vct(size)
+ g = make_vct(size)
+ b = make_vct(size)
+ er = [0, 60, 60, 116, 128, 252, 192, 252, 256, 60]
+ eg = [0, 0, 64, 0, 128, 252, 192, 252, 256, 0]
+ eb = [0, 80, 128, 252, 192, 0, 256, 80]
+ incr = 256.0 / size
+ x = 0.0
+ size.times do |i|
+ r[i] = envelope_interp(x, er) / 256.0
+ g[i] = envelope_interp(x, eg) / 256.0
+ b[i] = envelope_interp(x, eb) / 256.0
+ x += incr
+ end
+ [r, g, b]
+ end)
+ add_colormap("sin",
+ lambda do |size|
+ r = make_vct(size)
+ g = make_vct(size)
+ b = make_vct(size)
+ incr = (2.0 * PI) / size
+ x = 0.0
+ size.times do |i|
+ r[i] = sin(1.5 * x).abs
+ g[i] = sin(3.5 * x).abs
+ b[i] = sin(2.5 * x).abs
+ x += incr
+ end
+ [r, g, b]
+ end)
+ add_colormap("another-sin",
+ lambda do |size|
+ r = make_vct(size)
+ g = make_vct(size)
+ b = make_vct(size)
+ incr = (2.0 * PI) / size
+ x = 0.0
+ size.times do |i|
+ r[i] = sin(2.5 * x).abs
+ g[i] = sin(3.5 * x).abs
+ b[i] = sin(4.5 * x).abs
+ x += incr
+ end
+ [r, g, b]
+ end)
[1024, 256, 2, 512].each do |n|
set_colormap_size(n)
10.times do |i|
@@ -11488,9 +10890,9 @@ def test_07_02(old_colormap_size)
err = 0.01
if n > 2 and
x < (1.0 - (1.0 / n)) and
- (fneq_err(r, r1, err) or # okay
- fneq_err(g, g1, err) or # okay
- fneq_err(b, b1, err)) # okay
+ (fneq_err(r, r1, err) or
+ fneq_err(g, g1, err) or
+ fneq_err(b, b1, err))
snd_display("copper size reset %s: %1.4f (%1.4f): %s %s",
n,
x,
@@ -11517,36 +10919,33 @@ end
# ---------------- test 08: clm ----------------
def sweep2bins(flt, bins)
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1, false, 22050)
- phase = 0.0
- freq = 0.0
- incr = PI / 22050
- map_channel(lambda do |y|
- val = sin(phase)
- phase += freq
- freq += incr
- 0.5 * val
- end)
- if proc?(flt)
- map_channel(flt)
+ ind = open_sound("sweep.snd")
+ if mus_generator?(flt)
+ clm_channel(flt)
else
- map_channel(lambda do |y| flt.run(y, 0.0) end)
+ map_channel(flt)
end
- mx = maxamp
+ mx = maxamp()
size = (22050 / bins).round
- resp = Vct.new(bins) do |i| channel2vct(i * size, size).peak end
+ resp = Vct.new(bins) do |i|
+ channel2vct(i * size, size).peak
+ end
close_sound(ind)
[mx, resp]
end
def filter_response_max(f1)
- mx = 0.0
- 1000.times do |i| mx = [mx, f1.run(i.zero? ? 1.0 : 0.0, 0.0).abs].max end
+ mx = f1.run(1.0).abs
+ 1000.times do |i|
+ mx = [mx, f1.run(0.0).abs].max
+ end
mx
end
def filter_equal?(f1, f2)
- f1.order == f2.order and vequal(f1.xcoeffs, f2.xcoeffs) and vequal(f1.ycoeffs, f2.ycoeffs)
+ f1.order == f2.order and
+ vequal(f1.xcoeffs, f2.xcoeffs) and
+ vequal(f1.ycoeffs, f2.ycoeffs)
end
def f05equal?(f1, f2)
@@ -11557,12 +10956,11 @@ def analog_filter_tests
#
# Butterworth
#
- poles = [vct(1.000, 1.414, 1.000),
- vct(1.000, 1.848, 1.000, 1.000, 0.765, 1.000),
- vct(1.000, 1.932, 1.000, 1.000, 1.414, 1.000, 1.000, 0.518, 1.000),
- vct(1.000, 1.962, 1.000, 1.000, 1.663, 1.000, 1.000, 1.111, 1.000, 1.000, 0.390, 1.000),
- vct(1.000, 1.975, 1.000, 1.000, 1.782, 1.000, 1.000, 1.414, 1.000, 1.000, 0.908, 1.000,
- 1.000, 0.313, 1.000)]
+ poles = [vct(1, 1.414, 1),
+ vct(1, 1.848, 1, 1, 0.765, 1),
+ vct(1, 1.932, 1, 1, 1.414, 1, 1, 0.518, 1),
+ vct(1, 1.962, 1, 1, 1.663, 1, 1, 1.111, 1, 1, 0.390, 1),
+ vct(1, 1.975, 1, 1, 1.782, 1, 1, 1.414, 1, 1, 0.908, 1, 1, 0.313, 1)]
k = 0
2.step(11, 2) do |i|
vals = butterworth_prototype(i)
@@ -11582,10 +10980,12 @@ def analog_filter_tests
2.step(16, 2) do |i|
local = make_butterworth_lowpass(i, cutoff)
dsp = make_butter_lp(k, mus_srate * cutoff)
- snd_test_any_neq(local, dsp, :filter_equal?, "butterworth lowpass %1.4f", cutoff)
+ snd_test_any_neq(local, dsp, :filter_equal?,
+ "butterworth lowpass %1.4f", cutoff)
local = make_butterworth_highpass(i, cutoff)
dsp = make_butter_hp(k, mus_srate * cutoff)
- snd_test_any_neq(local, dsp, :filter_equal?, "butterworth highpass %1.4f", cutoff)
+ snd_test_any_neq(local, dsp, :filter_equal?,
+ "butterworth highpass %1.4f", cutoff)
k += 1
end
cutoff += 0.1
@@ -11599,133 +10999,128 @@ def analog_filter_tests
map_channel(chordalize())
close_sound(ind)
#
+ ind = new_sound("sweep.snd", 1, 22050, Mus_bfloat, Mus_next, false, 22050)
+ phase = 0.0
+ freq = 0.0
+ incr = PI / 22050.0
+ map_channel(lambda do |y|
+ val = sin(phase)
+ phase += freq
+ freq += incr
+ val * 0.5
+ end)
+ save_sound(ind)
+ close_sound(ind)
f1 = make_butterworth_lowpass(8, 0.1)
vals = sweep2bins(f1, 10)
snd_test_neq(vals[0], 0.5, "butterworth lp 8 max")
- snd_test_neq(vals[1],
- vct(0.500, 0.500, 0.359, 0.014, 0.001, 0.000, 0.000, 0.000, 0.000, 0.000),
- "butterworth lp 8 0.1 spect")
+ v1 = vct(0.500, 0.500, 0.359, 0.014, 0.001, 0.000, 0.000, 0.000, 0.000, 0.000)
+ snd_test_neq(vals[1], v1, "butterworth lp 8 0.1 spect")
f1 = make_butterworth_lowpass(12, 0.25)
vals = sweep2bins(f1, 10)
snd_test_neq(vals[0], 0.5, "butterworth lp 12 max")
- snd_test_neq(vals[1],
- vct(0.500, 0.500, 0.500, 0.500, 0.499, 0.358, 0.010, 0.000, 0.000, 0.000),
- "butterworth lp 12 0.25 spect")
+ v1 = vct(0.500, 0.500, 0.500, 0.500, 0.499, 0.358, 0.010, 0.000, 0.000, 0.000)
+ snd_test_neq(vals[1], v1, "butterworth lp 12 0.25 spect")
f1 = make_butterworth_lowpass(10, 0.4)
vals = sweep2bins(f1, 10)
snd_test_neq(vals[0], 0.5, "butterworth lp 10 max")
- if (not vequal(vals[1], vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.499, 0.361, 0.001))) and
- (not vequal(vals[1], vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.499, 0.360, 0.002)))
- snd_display(snd_format_neq(vals[1],
- vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.499, 0.361, 0.001),
- "butterworth lp 10 0.4 spect"))
+ v0 = vals[1]
+ v1 = vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.499, 0.361, 0.001)
+ v2 = vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.499, 0.360, 0.002)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2))
+ snd_test_neq(v0, v1, "butterworth lp 10 0.4 spect (v1)")
+ snd_test_neq(v0, v2, "butterworth lp 10 0.4 spect (v2)")
end
2.step(12, 2) do |i|
0.1.step(0.35, 0.1) do |j|
f1 = make_butterworth_lowpass(i, j)
- mx = filter_response_max(f1)
- if mx > 1.0
- snd_display(snd_format(mx, 1.0, ">", "butter low max %d %d", i, j))
- end
+ snd_test_gt(filter_response_max(f1), 1.0, "butter low max %d %d", i, j)
end
end
#
f1 = make_butterworth_highpass(8, 0.1)
vals = sweep2bins(f1, 10)
snd_test_neq(vals[0], 0.5, "butterworth hp 8 max")
- snd_test_neq(vals[1],
- vct(0.001, 0.348, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500),
- "butterworth hp 8 0.1 spect")
+ v1 = vct(0.001, 0.348, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500)
+ snd_test_neq(vals[1], v1, "butterworth hp 8 0.1 spect")
f1 = make_butterworth_highpass(12, 0.25)
vals = sweep2bins(f1, 10)
snd_test_neq(vals[0], 0.5, "butterworth hp 12 max")
- snd_test_neq(vals[1],
- vct(0.000, 0.000, 0.000, 0.011, 0.348, 0.500, 0.500, 0.500, 0.500, 0.500),
- "butterworth hp 12 0.25 spect")
+ v1 = vct(0.000, 0.000, 0.000, 0.011, 0.348, 0.500, 0.500, 0.500, 0.500, 0.500)
+ snd_test_neq(vals[1], v1, "butterworth hp 12 0.25 spect")
f1 = make_butterworth_highpass(10, 0.4)
vals = sweep2bins(f1, 10)
snd_test_neq(vals[0], 0.5, "butterworth hp 10 max")
- snd_test_neq(vals[1],
- vct(0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.005, 0.343, 0.501, 0.501),
- "butterworth hp 10 0.4 spect")
+ v1 = vct(0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.005, 0.343, 0.501, 0.501)
+ snd_test_neq(vals[1], v1, "butterworth hp 10 0.4 spect")
2.step(12, 2) do |i|
0.1.step(0.35, 0.1) do |j|
f1 = make_butterworth_highpass(i, j)
- mx = filter_response_max(f1)
- if mx > 1.0
- snd_display(snd_format(mx, 1.0, ">", "butter high max %d %d", i, j))
- end
+ snd_test_gt(filter_response_max(f1), 1.0, "butter high max %d %d", i, j)
end
end
#
f1 = make_butterworth_bandpass(4, 0.1, 0.2)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bp 4 max") # okay
- snd_test_neq(vals[1],
- vct(0.028, 0.350, 0.481, 0.479, 0.346, 0.132, 0.038, 0.009, 0.002, 0.000),
- "butterworth bp 4 0.1 0.2 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bp 4 max")
+ v1 = vct(0.028, 0.350, 0.481, 0.479, 0.346, 0.132, 0.038, 0.009, 0.002, 0.000)
+ snd_test_neq(vals[1], v1, "butterworth bp 4 0.1 0.2 spect")
f1 = make_butterworth_bandpass(12, 0.1, 0.2)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bp 12 max") # okay
- snd_test_neq(vals[1],
- vct(0.000, 0.323, 0.501, 0.500, 0.358, 0.009, 0.000, 0.000, 0.000, 0.000),
- "butterworth bp 12 0.1 0.2 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bp 12 max")
+ v1 = vct(0.000, 0.323, 0.501, 0.500, 0.358, 0.009, 0.000, 0.000, 0.000, 0.000)
+ snd_test_neq(vals[1], v1, "butterworth bp 12 0.1 0.2 spect")
f1 = make_butterworth_bandpass(8, 0.3, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bp 8 max") # okay
- snd_test_neq(vals[1],
- vct(0.000, 0.000, 0.000, 0.003, 0.034, 0.344, 0.499, 0.499, 0.353, 0.002),
- "butterworth bp 8 0.3 0.4 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bp 8 max")
+ v1 = vct(0.000, 0.000, 0.000, 0.003, 0.034, 0.344, 0.499, 0.499, 0.353, 0.002)
+ snd_test_neq(vals[1], v1, "butterworth bp 8 0.3 0.4 spect")
#
f1 = make_butterworth_bandstop(4, 0.1, 0.2)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bs 4 max") # okay
- snd_test_neq(vals[1],
- vct(0.500, 0.500, 0.347, 0.339, 0.481, 0.499, 0.500, 0.500, 0.500, 0.500),
- "butterworth bs 4 0.1 0.2 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bs 4 max")
+ v1 = vct(0.500, 0.500, 0.347, 0.339, 0.481, 0.499, 0.500, 0.500, 0.500, 0.500)
+ snd_test_neq(vals[1], v1, "butterworth bs 4 0.1 0.2 spect")
f1 = make_butterworth_bandstop(12, 0.1, 0.2)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bs 12 max") # okay
- snd_test_neq(vals[1],
- vct(0.500, 0.500, 0.365, 0.334, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500),
- "butterworth bs 12 0.1 0.2 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bs 12 max")
+ v1 = vct(0.500, 0.500, 0.365, 0.334, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500)
+ snd_test_neq(vals[1], v1, "butterworth bs 12 0.1 0.2 spect")
f1 = make_butterworth_bandstop(8, 0.3, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bs 8 max") # okay
- snd_test_neq(vals[1],
- vct(0.500, 0.500, 0.500, 0.500, 0.500, 0.498, 0.354, 0.332, 0.500, 0.500),
- "butterworth bs 8 0.3 0.4 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "butterworth bs 8 max")
+ v1 = vct(0.500, 0.500, 0.500, 0.500, 0.500, 0.498, 0.354, 0.332, 0.500, 0.500)
+ snd_test_neq(vals[1], v1, "butterworth bs 8 0.3 0.4 spect")
#
# Chebyshev
#
# ripple 0.01 0.1 1 for 2..10 even
- poles_01 = [vct(1.000, 4.456, 10.426),
- vct(1.000, 0.822, 2.006, 1.000, 1.984, 1.299),
- vct(1.000, 0.343, 1.372, 1.000, 0.937, 0.939, 1.000, 1.280, 0.506),
- vct(1.000, 0.189, 1.196, 1.000, 0.537, 0.925, 1.000, 0.804, 0.542,
- 1.000, 0.948, 0.272),
- vct(1.000, 0.119, 1.121, 1.000, 0.347, 0.940, 1.000, 0.540, 0.646,
- 1.000, 0.680, 0.352, 1.000, 0.754, 0.170)]
- zeros = [vct(0.000, 0.000, 1.000),
- vct(0.000, 0.000, 0.250, 0.000, 0.000, 1.000),
- vct(0.000, 0.000, 0.062, 0.000, 0.000, 1.000, 0.000, 0.000, 1.000),
- vct(0.000, 0.000, 0.016, 0.000, 0.000, 1.000, 0.000, 0.000, 1.000, 0.000, 0.000, 1.000),
- vct(0.000, 0.000, 0.004, 0.000, 0.000, 1.000, 0.000, 0.000, 1.000, 0.000, 0.000, 1.000,
- 0.000, 0.000, 1.000)]
- poles_1 = [vct(1.000, 2.372, 3.314),
- vct(1.000, 0.528, 1.330, 1.000, 1.275, 0.623),
- vct(1.000, 0.229, 1.129, 1.000, 0.627, 0.696, 1.000, 0.856, 0.263),
- vct(1.000, 0.128, 1.069, 1.000, 0.364, 0.799, 1.000, 0.545, 0.416,
- 1.000, 0.643, 0.146),
- vct(1.000, 0.082, 1.044, 1.000, 0.237, 0.862, 1.000, 0.369, 0.568,
- 1.000, 0.465, 0.274, 1.000, 0.515, 0.092)]
- poles_10 = [vct(1.000, 1.098, 1.103),
- vct(1.000, 0.279, 0.987, 1.000, 0.674, 0.279),
- vct(1.000, 0.124, 0.991, 1.000, 0.340, 0.558, 1.000, 0.464, 0.125),
- vct(1.000, 0.070, 0.994, 1.000, 0.199, 0.724, 1.000, 0.298, 0.341,
- 1.000, 0.352, 0.070),
- vct(1.000, 0.045, 0.996, 1.000, 0.130, 0.814, 1.000, 0.203, 0.521,
- 1.000, 0.255, 0.227, 1.000, 0.283, 0.045)]
+ poles_01 = [vct(1, 4.456, 10.426),
+ vct(1, 0.822, 2.006, 1, 1.984, 1.299),
+ vct(1, 0.343, 1.372, 1, 0.937, 0.939, 1, 1.280, 0.506),
+ vct(1, 0.189, 1.196, 1, 0.537, 0.925, 1, 0.804, 0.542,
+ 1, 0.948, 0.272),
+ vct(1, 0.119, 1.121, 1, 0.347, 0.940, 1, 0.540, 0.646,
+ 1, 0.680, 0.352, 1, 0.754, 0.170)]
+ zeros = [vct(0, 0, 1),
+ vct(0, 0, 0.250, 0, 0, 1),
+ vct(0, 0, 0.062, 0, 0, 1, 0, 0, 1),
+ vct(0, 0, 0.016, 0, 0, 1, 0, 0, 1, 0, 0, 1),
+ vct(0, 0, 0.004, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1)]
+ poles_1 = [vct(1, 2.372, 3.314),
+ vct(1, 0.528, 1.330, 1, 1.275, 0.623),
+ vct(1, 0.229, 1.129, 1, 0.627, 0.696, 1, 0.856, 0.263),
+ vct(1, 0.128, 1.069, 1, 0.364, 0.799, 1, 0.545, 0.416,
+ 1, 0.643, 0.146),
+ vct(1, 0.082, 1.044, 1, 0.237, 0.862, 1, 0.369, 0.568,
+ 1, 0.465, 0.274, 1, 0.515, 0.092)]
+ poles_10 = [vct(1, 1.098, 1.103),
+ vct(1, 0.279, 0.987, 1, 0.674, 0.279),
+ vct(1, 0.124, 0.991, 1, 0.340, 0.558, 1, 0.464, 0.125),
+ vct(1, 0.070, 0.994, 1, 0.199, 0.724, 1, 0.298, 0.341,
+ 1, 0.352, 0.070),
+ vct(1, 0.045, 0.996, 1, 0.130, 0.814, 1, 0.203, 0.521,
+ 1, 0.255, 0.227, 1, 0.283, 0.045)]
k = 0
2.step(11, 2) do |i|
vals = chebyshev_prototype(i, 0.01)
@@ -11740,289 +11135,285 @@ def analog_filter_tests
#
f1 = make_chebyshev_lowpass(8, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "chebyshev lp 8 max") # okay
- if (not vequal(vals[1], vct(0.508, 0.512, 0.468, 0.001, 0, 0, 0, 0, 0, 0))) and
- (not vequal(vals[1], vct(0.507, 0.512, 0.467, 0.001, 0, 0, 0, 0, 0, 0))) and
- (not vequal(vals[1], vct(0.508, 0.513, 0.469, 0.001, 0, 0, 0, 0, 0, 0))) and
- (not vequal(vals[1], vct(0.509, 0.508, 0.465, 0.001, 0, 0, 0, 0, 0, 0)))
- snd_display(snd_format_neq(vals[1],
- vct(0.508, 0.512, 0.468, 0.001, 0, 0, 0, 0, 0, 0),
- "chebyshev lp 8 0.1 spect"))
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "chebyshev lp 8 max")
+ v0 = vals[1]
+ v1 = vct(0.508, 0.512, 0.468, 0.001, 0, 0, 0, 0, 0, 0)
+ v2 = vct(0.507, 0.512, 0.467, 0.001, 0, 0, 0, 0, 0, 0)
+ v3 = vct(0.508, 0.513, 0.469, 0.001, 0, 0, 0, 0, 0, 0)
+ v4 = vct(0.509, 0.508, 0.465, 0.001, 0, 0, 0, 0, 0, 0)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2)) and
+ (not vequal(v0, v3)) and (not vequal(v0, v4))
+ snd_test_neq(v0, v1, "chebyshev lp 8 0.1 spect (v1)")
+ snd_test_neq(v0, v2, "chebyshev lp 8 0.1 spect (v2)")
+ snd_test_neq(v0, v3, "chebyshev lp 8 0.1 spect (v3)")
+ snd_test_neq(v0, v4, "chebyshev lp 8 0.1 spect (v4)")
end
f1 = make_chebyshev_lowpass(12, 0.25)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "chebyshev lp 12 max") # okay
- snd_test_neq(vals[1],
- vct(0.509, 0.500, 0.508, 0.508, 0.507, 0.413, 0, 0, 0, 0),
- "chebyshev lp 12 0.25 spect")
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "chebyshev lp 12 max")
+ v1 = vct(0.509, 0.500, 0.508, 0.508, 0.507, 0.413, 0, 0, 0, 0)
+ snd_test_neq(vals[1], v1, "chebyshev lp 12 0.25 spect")
f1 = make_chebyshev_lowpass(10, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "chebyshev lp 10 max") # okay
- snd_test_neq(vals[1],
- vct(0.465, 0.493, 0.509, 0.508, 0.477, 0.507, 0.508, 0.507, 0.431, 0),
- "chebyshev lp 10 0.4 spect")
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "chebyshev lp 10 max")
+ v1 = vct(0.465, 0.493, 0.509, 0.508, 0.477, 0.507, 0.508, 0.507, 0.431, 0)
+ snd_test_neq(vals[1], v1, "chebyshev lp 10 0.4 spect")
f1 = make_chebyshev_lowpass(8, 0.1, 0.01)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.49, :ffequal?, "chebyshev lp 8 0.1 0.01 max") # okay
- snd_test_neq(vals[1],
- vct(0.492, 0.491, 0.483, 0.006, 0, 0, 0, 0, 0, 0),
- "chebyshev lp 8 0.1 0.01 spect")
+ snd_test_any_neq(vals[0], 0.49, :ffequal?, "chebyshev lp 8 0.1 0.01 max")
+ v1 = vct(0.492, 0.491, 0.483, 0.006, 0, 0, 0, 0, 0, 0)
+ snd_test_neq(vals[1], v1, "chebyshev lp 8 0.1 0.01 spect")
f1 = make_chebyshev_lowpass(12, 0.25, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.49, :ffequal?, "chebyshev lp 12 0.1 max") # okay
- snd_test_neq(vals[1],
- vct(0.488, 0.488, 0.488, 0.488, 0.487, 0.403, 0, 0, 0, 0),
- "chebyshev lp 12 0.25 0.1 spect")
+ snd_test_any_neq(vals[0], 0.49, :ffequal?, "chebyshev lp 12 0.1 max")
+ v1 = vct(0.488, 0.488, 0.488, 0.488, 0.487, 0.403, 0, 0, 0, 0)
+ snd_test_neq(vals[1], v1, "chebyshev lp 12 0.25 0.1 spect")
f1 = make_chebyshev_lowpass(10, 0.4, 0.001)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.49, :ffequal?, "chebyshev lp 10 0.001 max") # okay
- snd_test_neq(vals[1],
- vct(0.497, 0.497, 0.497, 0.497, 0.497, 0.497, 0.497, 0.497, 0.488, 0),
- "chebyshev lp 10 0.4 0.001 spect")
+ snd_test_any_neq(vals[0], 0.49, :ffequal?, "chebyshev lp 10 0.001 max")
+ v1 = vct(0.497, 0.497, 0.497, 0.497, 0.497, 0.497, 0.497, 0.497, 0.488, 0)
+ snd_test_neq(vals[1], v1, "chebyshev lp 10 0.4 0.001 spect")
2.step(10, 2) do |i|
0.1.step(0.35, 0.1) do |j|
f1 = make_chebyshev_lowpass(i, j)
- mx = filter_response_max(f1)
- if mx > 1.0
- snd_display(snd_format(mx, 1.0, ">", "cheby low max %d %d", i, j))
- end
+ snd_test_gt(filter_response_max(f1), 1.0, "cheby low max %d %d", i, j)
end
end
#
f1 = make_chebyshev_highpass(8, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.55, :ffequal?, "chebyshev hp 8 max") # okay
- snd_test_neq(vals[1],
- vct(0, 0.341, 0.551, 0.509, 0.466, 0.501, 0.509, 0.505, 0.481, 0.461),
- "chebyshev hp 8 0.1 spect")
+ snd_test_any_neq(vals[0], 0.55, :ffequal?, "chebyshev hp 8 max")
+ v1 = vct(0, 0.341, 0.551, 0.509, 0.466, 0.501, 0.509, 0.505, 0.481, 0.461)
+ snd_test_neq(vals[1], v1, "chebyshev hp 8 0.1 spect")
f1 = make_chebyshev_highpass(12, 0.25)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.55, :ffequal?, "chebyshev hp 12 max") # okay
- snd_test_neq(vals[1],
- vct(0, 0, 0, 0, 0.299, 0.554, 0.509, 0.509, 0.500, 0.509),
- "chebyshev hp 12 0.25 spect")
+ snd_test_any_neq(vals[0], 0.55, :ffequal?, "chebyshev hp 12 max")
+ v1 = vct(0, 0, 0, 0, 0.299, 0.554, 0.509, 0.509, 0.500, 0.509)
+ snd_test_neq(vals[1], v1, "chebyshev hp 12 0.25 spect")
f1 = make_chebyshev_highpass(10, 0.4)
vals = sweep2bins(f1, 10)
- # snd_test_any_neq(vals[0], 0.55, :ffequal?, "chebyshev hp 10 max") # okay
- if (not vequal(vals[1], vct(0, 0, 0, 0, 0, 0, 0, 0.297, 0.786, 0.677))) and
- (not vequal(vals[1], vct(0, 0, 0, 0, 0, 0, 0, 0.301, 0.788, 0.660))) and
- (not vequal(vals[1], vct(0, 0, 0, 0, 0, 0, 0, 0.322, 0.861, 0.724))) and
- (not vequal(vals[1], vct(0, 0, 0, 0, 0, 0, 0, 0.262, 0.571, 0.509)))
- snd_display(snd_format_neq(vals[1],
- vct(0, 0, 0, 0, 0, 0, 0, 0.297, 0.786, 0.677),
- "chebyshev hp 10 0.4 spect"))
+ v0 = vals[1]
+ v1 = vct(0, 0, 0, 0, 0, 0, 0, 0.297, 0.786, 0.677)
+ v2 = vct(0, 0, 0, 0, 0, 0, 0, 0.301, 0.788, 0.660)
+ v3 = vct(0, 0, 0, 0, 0, 0, 0, 0.322, 0.861, 0.724)
+ v4 = vct(0, 0, 0, 0, 0, 0, 0, 0.262, 0.571, 0.509)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2)) and
+ (not vequal(v0, v3)) and (not vequal(v0, v4))
+ snd_test_neq(v0, v1, "chebyshev hp 10 0.4 spect (v1)")
+ snd_test_neq(v0, v2, "chebyshev hp 10 0.4 spect (v2)")
+ snd_test_neq(v0, v3, "chebyshev hp 10 0.4 spect (v3)")
+ snd_test_neq(v0, v4, "chebyshev hp 10 0.4 spect (v4)")
end
f1 = make_chebyshev_highpass(8, 0.1, 0.01)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.49, :ffequal?, "chebyshev hp 8 0.1 0.01 max") # okay
- snd_test_neq(vals[1],
- vct(0, 0.498, 0.498, 0.492, 0.491, 0.492, 0.492, 0.492, 0.491, 0.491),
- "chebyshev hp 8 0.1 0.01 spect")
+ snd_test_any_neq(vals[0], 0.49, :ffequal?, "chebyshev hp 8 0.1 0.01 max")
+ v1 = vct(0, 0.498, 0.498, 0.492, 0.491, 0.492, 0.492, 0.492, 0.491, 0.491)
+ snd_test_neq(vals[1], v1, "chebyshev hp 8 0.1 0.01 spect")
f1 = make_chebyshev_highpass(12, 0.25, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "chebyshev hp 12 0.1 max") # okay
- snd_test_neq(vals[1],
- vct(0, 0, 0, 0, 0.453, 0.516, 0.489, 0.489, 0.488, 0.488),
- "chebyshev hp 12 0.25 0.1 spect")
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "chebyshev hp 12 0.1 max")
+ v1 = vct(0, 0, 0, 0, 0.453, 0.516, 0.489, 0.489, 0.488, 0.488)
+ snd_test_neq(vals[1], v1, "chebyshev hp 12 0.25 0.1 spect")
f1 = make_chebyshev_highpass(10, 0.4, 0.001)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :ffequal?, "chebyshev 10 0.001 max") # okay
- snd_test_neq(vals[1],
- vct(0, 0, 0, 0, 0, 0, 0.002, 0.503, 0.505, 0.504),
- "chebyshev hp 10 0.4 0.001 spect")
+ snd_test_any_neq(vals[0], 0.5, :ffequal?, "chebyshev 10 0.001 max")
+ v0 = vals[1]
+ v1 = vct(0, 0, 0, 0, 0, 0, 0.002, 0.501, 0.504, 0.504)
+ v2 = vct(0, 0, 0, 0, 0, 0, 0.002, 0.503, 0.505, 0.504)
+ v3 = vct(0, 0, 0, 0, 0, 0, 0.002, 0.503, 0.501, 0.497)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2)) and (not vequal(v0, v3))
+ snd_test_neq(v0, v1, "chebyshev hp 10 0.4 0.001 spect (v1)")
+ snd_test_neq(v0, v2, "chebyshev hp 10 0.4 0.001 spect (v2)")
+ snd_test_neq(v0, v3, "chebyshev hp 10 0.4 0.001 spect (v3)")
+ end
2.step(10, 2) do |i|
0.1.step(0.35, 0.1) do |j|
f1 = make_chebyshev_highpass(i, j)
- mx = filter_response_max(f1)
- if mx > 1.0
- snd_display(snd_format(mx, 1.0, ">", "cheby high max %d %d", i, j))
- end
+ snd_test_gt(filter_response_max(f1), 1.0, "cheby high max %d %d", i, j)
end
end
#
f1 = make_chebyshev_bandpass(4, 0.1, 0.2)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bp 4 max") # okay
- snd_test_neq(vals[1],
- vct(0.009, 0.449, 0.509, 0.505, 0.442, 0.065, 0.013, 0.003, 0, 0),
- "chebyshev bp 4 0.1 0.2 spect")
-
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bp 4 max")
+ v1 = vct(0.009, 0.449, 0.509, 0.505, 0.442, 0.065, 0.013, 0.003, 0, 0)
+ snd_test_neq(vals[1], v1, "chebyshev bp 4 0.1 0.2 spect")
f1 = make_chebyshev_bandpass(6, 0.1, 0.2)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bp 6 max") # okay
- snd_test_neq(vals[1],
- vct(0.001, 0.376, 0.505, 0.498, 0.412, 0.011, 0.001, 0, 0, 0),
- "chebyshev bp 6 0.1 0.2 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bp 6 max")
+ v1 = vct(0.001, 0.376, 0.505, 0.498, 0.412, 0.011, 0.001, 0, 0, 0)
+ snd_test_neq(vals[1], v1, "chebyshev bp 6 0.1 0.2 spect")
f1 = make_chebyshev_bandpass(8, 0.3, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bp 8 max") # okay
- snd_test_neq(vals[1],
- vct(0, 0, 0, 0, 0.002, 0.363, 0.517, 0.513, 0.433, 0),
- "chebyshev bp 8 0.3 0.4 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bp 8 max")
+ v1 = vct(0, 0, 0, 0, 0.002, 0.363, 0.517, 0.513, 0.433, 0)
+ snd_test_neq(vals[1], v1, "chebyshev bp 8 0.3 0.4 spect")
f1 = make_chebyshev_bandpass(8, 0.2, 0.2, 0.01)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bp 10 0.2 max") # okay
- snd_test_neq(vals[1],
- vct(0, 0, 0.015, 0.483, 0.482, 0.021, 0.001, 0, 0, 0),
- "chebyshev bp 10 0.2 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bp 10 0.2 max")
+ v1 = vct(0, 0, 0.015, 0.483, 0.482, 0.021, 0.001, 0, 0, 0)
+ snd_test_neq(vals[1], v1, "chebyshev bp 10 0.2 spect")
#
f1 = make_chebyshev_bandstop(4, 0.1, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bs 4 max") # okay
- snd_test_neq(vals[1],
- vct(0.509, 0.505, 0.447, 0.033, 0.006, 0.006, 0.033, 0.445, 0.512, 0.509),
- "chebyshev bs 4 0.1 0.4 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bs 4 max")
+ v1 = vct(0.509, 0.505, 0.447, 0.033, 0.006, 0.006, 0.033, 0.445, 0.512, 0.509)
+ snd_test_neq(vals[1], v1, "chebyshev bs 4 0.1 0.4 spect")
f1 = make_chebyshev_bandstop(8, 0.1, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :f05equal?, "chebyshev bs 8 max") # okay
- if (not vequal(vals[1], vct(0.508, 0.512, 0.468, 0.001, 0, 0, 0.001, 0.345, 0.551, 0.507))) and
- (not vequal(vals[1], vct(0.507, 0.512, 0.467, 0.001, 0, 0, 0.001, 0.344, 0.59, 0.508))) and
- (not vequal(vals[1], vct(0.508, 0.513, 0.469, 0.001, 0, 0, 0.001, 0.345, 0.552, 0.508))) and
- (not vequal(vals[1], vct(0.509, 0.508, 0.465, 0.001, 0, 0, 0.001, 0.343, 0.548, 0.508)))
- snd_display(snd_format(vals[1],
- vct(0.508, 0.512, 0.468, 0.001, 0, 0, 0.001, 0.345, 0.551, 0.507),
- "chebyshev bs 8 0.1 0.4 spect"))
+ snd_test_any_neq(vals[0], 0.51, :f05equal?, "chebyshev bs 8 max")
+ v0 = vals[1]
+ v1 = vct(0.508, 0.512, 0.468, 0.001, 0, 0, 0.001, 0.345, 0.551, 0.507)
+ v2 = vct(0.507, 0.512, 0.467, 0.001, 0, 0, 0.001, 0.344, 0.590, 0.508)
+ v3 = vct(0.508, 0.513, 0.469, 0.001, 0, 0, 0.001, 0.345, 0.552, 0.508)
+ v4 = vct(0.509, 0.508, 0.465, 0.001, 0, 0, 0.001, 0.343, 0.548, 0.508)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2)) and
+ (not vequal(v0, v3)) and (not vequal(v0, v4))
+ snd_test_neq(v0, v1, "chebyshev bs 8 0.1 0.4 spect (v1)")
+ snd_test_neq(v0, v2, "chebyshev bs 8 0.1 0.4 spect (v2)")
+ snd_test_neq(v0, v3, "chebyshev bs 8 0.1 0.4 spect (v3)")
+ snd_test_neq(v0, v4, "chebyshev bs 8 0.1 0.4 spect (v4)")
end
f1 = make_chebyshev_bandstop(8, 0.1, 0.4, 0.01)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bs 8 0.01 max") # okay
- snd_test_neq(vals[1],
- vct(0.492, 0.491, 0.483, 0.006, 0, 0, 0.006, 0.494, 0.495, 0.492),
- "chebyshev bs 8 0.1 0.4 0.01 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "chebyshev bs 8 0.01 max")
+ v1 = vct(0.492, 0.491, 0.483, 0.006, 0, 0, 0.006, 0.494, 0.495, 0.492)
+ snd_test_neq(vals[1], v1, "chebyshev bs 8 0.1 0.4 0.01 spect")
#
# inverse-chebyshev
#
f1 = make_inverse_chebyshev_lowpass(8, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev lp 8 max") # okay
- if (not vequal(vals[1], vct(0.501, 0.496, 0.001, 0, 0.001, 0, 0, 0, 0, 0.001))) and
- (not vequal(vals[1], vct(0.500, 0.498, 0.001, 0, 0.001, 0, 0, 0, 0, 0.001)))
- snd_display(snd_format_neq(vals[1],
- vct(0.501, 0.496, 0.001, 0, 0.001, 0, 0, 0, 0, 0.001),
- "inverse_chebyshev lp 8 0.1 spect"))
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev lp 8 max")
+ v0 = vals[1]
+ v1 = vct(0.501, 0.496, 0.001, 0, 0.001, 0, 0, 0, 0, 0.001)
+ v2 = vct(0.500, 0.498, 0.001, 0, 0.001, 0, 0, 0, 0, 0.001)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2))
+ snd_test_neq(v0, v1, "inverse_chebyshev lp 8 0.1 spect (v1)")
+ snd_test_neq(v0, v2, "inverse_chebyshev lp 8 0.1 spect (v2)")
end
f1 = make_inverse_chebyshev_lowpass(12, 0.25)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev lp 12 max") # okay
- snd_test_neq(vals[1],
- vct(0.500, 0.500, 0.500, 0.500, 0.496, 0.001, 0.001, 0.001, 0.001, 0.001),
- "inverse_chebyshev lp 12 0.25 spect")
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev lp 12 max")
+ v1 = vct(0.500, 0.500, 0.500, 0.500, 0.496, 0.001, 0.001, 0.001, 0.001, 0.001)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev lp 12 0.25 spect")
f1 = make_inverse_chebyshev_lowpass(10, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev lp 10 max") # okay
- if (not vequal(vals[1], vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.497, 0.001, 0.001))) and
- (not vequal(vals[1], vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.497, 0.002, 0.002)))
- snd_display(snd_format_neq(vals[1],
- vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.497, 0.001, 0.001),
- "inverse_chebyshev lp 10 0.4 spect"))
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev lp 10 max")
+ v0 = vals[1]
+ v1 = vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.497, 0.001, 0.001)
+ v2 = vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.497, 0.002, 0.002)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2))
+ snd_test_neq(v0, v1, "inverse_chebyshev lp 10 0.4 spect (v1)")
+ snd_test_neq(v0, v2, "inverse_chebyshev lp 10 0.4 spect (v2)")
end
f1 = make_inverse_chebyshev_lowpass(10, 0.4, 120)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev lp 10 max") # okay
- snd_test_neq(vals[1],
- vct(0.501, 0.501, 0.501, 0.501, 0.501, 0.500, 0.345, 0.007, 0, 0),
- "inverse_chebyshev lp 10 0.4 120 spect")
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev lp 10 max")
+ v1 = vct(0.501, 0.501, 0.501, 0.501, 0.501, 0.500, 0.345, 0.007, 0, 0)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev lp 10 0.4 120 spect")
#
2.step(10, 2) do |i|
0.1.step(0.35, 0.1) do |j|
f1 = make_inverse_chebyshev_lowpass(i, j)
- mx = filter_response_max(f1)
- if mx > 1.0
- snd_display(snd_format(mx, 1.0, ">", "inv cheby low max %d %d", i, j))
- end
+ snd_test_gt(filter_response_max(f1), 1.0, "inv cheby low max %d %d", i, j)
end
end
#
f1 = make_inverse_chebyshev_highpass(8, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev hp 8 max") # okay
- snd_test_neq(vals[1],
- vct(0.001, 0.001, 0.440, 0.505, 0.505, 0.503, 0.502, 0.501, 0.501, 0.501),
- "inverse_chebyshev hp 8 0.1 spect")
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev hp 8 max")
+ v1 = vct(0.001, 0.001, 0.440, 0.505, 0.505, 0.503, 0.502, 0.501, 0.501, 0.501)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev hp 8 0.1 spect")
f1 = make_inverse_chebyshev_highpass(12, 0.25)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev hp 12 max") # okay
- snd_test_neq(vals[1],
- vct(0.001, 0.001, 0.001, 0.001, 0.001, 0.505, 0.506, 0.503, 0.501, 0.501),
- "inverse_chebyshev hp 12 0.25 spect")
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev hp 12 max")
+ v1 = vct(0.001, 0.001, 0.001, 0.001, 0.001, 0.505, 0.506, 0.503, 0.501, 0.501)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev hp 12 0.25 spect")
f1 = make_inverse_chebyshev_highpass(10, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev hp 10 max") # okay
- if (not vequal(vals[1], vct(0, 0, 0, 0.001, 0.001, 0.001, 0.001, 0.001, 0.503, 0.503))) and
- (not vequal(vals[1], vct(0, 0, 0, 0.001, 0.001, 0.001, 0.001, 0.001, 0.505, 0.503))) and
- (not vequal(vals[1], vct(0, 0, 0, 0.001, 0.001, 0.001, 0.001, 0.001, 0.509, 0.504)))
- snd_display(snd_format_neq(vals[1],
- vct(0, 0, 0, 0.001, 0.001, 0.001, 0.001, 0.001, 0.503, 0.503),
- "inverse_chebyshev hp 10 0.4 spect"))
+ snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev hp 10 max")
+ v0 = vals[1]
+ v1 = vct(0, 0, 0, 0.001, 0.001, 0.001, 0.001, 0.001, 0.503, 0.503)
+ v2 = vct(0, 0, 0, 0.001, 0.001, 0.001, 0.001, 0.001, 0.505, 0.503)
+ v3 = vct(0, 0, 0, 0.001, 0.001, 0.001, 0.001, 0.001, 0.509, 0.504)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2)) and (not vequal(v0, v3))
+ snd_test_neq(v0, v1, "inverse_chebyshev hp 10 0.4 spect (v1)")
+ snd_test_neq(v0, v2, "inverse_chebyshev hp 10 0.4 spect (v2)")
+ snd_test_neq(v0, v3, "inverse_chebyshev hp 10 0.4 spect (v3)")
end
f1 = make_inverse_chebyshev_highpass(10, 0.1, 120)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :ffequal?, "inverse_chebyshev hp 10 0.1 120 max") # okay
- snd_test_neq(vals[1],
- vct(0, 0, 0.007, 0.328, 0.502, 0.502, 0.502, 0.501, 0.501, 0.501),
- "inverse_chebyshev hp 10 0.1 120 spect")
+ snd_test_any_neq(vals[0], 0.51, :ffequal?,
+ "inverse_chebyshev hp 10 0.1 120 max")
+ v1 = vct(0, 0, 0.007, 0.328, 0.502, 0.502, 0.502, 0.501, 0.501, 0.501)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev hp 10 0.1 120 spect")
#
2.step(10, 2) do |i|
0.1.step(0.35, 0.1) do |j|
f1 = make_inverse_chebyshev_highpass(i, j)
- mx = filter_response_max(f1)
- if mx > 1.0
- snd_display(snd_format(mx, 1.0, ">", "inv cheby high max %d %d", i, j))
- end
+ snd_test_gt(filter_response_max(f1), 1.0,
+ "inv cheby high max %d %d", i, j)
end
end
#
f1 = make_inverse_chebyshev_bandpass(10, 0.1, 0.2)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bp 10 max") # okay
- snd_test_neq(vals[1],
- vct(0.001, 0.001, 0.498, 0.485, 0.001, 0.001, 0, 0.001, 0, 0.001),
- "inverse_chebyshev bp 10 0.1 0.2 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bp 10 max")
+ v1 = vct(0.001, 0.001, 0.498, 0.485, 0.001, 0.001, 0, 0.001, 0, 0.001)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev bp 10 0.1 0.2 spect")
f1 = make_inverse_chebyshev_bandpass(10, 0.1, 0.2, 30)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bp 10 30 max") # okay
- if (not vequal(vals[1], vct(0.026, 0.025, 0.509, 0.505, 0.02, 0.016, 0.012, 0.016, 0.011, 0.016))) and
- (not vequal(vals[1], vct(0.03, 0.042, 0.511, 0.505, 0.02, 0.016, 0.012, 0.016, 0.011, 0.016))) and
- (not vequal(vals[1], vct(0.022, 0.017, 0.511, 0.505, 0.02, 0.016, 0.012, 0.016, 0.011, 0.016)))
- snd_display(snd_format_neq(vals[1],
- vct(0.026, 0.025, 0.509, 0.505, 0.02, 0.016, 0.012, 0.016, 0.011, 0.016),
- "inverse_chebyshev bp 10 0.1 0.2 30 spect"))
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bp 10 30 max")
+ v0 = vals[1]
+ v1 = vct(0.026, 0.025, 0.509, 0.505, 0.02, 0.016, 0.012, 0.016, 0.011, 0.016)
+ v2 = vct(0.030, 0.042, 0.511, 0.505, 0.02, 0.016, 0.012, 0.016, 0.011, 0.016)
+ v3 = vct(0.022, 0.017, 0.511, 0.505, 0.02, 0.016, 0.012, 0.016, 0.011, 0.016)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2)) and (not vequal(v0, v3))
+ snd_test_neq(v0, v1, "inverse_chebyshev bp 10 0.1 0.2 30 spect (v1)")
+ snd_test_neq(v0, v2, "inverse_chebyshev bp 10 0.1 0.2 30 spect (v2)")
+ snd_test_neq(v0, v3, "inverse_chebyshev bp 10 0.1 0.2 30 spect (v3)")
end
f1 = make_inverse_chebyshev_bandpass(8, 0.1, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bp 8 max") # okay
- snd_test_neq(vals[1],
- vct(0.001, 0.001, 0.440, 0.506, 0.505, 0.503, 0.502, 0.434, 0.001, 0.001),
- "inverse_chebyshev bp 8 0.1 0.4 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bp 8 max")
+ v1 = vct(0.001, 0.001, 0.440, 0.506, 0.505, 0.503, 0.502, 0.434, 0.001, 0.001)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev bp 8 0.1 0.4 spect")
f1 = make_inverse_chebyshev_bandpass(8, 0.3, 0.4, 40)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bp 8 40 max") # okay
- snd_test_neq(vals[1],
- vct(0.002, 0.005, 0.007, 0.007, 0.005, 0.005, 0.503, 0.505, 0.006, 0.005),
- "inverse_chebyshev bp 8 0.3 0.4 40 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bp 8 40 max")
+ v1 = vct(0.002, 0.005, 0.007, 0.007, 0.005, 0.005, 0.503, 0.505, 0.006, 0.005)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev bp 8 0.3 0.4 40 spect")
#
f1 = make_inverse_chebyshev_bandstop(4, 0.1, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bs 4 max") # okay
- snd_test_neq(vals[1],
- vct(0.500, 0.054, 0.001, 0.001, 0, 0, 0, 0.001, 0.055, 0.503),
- "inverse_chebyshev bs 4 0.1 0.4 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bs 4 max")
+ v1 = vct(0.500, 0.054, 0.001, 0.001, 0, 0, 0, 0.001, 0.055, 0.503)
+ snd_test_neq(vals[1], v1, "inverse_chebyshev bs 4 0.1 0.4 spect")
f1 = make_inverse_chebyshev_bandstop(8, 0.1, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.51, :f05equal?, "inverse_chebyshev bs 8 max") # okay
- if (not vequal(vals[1], vct(0.501, 0.496, 0.001, 0.001, 0, 0, 0, 0.001, 0.507, 0.506))) and
- (not vequal(vals[1], vct(0.506, 0.328, 0.001, 0.001, 0, 0, 0, 0, 0.268, 0.511))) and
- (not vequal(vals[1], vct(0.5, 0.498, 0.001, 0.001, 0, 0, 0, 0.001, 0.507, 0.506)))
- snd_display(snd_format_neq(vals[1],
- vct(0.501, 0.496, 0.001, 0.001, 0, 0, 0, 0.001, 0.507, 0.506),
- "inverse_chebyshev bs 8 0.1 0.4 spect"))
+ snd_test_any_neq(vals[0], 0.51, :f05equal?, "inverse_chebyshev bs 8 max")
+ v0 = vals[1]
+ v1 = vct(0.501, 0.496, 0.001, 0.001, 0, 0, 0, 0.001, 0.507, 0.506)
+ v2 = vct(0.506, 0.328, 0.001, 0.001, 0, 0, 0, 0.000, 0.268, 0.511)
+ v3 = vct(0.500, 0.498, 0.001, 0.001, 0, 0, 0, 0.001, 0.507, 0.506)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2)) and (not vequal(v0, v3))
+ snd_test_neq(v0, v1, "inverse_chebyshev bs 8 0.1 0.4 spect (v1)")
+ snd_test_neq(v0, v2, "inverse_chebyshev bs 8 0.1 0.4 spect (v2)")
+ snd_test_neq(v0, v3, "inverse_chebyshev bs 8 0.1 0.4 spect (v3)")
end
f1 = make_inverse_chebyshev_bandstop(8, 0.1, 0.4, 90)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bs 8 90 max") # okay
- snd_test_neq(vals[1],
- vct(0.505, 0.325, 0, 0, 0, 0, 0, 0, 0.270, 0.506),
- "inverse_chebyshev bs 8 0.1 0.4 90 spect")
+ snd_test_any_neq(vals[0], 0.5, :f05equal?, "inverse_chebyshev bs 8 90 max")
+ v0 = vals[1]
+ v1 = vct(0.505, 0.325, 0, 0, 0, 0, 0, 0, 0.270, 0.506)
+ v2 = vct(0.506, 0.328, 0, 0, 0, 0, 0, 0, 0.269, 0.509)
+ v3 = vct(0.501, 0.327, 0, 0, 0, 0, 0, 0, 0.268, 0.506)
+ if (not vequal(v0, v1)) and (not vequal(v0, v2)) and (not vequal(v0, v3))
+ snd_test_neq(v0, v1, "inverse_chebyshev bs 8 0.1 0.4 90 spect (v1)")
+ snd_test_neq(v0, v2, "inverse_chebyshev bs 8 0.1 0.4 90 spect (v2)")
+ snd_test_neq(v0, v3, "inverse_chebyshev bs 8 0.1 0.4 90 spect (v3)")
+ end
if $with_test_gsl
if defined? gsl_roots
# gsl_roots isn't defined for ruby in snd-xen.c
@@ -12059,10 +11450,7 @@ def analog_filter_tests
2.step(11, 2) do |i|
0.1.step(0.44, 0.1) do |j|
f1 = make_bessel_lowpass(i, j)
- mx = filter_response_max(f1)
- if mx > 1.0
- snd_display(snd_format(mx, 1.0, ">", "bess low max %d %d", i, j))
- end
+ snd_test_gt(filter_response_max(f1), 1.0, "bess low max %d %d", i, j)
end
end
#
@@ -12080,7 +11468,7 @@ def analog_filter_tests
"bessel hp 12 0.25 spect")
f1 = make_bessel_highpass(10, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :ffequal?, "bessel hp 10 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :ffequal?, "bessel hp 10 max")
snd_test_neq(vals[1],
vct(0, 0, 0, 0, 0, 0, 0.004, 0.084, 0.343, 0.499),
"bessel hp 12 0.25 0.01 90 spect")
@@ -12104,7 +11492,7 @@ def analog_filter_tests
#
f1 = make_elliptic_lowpass(8, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 8 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 8 max")
if (not vequal(vals[1], vct(0.500, 0.515, 0.379, 0, 0, 0, 0, 0, 0, 0))) and
(not vequal(vals[1], vct(0.500, 0.509, 0.385, 0, 0, 0, 0, 0, 0, 0))) and
(not vequal(vals[1], vct(0.499, 0.498, 0.373, 0, 0, 0, 0, 0, 0, 0)))
@@ -12114,7 +11502,7 @@ def analog_filter_tests
end
f1 = make_elliptic_lowpass(12, 0.25)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 12 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 12 max")
if (not vequal(vals[1], vct(0.476, 0.500, 0.491, 0.499, 0.494, 0.412, 0.003, 0.001, 0, 0))) and
(not vequal(vals[1], vct(0.476, 0.500, 0.491, 0.499, 0.494, 0.561, 0.004, 0, 0, 0))) and
(not vequal(vals[1], vct(0.476, 0.500, 0.491, 0.499, 0.493, 0.299, 0.006, 0.001, 0, 0)))
@@ -12124,38 +11512,38 @@ def analog_filter_tests
end
f1 = make_elliptic_lowpass(4, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 4 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 4 max")
snd_test_neq(vals[1],
vct(0.447, 0.453, 0.462, 0.477, 0.494, 0.500, 0.497, 0.496, 0.445, 0.003),
"elliptic lp 4 0.4 spect")
f1 = make_elliptic_lowpass(8, 0.1, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 8 0.1 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 8 0.1 max")
snd_test_neq(vals[1],
vct(0.500, 0.499, 0.475, 0, 0, 0, 0, 0, 0, 0),
"elliptic lp 8 0.1 0.1 spect")
f1 = make_elliptic_lowpass(8, 0.1, 0.1, 90)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 8 0.1 90 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 8 0.1 90 max")
snd_test_neq(vals[1],
vct(0.500, 0.499, 0.475, 0, 0, 0, 0, 0, 0, 0),
"elliptic lp 8 0.1 0.1 90 spect")
f1 = make_elliptic_lowpass(8, 0.25, 0.01, 90)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 8 0.25 90 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic lp 8 0.25 90 max")
snd_test_neq(vals[1],
vct(0.500, 0.500, 0.500, 0.500, 0.499, 0.495, 0.001, 0, 0, 0),
"elliptic lp 8 0.25 0.01 90 spect")
#
f1 = make_elliptic_highpass(4, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 4 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 4 max")
snd_test_neq(vals[1],
vct(0.004, 0.438, 0.516, 0.499, 0.502, 0.495, 0.478, 0.463, 0.453, 0.447),
"elliptic hp 4 0.1 spect")
f1 = make_elliptic_highpass(12, 0.25)
vals = sweep2bins(f1, 10)
- # snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 12 max") # okay
+ # snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 12 max")
if (not vequal(vals[1], vct(0, 0.001, 0.001, 0.001, 0.026, 0.934, 0.518, 0.495, 0.503, 0.477))) and
(not vequal(vals[1], vct(0, 0.001, 0.001, 0.001, 0.033, 1.185, 0.519, 0.495, 0.503, 0.477))) and
(not vequal(vals[1], vct(0, 0.001, 0.001, 0.001, 0.018, 0.788, 0.520, 0.495, 0.503, 0.477)))
@@ -12165,217 +11553,215 @@ def analog_filter_tests
end
f1 = make_elliptic_highpass(12, 0.25, 0.01, 90)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 12 90 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 12 90 max")
snd_test_neq(vals[1],
vct(0, 0, 0, 0, 0.499, 0.517, 0.503, 0.501, 0.500, 0.500),
"elliptic hp 12 0.25 0.01 90 spect")
f1 = make_elliptic_highpass(4, 0.4)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 4 0.4 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 4 0.4 max")
snd_test_neq(vals[1],
vct(0, 0, 0, 0.001, 0.001, 0.002, 0.023, 0.447, 0.515, 0.502),
"elliptic hp 4 0.4 spect")
f1 = make_elliptic_highpass(8, 0.1, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 8 0.1 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 8 0.1 max")
snd_test_neq(vals[1],
vct(0, 0.478, 0.553, 0.506, 0.499, 0.501, 0.501, 0.499, 0.497, 0.495),
"elliptic hp 8 0.1 0.1 spect")
f1 = make_elliptic_highpass(8, 0.1, 0.1, 90)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 8 0.1 90 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 8 0.1 90 max")
snd_test_neq(vals[1],
vct(0, 0.478, 0.554, 0.506, 0.499, 0.501, 0.501, 0.499, 0.497, 0.495),
"elliptic hp 8 0.1 0.1 90 spect")
f1 = make_elliptic_highpass(8, 0.25, 0.01, 90)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 8 0.25 90 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic hp 8 0.25 90 max")
snd_test_neq(vals[1],
vct(0, 0, 0, 0.001, 0.516, 0.517, 0.507, 0.503, 0.501, 0.500),
"elliptic hp 8 0.25 0.01 90 spect")
#
f1 = make_elliptic_bandpass(4, 0.1, 0.2, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic bp 4 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic bp 4 max")
snd_test_neq(vals[1],
vct(0.036, 0.546, 0.55, 0.51, 0.501, 0.032, 0.024, 0.009, 0.021, 0.024),
"elliptic bp 4 0.1 0.2 0.1 spect")
f1 = make_elliptic_bandpass(6, 0.1, 0.2, 0.1, 90)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic bp 6 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic bp 6 max")
snd_test_neq(vals[1],
vct(0.002, 0.511, 0.532, 0.503, 0.492, 0.003, 0.001, 0.001, 0.001, 0.001),
"elliptic bp 6 0.1 0.2 0.1 90 spect")
#
f1 = make_elliptic_bandstop(4, 0.1, 0.3, 0.1)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic bs 4 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic bs 4 max")
snd_test_neq(vals[1],
vct(0.499, 0.502, 0.498, 0.037, 0.05, 0.54, 0.544, 0.527, 0.526, 0.521),
"elliptic bs 4 0.1 0.3 0.1 spect")
f1 = make_elliptic_bandstop(8, 0.1, 0.3, 0.1, 120)
vals = sweep2bins(f1, 10)
- snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic bs 8 max") # okay
+ snd_test_any_neq(vals[0], 0.5, :fffequal?, "elliptic bs 8 max")
if (not vequal(vals[1], vct(0.500, 0.499, 0.476, 0, 0, 0.495, 0.526, 0.505, 0.501, 0.501))) and
(not vequal(vals[1], vct(0.500, 0.499, 0.475, 0, 0, 0.495, 0.526, 0.505, 0.501, 0.501)))
snd_display(snd_format_neq(vals[1],
vct(0.500, 0.499, 0.476, 0, 0, 0.495, 0.526, 0.505, 0.501, 0.501),
"elliptic bs 8 0.1 0.3 0.1 120 spect"))
end
- end
+ end # $with_test_gsl
end
def poly_roots_tests
# degree=0
- unless (res = poly(0.0).roots).null?
- snd_display("poly_roots 0.0: %s?", res)
- end
- unless (res = poly(12.3).roots).null?
- snd_display("poly_roots 12.3: %s?", res)
- end
+ res = poly(0.0).roots
+ req = poly()
+ snd_test_neq(res, req, "poly_roots 0.0")
+ res = poly(12.3).roots
+ req = poly()
+ snd_test_neq(res, req, "poly_roots 12.3")
# degree 0 + x=0
- if (res = poly(0.0, 1.0).roots) != [0.0]
- snd_display("poly_roots 0.0 1.0: %s?", res)
- end
- if (res = poly(0.0, 0.0, 0.0, 121.0).roots) != [0.0, 0.0, 0.0]
- snd_display("poly_roots 0.0 0.0 0.0 121.0: %s?", res)
- end
+ res = poly(0.0, 1.0).roots
+ req = [0.0]
+ snd_test_neq(res, req, "poly_roots 0.0 1.0")
+ res = poly(0.0, 0.0, 0.0, 121.0).roots
+ req = [0.0, 0.0, 0.0]
+ snd_test_neq(res, req, "poly_roots 0.0 0.0 0.0 121.0")
# degree=1
- if (res = poly(-1.0, 1.0).roots) != [1.0]
- snd_display("poly_roots -1.0 1.0: %s?", res)
- end
- if (res = poly(-2.0, 4.0).roots) != [0.5]
- snd_display("poly_roots -2.0 4.0: %s?", res)
- end
- if (res = poly(Complex(0.0, -1.0), 1).roots) != [Complex(0.0, 1.0)]
- snd_display("poly_roots -i 1: %s?", res)
- end
+ res = poly(-1.0, 1.0).roots
+ req = [1.0]
+ snd_test_neq(res, req, "poly_roots -1.0 1.0")
+ res = poly(-2.0, 4.0).roots
+ req = [0.5]
+ snd_test_neq(res, req, "poly_roots -2.0 4.0")
+ res = poly(Complex(0.0, -1.0), 1).roots
+ req = [Complex(0.0, 1.0)]
+ snd_test_neq(res, req, "poly_roots -i 1")
# linear x^n
- vals = poly(-1.0, 0.0, 0.0, 0.0, 1.0).roots
- if vcneql(vals, [Complex(0.0, -1.0), -1.0, Complex(0.0, 1.0), 1.0]) and
- vcneql(vals, [1.0, -1.0, Complex(0.0, 1.0), Complex(-0.0, -1.0)])
- snd_display("poly_roots -1 0 0 0 1: %s?", vals)
- end
- vals = poly(-16, 0, 0, 0, 1).roots
- if vcneql(vals, [Complex(0.0, -2.0), -2.0, Complex(0.0, 2.0), 2.0]) and
- vcneql(vals, [2.0, -2.0, Complex(0.0, 2.0), Complex(-0.0, -2.0)])
- snd_display("poly_roots -16 0 0 0 1: %s?", vals)
- end
- if vcneql(res = poly(-32, 0, 0, 0, 0, 0, 0.5).roots,
- [Complex(1.0, -1.7320), Complex(-1.0, -1.7320), -2.0,
- Complex(-1.0, 1.7320), Complex(1.0, 1.7320), 2.0])
- snd_display("poly_roots -32 0 0 0 0 0 0.5: %s?", res)
- end
+ res = poly(-1.0, 0.0, 0.0, 0.0, 1.0).roots
+ req1 = [Complex(0.0, -1.0), -1.0, Complex(0.0, 1.0), 1.0]
+ req2 = [1.0, -1.0, Complex(0.0, 1.0), Complex(-0.0, -1.0)]
+ if vcneql(res, req1) and vcneql(res, req2)
+ snd_format_neq(res, req1, "poly_roots -1 0 0 0 1 (a)")
+ snd_format_neq(res, req2, "poly_roots -1 0 0 0 1 (b)")
+ end
+ res = poly(-16, 0, 0, 0, 1).roots
+ req1 = [Complex(0.0, -2.0), -2.0, Complex(0.0, 2.0), 2.0]
+ req2 = [2.0, -2.0, Complex(0.0, 2.0), Complex(-0.0, -2.0)]
+ if vcneql(res, req1) and vcneql(res, req2)
+ snd_format_neq(res, req1, "poly_roots -16 0 0 0 1 (a)")
+ snd_format_neq(res, req2, "poly_roots -16 0 0 0 1 (b)")
+ end
+ res = poly(-32, 0, 0, 0, 0, 0, 0.5).roots
+ req = [Complex(1.0, -1.7320), Complex(-1.0, -1.7320), -2.0,
+ Complex(-1.0, 1.7320), Complex(1.0, 1.7320), 2.0]
+ snd_test_any_neq(res, req, :vcequal?, "poly_roots -32 0 0 0 0 0 0.5")
# linear + x=0
- if (res = poly(0, -2, 4).roots) != [0.0, 0.5]
- snd_display("poly_roots 0 -2 4: %s?", res)
- end
+ res = poly(0, -2, 4).roots
+ req = [0.0, 0.5]
+ snd_test_neq(res, req, "poly_roots 0 -2 4")
# degree=2
- if (res = poly(-1, 0, 1).roots) != [1.0, -1.0]
- snd_display("poly_roots -1 0 1: %s?", res)
- end
- if (res = poly(15, -8, 1).roots) != [5.0, 3.0]
- snd_display("poly_roots 15 -8 1: %s?", res)
- end
- if (res = poly(1, -2, 1).roots) != [1.0, 1.0]
- snd_display("poly_roots 1 -2 1: %s?", res)
- end
- if (res = poly(-1, Complex(0.0, 2.0), 1).roots) != [Complex(0.0, -1.0), Complex(0.0, -1.0)]
- snd_display("poly_roots -1 2i 1: %s?", res)
- end
- if vcneql(res = poly(1, 1, 5).roots, [Complex(-0.1, 0.43589), Complex(-0.1, -0.43589)])
- snd_display("poly_roots 1 1 5: %s?", res)
- end
+ res = poly(-1, 0, 1).roots
+ req = [1.0, -1.0]
+ snd_test_neq(res, req, "poly_roots -1 0 1")
+ res = poly(15, -8, 1).roots
+ req = [5.0, 3.0]
+ snd_test_neq(res, req, "poly_roots 15 -8 1")
+ res = poly(1, -2, 1).roots
+ req = [1.0, 1.0]
+ snd_test_neq(res, req, "poly_roots 1 -2 1")
+ res = poly(-1, Complex(0.0, 2.0), 1).roots
+ req = [Complex(0.0, -1.0), Complex(0.0, -1.0)]
+ snd_test_neq(res, req, "poly_roots -1 2i 1")
+ res = poly(1, 1, 5).roots
+ req = [Complex(-0.1, 0.43589), Complex(-0.1, -0.43589)]
+ snd_test_any_neq(res, req, :vcequal?, "poly_roots 1 1 5")
# 2 + x=0
- if (res = poly(0, 0, -1, 0, 1).roots) != [0.0, 0.0, 1.0, -1.0]
- snd_display("poly_roots 0 0 -1 0 1: %s?", res)
- end
+ res = poly(0, 0, -1, 0, 1).roots
+ req = [0.0, 0.0, 1.0, -1.0]
+ snd_test_neq(res, req, "poly_roots 0 0 -1 0 1")
# quadratic in x^(n/2)
- if (res = poly(1, 0, -2, 0, 1).roots) != [-1.0, 1.0, -1.0, 1.0] and res != [1.0, 1.0, -1.0, -1.0]
- snd_display("poly_roots 1 0 -2 0 1: %s?", res)
- end
- if vcneql(res = poly(64, 0, 0, -16, 0, 0, 1).roots,
- [Complex(-1.0, -1.73205), Complex(-1.0, 1.73205), 2.0,
- Complex(-1.0, -1.73205), Complex(-1.0, 1.73205), 2.0])
- snd_display("poly_roots 64 0 0 -16 0 0 1: %s?", res)
- end
+ res = poly(1, 0, -2, 0, 1).roots
+ req1 = [-1.0, 1.0, -1.0, 1.0]
+ req2 = [1.0, 1.0, -1.0, -1.0]
+ if res != req1 and res != req2
+ snd_format_neq(res, req1, "poly_roots 1 0 -2 0 1 (a)")
+ snd_format_neq(res, req2, "poly_roots 1 0 -2 0 1 (b)")
+ end
+ res = poly(64, 0, 0, -16, 0, 0, 1).roots
+ req = [Complex(-1.0, -1.73205), Complex(-1.0, 1.73205), 2.0,
+ Complex(-1.0, -1.73205), Complex(-1.0, 1.73205), 2.0]
+ snd_test_any_neq(res, req, :vcequal?, "poly_roots 64 0 0 -16 0 0 1")
# degree=3
- unless vequal(res = poly(-15, 23, -9, 1).roots, [5.0, 1.0, 3.0])
- snd_display("poly_roots -15 23 -9 1: %s?", res)
- end
- if vcneql(res = poly(-126, -15, 0, 1).roots,
- [6.0, Complex(-3.0, 3.46410), Complex(-3.0, -3.46410)])
- snd_display("poly_roots -126 -15 0 1: %s?", res)
- end
- if (res = poly(-1, 3, -3, 1).roots) != [1.0, 1.0, 1.0]
- snd_display("poly_roots -1 3 -3 1: %s?", res)
- end
- unless vequal(res = poly(1, -1, -1, 1).roots, [1.0, -1.0, 1.0])
- snd_display("poly_roots 1 -1 -1 1: %s?", res)
- end
- unless vequal(res = poly(2, -2, -2, 2).roots, [1.0, -1.0, 1.0])
- snd_display("poly_roots 2 -2 -2 2: %s %s %s?", res)
- end
+ res = poly(-15, 23, -9, 1).roots
+ req = [5.0, 1.0, 3.0]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots -15 23 -9 1")
+ res = poly(-126, -15, 0, 1).roots
+ req = [6.0, Complex(-3.0, 3.46410), Complex(-3.0, -3.46410)]
+ snd_test_any_neq(res, req, :vcequal?, "poly_roots -126 -15 0 1")
+ res = poly(-1, 3, -3, 1).roots
+ req = [1.0, 1.0, 1.0]
+ snd_test_neq(res, req, "poly_roots -1 3 -3 1")
+ res = poly(1, -1, -1, 1).roots
+ req = [1.0, -1.0, 1.0]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots 1 -1 -1 1")
+ res = poly(2, -2, -2, 2).roots
+ req = [1.0, -1.0, 1.0]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots 2 -2 -2 2")
# degree=4
- if (res = poly(-15, 8, 14, -8, 1).roots) != [5.0, 3.0, 1.0, -1.0]
- snd_display("poly_roots -15 8 14 -8 1: [5.0, 3.0, 1.0, -1.0] != %s?", res)
- end
- vals = (poly(2, 1) * poly(-3, 1) * poly(8, 1) * poly(-9, 1)).reduce.roots
- unless vequal(vals, [9, 3, -2, -8])
- snd_display("poly_roots 4(1): %s?", vals)
- end
- vals = (poly(0.2, 1) * poly(-3, 1) * poly(0.8, 1) * poly(-9, 1)).reduce.roots
- unless vequal(vals, [9, 3, -0.2, -0.8])
- snd_display("poly_roots 4(2): %s?", vals)
- end
- vals = (poly(0.02, 1) * poly(-32, 1) * poly(0.8, 1) * poly(-9, 1)).reduce.roots
- unless vequal(vals, [32, 9, -0.02, -0.8])
- snd_display("poly_roots 4(3): %s?", vals)
- end
+ res = poly(-15, 8, 14, -8, 1).roots
+ req = [5.0, 3.0, 1.0, -1.0]
+ snd_test_neq(res, req, "poly_roots -15 8 14 -8 1: [5.0, 3.0, 1.0, -1.0]")
+ res = (poly(2, 1) * poly(-3, 1) * poly(8, 1) * poly(-9, 1)).reduce.roots
+ req = [9, 3, -2, -8]
+ snd_test_neq(res, req, "poly_roots 4(1)")
+ res = (poly(0.2, 1) * poly(-3, 1) * poly(0.8, 1) * poly(-9, 1)).reduce.roots
+ req = [9, 3, -0.2, -0.8]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots 4(2)")
+ res = (poly(0.02, 1) * poly(-32, 1) * poly(0.8, 1) * poly(-9, 1)).reduce.roots
+ req = [32, 9, -0.02, -0.8]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots 4(3)")
# degree>4
- vals = (poly(1, 1) * poly(2, 1) * poly(-3, 1) * poly(-1, 1) * poly(-2, 1)).reduce.roots
- unless vequal(vals, [3, 2, -1, -2, 1])
- snd_display("poly_roots n(1): %s?", vals)
- end
- vals = (poly(1, 1) * poly(2, 1) * poly(-3, 1) * poly(8, 1) * poly(-9, 1)).reduce.roots
- unless vequal(vals, [9, 3, -2, -8, -1])
- snd_display("poly_roots n(2): %s?", vals)
- end
- vals = (poly(-1, 0, 1) * poly(9, 1) * poly(-3, 1) * poly(-10, 1) * poly(-2, 1)).reduce.roots
- unless vequal(vals, [10, 3, -1, -9, 2, 1])
- snd_display("poly_roots n(3): %s?", vals)
- end
- vals = poly(-1, 0, 1) * poly(-4, 0, 1) * poly(-3, 1) * poly(-10, 1) * poly(-9, 0, 1)
- vals = vals.reduce.roots
- unless vequal(vals, [10, 3, -2, -3, -1, 3, 2, 1])
- snd_display("poly_roots n(4): %s?", vals)
- end
- vals = (poly(-1, 0, 1) * poly(-4, 0, 1) * poly(-16, 0, 1) * poly(-25, 0, 1) *
- poly(-9, 0, 1)).reduce.roots
- unless vequal(vals, [5, -3, -4, -5, 4, -2, 3, -1, 2, 1])
- snd_display("poly_roots n(5): %s?", vals)
- end
- vals = (poly(1, 1) * poly(2, 1) * poly(-3, 1) * poly(1, 1) * poly(-2, 1)).reduce.roots
- unless vequal(vals, [3, -1, -1, -2, 2])
- snd_display("poly_roots n(6): %s?", vals)
- end
- vals = poly(-64, 0, 0, 0, 0, 0, 1).roots
- if vcneql(vals, [Complex(0.999, -1.732), Complex(-1.0, -1.732), -2.0,
- Complex(-1.0, 1.732), Complex(1.0, 1.732), 2.0])
- snd_display("poly_roots 64 6: %s?", vals)
- end
- vals = poly(64, 0, 0, -16, 0, 0, 1).roots
- if vcneql(vals, [Complex(-1.0, -1.732), Complex(-1.0, 1.732), 2.0,
- Complex(-1.0, -1.732), Complex(-1.0, 1.732), 2.0])
- snd_display("poly_roots 64 16 6: %s?", vals)
- end
+ res = poly(1, 1) * poly(2, 1) * poly(-3, 1) * poly(-1, 1) * poly(-2, 1)
+ res = res.reduce.roots
+ req = [3, 2, -1, -2, 1]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots n(1)")
+ res = poly(1, 1) * poly(2, 1) * poly(-3, 1) * poly(8, 1) * poly(-9, 1)
+ res = res.reduce.roots
+ req = [9, 3, -2, -8, -1]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots n(2)")
+ res = poly(-1, 0, 1) * poly(9, 1) * poly(-3, 1) * poly(-10, 1) * poly(-2, 1)
+ res = res.reduce.roots
+ req = [10, 3, -1, -9, 2, 1]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots n(3)")
+ res = poly(-1, 0, 1) * poly(-4, 0, 1) * poly(-3, 1) *
+ poly(-10, 1) * poly(-9, 0, 1)
+ res = res.reduce.roots
+ req = [10, 3, -2, -3, -1, 3, 2, 1]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots n(4)")
+ res = poly(-1, 0, 1) * poly(-4, 0, 1) * poly(-16, 0, 1) *
+ poly(-25, 0, 1) * poly(-9, 0, 1)
+ res = res.reduce.roots
+ req = [5, -3, -4, -5, 4, -2, 3, -1, 2, 1]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots n(5)")
+ res = poly(1, 1) * poly(2, 1) * poly(-3, 1) * poly(1, 1) * poly(-2, 1)
+ res = res.reduce.roots
+ req = [3, -1, -1, -2, 2]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots n(6)")
+ res = poly(-64, 0, 0, 0, 0, 0, 1).roots
+ req = [Complex(0.999, -1.732), Complex(-1.0, -1.732), -2.0,
+ Complex(-1.0, 1.732), Complex(1.0, 1.732), 2.0]
+ snd_test_any_neq(res, req, :vcequal?, "poly_roots 64 6")
+ res = poly(64, 0, 0, -16, 0, 0, 1).roots
+ req = [Complex(-1.0, -1.732), Complex(-1.0, 1.732), 2.0,
+ Complex(-1.0, -1.732), Complex(-1.0, 1.732), 2.0]
+ snd_test_any_neq(res, req, :vcequal?, "poly_roots 64 16 6")
10.times do poly(random(1.0), random(1.0), random(1.0)).roots end
10.times do poly(mus_random(1.0), mus_random(1.0), mus_random(1.0)).roots end
- vals1 = convolution(vct(1, 2, 3, 0, 0, 0, 0, 0), vct(1, 2, 3, 0, 0, 0, 0, 0), 8)
- vals2 = poly(1, 2, 3, 0) * poly(1, 2, 3, 0)
- unless vequal(vals1, vals2)
- snd_display("poly_multiply convolve: %s %s?", vals1, vals2)
- end
+ res = convolution(vct(1, 2, 3, 0, 0, 0, 0, 0), vct(1, 2, 3, 0, 0, 0, 0, 0), 8)
+ req = poly(1, 2, 3, 0) * poly(1, 2, 3, 0)
+ snd_test_any_neq(res, req, :vequal?, "poly_multiply convolve")
10.times do
poly(make_rectangular(mus_random(1.0), mus_random(1.0)),
make_rectangular(mus_random(1.0), mus_random(1.0))).roots
@@ -12385,7 +11771,10 @@ def poly_roots_tests
make_rectangular(mus_random(1.0), mus_random(1.0)),
make_rectangular(mus_random(1.0), mus_random(1.0))).roots
end
- 10.times do poly(mus_random(1.0), mus_random(1.0), mus_random(1.0), mus_random(1.0)).roots end
+ 10.times do
+ poly(mus_random(1.0), mus_random(1.0),
+ mus_random(1.0), mus_random(1.0)).roots
+ end
10.times do
poly(make_rectangular(mus_random(1.0), mus_random(1.0)),
make_rectangular(mus_random(1.0), mus_random(1.0)),
@@ -12393,7 +11782,8 @@ def poly_roots_tests
make_rectangular(mus_random(1.0), mus_random(1.0))).roots
end
10.times do
- poly(mus_random(1.0), mus_random(1.0), mus_random(1.0), mus_random(1.0), mus_random(1.0)).roots
+ poly(mus_random(1.0), mus_random(1.0), mus_random(1.0),
+ mus_random(1.0), mus_random(1.0)).roots
end
10.times do
poly(make_rectangular(mus_random(1.0), mus_random(1.0)),
@@ -12415,38 +11805,36 @@ def poly_roots_tests
v[(i - 1) / 2] = 1.0
v.to_poly.roots
end
- unless vequal(res = poly(1, -1, -1, 1).roots, [1.0, -1.0, 1.0])
- snd_display("poly_roots 1 -1 -1 1: %s?", res)
- end
- unless vequal(res = poly_roots(vct(2, -1, -2, 1)), [2.0, -1.0, 1.0])
- snd_display("poly_roots 2 -1 -2 1: %s?", res)
- end
- # FIXME
- # 0.544 comes first with poly.rb
- if vcneql(res = poly(-1, 1, 1, 1).roots,
- [0.544, Complex(-0.772, 1.115), Complex(-0.772, -1.115)]) and
- vcneql(res = poly(-1, 1, 1, 1).roots,
- [Complex(-0.772, 1.115), Complex(-0.772, -1.115), 0.544])
- snd_display("poly_roots -1 1 1 1: %s?", res)
- end
- if (res = poly_roots(vct(-1, 3, -3, 1))) != [1.0, 1.0, 1.0]
- snd_display("poly_roots -1 3 -3 1: %s?", res)
- end
- if (res = poly_roots(vct(1, -4, 6, -4, 1))) != [1.0, 1.0, 1.0, 1.0]
- snd_display("poly_roots 1 -4 6 -4 1: %s?", res)
- end
- if vcneql(res = poly_roots(vct(0.5, 0, 0, 1)),
- [Complex(0.397, -0.687), -0.794, Complex(0.397, 0.687)]) and
- vcneql(res, [Complex(0.397, 0.687), Complex(0.397, -0.687), -0.794])
- snd_display("poly_roots 0.5 0 0 1: %s?", res)
- end
- # FIXME
- # reduce added
- # without reduce: 3.0 -1.0 -2.0 -3.0 2.0-1.1555579666323415e-33i 1.0+2.9582283945787943e-31i
- res = (poly(-1, 1) * poly(1, 1) * poly(-2, 1) * poly(2, 1) * poly(-3, 1) * poly(3, 1)).reduce.roots
- if vcneql(res, [-3.0, 3.0, -1.0, 1.0, -2.0, 2.0])
- snd_display("cube in 2: %s?", res)
- end
+ res = poly(1, -1, -1, 1).roots
+ req = [1.0, -1.0, 1.0]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots 1 -1 -1 1")
+ res = poly_roots(vct(2, -1, -2, 1))
+ req = [2.0, -1.0, 1.0]
+ snd_test_any_neq(res, req, :vequal?, "poly_roots 2 -1 -2 1")
+ res = poly(-1, 1, 1, 1).roots
+ req = [0.544, Complex(-0.772, 1.115), Complex(-0.772, -1.115)]
+ snd_test_any_neq(res, req, :vcequal?, "poly_roots -1 1 1 1")
+ res = poly_roots(vct(-1, 3, -3, 1))
+ req = [1.0, 1.0, 1.0]
+ snd_test_neq(res, req, "poly_roots -1 3 -3 1")
+ res = poly_roots(vct(1, -4, 6, -4, 1))
+ req = [1.0, 1.0, 1.0, 1.0]
+ snd_test_neq(res, req, "poly_roots 1 -4 6 -4 1")
+ res = poly_roots(vct(0.5, 0, 0, 1))
+ req1 = [Complex(0.397, -0.687), -0.794, Complex(0.397, 0.687)]
+ req2 = [Complex(0.397, 0.687), Complex(0.397, -0.687), -0.794]
+ if vcneql(res, req1) and vcneql(res, req2)
+ snd_format_neq(res, req1, "poly_roots 0.5 0 0 1 (a)")
+ snd_format_neq(res, req2, "poly_roots 0.5 0 0 1 (b)")
+ end
+ # FIXME: reduce added (poly)
+ # without reduce:
+ # 3.0 -1.0 -2.0 -3.0 2.0-1.1555579666323415e-33i 1.0+2.9582283945787943e-31i
+ res = poly(-1, 1) * poly(1, 1) * poly(-2, 1) * poly(2, 1) *
+ poly(-3, 1) * poly(3, 1)
+ res = res.reduce.roots
+ req = [-3.0, 3.0, -1.0, 1.0, -2.0, 2.0]
+ snd_test_any_neq(res, req, :vequal?, "cube in 2")
end
def jc_reverb_1(decay_dur, low_pass, volume, amp_env)
@@ -12458,7 +11846,7 @@ def jc_reverb_1(decay_dur, low_pass, volume, amp_env)
comb3 = make_comb(0.715, 5399)
comb4 = make_comb(0.697, 5801)
outdel = make_delay((0.013 * srate).round)
- dur = decay_dur + frames / srate
+ dur = decay_dur + framples / srate
envA = (amp_env ? make_env(:envelope, amp_env, :scaler, volume, :duration, dur) : false)
comb_sum_1 = comb_sum_2 = comb_sum = all_sums = delA = delB = 0.0
map_chan(lambda do |inval|
@@ -12533,9 +11921,9 @@ def fm_violin_1(start, dur, freq, amp, *args)
fmosc1 = if modulate
if easy_case
make_polyshape(:frequency, fm1_rat * freq,
- :coeffs, partials2polynomial([fm1_rat.to_i, index1,
- (fm2_rat / fm1_rat).floor, index2,
- (fm3_rat / fm1_rat).floor, index3]))
+ :coeffs, partials2polynomial([fm1_rat.to_i, index1,
+ (fm2_rat / fm1_rat).floor, index2,
+ (fm3_rat / fm1_rat).floor, index3]))
else
make_oscil(:frequency, fm1_rat * freq)
end
@@ -12576,8 +11964,8 @@ def fm_violin_1(start, dur, freq, amp, *args)
env(indf1) * polyshape(fmosc1, 1.0, vib)
else
(env(indf1) * oscil(fmosc1, fm1_rat * vib + fuzz) +
- env(indf2) * oscil(fmosc2, fm2_rat * vib + fuzz) +
- env(indf3) * oscil(fmosc3, fm3_rat * vib + fuzz))
+ env(indf2) * oscil(fmosc2, fm2_rat * vib + fuzz) +
+ env(indf3) * oscil(fmosc3, fm3_rat * vib + fuzz))
end
end
env(ampf) * amp_fuzz * oscil(carrier, vib + ind_fuzz * modulation)
@@ -12595,18 +11983,19 @@ end
def fltit
coeffs = vct(0.1, 0.2, 0.3, 0.4, 0.4, 0.3, 0.2, 0.1)
flt = make_fir_filter(8, coeffs)
+ xcof = flt.xcoeffs
es = make_array(8) do |i|
if i == 5
make_env(:envelope, [0, 0.4, 1, 1], :duration, 1.0)
else
- make_env(:envelope, [0, coeffs[i], 1, 0], :length, 101)
+ make_env(:envelope, [0, coeffs[i], 1, 0], :duration, 0.5)
end
end
lambda do |x|
- val = fir_filter(flt, x)
- xcof = flt.xcoeffs
- es.each_with_index do |en, i| xcof[i] = env(en) end
- val
+ es.each_with_index do |en, i|
+ xcof[i] = env(en)
+ end
+ fir_filter(flt, x)
end
end
@@ -12614,12 +12003,14 @@ def freq_sweep(dur)
phase = 0.0
freq = 0.0
incr = PI / (dur * 1.05 * mus_srate)
- map_channel(lambda do |y|
- val = sin(phase)
- phase += freq
- freq += incr
- 0.5 * val
- end)
+ len = framples()
+ data = Vct.new(len) do |i|
+ val = sin(phase)
+ phase += freq
+ freq += incr
+ val
+ end.scale!(0.5)
+ vct2channel(data)
end
def make_ssb_am_1(freq, order = 40)
@@ -12628,7 +12019,7 @@ def make_ssb_am_1(freq, order = 40)
end
freq = freq.to_f
carrier_freq = freq.abs
- cos_carrier = make_oscil(freq, 0.5 * PI)
+ cos_carrier = make_oscil(freq, HALF_PI)
sin_carrier = make_oscil(freq)
dly = make_delay(order)
hlb = make_hilbert_transform(order)
@@ -12651,25 +12042,21 @@ end
def rough_spectrum(ind)
rd = make_sampler(0, ind, 0)
- mx = 0.0
- Vct.new(10) do
+ spect = Vct.new(10) do
sum = 0.0
1000.times do
val = rd.call
sum = sum + val * val
end
- if sum > mx
- mx = sum
- end
sum
- end.scale!(1.0 / mx)
+ end
+ spect.scale!(1.0 / spect.peak)
end
def print_and_check(gen, name, desc, desc1 = "", desc2 = "")
if gen.name != name
- snd_display("mus_name %s: %s?", name, gen.name)
+ snd_display_prev_caller("mus_name %s: %s?", name, gen.name)
end
- # xen->sample: #<Proc:0x084bdd14@/usr/home/mike/Project/Sndtest/snd-test-new.rb:4470>
if gen.name != "xen->sample"
if gen.to_s != desc and gen.to_s != desc1 and gen.to_s != desc2
snd_display_prev_caller("mus_describe %s: %s?", gen.name, gen)
@@ -12684,7 +12071,7 @@ end
def test_gen_equal(g0, g1, g2)
# g0 = g1 at start != g2
g3 = g0
- gad = make_frame(2)
+ gad = make_vct(2)
unless g0.eql?(g3)
snd_display_prev_caller("let %s %s.eql? %s?", g0.name, g0, g3)
end
@@ -12768,46 +12155,6 @@ def fm_test(gen)
end
end
-def frame_equal?(f1, f2)
- if f1 and f2 and (len = f1.length) == f2.length
- len.times do |chn|
- if fneq(frame_ref(f1, chn), frame_ref(f2, chn))
- return false
- end
- end
- true
- else
- false
- end
-end
-
-def make_random_frame(size)
- fr = make_frame(size)
- size.times do |chn| frame_set!(fr, chn, 1.0 - random(2.0)) end
- fr
-end
-
-def make_random_mixer(size)
- mx = make_mixer(size)
- size.times do |i|
- size.times do |j|
- mixer_set!(mx, i, j, 1.0 - random(2.0))
- end
- end
- mx
-end
-
-def mixer_copy(umx)
- size = umx.length
- mx = make_mixer(size)
- size.times do |i|
- size.times do |j|
- mixer_set!(mx, i, j, mixer_ref(umx, i, j))
- end
- end
- mx
-end
-
def test_08_00
set_mus_srate(22050)
samps = seconds2samples(1.0)
@@ -12818,10 +12165,10 @@ def test_08_00
if fneq(secs, 1.0)
snd_display("samples2seconds: %s?", secs)
end
- if mus_file_buffer_size != $default_file_buffer_size
- snd_display("mus_file_buffer_size: %s?", mus_file_buffer_size)
- end
- if (res = Snd.catch do set_mus_file_buffer_size(false) end).first != :wrong_type_arg
+ set_mus_file_buffer_size($default_file_buffer_size)
+ if (res = Snd.catch do
+ set_mus_file_buffer_size(false)
+ end).first != :wrong_type_arg
snd_display("mus_file_buffer_size bad size: %s?", res)
end
set_mus_file_buffer_size(128)
@@ -12832,6 +12179,10 @@ def test_08_00
if (res = mus_array_print_length) != 8
snd_display("mus_array_print_length: %s?", res)
end
+ set_mus_array_print_length(12)
+ if (res = mus_array_print_length) != 12
+ snd_display("mus_array_print_length: %s?", res)
+ end
set_mus_array_print_length(32)
if (res = mus_array_print_length) != 32
snd_display("set_mus_array_print_length: %s?", res)
@@ -12921,15 +12272,15 @@ def test_08_00
end
10.times do
val = mus_random(1.0)
- if fneq(res1 = polynomial(lv7, val), res2 = cosh(7.0 * acosh(val)))
- snd_display("ccosh cheb 7 %s: %s %s?", val, res1, res2)
- end
- if fneq(res1 = polynomial(lv7, val), res2 = cos(7.0 * acos(val)))
- snd_display("cos cheb 7 %s: %s %s?", val, res1, res2)
- end
- if fneq(res1 = polynomial(lv8, val), res2 = sin(7.0 * acos(val)) / sin(acos(val)))
- snd_display("acos cheb 7 %s: %s %s?", val, res1, res2)
- end
+ res = polynomial(lv7, val)
+ req = cosh(7.0 * acosh(val)).to_f
+ snd_test_neq(res, req, "ccosh cheb 7 %s", val)
+ res = polynomial(lv7, val)
+ req = cos(7.0 * acos(val))
+ snd_test_neq(res, req, "cos cheb 7 %s", val)
+ res = polynomial(lv8, val)
+ req = sin(7.0 * acos(val)) / sin(acos(val))
+ snd_test_neq(res, req, "acos cheb 7 %s", val)
end
end
#
@@ -13019,19 +12370,9 @@ def test_08_00
v0 = make_vct(10)
v1 = make_vct(10)
vct_fill!(v0, 1.0)
- multiply_arrays(v0, v1, 1)
- unless vequal(v0, vct(0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0))
- snd_display("multiply_arrays[0]: %s?", v0)
- end
- multiply_arrays(v0, v1, 100)
- if fneq(vct_peak(v0), 0.0)
- snd_display("multiply_arrays[100]: %s?", v0)
- end
- vct_fill!(v0, 1.0)
vct_fill!(v1, 0.5)
- multiply_arrays(v0, v1)
- if fneq(v0[0], 0.5)
- snd_display("multiply_arrays: %s?", v0[0])
+ v0.map_with_index! do |x, i|
+ x * v1[i]
end
if fneq(res = dot_product(v0, v1), 2.5)
snd_display("dot_product: %s?", res)
@@ -13042,9 +12383,11 @@ def test_08_00
if fneq(res = dot_product(v0, v1, 3), 0.75)
snd_display("dot_product (3): %s?", res)
end
- clear_array(v0)
+ v0.map! do |x|
+ 0.0
+ end
if fneq(v0[3], 0.0)
- snd_display("clear_array: %s?", v0)
+ snd_display("clear v0: %s?", v0)
end
vct_fill!(v0, 1.0)
vct_fill!(v1, 0.5)
@@ -13061,19 +12404,6 @@ def test_08_00
if fneq(v0[0], 1.0) or fneq(v1[0], 1.0)
snd_display("polar2rectangular (1 1): %s %s?", v0[0], v1[0])
end
- v0 = make_vct(1, 1.0)
- v1 = make_vct(1, 1.0)
- val = 0.123
- rectangular2polar(v0, v1)
- val = v0.first
- polar2rectangular(v0, v1)
- v = vct(v1.first)
- if fneq(v[0], 1.0)
- snd_display("run r->p not inverted: %s?", v)
- end
- if fneq(val, sqrt(2.0))
- snd_display("r->p: %s?", val)
- end
#
ind = open_sound("oboe.snd")
rl = channel2vct(1200, 512)
@@ -13167,7 +12497,7 @@ def test_08_00
err = 0.0
x = -10.0
2000.times do |i|
- diff = (Math.cos(x) - new_cos.call(x)).abs
+ diff = (cos(x) - new_cos.call(x)).abs
if diff > err
err = diff
end
@@ -13179,173 +12509,194 @@ def test_08_00
#
# POLY
#
- unless vequal(res = poly(0.1, 0.2, 0.3) + vct(0, 1, 2, 3, 4), vct(0.1, 1.2, 2.3, 3, 4))
- snd_display("poly_add 1: %s?", res)
- end
- unless vequal(res = poly(0.1, 0.2, 0.3) + 0.5, vct(0.6, 0.2, 0.3))
- snd_display("poly_add 2: %s?", res)
- end
- unless vequal(res = 0.5 + poly(0.1, 0.2, 0.3), vct(0.6, 0.2, 0.3))
- snd_display("poly_add 3: %s?", res)
- end
+ res = poly(0.1, 0.2, 0.3) + vct(0, 1, 2, 3, 4)
+ req = vct(0.1, 1.2, 2.3, 3, 4)
+ snd_test_neq(res, req, "poly_add 1")
+ res = poly(0.1, 0.2, 0.3) + 0.5
+ req = vct(0.6, 0.2, 0.3)
+ snd_test_neq(res, req, "poly_add 2")
+ res = 0.5 + poly(0.1, 0.2, 0.3)
+ req = vct(0.6, 0.2, 0.3)
+ snd_test_neq(res, req, "poly_add 3")
#
- unless vequal(res = poly(1, 1) * vct(-1, 1), vct(-1, 0, 1, 0))
- snd_display("poly_multiply 1: %s?", res)
- end
- unless vequal(res = poly(-5, 1) * vct(3, 7, 2), vct(-15, -32, -3, 2, 0))
- snd_display("poly_multiply 2: %s?", res)
- end
- unless vequal(res = poly(-30, -4, 2) * vct(0.5, 1), vct(-15, -32, -3, 2, 0))
- snd_display("poly_multiply 3: %s?", res)
- end
- unless vequal(res = poly(-30, -4, 2) * 0.5, vct(-15, -2, 1))
- snd_display("poly_multiply 4: %s?", res)
- end
- unless vequal(res = 2.0 * poly(-30, -4, 2), vct(-60, -8, 4))
- snd_display("poly_multiply 5: %s?", res)
- end
- #
- if (not vequal((res = poly(-1, 0, 1) / vct(1, 1))[0], vct(-1, 1, 0))) or
- (not vequal(res[1], vct(0, 0, 0)))
- snd_display("poly_div 1: %s?", res)
- end
- if (not vequal((res = poly(-15, -32, -3, 2) / vct(-5, 1))[0], vct(3, 7, 2, 0))) or
- (not vequal(res[1], vct(0, 0, 0, 0)))
- snd_display("poly_div 2: %s?", res)
- end
- if (not vequal((res = poly(-15, -32, -3, 2) / vct(3, 1))[0], vct(-5, -9, 2, 0))) or
- (not vequal(res[1], vct(0, 0, 0, 0)))
- snd_display("poly_div 3: %s?", res)
- end
- if (not vequal((res = poly(-15, -32, -3, 2) / vct(0.5, 1))[0], vct(-30, -4, 2, 0))) or
- (not vequal(res[1], vct(0, 0, 0, 0)))
- snd_display("poly_div 4: %s?", res)
- end
- if (not vequal((res = poly(-15, -32, -3, 2) / vct(3, 7, 2))[0], vct(-5, 1, 0, 0))) or
- (not vequal(res[1], vct(0, 0, 0, 0)))
- snd_display("poly_div 5: %s?", res)
- end
- unless vequal((res = poly(-15, -32, -3, 2) / 2.0)[0], vct(-7.5, -16, -1.5, 1))
- snd_display("poly_div 6: %s?", res)
- end
- unless vequal((res = poly(-1, 0, 0, 0, 1) / vct(1, 0, 1))[0], vct(-1, 0, 1, 0, 0)) and
- vequal(res[1], vct(0, 0, 0, 0, 0))
- snd_display("poly_div 7: %s?", res)
- end
- unless vequal((res = poly(-1, 0, 0, 0, 0, 0, 0, 0, 1) / vct(1, 0, 0, 0, 1))[0],
- vct(-1, 0, 0, 0, 1, 0, 0, 0, 0)) and
- vequal(res[1], vct(0, 0, 0, 0, 0, 0, 0, 0, 0))
- snd_display("poly_div 8: %s?", res)
- end
- unless vequal((res = poly(-1, 0, 1) / vct(-1, 0, 1))[0], vct(1, 0, 0)) and
- vequal(res[1], vct(0, 0, 0))
- snd_display("poly_div 9: %s?", res)
- end
- unless vequal((res = poly(-1, 0, 1) / vct(2, 1))[0], vct(-2, 1, 0)) and
- vequal(res[1], vct(3, 0, 0))
- snd_display("poly_div 10: %s?", res)
- end
- unless vequal((res = poly(2, 1) / vct(-1, 0, 1))[0], vct(0)) and
- vequal(res[1], vct(-1, 0, 1))
- snd_display("poly_div 11: %s?", res)
- end
- unless vequal((res = poly(1, 2, 3, 0, 1) / vct(0, 0, 0, 1))[0], vct(0, 1, 0, 0, 0)) and
- vequal(res[1], vct(1, 2, 3, 0, 0))
- snd_display("poly_div 12: %s?", res)
+ res = poly(1, 1) * vct(-1, 1)
+ req = vct(-1, 0, 1, 0)
+ snd_test_neq(res, req, "poly_multiply 1")
+ res = poly(-5, 1) * vct(3, 7, 2)
+ req = vct(-15, -32, -3, 2, 0)
+ snd_test_neq(res, req, "poly_multiply 2")
+ res = poly(-30, -4, 2) * vct(0.5, 1)
+ req = vct(-15, -32, -3, 2, 0)
+ snd_test_neq(res, req, "poly_multiply 3")
+ res = poly(-30, -4, 2) * 0.5
+ req = vct(-15, -2, 1)
+ snd_test_neq(res, req, "poly_multiply 4")
+ res = 2.0 * poly(-30, -4, 2)
+ req = vct(-60, -8, 4)
+ snd_test_neq(res, req, "poly_multiply 5")
+ #
+ res = poly(-1, 0, 1) / vct(1, 1)
+ req1 = vct(-1, 1, 0)
+ req2 = vct(0, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 1a")
+ snd_format_neq(res[1], req2, "poly_div 1b")
+ end
+ res = poly(-15, -32, -3, 2) / vct(-5, 1)
+ req1 = vct(3, 7, 2, 0)
+ req2 = vct(0, 0, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 2a")
+ snd_format_neq(res[1], req2, "poly_div 2b")
+ end
+ res = poly(-15, -32, -3, 2) / vct(3, 1)
+ req1 = vct(-5, -9, 2, 0)
+ req2 = vct(0, 0, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 3a")
+ snd_format_neq(res[1], req2, "poly_div 3b")
+ end
+ res = poly(-15, -32, -3, 2) / vct(0.5, 1)
+ req1 = vct(-30, -4, 2, 0)
+ req2 = vct(0, 0, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 4a")
+ snd_format_neq(res[1], req2, "poly_div 4b")
+ end
+ res = poly(-15, -32, -3, 2) / vct(3, 7, 2)
+ req1 = vct(-5, 1, 0, 0)
+ req2 = vct(0, 0, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 5a")
+ snd_format_neq(res[1], req2, "poly_div 5b")
+ end
+ res = poly(-15, -32, -3, 2) / 2.0
+ req = vct(-7.5, -16, -1.5, 1)
+ snd_test_neq(res[0], req, "poly_div 6")
+ res = poly(-1, 0, 0, 0, 1) / vct(1, 0, 1)
+ req1 = vct(-1, 0, 1, 0, 0)
+ req2 = vct(0, 0, 0, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 7a")
+ snd_format_neq(res[1], req2, "poly_div 7b")
+ end
+ res = poly(-1, 0, 0, 0, 0, 0, 0, 0, 1) / vct(1, 0, 0, 0, 1)
+ req1 = vct(-1, 0, 0, 0, 1, 0, 0, 0, 0)
+ req2 = vct(0, 0, 0, 0, 0, 0, 0, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 8a")
+ snd_format_neq(res[1], req2, "poly_div 8b")
+ end
+ res = poly(-1, 0, 1) / vct(-1, 0, 1)
+ req1 = vct(1, 0, 0)
+ req2 = vct(0, 0, 0)
+ snd_format_neq(res[0], req1, "poly_div 9a")
+ snd_format_neq(res[1], req2, "poly_div 9b")
+ res = poly(-1, 0, 1) / vct(2, 1)
+ req1 = vct(-2, 1, 0)
+ req2 = vct(3, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 10a")
+ snd_format_neq(res[1], req2, "poly_div 10b")
+ end
+ res = poly(2, 1) / vct(-1, 0, 1)
+ req1 = vct(0)
+ req2 = vct(-1, 0, 1)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 11a")
+ snd_format_neq(res[1], req2, "poly_div 11b")
+ end
+ res = poly(1, 2, 3, 0, 1) / vct(0, 0, 0, 1)
+ req1 = vct(0, 1, 0, 0, 0)
+ req2 = vct(1, 2, 3, 0, 0)
+ unless vequal(res[0], req1) or vequal(res[1], req2)
+ snd_format_neq(res[0], req1, "poly_div 12a")
+ snd_format_neq(res[1], req2, "poly_div 12b")
end
#
ind = open_sound("1a.snd")
v1 = channel2vct(0, 100, ind, 0)
v2 = channel2vct(0, 100, ind, 0)
- vals = poly_div(v1, v2)[0]
- res = make_vct(100)
- res[0] = 1.0
- unless vequal(vals, res)
- snd_display("poly1 1a: %s?", valse)
- end
+ res = poly_div(v1, v2)[0]
+ req = make_vct(100)
+ req[0] = 1.0
+ snd_test_neq(res, req, "poly1 1a")
close_sound(ind)
#
- unless vequal(res = poly(0.5, 1, 2, 4).derivative, vct(1, 4, 12))
- snd_display("poly_derivative: %s?", res)
- end
+ res = poly(0.5, 1, 2, 4).derivative
+ req = vct(1, 4, 12)
+ snd_test_neq(res, req, "poly_derivative")
#
- unless vequal(res = poly(1, 2, 3).reduce, vct(1, 2, 3))
- snd_display("reduce 1: %s?", res)
- end
- unless vequal(res = poly(1, 2, 3, 0, 0, 0).reduce, vct(1, 2, 3))
- snd_display("reduce 2: %s?", res)
- end
- unless vequal(res = poly(0, 0, 0, 0, 1, 0).reduce, vct(0, 0, 0, 0, 1))
- snd_display("reduce 3: %s?", res)
- end
+ res = poly(1, 2, 3).reduce
+ req = vct(1, 2, 3)
+ snd_test_neq(res, req, "reduce 1")
+ res = poly(1, 2, 3, 0, 0, 0).reduce
+ req = vct(1, 2, 3)
+ snd_test_neq(res, req, "reduce 2")
+ res = poly(0, 0, 0, 0, 1, 0).reduce
+ req = vct(0, 0, 0, 0, 1)
+ snd_test_neq(res, req, "reduce 3")
#
res = (poly(2, 1) * vct(-3, 1)).reduce.gcd(vct(2, 1))
- unless vequal(res, vct(2, 1))
- snd_display("poly_gcd 1: %s?", res)
- end
+ req = vct(2, 1)
+ snd_test_neq(res, req, "poly_gcd 1")
res = (poly(2, 1) * vct(-3, 1)).reduce.gcd(vct(3, 1))
- unless vequal(res, vct(0))
- snd_display("poly_gcd 2: %s?", res)
- end
+ req = vct(0)
+ snd_test_neq(res, req, "poly_gcd 2")
res = (poly(2, 1) * vct(-3, 1)).reduce.gcd(vct(-3, 1))
- unless vequal(res, vct(-3, 1))
- snd_display("poly_gcd 3: %s?", res)
- end
+ req = vct(-3, 1)
+ snd_test_neq(res, req, "poly_gcd 3")
res = (poly(8, 1) * poly(2, 1) * poly(-3, 1)).reduce.gcd(vct(-3, 1))
- unless vequal(res, vct(-3, 1))
- snd_display("poly_gcd 4: %s?", res)
- end
- res = (poly(8, 1) * poly(2, 1) * [-3, 1]).reduce.gcd((poly(8, 1) * [-3, 1]).reduce)
- unless vequal(res, vct(-24, 5, 1))
- snd_display("poly_gcd 5: %s?", res)
- end
- unless vequal(res = poly(-1, 0, 1).gcd([2, -2, -1, 1]), [0])
- snd_display("poly_gcd 6: %s?", res)
- end
- unless vequal(res = poly(2, -2, -1, 1).gcd([-1, 0, 1]), [1, -1])
- snd_display("poly_gcd 7: %s?", res)
- end
- unless vequal(res = poly(2, -2, -1, 1).gcd([-2.5, 1]), [0])
- snd_display("poly_gcd 8: %s?", res)
- end
- #
- poly_roots_tests
- #
- if fneq(res = poly(-1, 0, 1).resultant([1, -2, 1]), 0.0)
- snd_display("poly_resultant 0: %s?", res)
- end
- if fneq(res = poly(-1, 0, 2).resultant([1, -2, 1]), 1.0)
- snd_display("poly_resultant 1: %s?", res)
- end
- if fneq(res = poly(-1, 0, 1).resultant([1, 1]), 0.0)
- snd_display("poly_resultant 2: %s?", res)
- end
- if fneq(res = poly(-1, 0, 1).resultant([2, 1]), 3.0)
- snd_display("poly_resultant 3: %s?", res)
- end
-
- if fneq(poly(-1, 0, 1).discriminant, -4.0)
- snd_display("poly_discriminat 0: %s?", res)
- end
- if fneq(poly(1, -2, 1).discriminant, 0.0)
- snd_display("poly_discriminat 1: %s?", res)
- end
+ req = vct(-3, 1)
+ snd_test_neq(res, req, "poly_gcd 4")
+ res = poly(8, 1) * poly(2, 1) * [-3, 1]
+ res = res.reduce.gcd((poly(8, 1) * [-3, 1]).reduce)
+ req = vct(-24, 5, 1)
+ snd_test_neq(res, req, "poly_gcd 5")
+ res = poly(-1, 0, 1).gcd([2, -2, -1, 1])
+ req = [0]
+ snd_test_neq(res, req, "poly_gcd 6")
+ res = poly(2, -2, -1, 1).gcd([-1, 0, 1])
+ req = [1, -1]
+ snd_test_neq(res, req, "poly_gcd 7")
+ res = poly(2, -2, -1, 1).gcd([-2.5, 1])
+ req = [0]
+ snd_test_neq(res, req, "poly_gcd 8")
+ #
+ poly_roots_tests()
+ #
+ res = poly(-1, 0, 1).resultant([1, -2, 1])
+ req = 0.0
+ snd_test_neq(res, req, "poly_resultant 0")
+ res = poly(-1, 0, 2).resultant([1, -2, 1])
+ req = 1.0
+ snd_test_neq(res, req, "poly_resultant 1")
+ res = poly(-1, 0, 1).resultant([1, 1])
+ req = 0.0
+ snd_test_neq(res, req, "poly_resultant 2")
+ res = poly(-1, 0, 1).resultant([2, 1])
+ req = 3.0
+ snd_test_neq(res, req, "poly_resultant 3")
+ #
+ res = poly(-1, 0, 1).discriminant
+ req = -4.0
+ snd_test_neq(res, req, "poly_discriminant 0")
+ res = poly(1, -2, 1).discriminant
+ req = 0.0
+ snd_test_neq(res, req, "poly_discriminant 1")
res = (poly(-1, 1) * poly(-1, 1) * poly(3, 1)).reduce.discriminant
- if fneq(res, 0.0)
- snd_display("poly_discriminat 2: %s?", res)
- end
- res = (poly(-1, 1) * poly(-1, 1) * poly(3, 1) * poly(2, 1)).reduce.discriminant
- if fneq(res, 0.0)
- snd_display("poly_discriminat 3: %s?", res)
- end
+ req = 0.0
+ snd_test_neq(res, req, "poly_discriminant 2")
+ res = (poly(-1, 1) * poly(-1, 1) *
+ poly(3, 1) * poly(2, 1)).reduce.discriminant
+ req = 0.0
+ snd_test_neq(res, req, "poly_discriminant 3")
res = (poly(1, 1) * poly(-1, 1) * poly(3, 1) * poly(2, 1)).reduce.discriminant
- if fneq(res, 2304.0)
- snd_display("poly_discriminat 4: %s?", res)
- end
+ req = 2304.0
+ snd_test_neq(res, req, "poly_discriminant 4")
res = (poly(1, 1) * poly(-1, 1) * poly(3, 1) * poly(3, 1)).reduce.discriminant
- if fneq(res, 0.0)
- snd_display("poly_discriminat 5: %s?", res)
- end
+ req = 0.0
+ snd_test_neq(res, req, "poly_discriminant 5")
#
v0 = make_vct!(10) do |i| i end
if fneq(res = array_interp(v0, 3.5), 3.5)
@@ -13438,7 +12789,7 @@ def test_08_01
gen2 = make_delay(3)
gen1 = make_delay(4, :initial_contents, [1.0, 0.5, 0.25, 0.0])
gen3 = make_delay(4, :initial_contents, vct(1.0, 0.5, 0.25, 0.0))
- print_and_check(gen, "delay", "delay line[3, step]: [0.000 0.000 0.000]")
+ print_and_check(gen, "delay", "delay line[3, step]: [0 0 0]")
v0 = make_vct!(10) do |i| delay(gen, i) end
v1 = make_vct!(10) do |i| delay?(gen2) ? delay(gen2, i) : -1.0 end
unless vequal(v1, v0)
@@ -13517,7 +12868,7 @@ def test_08_01
end
delay(del, 1.0)
delay(del, 0.0, 0.4)
- if (res = del.to_s) != "delay line[5,8, linear]: [0.000 0.000 1.000 0.000 0.000]"
+ if (res = del.to_s) != "delay line[5,8, linear]: [0 0 1 0 0]"
snd_display("describe zdelay: %s", res)
end
if (res = Snd.catch do tap(make_oscil) end).first != :wrong_type_arg
@@ -13528,24 +12879,24 @@ def test_08_01
flt = make_one_zero(0.5, 0.4)
v = make_vct(20)
inval = 1.0
- vct_map!(v, lambda do | |
- res = delay(dly, inval + one_zero(flt, tap(dly)) * 0.6)
- inval = 0.0
- res
- end)
+ v.map! do |x|
+ res = delay(dly, inval + one_zero(flt, tap(dly)) * 0.6)
+ inval = 0.0
+ res
+ end
unless vequal(v, vct(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.3, 0.24, 0.0, 0.09,
- 0.144, 0.058, 0.027, 0.065, 0.052, 0.022, 0.026, 0.031, 0.019, 0.013))
+ 0.144, 0.058, 0.027, 0.065, 0.052, 0.022, 0.026, 0.031, 0.019, 0.013))
snd_display("tap with low pass: %s?", v)
end
#
dly = make_delay(3)
v = make_vct(20)
inval = 1.0
- vct_map!(v, lambda do | |
- res = delay(dly, inval + tap(dly))
- inval = 0.0
- res
- end)
+ v.map! do |x|
+ res = delay(dly, inval + tap(dly))
+ inval = 0.0
+ res
+ end
unless vequal(v, vct(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0,
0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0))
snd_display("simple tap: %s?", v)
@@ -13553,11 +12904,12 @@ def test_08_01
dly = make_delay(6)
v = make_vct(20)
inval = 1.0
- vct_map!(v, lambda do | |
- res = delay(dly, inval + tap(dly, -2.0))
- inval = 0.0
- res
- end)
+ snd_test_neq(tap?(dly), true, "tap?")
+ v.map! do |x|
+ res = delay(dly, inval + tap(dly, -2.0))
+ inval = 0.0
+ res
+ end
unless vequal(v, vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0))
snd_display("tap back 2: %s?", v)
@@ -13714,7 +13066,7 @@ def test_08_01
impulse = 0.0
val
end
- unless vequal(data, vct(0.6, 0.0, 0.0, 0.0, 0.0))
+ unless vequal(data, vct(0.6, 0.4, 0.0, 0.0, 0.0))
snd_display("delay size 0, max 1, off 0.4: %s", data)
end
dly = make_delay(:size, 0, :max_size, 1)
@@ -13728,7 +13080,7 @@ def test_08_01
impulse = 0.0
val
end
- unless vequal(data, vct(1.4, 0.0, 0.0, 0.0, 0.0))
+ unless vequal(data, vct(1.4, -0.4, 0.0, 0.0, 0.0))
snd_display("delay size 0, max 1, off -0.4: %s", data)
end
dly = make_delay(:size, 0, :max_size, 100)
@@ -13737,7 +13089,7 @@ def test_08_01
snd_display("delay 0 -> 100: %s", v)
end
9.downto(0) do |i| v[i] = delay(dly, 0.5, i) end
- unless vequal(v, vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.0))
+ unless vequal(v, vct(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5))
snd_display("delay 100 -> 0: %s", v)
end
dly.reset
@@ -13760,10 +13112,10 @@ def test_08_02
gen1 = make_all_pass(0.4, 0.6, 3)
print_and_check(gen,
"all-pass",
- "all-pass feedback: 0.400, feedforward: 0.600, line[3, step]:[0.000 0.000 0.000]")
+ "all-pass feedback: 0.400, feedforward: 0.600, line[3, step]:[0 0 0]")
v0 = make_vct!(10) do all_pass(gen, 1.0) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | all_pass?(gen1) ? all_pass(gen1, 1.0) : -1.0 end)
+ v1.map! do |x| all_pass?(gen1) ? all_pass(gen1, 1.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map all-pass: %s %s?", v0, v1)
end
@@ -13809,7 +13161,9 @@ def test_08_02
test_gen_equal(make_all_pass(0.7, 0.5, 3, :initial_contents, [1.0, 0.0, 0.0]),
make_all_pass(0.7, 0.5, 3, :initial_contents, [1.0, 0.0, 0.0]),
make_all_pass(0.7, 0.5, 3, :initial_contents, [1.0, 1.0, 1.0]))
- err = Snd.catch do make_all_pass(:feedback, 0.2, :feedforward, 0.1, :size, -1) end
+ err = Snd.catch do
+ make_all_pass(:feedback, 0.2, :feedforward, 0.1, :size, -1)
+ end
if err.first != :out_of_range or
err[1] != "make_all_pass" or
err[2] != "size _1 < 0?" or
@@ -13818,10 +13172,11 @@ def test_08_02
#
gen = make_moving_average(4)
gen1 = make_moving_average(4)
- print_and_check(gen, "moving-average", "moving-average 0.000, line[4]:[0.000 0.000 0.000 0.000]")
+ print_and_check(gen, "moving-average",
+ "moving-average 0.000, line[4]:[0 0 0 0]")
v0 = make_vct!(10) do moving_average(gen, 1.0) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | moving_average?(gen1) ? moving_average(gen1, 1.0) : -1.0 end)
+ v1.map! do |x| moving_average?(gen1) ? moving_average(gen1, 1.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map moving_average: %s %s?", v0, v1)
end
@@ -13887,19 +13242,19 @@ def test_08_02
test_gen_equal(make_moving_average(3, :initial_contents, [1.0, 0.0, 0.0]),
make_moving_average(3, :initial_contents, [1.0, 0.0, 0.0]),
make_moving_average(3, :initial_contents, [1.0, 1.0, 1.0]))
- err = Snd.catch do make_moving_average(:size, -2) end
+ err = Snd.catch do make_moving_average(:size, -1) end
if err.first != :out_of_range or
err[1] != "make_moving_average" or
- err[2] != "size _2 < 0?" or
+ err[2] != "size -1 < 0?" or
snd_display("make_moving_average bad size error message: %s", err.inspect)
end
#
gen = make_comb(0.4, 3)
gen1 = make_comb(0.4, 3)
- print_and_check(gen, "comb", "comb scaler: 0.400, line[3, step]: [0.000 0.000 0.000]")
+ print_and_check(gen, "comb", "comb scaler: 0.400, line[3, step]: [0 0 0]")
v0 = make_vct!(10) do comb(gen, 1.0) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | comb?(gen1) ? comb(gen1, 1.0) : -1.0 end)
+ v1.map! do |x| comb?(gen1) ? comb(gen1, 1.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map comb: %s %s?", v0, v1)
end
@@ -13943,7 +13298,7 @@ def test_08_02
end
comb(del, 1.0)
comb(del, 0.0, 0.4)
- if (res = del.to_s) != "comb scaler: 0.000, line[5,8, linear]: [0.000 0.000 1.000 0.000 0.000]"
+ if (res = del.to_s) != "comb scaler: 0.000, line[5,8, linear]: [0 0 1 0 0]"
snd_display("describe zcomb: %s", res)
end
del.feedback = 1.0
@@ -13954,12 +13309,11 @@ def test_08_02
gen = make_filtered_comb(0.4, 5, :filter, make_one_zero(0.3, 0.7))
print_and_check(gen,
"filtered-comb",
- "filtered-comb scaler: 0.400, line[5, step]: [0.000 0.000 0.000 0.000 0.000], filter: [one-zero a0: 0.300, a1: 0.700, x1: 0.000]")
+ "filtered-comb scaler: 0.400, line[5, step]: [0 0 0 0 0], filter: [one-zero a0: 0.300, a1: 0.700, x1: 0.000]")
v0 = make_vct!(20) do |i| filtered_comb(gen, (i.zero? ? 1.0 : 0.0)) end
- unless vequal(v0,
- vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.12, 0.28, 0, 0, 0, 0.014, 0.067, 0.078, 0, 0))
- snd_display("filtered_comb: %s?", v0)
- end
+ v1 = vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.12, 0.28,
+ 0, 0, 0, 0.014, 0.067, 0.078, 0, 0)
+ snd_test_neq(v0, v1, "filtered_comb")
unless filtered_comb?(gen)
snd_display("%s not filtered_comb?", gen)
end
@@ -13975,22 +13329,21 @@ def test_08_02
gen = make_filtered_comb(0.9, 5, :filter, make_one_zero(0.5, 0.5))
print_and_check(gen,
"filtered-comb",
- "filtered-comb scaler: 0.900, line[5, step]: [0.000 0.000 0.000 0.000 0.000], filter: [one-zero a0: 0.500, a1: 0.500, x1: 0.000]")
+ "filtered-comb scaler: 0.900, line[5, step]: [0 0 0 0 0], filter: [one-zero a0: 0.500, a1: 0.500, x1: 0.000]")
v0 = make_vct!(20) do |i| filtered_comb(gen, (i.zero? ? 1.0 : 0.0)) end
- unless vequal(v0,
- vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.45, 0.45, 0, 0, 0, 0.202, 0.405, 0.202, 0, 0))
- snd_display("filtered_comb: 0.5 0.5 %s?", v0)
- end
- gen = make_filtered_comb(0.9, 5, :filter, make_fir_filter(5, vct(0.1, 0.2, 0.3, 0.2, 0.1)))
+ v1 = vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.45, 0.45,
+ 0, 0, 0, 0.202, 0.405, 0.202, 0, 0)
+ snd_test_neq(v0, v1, "filtered_comb: 0.5 0.5")
+ gen = make_filtered_comb(0.9, 5,
+ :filter,
+ make_fir_filter(5, vct(0.1, 0.2, 0.3, 0.2, 0.1)))
print_and_check(gen,
"filtered-comb",
- "filtered-comb scaler: 0.900, line[5, step]: [0.000 0.000 0.000 0.000 0.000], filter: [fir-filter order: 5, xs: [0.100 0.200 0.300 0.200 0.100]]")
+ "filtered-comb scaler: 0.900, line[5, step]: [0 0 0 0 0], filter: [fir-filter order: 5, xs: [0.1 0.2 0.3 0.2 0.1]]")
v0 = make_vct!(20) do |i| filtered_comb(gen, (i.zero? ? 1.0 : 0.0)) end
- unless vequal(v0,
- vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0.09, 0.18, 0.27, 0.18, 0.09, 0.008, 0.032, 0.081, 0.13, 0.154))
- snd_display("filtered_comb (fir): %s?", v0)
- end
+ v1 = vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0.09, 0.18, 0.27, 0.18, 0.09, 0.008, 0.032, 0.081, 0.13, 0.154)
+ snd_test_neq(v0, v1, "filtered_comb (fir)")
d1 = make_filtered_comb(0.7, 3, :filter, make_one_pole(0.3, 0.7))
d2 = make_filtered_comb(0.7, 3, :filter, make_one_pole(0.3, 0.7))
d3 = make_filtered_comb(0.7, 4, :filter, make_one_pole(0.3, 0.7))
@@ -13998,41 +13351,43 @@ def test_08_02
filtered_comb(d2, 1.0)
filtered_comb(d3, 1.0)
test_gen_equal(d1, d2, d3)
- test_gen_equal(make_filtered_comb(0.7, 3, :initial_element, 1.0,:filter, make_one_zero(0.5, 0.5)),
- make_filtered_comb(0.7, 3, :initial_element, 1.0,:filter, make_one_zero(0.5, 0.5)),
- make_filtered_comb(0.7, 3, :initial_element, 0.5,:filter, make_one_zero(0.5, 0.5)))
- test_gen_equal(make_filtered_comb(0.7, 3, :initial_element, 1.0,:filter, make_one_zero(0.5, 0.5)),
- make_filtered_comb(0.7, 3, :initial_element, 1.0,:filter, make_one_zero(0.5, 0.5)),
- make_filtered_comb(0.7, 3, :initial_element, 1.0,:filter, make_one_zero(0.25, 0.25)))
+ test_gen_equal(make_filtered_comb(0.7, 3, :initial_element, 1.0,
+ :filter, make_one_zero(0.5, 0.5)),
+ make_filtered_comb(0.7, 3, :initial_element, 1.0,
+ :filter, make_one_zero(0.5, 0.5)),
+ make_filtered_comb(0.7, 3, :initial_element, 0.5,
+ :filter, make_one_zero(0.5, 0.5)))
+ test_gen_equal(make_filtered_comb(0.7, 3, :initial_element, 1.0,
+ :filter, make_one_zero(0.5, 0.5)),
+ make_filtered_comb(0.7, 3, :initial_element, 1.0,
+ :filter, make_one_zero(0.5, 0.5)),
+ make_filtered_comb(0.7, 3, :initial_element, 1.0,
+ :filter, make_one_zero(0.25, 0.25)))
test_gen_equal(make_filtered_comb(0.7, 3, :initial_contents, [1.0, 0.0, 0.0],
:filter, make_one_zero(0.5, 0.5)),
make_filtered_comb(0.7, 3, :initial_contents, [1.0, 0.0, 0.0],
:filter, make_one_zero(0.5, 0.5)),
make_filtered_comb(0.7, 3, :initial_contents, [1.0, 1.0, 1.0],
:filter, make_one_zero(0.5, 0.5)))
- del = make_filtered_comb(0.0, 5, :max_size, 8, :filter, make_one_zero(0.5, 0.5))
+ del = make_filtered_comb(0.0, 5, :max_size, 8,
+ :filter, make_one_zero(0.5, 0.5))
filtered_comb(del, 1.0)
4.times do filtered_comb(del, 0.0) end
v0 = make_vct!(5) do filtered_comb(del, 0.0, 0.4) end
- unless vequal(v0, vct(0.6, 0.4, 0, 0, 0))
- snd_display("zfiltered_comb: %s?", v0)
- end
+ snd_test_neq(v0, vct(0.6, 0.4, 0, 0, 0), "zfiltered_comb")
filtered_comb(del, 1.0)
filtered_comb(del, 0.0, 0.4)
- if (res = mus_describe(del)) != "filtered-comb scaler: 0.000, line[5,8, linear]: [0.000 0.000 1.000 0.000 0.000], filter: [one-zero a0: 0.500, a1: 0.500, x1: 0.000]"
- snd_display("describe zfiltered_comb: %s?", res)
- end
+ snd_test_neq(mus_describe(del), "filtered-comb scaler: 0.000, line[5,8, linear]: [0 0 1 0 0], filter: [one-zero a0: 0.500, a1: 0.500, x1: 0.000]",
+ "describe zfiltered_comb")
del.feedback = 1.0
- if fneq(del.feedback, 1.0)
- snd_display("filtered_echo feedback set: %s?", del.feedback)
- end
+ snd_test_neq(del.feedback, 1.0, "filtered_echo feedback set")
#
gen = make_notch(0.4, 3)
gen1 = make_notch(0.4, 3)
- print_and_check(gen, "notch", "notch scaler: 0.400, line[3, step]: [0.000 0.000 0.000]")
+ print_and_check(gen, "notch",
+ "notch scaler: 0.400, line[3, step]: [0 0 0]")
v0 = make_vct!(10) do notch(gen, 1.0) end
- v1 = make_vct(10)
- vct_map!(v1, lambda do | | notch?(gen1) ? notch(gen1, 1.0) : -1.0 end)
+ v1 = Vct.new(10) do |x| notch?(gen1) ? notch(gen1, 1.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map notch: %s %s?", v0, v1)
end
@@ -14069,162 +13424,168 @@ def test_08_02
make_notch(0.7, 3, :initial_contents, [1.0, 1.0, 1.0]))
# make sure all-pass is the same as comb/notch given the appropriate
# feedback/forward settings
- [[make_comb(0.5, 5), vct(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5)],
- [make_all_pass(0.5, 0.0, 5), vct(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5)],
- [make_notch(0.5, 5), vct(0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
- [make_all_pass(0.0, 0.5, 5), vct(0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0)]
- ].each do |gen, v1|
- v0 = make_vct!(11) do |i| gen.run(i.zero? ? 1.0 : 0.0) end
- unless vequal(v0, v1)
- snd_display("0 %s (0.5, 0.0, 5): %s", gen.name, v0)
- end
+ [[make_comb(0.5, 5),
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5)],
+ [make_all_pass(0.5, 0.0, 5),
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5)],
+ [make_notch(0.5, 5),
+ vct(0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
+ [make_all_pass(0.0, 0.5, 5),
+ vct(0.5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0)]].each do |gen, v1|
+ v0 = Vct.new(11) do |i|
+ gen.run(i.zero? ? 1.0 : 0.0)
+ end
+ snd_test_neq(v0, v1, "0 %s (0.5, 0.0, 5)", gen.name)
end
# make sure all-pass is the same as zcomb/znotch given the
# appropriate feedback/forward and "pm" settings
[[make_comb(0.5, 5, :max_size, 20),
- vct(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5)],
- [make_all_pass(0.5, 0.0, 5, :max_size, 20),
- vct(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5)],
- [make_notch(0.5, 5, :max_size, 20),
- vct(0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
- [make_all_pass(0.0, 0.5, 5, :max_size, 20),
- vct(0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0)]].each do |gen, v1|
- v0 = make_vct!(11) do |i| gen.run(i.zero? ? 1.0 : 0.0) end
- unless vequal(v0, v1)
- snd_display("1 %s (0.5, 0.0, 5): %s", gen.name, v0)
- end
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5)],
+ [make_all_pass(0.5, 0.0, 5, :max_size, 20),
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5)],
+ [make_notch(0.5, 5, :max_size, 20),
+ vct(0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
+ [make_all_pass(0.0, 0.5, 5, :max_size, 20),
+ vct(0.5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0)]].each do |gen, v1|
+ v0 = Vct.new(11) do |i|
+ gen.run(i.zero? ? 1.0 : 0.0)
+ end
+ snd_test_neq(v0, v1, "1 %s (0.5, 0.0, 5)", gen.name)
end
# now actually use the size difference
[[make_comb(0.5, 5, :max_size, 20),
- vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.16, 0.36, 0.2, 0.04, 0.0, 0.0, 0.0)],
- [make_all_pass(0.5, 0.0, 5, :max_size, 20),
- vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.16, 0.36, 0.2, 0.04, 0.0, 0.0, 0.0)],
- [make_notch(0.5, 5, :max_size, 20),
- vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
- [make_all_pass(0.0, 0.5, 5, :max_size, 20),
- vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)]].each do |gen, v1|
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.16, 0.36, 0.2, 0.04, 0.0, 0.0, 0.0)],
+ [make_all_pass(0.5, 0.0, 5, :max_size, 20),
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.16, 0.36, 0.2, 0.04, 0.0, 0.0, 0.0)],
+ [make_notch(0.5, 5, :max_size, 20),
+ vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
+ [make_all_pass(0.0, 0.5, 5, :max_size, 20),
+ vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.0, 0.0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]].each do |gen, v1|
angle = -0.2
- v0 = make_vct!(20) do |i| gen.run((i.zero? ? 1.0 : 0.0), angle += 0.2) end
- unless vequal(v0, v1)
- snd_display("2 %s (0.5, 0.0, 5): %s", gen.name, v0)
+ v0 = Vct.new(20) do |i|
+ gen.run((i.zero? ? 1.0 : 0.0), angle += 0.2)
end
+ snd_test_neq(v0, v1, "2 %s (0.5, 0.0, 5)", gen.name)
end
[[make_comb(0.5, 5, :max_size, 20),
- vct(0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.16, 0.16, 0.0,
- 0.08, 0.064, 0.016, 0.035, 0.013, 0.018, 0.007, 0.007, 0.003, 0.002)],
- [make_all_pass(0.5, 0.0, 5, :max_size, 20),
- vct(0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.16, 0.16, 0.0,
- 0.08, 0.064, 0.016, 0.035, 0.013, 0.018, 0.007, 0.007, 0.003, 0.002)],
- [make_notch(0.5, 5, :max_size, 20),
- vct(0.5, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
- [make_all_pass(0.0, 0.5, 5, :max_size, 20),
- vct(0.5, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)]].each do |gen, v1|
- angle = +0.2
- v0 = make_vct!(20) do |i| gen.run((i.zero? ? 1.0 : 0.0), angle -= 0.2) end
- unless vequal(v0, v1)
- snd_display("3 %s (0.5, 0.0, 5): %s", gen.name, v0)
- end
+ vct(0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.16, 0.16, 0.0,
+ 0.08, 0.064, 0.016, 0.035, 0.013, 0.018, 0.007, 0.007, 0.003, 0.002)],
+ [make_all_pass(0.5, 0.0, 5, :max_size, 20),
+ vct(0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.16, 0.16, 0.0,
+ 0.08, 0.064, 0.016, 0.035, 0.013, 0.018, 0.007, 0.007, 0.003, 0.002)],
+ [make_notch(0.5, 5, :max_size, 20),
+ vct(0.5, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
+ [make_all_pass(0.0, 0.5, 5, :max_size, 20),
+ vct(0.5, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]].each do |gen, v1|
+ angle = 0.2
+ v0 = Vct.new(20) do |i|
+ gen.run((i.zero? ? 1.0 : 0.0), angle -= 0.2)
+ end
+ snd_test_neq(v0, v1, "3 %s (0.5, 0.0, 5)", gen.name)
end
[[make_comb(0.5, 5, :max_size, 20),
- vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.95, 0.06, 0.0, 0.0, 0.0,
- 0.428, 0.079, 0.004, 0.0, 0.0, 0.182, 0.067, 0.008, 0.0, 0.0)],
- [make_all_pass(0.5, 0.0, 5, :max_size, 20),
- vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.95, 0.06, 0.0, 0.0, 0.0,
- 0.428, 0.079, 0.004, 0.0, 0.0, 0.182, 0.067, 0.008, 0.0, 0.0)],
- [make_notch(0.5, 5, :max_size, 20),
- vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.95, 0.06, 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
- [make_all_pass(0.0, 0.5, 5, :max_size, 20),
- vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.95, 0.06, 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)]].each do |gen, v1|
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.95, 0.06, 0.0, 0.0, 0.0,
+ 0.428, 0.079, 0.004, 0.0, 0.0, 0.182, 0.067, 0.008, 0.0, 0.0)],
+ [make_all_pass(0.5, 0.0, 5, :max_size, 20),
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.95, 0.06, 0.0, 0.0, 0.0,
+ 0.428, 0.079, 0.004, 0.0, 0.0, 0.182, 0.067, 0.008, 0.0, 0.0)],
+ [make_notch(0.5, 5, :max_size, 20),
+ vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.95, 0.06, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
+ [make_all_pass(0.0, 0.5, 5, :max_size, 20),
+ vct(0.5, 0, 0, 0, 0, 0.95, 0.06, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]].each do |gen, v1|
angle = -0.01
- v0 = make_vct!(20) do |i| gen.run((i.zero? ? 1.0 : 0.0), angle += 0.01) end
- unless vequal(v0, v1)
- snd_display("4 %s (0.5, 0.0, 5): %s", gen.name, v0)
+ v0 = Vct.new(20) do |i|
+ gen.run((i.zero? ? 1.0 : 0.0), angle += 0.01)
end
+ snd_test_neq(v0, v1, "4 %s (0.5, 0.0, 5)", gen.name)
end
# now run off either end of the delay line "by accident"
[[make_comb(0.5, 5, :max_size, 10),
- vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5,
- 1.0, 0.25, 0.125, 0.094, 0.062, 0.055, 0.047, 0.039, 0.031, 0.029)],
- [make_all_pass(0.5, 0.0, 5, :max_size, 10),
- vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5,
- 1.0, 0.25, 0.125, 0.094, 0.062, 0.055, 0.047, 0.039, 0.031, 0.029)],
- [make_notch(0.5, 5, :max_size, 10),
- vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
- [make_all_pass(0.0, 0.5, 5, :max_size, 10),
- vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)]].each do |gen, v1|
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5,
+ 1.0, 0.25, 0.125, 0.094, 0.062, 0.055, 0.047, 0.039, 0.031, 0.029)],
+ [make_all_pass(0.5, 0.0, 5, :max_size, 10),
+ vct(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5,
+ 1.0, 0.25, 0.125, 0.094, 0.062, 0.055, 0.047, 0.039, 0.031, 0.029)],
+ [make_notch(0.5, 5, :max_size, 10),
+ vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
+ [make_all_pass(0.0, 0.5, 5, :max_size, 10),
+ vct(0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]].each do |gen, v1|
angle = -0.5
- v0 = make_vct!(20) do |i| gen.run((i.zero? ? 1.0 : 0.0), angle += 0.5) end
- unless vequal(v0, v1)
- snd_display("5 %s (0.5, 0.0, 5): %s", gen.name, v0)
+ v0 = Vct.new(20) do |i|
+ gen.run((i.zero? ? 1.0 : 0.0), angle += 0.5)
end
+ snd_test_neq(v0, v1, "5 %s (0.5, 0.0, 5)", gen.name)
end
[[make_comb(0.5, 5, :max_size, 10),
- vct(0.0, 0.0, 0.0, 0.5, 0.0, 0.125, 0.0, 0.031, 0.016, 0.004,
- 1.0, 0.0, 0.25, 0.031, 0.0, 0.012, 0.002, 0.250, 0.125, 0.008)],
- [make_all_pass(0.5, 0.0, 5, :max_size, 10),
- vct(0.0, 0.0, 0.0, 0.5, 0.0, 0.125, 0.0, 0.031, 0.016, 0.004,
- 1.0, 0.0, 0.25, 0.031, 0.0, 0.012, 0.002, 0.250, 0.125, 0.008)],
- [make_notch(0.5, 5, :max_size, 10),
- vct(0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
- [make_all_pass(0.0, 0.5, 5, :max_size, 10),
- vct(0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)]].each do |gen, v1|
- angle = +0.5
- v0 = make_vct!(20) do |i| gen.run((i.zero? ? 1.0 : 0.0), angle -= 0.5) end
- unless vequal(v0, v1)
- snd_display("6 %s (0.0, 0.5, 5): %s", gen.name, v0)
- end
+ vct(0.0, 0.0, 0.0, 0.5, 0.0, 0.125, 0.0, 0.031, 0.016, 0.004,
+ 1.0, 0.0, 0.25, 0.031, 0.0, 0.012, 0.002, 0.250, 0.125, 0.008)],
+ [make_all_pass(0.5, 0.0, 5, :max_size, 10),
+ vct(0.0, 0.0, 0.0, 0.5, 0.0, 0.125, 0.0, 0.031, 0.016, 0.004,
+ 1.0, 0.0, 0.25, 0.031, 0.0, 0.012, 0.002, 0.250, 0.125, 0.008)],
+ [make_notch(0.5, 5, :max_size, 10),
+ vct(0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)],
+ [make_all_pass(0.0, 0.5, 5, :max_size, 10),
+ vct(0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)]].each do |gen, v1|
+ angle = 0.5
+ v0 = Vct.new(20) do |i|
+ gen.run((i.zero? ? 1.0 : 0.0), angle -= 0.5)
+ end
+ snd_test_neq(v0, v1, "6 %s (0.0, 0.5, 5)", gen.name)
end
#
gen = make_filtered_comb(0.5, 5, :filter, make_one_zero(0.5, 0.5))
v0 = Vct.new(21) do |i| filtered_comb(gen, i.zero? ? 1.0 : 0.0) end
- unless vequal(v0,
- vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0.25, 0.25, 0, 0, 0, 0.062, 0.125, 0.062, 0, 0, 0.016))
- snd_display("0 filtered_comb (0.5, 5): %s?", v0)
- end
- gen = make_filtered_comb(0.5, 5, :max_size, 20, :filter, make_one_zero(0.25, 0.75))
+ v1 = vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0.25, 0.25, 0, 0, 0, 0.062, 0.125, 0.062, 0, 0, 0.016)
+ snd_test_neq(v0, v1, "0 filtered_comb (0.5, 5)")
+ #
+ gen = make_filtered_comb(0.5, 5, :filter, make_one_zero(0.25, 0.75))
v0 = Vct.new(21) do |i| filtered_comb(gen, i.zero? ? 1.0 : 0.0) end
- unless vequal(v0,
- vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0.125, 0.375, 0, 0, 0, 0.016, 0.094, 0.141, 0, 0, 0.002))
- snd_display("1 filtered_comb (0.5, 5): %s?", v0)
- end
- gen = make_filtered_comb(0.5, 5, :max_size, 20, :filter, make_one_zero(0.5, 0.5))
+ v1 = vct(0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0.125, 0.375, 0, 0, 0, 0.016, 0.094, 0.141, 0, 0, 0.002)
+ snd_test_neq(v0, v1, "1 filtered_comb (0.5, 5)")
+ #
+ gen = make_filtered_comb(0.5, 5, :max_size, 20,
+ :filter, make_one_zero(0.5, 0.5))
angle = -0.2
- v0 = Vct.new(20) do |i| filtered_comb(gen, i.zero? ? 1.0 : 0.0, angle += 0.2) end
- unless vequal(v0,
- vct(0, 0, 0, 0, 0, 0, 0.8, 0.4, 0, 0,
- 0, 0, 0, 0.08, 0.22, 0.3, 0.140, 0.04, 0, 0))
- snd_display("2 filtered_comb (0.5, 5): %s?", v0)
+ v0 = Vct.new(20) do |i|
+ filtered_comb(gen, i.zero? ? 1.0 : 0.0, angle += 0.2)
end
- gen = make_filtered_comb(0.5, 5, :max_size, 20, :filter, make_one_zero(0.5, 0.5))
+ v1 = vct(0, 0, 0, 0, 0, 0, 0.8, 0.4, 0, 0,
+ 0, 0, 0, 0.08, 0.22, 0.3, 0.140, 0.04, 0, 0)
+ snd_test_neq(v0, v1, "2 filtered_comb (0.5, 5)")
+ #
+ gen = make_filtered_comb(0.5, 5, :max_size, 20,
+ :filter, make_one_zero(0.5, 0.5))
angle = 0.2
- v0 = Vct.new(20) do |i| filtered_comb(gen, i.zero? ? 1.0 : 0.0, angle -= 0.2) end
- unless vequal(v0,
- vct(0, 0, 0, 0, 0.8, 0, 0, 0.08, 0.2, 0.04,
- 0.02, 0.068, 0.042, 0.019, 0.026, 0.015, 0.011, 0.009, 0.006, 0.004))
- snd_display("3 filtered_comb (0.5, 5): %s?", v0)
+ v0 = Vct.new(20) do |i|
+ filtered_comb(gen, i.zero? ? 1.0 : 0.0, angle -= 0.2)
end
- gen = make_filtered_comb(0.5, 5, :max_size, 20, :filter, make_one_zero(0.5, 0.5))
+ v1 = vct(0, 0, 0, 0, 0.8, 0, 0, 0.08, 0.2, 0.04,
+ 0.02, 0.068, 0.042, 0.019, 0.026, 0.015, 0.011, 0.009, 0.006, 0.004)
+ snd_test_neq(v0, v1, "3 filtered_comb (0.5, 5)")
+ #
+ gen = make_filtered_comb(0.5, 5, :max_size, 20,
+ :filter, make_one_zero(0.5, 0.5))
angle = -0.01
- v0 = Vct.new(20) do |i| filtered_comb(gen, i.zero? ? 1.0 : 0.0, angle += 0.01) end
- unless vequal(v0,
- vct(0, 0, 0, 0, 0, 0.95, 0.06, 0, 0, 0,
- 0.214, 0.251, 0.043, 0.002, 0, 0.045, 0.106, 0.081, 0.023, 0.003))
- snd_display("4 filtered_comb (0.5, 5): %s?", v0)
+ v0 = Vct.new(20) do |i|
+ filtered_comb(gen, i.zero? ? 1.0 : 0.0, angle += 0.01)
end
+ v1 = vct(0, 0, 0, 0, 0, 0.95, 0.06, 0, 0, 0,
+ 0.214, 0.251, 0.043, 0.002, 0, 0.045, 0.106, 0.081, 0.023, 0.003)
+ snd_test_neq(v0, v1, "4 filtered_comb (0.5, 5)")
end
def test_08_03
@@ -14232,8 +13593,7 @@ def test_08_03
gen1 = make_one_pole(0.4, 0.7)
print_and_check(gen, "one-pole", "one-pole a0: 0.400, b1: 0.700, y1: 0.000")
v0 = make_vct!(10) do one_pole(gen, 1.0) end
- v1 = make_vct(10)
- vct_map!(v1, lambda do | | one_pole?(gen1) ? one_pole(gen1, 1.0) : -1.0 end)
+ v1 = Vct.new(10) do |x| one_pole?(gen1) ? one_pole(gen1, 1.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map one_pole: %s %s?", v0, v1)
end
@@ -14271,8 +13631,7 @@ def test_08_03
gen1 = make_one_zero(0.4, 0.7)
print_and_check(gen, "one-zero", "one-zero a0: 0.400, a1: 0.700, x1: 0.000")
v0 = make_vct!(10) do one_zero(gen, 1.0) end
- v1 = make_vct(10)
- vct_map!(v1, lambda do | | one_zero?(gen1) ? one_zero(gen1, 1.0) : -1.0 end)
+ v1 = Vct.new(10) do |x| one_zero?(gen1) ? one_zero(gen1, 1.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map one_zero: %s %s?", v0, v1)
end
@@ -14305,8 +13664,7 @@ def test_08_03
"two-zero",
"two-zero a0: 0.400, a1: 0.700, a2: 0.300, x1: 0.000, x2: 0.000")
v0 = make_vct!(10) do two_zero(gen, 1.0) end
- v1 = make_vct(10)
- vct_map!(v1, lambda do | | two_zero?(gen1) ? two_zero(gen1, 1.0) : -1.0 end)
+ v1 = Vct.new(10) do |x| two_zero?(gen1) ? two_zero(gen1, 1.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map two_zero: %s %s?", v0, v1)
end
@@ -14372,8 +13730,7 @@ def test_08_03
"two-pole",
"two-pole a0: 0.400, b1: 0.700, b2: 0.300, y1: 0.000, y2: 0.000")
v0 = make_vct!(10) do two_pole(gen, 1.0) end
- v1 = make_vct(10)
- vct_map!(v1, lambda do | | two_pole?(gen1) ? two_pole(gen1, 1.0) : -1.0 end)
+ v1 = Vct.new(10) do |x| two_pole?(gen1) ? two_pole(gen1, 1.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map two_pole: %s %s?", v0, v1)
end
@@ -14439,18 +13796,6 @@ def test_08_03
if fneq(val = gen.call(1.0, 0.0), 0.336)
snd_display("a0->out 2pole (0.336): %s?", val)
end
- if (res = Snd.catch do make_two_pole(:b1, 3.0) end).first != :mus_error
- snd_display("make_two_pole bad b1: %s", res.inspect)
- end
- if (res = Snd.catch do make_two_pole(:b2, 2.0) end).first != :mus_error
- snd_display("make_two_pole bad b2: %s", res.inspect)
- end
- if (res = Snd.catch do make_two_pole(:b2, 2.0, :b1) end).first != :mus_error
- snd_display("make_two_pole bad keys: %s", res.inspect)
- end
- if (res = Snd.catch do make_two_pole(:b2, 2.0, 3.0) end).first != :mus_error
- snd_display("make_two_pole bad args: %s", res.inspect)
- end
#
gen = make_oscil(440.0)
gen1 = make_oscil(440.0)
@@ -14458,8 +13803,7 @@ def test_08_03
print_and_check(gen, "oscil", "oscil freq: 440.000Hz, phase: 0.000")
v0 = make_vct!(10) do oscil(gen, 0.0) end
v1 = make_vct!(10) do mus_apply(gen1, 0.0, 0.0) end
- v2 = make_vct(10)
- vct_map!(v2, lambda do | | oscil?(gen2) ? oscil(gen2, 0.0) : -1.0 end)
+ v2 = Vct.new(10) do |x| oscil?(gen2) ? oscil(gen2, 0.0) : -1.0 end
unless vequal(v0, v2)
snd_display("map oscil: %s %s?", v0, v2)
end
@@ -14620,8 +13964,9 @@ def test_08_04
"asymmetric-fm",
"asymmetric-fm freq: 440.000Hz, phase: 0.000, ratio: 1.000, r: 1.000")
v0 = make_vct!(10) do asymmetric_fm(gen, 0.0) end
- v1 = make_vct(10)
- vct_map!(v1, lambda do | | asymmetric_fm?(gen1) ? asymmetric_fm(gen1, 0.0) : -1.0 end)
+ v1 = Vct.new(10) do |x|
+ asymmetric_fm?(gen1) ? asymmetric_fm(gen1, 0.0) : -1.0
+ end
unless vequal(v0, v1)
snd_display("map asymmetric_fm: %s %s?", v0, v1)
end
@@ -14686,7 +14031,7 @@ def test_08_04
spectr1 = snd_spectrum(vct0, Rectangular_window, 2048, true)
spectr2 = snd_spectrum(vct1, Rectangular_window, 2048, true)
(1...512).each do |i|
- if fneq_err(spectr1[i], spectr2[i], 0.02) # okay
+ if fneq_err(spectr1[i], spectr2[i], 0.02)
snd_display("asymmetric_fm 2: %s: %s %s?", i, spectr1[i], spectr2[i])
break
end
@@ -14704,7 +14049,8 @@ def test_08_04
sr = 0.5 * (r + (1.0 / r))
th = a
mth = ratio * th
- val2 = exp(index * cr * (1.0 + cos(mth))) * cos(th + (index * sr * sin(mth)))
+ val2 = exp(index * cr * (1.0 + cos(mth))) *
+ cos(th + (index * sr * sin(mth)))
if fneq(val1, val2) or fneq(val1, val3)
snd_display("asyfm by hand: %s: 1 %s 2 %s 3 %s?", i, val1, val2, val3)
end
@@ -14785,14 +14131,14 @@ end
def test_08_05
gen = make_fir_filter(3, vct(0.5, 0.25, 0.125))
gen1 = make_fir_filter(3, vct(0.5, 0.25, 0.125))
- print_and_check(gen, "fir-filter", "fir-filter order: 3, xs: [0.500 0.250 0.125]")
+ print_and_check(gen, "fir-filter", "fir-filter order: 3, xs: [0.5 0.25 0.125]")
v0 = make_vct!(10) do |i| fir_filter(gen, i.zero? ? 1.0 : 0.0) end
v1 = make_vct(10)
inp = -1
- vct_map!(v1, lambda do | |
- inp += 1
- fir_filter?(gen1) ? fir_filter(gen1, inp.zero? ? 1.0 : 0.0) : -1.0
- end)
+ v1.map! do |x|
+ inp += 1
+ fir_filter?(gen1) ? fir_filter(gen1, inp.zero? ? 1.0 : 0.0) : -1.0
+ end
unless vequal(v0, v1)
snd_display("map fir_filter: %s %s?", v0, v1)
end
@@ -14831,12 +14177,16 @@ def test_08_05
test_gen_equal(f1, f2, f3)
coeffs = vct(0.1, 0.2, 0.3, 0.4, 0.4, 0.3, 0.2, 0.1)
flt = make_fir_filter(8, coeffs)
- es = make_array(8) do |i| make_env([0, coeffs[i], 1, 0], :length, 102) end
+ xcof = flt.xcoeffs
+ es = make_array(8) do |i|
+ make_env([0, coeffs[i], 1, 0], :length, 102)
+ end
es[5] = make_env([0, 0.4, 1, 1], :length, 102)
data = make_vct!(100) do |i|
val = fir_filter(flt, (i % 12).zero? ? 1.0 : 0.0)
- xcof = flt.xcoeffs
- es.each_with_index do |en, j| xcof[j] = env(en) end
+ es.each_with_index do |en, j|
+ xcof[j] = env(en)
+ end
val
end
if fneq(data[1], 0.2) or fneq(data[10], 0.0) or
@@ -14857,14 +14207,14 @@ def test_08_05
#
gen = make_iir_filter(3, vct(0.5, 0.25, 0.125))
gen1 = make_iir_filter(3, vct(0.5, 0.25, 0.125))
- print_and_check(gen, "iir-filter", "iir-filter order: 3, ys: [0.500 0.250 0.125]")
+ print_and_check(gen, "iir-filter", "iir-filter order: 3, ys: [0.5 0.25 0.125]")
v0 = make_vct!(10) do |i| iir_filter(gen, i.zero? ? 1.0 : 0.0) end
v1 = make_vct(10)
inp = -1
- vct_map!(v1, lambda do | |
- inp += 1
- iir_filter?(gen1) ? iir_filter(gen1, inp.zero? ? 1.0 : 0.0) : -1.0
- end)
+ v1.map! do |x|
+ inp += 1
+ iir_filter?(gen1) ? iir_filter(gen1, inp.zero? ? 1.0 : 0.0) : -1.0
+ end
unless vequal(v0, v1)
snd_display("map iir_filter: %s %s?", v0, v1)
end
@@ -14906,14 +14256,14 @@ def test_08_05
gen1 = make_filter(3, vct(0.5, 0.25, 0.125), vct(0.5, 0.25, 0.125))
print_and_check(gen,
"filter",
- "filter order: 3, xs: [0.500 0.250 0.125], ys: [0.500 0.250 0.125]")
+ "filter order: 3, xs: [0.5 0.25 0.125], ys: [0.5 0.25 0.125]")
v0 = make_vct!(10) do |i| filter(gen, i.zero? ? 1.0 : 0.0) end
v1 = make_vct(10)
inp = -1
- vct_map!(v1, lambda do | |
- inp += 1
- filter?(gen1) ? filter(gen1, inp.zero? ? 1.0 : 0.0) : -1.0
- end)
+ v1.map! do |x|
+ inp += 1
+ filter?(gen1) ? filter(gen1, inp.zero? ? 1.0 : 0.0) : -1.0
+ end
unless vequal(v0, v1)
snd_display("map filter: %s %s?", v0, v1)
end
@@ -14999,7 +14349,7 @@ def test_08_05
snd_display("cascade2canonical 3: %s?", res)
end
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next)
pad_channel(0, 10000)
freq_sweep(0.45)
sp = rough_spectrum(ind)
@@ -15062,10 +14412,7 @@ def test_08_05
end
undo_edit
#
- # analog filter (requires --with-gsl)
- if $with_test_gsl
- analog_filter_tests
- end
+ analog_filter_tests
#
v = spectrum2coeffs(10, vct(0, 1.0, 0, 0, 0, 0, 0, 0, 1.0, 0))
v1 = make_fir_coeffs(10, vct(0, 1.0, 0, 0, 0, 0, 0, 0, 1.0, 0))
@@ -15218,39 +14565,39 @@ def test_08_05
#
b = make_iir_band_stop_2(440.0, 500.0)
v = make_vct!(10) do |i| butter(b, i.zero? ? 1.0 : 0.0) end
- unless vequal(v, vct(0.992, -0.017, -0.016, -0.015, -0.014, -0.012, -0.011, -0.009, -0.007,-0.005))
- snd_display("iir bp-2 bandstop: %s?", v)
- end
+ v1 = vct(0.992, -0.017, -0.016, -0.015, -0.014,
+ -0.012, -0.011, -0.009, -0.007, -0.005)
+ snd_test_neq(v, v1, "iir bp-2 bandstop: %s?")
b = make_iir_band_stop_2(1000.0, 1500.0)
map_channel(lambda do |y| butter(b, y) end)
sp = rough_spectrum(ind)
if (not vequal(sp, vct(0.836, 0.525, 0.943, 0.979, 0.989, 0.994, 0.997, 0.997, 0.997, 1))) and
- (not vequal(sp, vct(0.838, 0.527, 0.945, 0.981, 0.991, 0.996, 0.999, 1, 0.999, 0.998)))
+ (not vequal(sp, vct(0.838, 0.527, 0.945, 0.981, 0.991, 0.996, 0.999, 1, 0.999, 0.998)))
snd_display("iir bs-2 rough spectrum: %s?", sp)
end
undo_edit
#
b = make_butter_hp(4, 440.0)
v = make_vct!(10) do |i| butter(b, i.zero? ? 1.0 : 0.0) end
- if (not vequal(v, vct(0.725, -0.466, -0.315, -0.196, -0.104,
- -0.036, 0.014, 0.047, 0.0685, 0.0775))) and
- (not vequal(v, vct(0.725, -0.466, -0.315, -0.196, -0.104,
- 0.035, 0.015, 0.049, 0.070, 0.081))) and
- (not vequal(v, vct(0.725, -0.466, -0.315, -0.196, -0.104,
- -0.035, 0.014, 0.049, 0.069, 0.079)))
- snd_display(snd_format_neq(v,
- vct(0.725, -0.466, -0.315, -0.196, -0.104,
- -0.036, 0.014, 0.047, 0.0685, 0.0775),
- "butter hp"))
+ v1 = vct(0.725, -0.466, -0.315, -0.196, -0.104,
+ -0.036, 0.014, 0.047, 0.0685, 0.0775)
+ v2 = vct(0.725, -0.466, -0.315, -0.196, -0.104,
+ -0.035, 0.015, 0.049, 0.070, 0.081)
+ v3 = vct(0.725, -0.466, -0.315, -0.196, -0.104,
+ -0.035, 0.014, 0.049, 0.069, 0.079)
+ if (not vequal(v, v1)) and (not vequal(v, v2)) and (not vequal(v, v3))
+ snd_test_neq(v, v1, "butter hp (1)")
+ snd_test_neq(v, v2, "butter hp (2)")
+ snd_test_neq(v, v3, "butter hp (3)")
end
b = make_butter_hp(4, 1000.0)
map_channel(lambda do |y| butter(b, y) end)
sp = rough_spectrum(ind)
if (not vequal(sp, vct(0.0505, 0.982, 1.0, 1.0, 0.998, 0.998, 0.999, 0.998, 0.996, 0.999))) and
- (not vequal(sp, vct(0.051, 0.982, 1.0, 1.0, 0.998, 0.998, 0.998, 0.999, 0.997, 0.995))) and
- (not vequal(sp, vct(0.051, 0.991, 1.0, 1.0, 0.998, 0.998, 0.999, 0.999, 0.997, 0.995))) and
- (not vequal(sp, vct(0.045, 0.970, 1.0, 1.0, 0.998, 0.998, 0.999, 0.999, 0.997, 0.995))) and
- (not vequal(sp, vct(0.052, 0.971, 1.0, 1.0, 0.998, 0.998, 0.999, 0.999, 0.997, 0.995)))
+ (not vequal(sp, vct(0.051, 0.982, 1.0, 1.0, 0.998, 0.998, 0.998, 0.999, 0.997, 0.995))) and
+ (not vequal(sp, vct(0.051, 0.991, 1.0, 1.0, 0.998, 0.998, 0.999, 0.999, 0.997, 0.995))) and
+ (not vequal(sp, vct(0.045, 0.970, 1.0, 1.0, 0.998, 0.998, 0.999, 0.999, 0.997, 0.995))) and
+ (not vequal(sp, vct(0.052, 0.971, 1.0, 1.0, 0.998, 0.998, 0.999, 0.999, 0.997, 0.995)))
snd_display("butter hp rough spectrum: %s?", sp)
end
undo_edit
@@ -15303,7 +14650,7 @@ def test_08_06
print_and_check(gen, "sawtooth-wave", "sawtooth-wave freq: 440.000Hz, phase: 3.142, amp: 1.000")
v0 = Vct.new(10) do sawtooth_wave(gen, 0.0) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | sawtooth_wave?(gen1) ? sawtooth_wave(gen1, 0.0) : -1.0 end)
+ v1.map! do |x| sawtooth_wave?(gen1) ? sawtooth_wave(gen1, 0.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map sawtooth_wave: %s %s?", v0, v1)
end
@@ -15353,10 +14700,10 @@ def test_08_06
v0 = make_vct!(10) do |i| square_wave(gen, 0.0) end
v1 = make_vct(10)
w = 1.0
- vct_map!(v1, lambda do | |
- w = gen1.width
- square_wave?(gen1) ? square_wave(gen1, 0.0) : -1.0
- end)
+ v1.map! do |x|
+ w = gen1.width
+ square_wave?(gen1) ? square_wave(gen1, 0.0) : -1.0
+ end
if fneq(w, 0.5)
snd_display("mus_width opt: %s?", w)
end
@@ -15414,7 +14761,7 @@ def test_08_06
print_and_check(gen, "triangle-wave", "triangle-wave freq: 440.000Hz, phase: 0.000, amp: 1.000")
v0 = make_vct!(10) do |i| triangle_wave(gen, 0.0) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | triangle_wave?(gen2) ? triangle_wave(gen2, 0.0) : -1.0 end)
+ v1.map! do |x| triangle_wave?(gen2) ? triangle_wave(gen2, 0.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map triangle_wave: %s %s?", v0, v1)
end
@@ -15462,7 +14809,7 @@ def test_08_06
print_and_check(gen, "pulse-train", "pulse-train freq: 440.000Hz, phase: 0.000, amp: 1.000")
v0 = make_vct!(10) do |i| pulse_train(gen, 0.0) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | pulse_train?(gen1) ? pulse_train(gen1, 0.0) : -1.0 end)
+ v1.map! do |x| pulse_train?(gen1) ? pulse_train(gen1, 0.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map pulse_train: %s %s?", v0, v1)
end
@@ -15504,194 +14851,96 @@ def test_08_06
end
set_mus_srate(old_srate)
#
- gen = make_ppolar(1200.0, 0.1)
- v0 = make_vct!(10) do |i| two_pole(gen, i.zero? ? 1.0 : 0.0) end
- unless two_pole?(gen)
- snd_display("%s not ppolar?", gen)
- end
- if gen.order != 2
- snd_display("ppolar order: %s?", gen.order)
- end
- if fneq(gen.a0, 1.0)
- snd_display("ppolar a0: %s?", gen.a0)
- end
- if fneq(gen.b1, -0.188)
- snd_display("ppolar b1: %s?", gen.b1)
- end
- if fneq(gen.b2, 0.01)
- snd_display("ppolar b2: %s?", gen.b2)
- end
- if fneq(v0[0], 1.0) or fneq(v0[1], 0.188)
- snd_display("ppolar output: %s?", v0)
- end
- if fneq(gen.frequency, 1200.0)
- snd_display("ppolar freq: %s?", gen.frequency)
- end
- if fneq(gen.scaler, 0.1)
- snd_display("ppolar scaler: %s?", gen.scaler)
- end
- #
- z1 = make_ppolar(600.0, 0.1)
- z2 = make_ppolar(600.0, 0.1)
- z3 = make_ppolar(1200.0, 0.1)
- two_pole(z1, 1.0)
- two_pole(z2, 1.0)
- two_pole(z3, 1.0)
- test_gen_equal(z1, z2, z3)
- z1 = make_ppolar(:radius, 0.1, :frequency, 600.0)
- z2 = make_ppolar(:radius, 0.1, :frequency, 600.0)
- z3 = make_ppolar(:radius, 0.2, :frequency, 1200.0)
- two_pole(z1, 1.0)
- two_pole(z2, 1.0)
- two_pole(z3, 1.0)
- test_gen_equal(z1, z2, z3)
- z1 = make_ppolar(600.0, 0.1)
- z2 = make_ppolar(600.0, 0.1)
- z3 = make_ppolar(600.0, 0.1)
- two_pole(z1, 1.0)
- two_pole(z2, 1.0)
- two_pole(z3, 0.5)
- test_gen_equal(z1, z2, z3)
- #
gen = make_two_pole(1200.0, 0.1)
unless two_pole?(gen)
- snd_display("%s not 2ppolar?", gen)
+ snd_display("%s not 2-polar?", gen)
end
if gen.order != 2
- snd_display("2ppolar order: %s?", gen.order)
+ snd_display("2-polar order: %s?", gen.order)
end
if fneq(gen.a0, 1.0)
- snd_display("2ppolar a0: %s?", gen.a0)
+ snd_display("2-polar a0: %s?", gen.a0)
end
if fneq(gen.b1, -0.188)
- snd_display("2ppolar b1: %s?", gen.b1)
+ snd_display("2-polar b1: %s?", gen.b1)
end
if fneq(gen.b2, 0.01)
- snd_display("2ppolar b2: %s?", gen.b2)
+ snd_display("2-polar b2: %s?", gen.b2)
end
if fneq(gen.frequency, 1200.0)
- snd_display("2ppolar freq: %s?", gen.frequency)
+ snd_display("2-polar freq: %s?", gen.frequency)
end
if fneq(gen.scaler, 0.1)
- snd_display("2ppolar scaler: %s?", gen.scaler)
+ snd_display("2-polar scaler: %s?", gen.scaler)
end
#
gen = make_two_pole(:frequency, 1200.0, :radius, 0.1)
unless two_pole?(gen)
- snd_display("%s not f2ppolar?", gen)
+ snd_display("%s not f2-polar?", gen)
end
if gen.order != 2
- snd_display("f2ppolar order: %s?", gen.order)
+ snd_display("f2-polar order: %s?", gen.order)
end
if fneq(gen.a0, 1.0)
- snd_display("f2ppolar a0: %s?", gen.a0)
+ snd_display("f2-polar a0: %s?", gen.a0)
end
if fneq(gen.b1, -0.188)
- snd_display("f2ppolar b1: %s?", gen.b1)
+ snd_display("f2-polar b1: %s?", gen.b1)
end
if fneq(gen.b2, 0.01)
- snd_display("f2ppolar b2: %s?", gen.b2)
+ snd_display("f2-polar b2: %s?", gen.b2)
end
if fneq(gen.frequency, 1200.0)
- snd_display("f2ppolar freq: %s?", gen.frequency)
+ snd_display("f2-polar freq: %s?", gen.frequency)
end
if fneq(gen.scaler, 0.1)
- snd_display("f2ppolar scaler: %s?", gen.scaler)
+ snd_display("f2-polar scaler: %s?", gen.scaler)
end
#
- gen = make_zpolar(:radius, 0.1, :frequency, 1200.0)
- v0 = make_vct!(10) do |i| two_zero(gen, i.zero? ? 1.0 : 0.0) end
- unless two_zero?(gen)
- snd_display("%s not zpolar?", gen)
- end
- if gen.order != 2
- snd_display("zpolar order: %s?", gen.order)
- end
- if fneq(gen.a0, 1.0)
- snd_display("zpolar a0: %s?", gen.a0)
- end
- if fneq(gen.a1, -0.188)
- snd_display("zpolar a1: %s?", gen.a1)
- end
- if fneq(gen.a2, 0.01)
- snd_display("zpolar a2: %s?", gen.a2)
- end
- if fneq(v0[0], 1.0) or fneq(v0[1], -0.188)
- snd_display("zpolar output: %s?", v0)
- end
- if fneq(gen.frequency, 1200.0)
- snd_display("zpolar freq: %s?", gen.frequency)
- end
- if fneq(gen.scaler, 0.1)
- snd_display("zpolar scaler: %s?", gen.scaler)
- end
- #
- z1 = make_zpolar(0.1, 600.0)
- z2 = make_zpolar(0.1, 600.0)
- z3 = make_zpolar(0.1, 1200.0)
- two_zero(z1, 1.0)
- two_zero(z2, 1.0)
- two_zero(z3, 1.0)
- test_gen_equal(z1, z2, z3)
- z1 = make_zpolar(:radius, 0.1, :frequency, 600.0)
- z2 = make_zpolar(:radius, 0.1, :frequency, 600.0)
- z3 = make_zpolar(:radius, 0.2, :frequency, 1200.0)
- two_zero(z1, 1.0)
- two_zero(z2, 1.0)
- two_zero(z3, 1.0)
- test_gen_equal(z1, z2, z3)
- z1 = make_zpolar(0.1, 600.0)
- z2 = make_zpolar(0.1, 600.0)
- z3 = make_zpolar(0.1, 600.0)
- two_zero(z1, 1.0)
- two_zero(z2, 1.0)
- two_zero(z3, 0.5)
- test_gen_equal(z1, z2, z3)
- #
gen = make_two_zero(1200.0, 0.1)
unless two_zero?(gen)
- snd_display("%s not 2zpolar?", gen)
+ snd_display("%s not 2-zp?", gen)
end
if gen.order != 2
- snd_display("2zpolar order: %s?", gen.order)
+ snd_display("2-zp order: %s?", gen.order)
end
if fneq(gen.a0, 1.0)
- snd_display("2zpolar a0: %s?", gen.a0)
+ snd_display("2-zp a0: %s?", gen.a0)
end
if fneq(gen.a1, -0.188)
- snd_display("2zpolar a1: %s?", gen.a1)
+ snd_display("2-zp a1: %s?", gen.a1)
end
if fneq(gen.a2, 0.01)
- snd_display("2zpolar a2: %s?", gen.a2)
+ snd_display("2-zp a2: %s?", gen.a2)
end
if fneq(gen.frequency, 1200.0)
- snd_display("2zpolar freq: %s?", gen.frequency)
+ snd_display("2-zp freq: %s?", gen.frequency)
end
if fneq(gen.scaler, 0.1)
- snd_display("2zpolar scaler: %s?", gen.scaler)
+ snd_display("2-zp scaler: %s?", gen.scaler)
end
#
gen = make_two_zero(:frequency, 1200.0, :radius, 0.1)
unless two_zero?(gen)
- snd_display("%s not f2zpolar?", gen)
+ snd_display("%s not f2-zp?", gen)
end
if gen.order != 2
- snd_display("f2zpolar order: %s?", gen.order)
+ snd_display("f2-zp order: %s?", gen.order)
end
if fneq(gen.a0, 1.0)
- snd_display("f2zpolar a0: %s?", gen.a0)
+ snd_display("f2-zp a0: %s?", gen.a0)
end
if fneq(gen.a1, -0.188)
- snd_display("f2zpolar a1: %s?", gen.a1)
+ snd_display("f2-zp a1: %s?", gen.a1)
end
if fneq(gen.a2, 0.01)
- snd_display("f2zpolar a2: %s?", gen.a2)
+ snd_display("f2-zp a2: %s?", gen.a2)
end
if fneq(gen.frequency, 1200.0)
- snd_display("f2zpolar freq: %s?", gen.frequency)
+ snd_display("f2-zp freq: %s?", gen.frequency)
end
if fneq(gen.scaler, 0.1)
- snd_display("f2zpolar scaler: %s?", gen.scaler)
+ snd_display("f2-zp scaler: %s?", gen.scaler)
end
#
gen = make_formant(1200.0, 0.9)
@@ -15700,10 +14949,10 @@ def test_08_06
v0 = make_vct!(10) do |i| formant(gen, i.zero? ? 1.0 : 0.0) end
v1 = make_vct(10)
inp = -1
- vct_map!(v1, lambda do | |
- inp += 1
- formant?(gen1) ? formant(gen1, inp.zero? ? 1.0 : 0.0) : -1.0
- end)
+ v1.map! do |x|
+ inp += 1
+ formant?(gen1) ? formant(gen1, inp.zero? ? 1.0 : 0.0) : -1.0
+ end
unless vequal(v0, v1)
snd_display("map formant: %s %s?", v0, v1)
end
@@ -15741,38 +14990,40 @@ def test_08_06
formant(f3, 1.0)
test_gen_equal(f1, f2, f3)
#
- fs = [make_formant(1000.0, 0.1), make_formant(100.0, 0.2)]
+ amps = vct(0.5, 0.25)
+ ff = [make_formant(1000.0, 0.1), make_formant(100.0, 0.2)]
+ fs = make_formant_bank(ff, amps)
f0 = make_formant(1000.0, 0.1)
f1 = make_formant(100.0, 0.2)
- amps = vct(0.5, 0.25)
v0 = make_vct!(10) do |i|
val = i.zero? ? 1.0 : 0.0
(0.5 * formant(f0, val)) + (0.25 * formant(f1, val))
end
- v1 = make_vct!(10) do |i| formant_bank(amps, fs, i.zero? ? 1.0 : 0.0) end
+ v1 = make_vct!(10) do |i|
+ val = i.zero? ? 1.0 : 0.0
+ formant_bank(fs, val)
+ end
unless vequal(v0, v1)
snd_display("formant_bank 1: %s %s?", v0, v1)
end
#
- fs = [make_formant(1000.0, 0.1), make_formant(100.0, 0.2)]
amps = vct(0.5, 0.25)
- v = make_vct!(5) do |i| formant_bank(amps, fs, i.zero? ? 1.0 : 0.0) end
+ ff = [make_formant(1000.0, 0.1), make_formant(100.0, 0.2)]
+ fs = make_formant_bank(ff, amps)
+ v = make_vct!(5) do |i|
+ val = i.zero? ? 1.0 : 0.0
+ formant_bank(fs, val)
+ end
unless vequal(v, vct(0.368, 0.095, -0.346, -0.091, -0.020))
snd_display("run formant_bank: %s?", v)
end
- fs = make_array(1)
- amps = make_vct(1, 1.0)
- fs[0] = make_oscil(440.0)
- if (res = Snd.catch do formant_bank(amps, fs, 1.0) end).first != :wrong_type_arg
- snd_display("formant_bank gets oscil: %s", res.inspect)
- end
#
ob = open_sound("oboe.snd")
poltergeist = lambda do |frek, amp, r, gain, frek_env, r_env|
# test courtesy of Anders Vinjar
filt = make_formant(frek, r)
- fe = make_env(:envelope, frek_env, :length, frames, :offset, frek)
- re = make_env(:envelope, r_env, :length, frames, :offset, r)
+ fe = make_env(:envelope, frek_env, :length, framples, :offset, frek)
+ re = make_env(:envelope, r_env, :length, framples, :offset, r)
lambda do |y|
outval = gain * formant(filt, amp * y)
mus_set_formant_radius_and_frequency(filt, env(re), env(fe))
@@ -15784,671 +15035,88 @@ def test_08_06
close_sound(ob)
end
-include Mixer_matrix
-
-def test_08_07
- gen = make_mixer(2, 0.5, 0.25, 0.125, 1.0)
- fr0 = make_frame(2, 1.0, 1.0)
- fr1 = make_frame(2, 0.0, 0.0)
- print_and_check(gen,
- "mixer",
- "mixer chans: 2, [
- 0.500 0.250
- 0.125 1.000
-]")
- ap = mus_array_print_length
- mx = make_mixer(8)
- set_mus_array_print_length(4)
- mx.length.times do |i|
- mx.length.times do |j|
- mixer_set!(mx, i, j, j + i * 8)
- end
- end
- print_and_check(mx,
- "mixer",
- "mixer chans: 8, [
- 0.000 1.000 2.000 3.000...
- 8.000 9.000 10.000 11.000...
- 16.000 17.000 18.000 19.000...
- 24.000 25.000 26.000 27.000...
-]")
- set_mus_array_print_length(12)
- print_and_check(mx,
- "mixer",
- "mixer chans: 8, [
- 0.000 1.000 2.000 3.000 4.000 5.000 6.000 7.000
- 8.000 9.000 10.000 11.000 12.000 13.000 14.000 15.000
- 16.000 17.000 18.000 19.000 20.000 21.000 22.000 23.000
- 24.000 25.000 26.000 27.000 28.000 29.000 30.000 31.000
- 32.000 33.000 34.000 35.000 36.000 37.000 38.000 39.000
- 40.000 41.000 42.000 43.000 44.000 45.000 46.000 47.000
- 48.000 49.000 50.000 51.000 52.000 53.000 54.000 55.000
- 56.000 57.000 58.000 59.000 60.000 61.000 62.000 63.000
-]")
- set_mus_array_print_length(ap)
- print_and_check(fr0, "frame", "frame[2]: [1.000 1.000]")
- unless frame?(fr0)
- snd_display("%s not a frame?", fr0)
- end
- unless mixer?(gen)
- snd_display("%s not a mixer?", gen)
- end
- if fr0.eql?(fr1)
- snd_display("frame=? %s %s?", fr0, fr1)
- end
- if fr0.channels != 2
- snd_display("frame channels: %s?", fr0.channels)
- end
- if fr1.length != 2
- snd_display("frame length: %s?", fr1.length)
- end
- if gen.channels != 2
- snd_display("mixer channels: %s?", gen.channels)
- end
- frame2frame(fr0, gen, fr1)
- if fneq(frame_ref(fr0, 0), 1.0) or
- fneq(frame_ref(fr1, 1), 1.25) or
- fneq(mixer_ref(gen, 0, 0), 0.5)
- snd_display("fr0: %s?", fr0)
- end
- frame_set!(fr1, 0, 1.0)
- fr3 = frame_add(fr0, fr1)
- fr4 = frame_multiply(fr0, fr1)
- fr5 = sample2frame(fr1, 0.5)
- if fneq(frame_ref(fr3, 0), 2.0) or
- fneq(frame_ref(fr4, 0), 1.0)
- snd_display("fr+*: %s %s?", fr3, fr4)
- end
- if fneq(res = frame_ref(fr5, 0), 0.5)
- snd_display("sample2frame: %s?", res)
- end
- sample2frame(fr1, 0.5, fr5)
- if fneq(res = frame_ref(fr5, 0), 0.5)
- snd_display("repeat sample2frame: %s?", res)
- end
- fr3 = make_frame(2)
- fr4 = make_frame(4)
- frame_set!(fr3, 0, 1.0)
- frame_set!(fr4, 0, 0.5)
- frame_set!(fr4, 2, 0.5)
- unless vequal(frame2list(res = frame_add(fr3, fr4)), [1.5, 0.0])
- snd_display("frame_add unequal chans: %s?", res)
- end
- fr3.reset
- if fneq(frame_ref(fr3, 0), 0.0)
- snd_display("reset frame: %s?", fr3)
- end
- fr3 = make_frame(2)
- fr4 = make_frame(4)
- frame_set!(fr3, 0, 1.0)
- frame_set!(fr4, 0, 0.5)
- frame_set!(fr4, 2, 1.0)
- unless vequal(frame2list(res = frame_multiply(fr3, fr4)), [0.5, 0.0])
- snd_display("frame_multiply unequal chans: %s?", res)
- end
- mx1 = make_mixer(2, 1.0, 0.0, 0.0, 1.0)
- mx2 = mixer_multiply(gen, mx1)
- fr4 = make_frame(2, 1.0, 1.0)
- fr5 = make_frame(2, 1.0, 1.0)
- if fneq(res = frame2sample(mx1, fr1), 1.0)
- snd_display("frame2sample: %s?", res)
- end
- if fneq(res = frame2sample(fr5, fr4), 2.0)
- snd_display("frame2sample: %s?", res)
- end
- unless (res = frame2list(fr1)).eql?([1.0, 1.25])
- snd_display("frame2list: %s?", res)
- end
- if fneq(mixer_ref(mx2, 0, 1), 0.25) or fneq(mixer_ref(mx2, 1, 0), 0.125)
- snd_display("mixer_multiply: %s?", mx2)
- end
- unless mx2.eql?(gen)
- snd_display("mixer=? %s %s?", gen, mx2)
- end
- if mx2.eql?(mx1)
- snd_display("mixer!=? %s %s?", mx1, mx2)
- end
- unless vct?(fr4.data)
- snd_display("mus_data frame: %s?", fr4.data)
- end
- # mus-data doesn't apply from scheme (ruby) level here
- # unless vct?(mx1.data)
- # snd_display("mus_data mixer: %s?", mx1.data)
- # end
- mixer_set!(mx2, 0, 0, 2.0)
- if fneq(mixer_ref(mx2, 0, 0), 2.0)
- snd_display("mixer_set!: %s?", mx2)
- end
- fr0 = sample2frame(mx2, 1.0)
- if fneq(frame_ref(fr0, 0), 2.0) or fneq(frame_ref(fr0, 1), 0.25)
- snd_display("sample2frame: %s?", fr0)
- end
- frout = make_frame(2)
- sample2frame(mx2, 1.0, frout)
- unless frout.eql?(fr0)
- snd_display("sample2frame via frout: %s %s?", frout, fr0)
- end
- fr1 = make_frame(2, 0.1, 0.2)
- val = frame_add(fr1, 1.0)
- if fneq(frame_ref(val, 0), 1.1) or fneq(frame_ref(val, 1), 1.2)
- snd_display("8 frame_offset: %s?", val)
- end
- val = frame_add(1.0, fr1)
- if fneq(frame_ref(val, 0), 1.1) or fneq(frame_ref(val, 1), 1.2)
- snd_display("8 frame_offset a: %s?", val)
- end
- val = frame_multiply(fr1, 2.0)
- if fneq(frame_ref(val, 0), 0.2) or fneq(frame_ref(val, 1), 0.4)
- snd_display("8 frame_scale: %s?", val)
- end
- val = frame_multiply(2.0, fr1)
- if fneq(frame_ref(val, 0), 0.2) or fneq(frame_ref(val, 1), 0.4)
- snd_display("8 frame_scale a: %s?", val)
- end
- val = frame_copy(fr1)
- if fneq(frame_ref(val, 0), 0.1) or fneq(frame_ref(val, 1), 0.2)
- snd_display("8 frame_copy: %s?", val)
- end
- #
- mx1 = make_mixer(2, 1, 2, 3, 4)
- mx2 = mixer_multiply(mx1, 2.0)
- unless mx2.eql?(make_mixer(2, 2, 4, 6, 8))
- snd_display("8 mixer_scale 2: %s?", mx2)
- end
- mx2 = mixer_multiply(2.0, mx1)
- unless mx2.eql?(make_mixer(2, 2, 4, 6, 8))
- snd_display("8 mixer_scale 2a: %s?", mx2)
- end
- mx2 = mixer_add(2.0, mx1)
- unless mx2.eql?(make_mixer(2, 3, 4, 5, 6))
- snd_display("8 mixer_scale 3: %s?", mx2)
- end
- mx2 = mixer_add(mx1, 2.0)
- unless mx2.eql?(make_mixer(2, 3, 4, 5, 6))
- snd_display("8 mixer_scale 3a: %s?", mx2)
- end
- #
- mx1 = make_scalar_mixer(2, 2.0)
- mx2 = make_mixer(2, 0.1, 0.2, 0.3, 0.4)
- nmx = mixer_add(mx1, mx2)
- if fneq(mixer_ref(mx1, 0, 0), 2.0) or
- fneq(mixer_ref(mx1, 0, 1), 0.0) or
- fneq(mixer_ref(mx1, 1, 0), 0.0) or
- fneq(mixer_ref(mx1, 1, 1), 2.0)
- snd_display("make_scalar_mixer 2: %s?", mx1)
- end
- if fneq(mixer_ref(mx2, 0, 0), 0.1) or
- fneq(mixer_ref(mx2, 0, 1), 0.2) or
- fneq(mixer_ref(mx2, 1, 0), 0.3) or
- fneq(mixer_ref(mx2, 1, 1), 0.4)
- snd_display("make_mixer 0.1, 0.2, 0.3, 0.4: %s?", mx2)
- end
- if fneq(mixer_ref(nmx, 0, 0), 2.1) or
- fneq(mixer_ref(nmx, 0, 1), 0.2) or
- fneq(mixer_ref(nmx, 1, 0), 0.3) or
- fneq(mixer_ref(nmx, 1, 1), 2.4)
- snd_display("mixer_add: %s?", nmx)
- end
- mx1 = mixer_multiply(mx1, 0.5)
- if fneq(mixer_ref(mx1, 0, 0), 1.0) or
- fneq(mixer_ref(mx1, 0, 1), 0.0) or
- fneq(mixer_ref(mx1, 1, 0), 0.0) or
- fneq(mixer_ref(mx1, 1, 1), 1.0)
- snd_display("mixer_multiply (identity): %s?", mx1)
- end
- mx1.reset
- if fneq(mixer_ref(mx1, 0, 0), 0.0)
- snd_display("reset mixer: %s?", mx1)
- end
- #
- if (res = Snd.catch do make_mixer(2, 0.0, 0.0, 0.0, 0.0, 0.0) end).first != :mus_error
- snd_display("make_mixer extra args: %s", res.inspect)
- end
- if (res = Snd.catch do
- fr1 = make_frame(2, 1.0, 0.0)
- frame2sample(make_oscil, fr1)
- end).first != :mus_error
- snd_display("frame2sample bad arg: %s", res.inspect)
- end
- hi = make_mixer(1, 1)
- if (res = Snd.catch do mixer_set!(hi, 1, 1, 1.0) end).first != :mus_error
- snd_display("mixer_set! 1 1 of 0: %s (%s)", res.inspect, hi)
- end
- hi = make_mixer(1)
- if (res = Snd.catch do mixer_set!(hi, 1, 0, 1.0) end).first != :mus_error
- snd_display("mixer_set! 1 0 of 0: %s (%s)", res.inspect, hi)
- end
- hi = make_mixer(1)
- if (res = Snd.catch do mixer_set!(hi, 0, 1, 1.0) end).first != :mus_error
- snd_display("mixer_set! 0 1 of 0: %s (%s)", res.inspect, hi)
- end
- hi = make_frame(1)
- if (res = Snd.catch do frame_set!(hi, 1, 1.0) end).first != :mus_error
- snd_display("frame_set! 1 of 0: %s (%s)", res.inspect, hi)
- end
- if (res = Snd.catch do make_frame(0) end).first != :out_of_range
- snd_display("make_frame 0: %s", res.inspect)
- end
- if (res = Snd.catch do make_mixer(0) end).first != :out_of_range
- snd_display("make_mixer 0: %s", res.inspect)
- end
- #
- fr1 = make_frame(1, 1)
- fr2 = make_frame(2, 1, 2)
- fr4 = make_frame(4, 1, 2, 3, 4)
- fr8 = make_frame(8, 1, 2, 3, 4, 5, 6, 7, 8)
- mx1 = make_mixer(1, 5)
- mx1id = make_mixer(1, 1)
- mx2 = make_mixer(2, 1, 2, 3, 4)
- mx2id = make_mixer(2, 1, 0, 0, 1)
- mx4 = make_mixer(4)
- mx4id = make_mixer(4)
- mx8 = make_mixer(8)
- mx8id = make_mixer(8)
- 4.times do |i|
- mixer_set!(mx4id, i, i, 1)
- mixer_set!(mx4, 0, i, 1)
- end
- 8.times do |i|
- mixer_set!(mx8id, i, i, 1)
- mixer_set!(mx8, i, 0, 1)
- end
- unless (res = frame2frame(fr1, mx1id)).eql?(make_frame(1, 1))
- snd_display("frame2frame 1 id: %s?", res)
- end
- unless (res = frame2frame(fr1, mx1)).eql?(make_frame(1, 5))
- snd_display("frame2frame 1: %s?", res)
- end
- unless (res = frame2frame(fr1, mx2id)).eql?(make_frame(2, 1, 0))
- snd_display("frame2frame 2 1 id: %s?", res)
- end
- unless (res = frame2frame(fr1, mx2)).eql?(make_frame(2, 1, 2))
- snd_display("frame2frame 2 1: %s?", res)
- end
- unless (res = frame2frame(fr1, mx4)).eql?(make_frame(4, 1, 1, 1, 1))
- snd_display("frame2frame 4 1: %s?", res)
- end
- unless (res = frame2frame(fr1, mx8)).eql?(make_frame(8, 1, 0, 0, 0, 0, 0, 0, 0))
- snd_display("frame2frame 8 1: %s?", res)
- end
- unless (res = frame2frame(fr2, mx1)).eql?(make_frame(1, 5))
- snd_display("frame2frame 1 2: %s?", res)
- end
- unless (res = frame2frame(fr2, mx2id)).eql?(make_frame(2, 1, 2))
- snd_display("frame2frame 2 id 2: %s?", res)
- end
- unless (res = frame2frame(fr2, mx2)).eql?(make_frame(2, 7, 10))
- snd_display("frame2frame 2 2: %s?", res)
- end
- unless (res = frame2frame(fr2, mx4id)).eql?(make_frame(4, 1, 2, 0, 0))
- snd_display("frame2frame 4 id 2: %s?", res)
- end
- unless (res = frame2frame(fr2, mx8id)).eql?(make_frame(8, 1, 2, 0, 0, 0, 0, 0, 0))
- snd_display("frame2frame 8 id 2: %s?", res)
- end
- unless (res = frame2frame(fr2, mx4)).eql?(make_frame(4, 1, 1, 1, 1))
- snd_display("frame2frame 4 2: %s?", res)
- end
- unless (res = frame2frame(fr2, mx8)).eql?(make_frame(8, 3, 0, 0, 0, 0, 0, 0, 0))
- snd_display("frame2frame 8 2: %s?", res)
- end
- unless (res = frame2frame(fr4, mx1)).eql?(make_frame(1, 5))
- snd_display("frame2frame 1 4: %s?", res)
- end
- unless (res = frame2frame(fr8, mx1)).eql?(make_frame(1, 5))
- snd_display("frame2frame 1 8: %s?", res)
- end
- unless (res = frame2frame(fr4, mx4)).eql?(make_frame(4, 1, 1, 1, 1))
- snd_display("frame2frame 4 4: %s?", res)
- end
- unless (res = frame2frame(fr4, mx8)).eql?(make_frame(8, 10, 0, 0, 0, 0, 0, 0, 0))
- snd_display("frame2frame 8 4: %s?", res)
- end
- #
- fr1 = make_frame(2)
- fr2 = make_frame(2)
- mx1 = make_mixer(2)
- mx2 = make_mixer(2)
- frame_set!(fr1, 0, 0.1)
- fradd = frame_add(fr1, fr1, fr2)
- unless fr2.eql?(fradd)
- snd_display("frame_add with res frame: %s %s?", fr2, fradd)
- end
- unless fr2.eql?(make_frame(2, 0.2, 0.0))
- snd_display("frame_add res: %s?", fr2)
- end
- fradd = frame_multiply(fr1, fr1, fr2)
- unless fr2.eql?(fradd)
- snd_display("frame_multiply with res frame: %s %s?", fr2, fradd)
- end
- if fneq(frame_ref(fr2, 0), 0.01) or fneq(frame_ref(fr2, 1), 0.0)
- snd_display("frame_multiply res: %s?", fr2)
- end
- mixer_set!(mx1, 0, 0, 0.1)
- mxadd = mixer_multiply(mx1, mx1, mx2)
- unless mx2.eql?(mxadd)
- snd_display("mixer_multiply with res mixer: %s %s?", mx2, mxadd)
- end
- if fneq(mixer_ref(mx2, 0, 0), 0.01)
- snd_display("mixer_multiply res: %s?", mx2)
- end
- #
- [1, 2, 4, 8].each do |chans|
- m1 = make_mixer(chans)
- if m1.channels != chans or m1.length != chans
- snd_display("mixer %s chans but: %s %s?", chans, m1.channels, m1.length)
- end
- chans.times do |i|
- chans.times do |j|
- mixer_set!(m1, i, j, i * 0.01 + j * 0.1)
- end
- end
- chans.times do |i|
- chans.times do |j|
- if fneq(res0 = mixer_ref(m1, i, j), res1 = i * 0.01 + j * 0.1)
- snd_display("mixer[%s %s] = %s (%s)?", i, j, res0, res1)
- end
- end
- end
- mempty = make_mixer(chans)
- midentity = make_mixer(chans)
- mpick = make_mixer(chans)
- chans.times do |i| mixer_set!(midentity, i, i, 1.0) end
- mixer_set!(mpick, chans - 1, chans - 1, 1.0)
- mzero = mixer_multiply(m1, mempty)
- msame = mixer_multiply(m1, midentity)
- mone = mixer_multiply(m1, mpick)
- chans.times do |i|
- chans.times do |j|
- if fneq(res = mixer_ref(mzero, i, j), 0.0)
- snd_display("mzero %s %s = %s?", i, j, res)
- end
- if fneq(res0 = mixer_ref(m1, i, j), res1 = mixer_ref(msame, i, j))
- snd_display("msame %s %s?", res0, res1)
- end
- if fneq(res = mixer_ref(mone, i, j), 0.0) and
- i != chans - 1 and
- j != chans - 1
- snd_display("mone %s %s = %s?", i, j, res)
- end
- end
- end
- end
- #
- mx = make_mixer(4, 4)
- if (res = Snd.catch do mx.length = 2 end).first != :mus_error
- snd_display("set_mixer_length: %s %s", res.inspect, mx.length)
- end
- #
- if fneq(res = mixer_determinant(make_mixer(2, 1, 2, 3, 4)), -2.0)
- snd_display("mixer_determinant -2: %s?", res)
- end
- if fneq(res = mixer_determinant(make_mixer(3, 1, 2, 3, 4, 5, 6, 7, 8, 9)), 0.0)
- snd_display("mixer_determinant 0: %s?", res)
- end
- if fneq(res = mixer_determinant(make_mixer(4, 1, 2, 3, 4, 8, 7, 6, 5, 1, 8, 2, 7, 3, 6, 4, 5)),
- -144.0)
- snd_display("mixer_determinant -144: %s?", res)
- end
- if fneq(res = mixer_determinant(make_mixer(5, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
- 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
- 73, 79, 83, 89, 97)), -4656.0)
- snd_display("mixer_determinant -4656: %s?", res)
- end
- if fneq(res = mixer_determinant(make_mixer(6, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,
- 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89,
- 97, 101, 103, 107, 109, 113,
- 127, 131, 137, 139, 149, 151)), -14304.0)
- snd_display("mixer_determinant -14304: %s?", res)
- end
- unless mixer_equal?(res = mixer_transpose(make_mixer(2, 1, 2, 3, 4)),
- make_mixer(2, 1.0, 3.0, 2.0, 4.0))
- snd_display("mixer_transpose 1: %s?", res)
- end
- unless mixer_equal?(res = mixer_transpose(make_mixer(3, 1, 2, 3, 4, 5, 6, 7, 8, 9)),
- make_mixer(3, 1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0))
- snd_display("mixer_transpose 2: %s?", res)
- end
- unless mixer_equal?(res = mixer_multiply(make_mixer(2, 1, 0, 0, 1), make_mixer(2, 2, 0, 0, 2)),
- make_mixer(2, 2.0, 0.0, 0.0, 2.0))
- snd_display("mixer_multiply 1: %s?", res)
- end
- unless mixer_equal?(res = mixer_multiply(make_mixer(3, 2, 3, 5, 7, 11, 13, 19, 23, 29),
- make_mixer(3, 41, 43, 47, 53, 59, 61, 67, 71, 73)),
- make_mixer(3, 576, 618, 642, 1741, 1873, 1949, 3941, 4233, 4413))
- snd_display("mixer_multiply 2: %s?", res)
- end
- unless mixer_equal?(res = mixer_inverse(make_mixer(2, 1, 0, 0, 1)), make_mixer(2, 1, 0, 0, 1))
- snd_display("mixer_inverse 1: %s?", res)
- end
- unless mixer_equal?(res = mixer_inverse(make_mixer(2, 2, 3, 5, 8)), make_mixer(2, 8, -3, -5, 2))
- snd_display("mixer_inverse 2: %s?", res)
- end
- unless mixer_equal?(res = mixer_inverse(make_mixer(3, 2, 3, 5, 7, 11, 13, 17, 19, 23)),
- make_mixer(3, -0.077, -0.333, 0.205, -0.769, 0.5, -0.115,
- 0.692, -0.167, -0.013))
- snd_display("mixer_inverse 3: %s?", res)
- end
- unless mixer_equal?(res = mixer_inverse(make_mixer(4, 2, 3, 5, 7, 17, 19, 23, 29,
- 41, 43, 47, 53, 67, 71, 73, 97)),
- make_mixer(4, -7, 4.708, -1.042, -0.333, 9, -6.396, 1.396, 0.5,
- -1, 0.875, -0.042, -0.167, -1, 0.771, -0.271, 0))
- snd_display("mixer_inverse 4: %s?", res)
- end
- unless mixer_equal?(res = mixer_inverse(make_mixer(6, 2, 3, 5, 7, 11, 13,
- 17, -19, 23, 29, 31, 37,
- 41, 43, 47, 53, 59, 61,
- 67, 71, 73, 79, 83, 89,
- 97, 101, 103, 107, 109, 113,
- 127, 131, 137, 139, 149, 151)),
- make_mixer(6, -1.355, 0.02, -0, 1.09, -1.153, 0.333, 0.092,
- -0.025, 0, -0.042, 0.07, -0.029, 1.612,
- 0.006, -0.25, -1.205, 1.249, -0.264,
- 0.079, 0.002, 0.25, -0.314, 0.425, -0.241,
- -0.551, -0.011, 0.25, 0.2, -0.476, 0.188,
- 0.068, 0.009, -0.25, 0.306, -0.145, 0.028))
- snd_display("mixer_inverse 5: %s?", res)
- end
- unless mixer_equal?(res = mixer_multiply(make_mixer(2, 2, 3, 5, 8),
- mixer_inverse(make_mixer(2, 2, 3, 5, 8))),
- make_scalar_mixer(2, 1.0))
- snd_display("mixer_inverse 6: %s?", res)
- end
- unless mixer_equal?(res = mixer_multiply(make_mixer(3, 2, 3, 5, 7, 11, 13, 17, 19, 23),
- mixer_inverse(make_mixer(3, 2, 3, 5,
- 7, 11, 13,
- 17, 19, 23))),
- make_scalar_mixer(3, 1.0))
- snd_display("mixer_inverse 7: %s?", res)
- end
- unless mixer_diagonal?(make_scalar_mixer(2, 2.0))
- snd_display("mixer_diagonal 1")
- end
- unless mixer_diagonal?(make_mixer(3, 1, 0, 0, 0, 1, 0, 0, 0, 1))
- snd_display("mixer_diagonal 2")
- end
- if mixer_diagonal?(make_mixer(3, 1, 0, 0, 0, 1, 1, 0, 0, 1))
- snd_display("mixer_diagonal 3")
- end
- unless mixer_diagonal?(make_mixer(3, 0, 0, 0, 0, 1, 0, 0, 0, 1))
- snd_display("mixer_diagonal 4")
- end
- unless mixer_symmetric?(make_mixer(3, 0, 0, 0, 0, 1, 0, 0, 0, 1))
- snd_display("mixer_symmetric 1")
- end
- unless mixer_symmetric?(make_mixer(3, 1, 2, 0, 2, 1, 0, 0, 0, 1))
- snd_display("mixer_symmetric 2")
- end
- if mixer_symmetric?(make_mixer(3, 1, 2, 0, 2, 1, 0, 0, 2, 1))
- snd_display("mixer_symmetric 3")
- end
- unless mixer_equal?(make_scalar_mixer(2, 2.0), make_mixer(2, 2.0, 0, 0, 2.0))
- snd_display("mixer_equal? 1")
- end
- if mixer_equal?(make_mixer(2, 1, 2, 3, 4), make_mixer(3, 1, 2, 3, 4, 5, 6, 7, 8, 9))
- snd_display("mixer_equal? 2")
- end
- if mixer_equal?(make_mixer(2, 1, 2, 3, 4), make_mixer(2, 1, 2, 3, 5))
- snd_display("mixer_equal? 3")
- end
- unless mixer_equal?(res = mixer_poly(make_mixer(2, 1, 0, 0, 1), 1, 1), make_mixer(2, 2, 0, 0, 2))
- snd_display("mixer_poly 1: %s?", res)
- end
- unless mixer_equal?(res = mixer_poly(make_mixer(1, 1), 1), make_mixer(1, 1))
- snd_display("mixer_poly 2: %s?", res)
- end
- unless mixer_equal?(res = mixer_poly(make_mixer(2, 1, 0, 0, 1), 1, 0, 0),
- make_mixer(2, 1, 0, 0, 1))
- snd_display("mixer_poly 3: %s?", res)
- end
- unless mixer_equal?(res = mixer_poly(make_mixer(2, 1, 2, 4, 3), 1, 0, 0),
- make_mixer(2, 9, 8, 16, 17))
- snd_display("mixer_poly 4: %s?", res)
- end
- unless mixer_equal?(res = mixer_poly(make_mixer(2, 1, 2, 4, 3), 1, 1, 0),
- make_mixer(2, 10, 10, 20, 20))
- snd_display("mixer_poly 5: %s?", res)
- end
- unless mixer_equal?(res = mixer_poly(make_mixer(2, 1, 2, 4, 3), 1, 1, 2),
- make_mixer(2, 12, 10, 20, 22))
- snd_display("mixer_poly 6: %s?", res)
- end
- unless mixer_equal?(res = mixer_poly(make_mixer(2, 1, 2, 4, 3), 1, 0, 0, 0),
- make_mixer(2, 41, 42, 84, 83))
- snd_display("mixer_poly 7: %s?", res)
- end
- unless mixer_equal?(res = mixer_poly(make_mixer(2, 1, 2, 4, 3), 1, 0, 1, 0),
- make_mixer(2, 42, 44, 88, 86))
- snd_display("mixer_poly 8: %s?", res)
- end
-end
-
def test_08_08
- #
- # try random input to mixer_inverse
- #
- (2...20).each do |k|
- mx = make_random_mixer(k)
- imx = mixer_inverse(mixer_copy(mx))
- mmx = mixer_multiply(mx, imx)
- unless mixer_equal?(mmx, make_scalar_mixer(k, 1.0))
- snd_display("mixer_inverse %s: %s * %s -> %s?", k, mx, imx, mmx)
- end
- end
- unless frame_equal?(res = frame_reverse(make_frame(2, 0.5, 2.0)),
- make_frame(2, 2.0, 0.5))
- snd_display("frame_reverse 2: %s?", res)
- end
- unless frame_equal?(res = frame_reverse(make_frame(3, 0.5, 1.0, 2.0)),
- make_frame(3, 2.0, 1.0, 0.5))
- snd_display("frame_reverse 3: %s?", res)
- end
- #
- hi = make_mixer(3, 10, 5, 1, 1, 20, 5, 1, 3, 7)
- ho = make_mixer(3, 10, 5, 2, 1, 3, 2, 1, 3, 2)
- unless mixer_equal?(res = mixer_multiply(hi, ho),
- make_mixer(3, 106, 68, 32, 35, 80, 52, 20, 35, 22))
- snd_display("mixer_multiply 3x3 1: %s?", res)
- end
- unless mixer_equal?(res = mixer_multiply(hi, mixer_transpose(ho)),
- make_mixer(3, 127, 27, 27, 120, 71, 71, 39, 24, 24))
- snd_display("mixer_multiply 3x3 2: %s?", res)
- end
- unless mixer_equal?(res = mixer_multiply(mixer_transpose(hi), mixer_transpose(ho)),
- make_mixer(3, 107, 15, 15, 156, 71, 71, 49, 30, 30))
- snd_display("mixer_multiply 3x3 3: %s?", res)
- end
- unless frame_equal?(res = mixer_solve(make_mixer(2, 0.001, 1, 1, 2), make_frame(2, 1, 3)),
- make_frame(2, 1.002, 0.999))
- snd_display("mixer_solve G1: %s?", res)
- end
- unless frame_equal?(res = mixer_solve(make_mixer(2, 0.0001, 1, 1, 1), make_frame(2, 1, 3)),
- make_frame(2, 2, 1))
- snd_display("mixer_solve G2: %s?", res)
- end
- unless frame_equal?(res = mixer_solve(make_mixer(2, 0.986, 0.579, 0.409, 0.237),
- make_frame(2, 0.235, 0.107)),
- make_frame(2, 2, -3))
- snd_display("mixer_solve G3: %s?", res)
- end
- # G4, G5 (invert_matrix) skipped
- unless frame_equal?(res = mixer_solve(make_mixer(3, 1, 4, 7, 2, 5, 8, 3, 6, 10),
- make_frame(3, 1, 1, 1)),
- make_frame(3, -0.333, 0.333, 0))
- snd_display("mixer_solve G6: %s?", res)
- end
- unless frame_equal?(res = mixer_solve(make_mixer(2, 1, 0, 0, 1.0e-6), make_frame(2, 1, 1.0e-6)),
- make_frame(2, 1, 1))
- snd_display("mixer_solve G7: %s?", res)
- end
- # G8, G9 (invert_matrix) skipped
- unless frame_equal?(res = mixer_solve(make_mixer(2, 10, 100000, 1, 1), make_frame(2, 100000, 2)),
- make_frame(2, 1, 1))
- snd_display("mixer_solve G10: %s?", res)
- end
- #
- [[:Hamming_window, 0.0, vct(0.080, 0.115, 0.215, 0.364, 0.540, 0.716, 0.865, 1.000,
- 1.000, 0.865, 0.716, 0.540, 0.364, 0.215, 0.115, 0.080)],
- [:Rectangular_window, 0.0, vct(1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000,
- 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000)],
- [:Hann_window, 0.0, vct(0.000, 0.038, 0.146, 0.309, 0.500, 0.691, 0.854, 1.000,
- 1.000, 0.854, 0.691, 0.500, 0.309, 0.146, 0.038, 0.000)],
- [:Welch_window, 0.0, vct(0.000, 0.234, 0.438, 0.609, 0.750, 0.859, 0.938, 1.000,
- 1.000, 0.938, 0.859, 0.750, 0.609, 0.438, 0.234, 0.000)],
- [:Connes_window, 0.0, vct(0.000, 0.055, 0.191, 0.371, 0.562, 0.739, 0.879, 1.000,
- 1.000, 0.879, 0.739, 0.562, 0.371, 0.191, 0.055, 0.000)],
- [:Parzen_window, 0.0, vct(0.000, 0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 1.000,
- 1.000, 0.750, 0.625, 0.500, 0.375, 0.250, 0.125, 0.000)],
- [:Bartlett_window, 0.0, vct(0.000, 0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 1.000,
- 1.000, 0.750, 0.625, 0.500, 0.375, 0.250, 0.125, 0.000)],
- [:Blackman2_window, 0.0, vct(0.005, 0.020, 0.071, 0.177, 0.344, 0.558, 0.775, 1.000,
- 1.000, 0.775, 0.558, 0.344, 0.177, 0.071, 0.020, 0.005)],
- [:Blackman3_window, 0.0, vct(0.000, 0.003, 0.022, 0.083, 0.217, 0.435, 0.696, 1.000,
- 1.000, 0.696, 0.435, 0.217, 0.083, 0.022, 0.003, 0.000)],
- [:Blackman4_window, 0.0, vct(0.002, 0.002, 0.003, 0.017, 0.084, 0.263, 0.562, 1.000,
- 1.000, 0.562, 0.263, 0.084, 0.017, 0.003, 0.002, 0.002)],
- [:Blackman5_window, 0.0, vct(0.000, 0.000, 0.003, 0.022, 0.097, 0.280, 0.574, 1.000,
- 1.000, 0.574, 0.280, 0.097, 0.022, 0.003, 0.000, 0.000)],
- [:Blackman6_window, 0.0, vct(0.000, 0.000, 0.001, 0.011, 0.064, 0.223, 0.520, 1.000,
- 1.000, 0.520, 0.223, 0.064, 0.011, 0.001, 0.000, 0.000)],
- [:Blackman7_window, 0.0, vct(0.000, 0.000, 0.000, 0.006, 0.042, 0.177, 0.471, 1.000,
- 1.000, 0.471, 0.177, 0.042, 0.006, 0.000, 0.000, 0.000)],
- [:Blackman8_window, 0.0, vct(0.000, 0.000, 0.000, 0.003, 0.028, 0.141, 0.426, 1.000,
- 1.000, 0.426, 0.141, 0.028, 0.003, 0.000, 0.000, 0.000)],
- [:Blackman9_window, 0.0, vct(0.000, 0.000, 0.000, 0.001, 0.018, 0.112, 0.385, 1.000,
- 1.000, 0.385, 0.112, 0.018, 0.001, 0.000, 0.000, 0.000)],
- [:Blackman10_window, 0.0, vct(0.000, 0.000, 0.000, 0.001, 0.012, 0.089, 0.349, 1.000,
- 1.000, 0.349, 0.089, 0.012, 0.001, 0.000, 0.000, 0.000)],
- [:Rv2_window, 0.0, vct(0.000, 0.001, 0.021, 0.095, 0.250, 0.478, 0.729, 1.000,
- 1.000, 0.729, 0.478, 0.250, 0.095, 0.021, 0.001, 0.000)],
- [:Rv3_window, 0.0, vct(0.000, 0.000, 0.003, 0.029, 0.125, 0.330, 0.622, 1.000,
- 1.000, 0.622, 0.330, 0.125, 0.029, 0.003, 0.000, 0.000)],
- [:Rv4_window, 0.0, vct(0.000, 0.000, 0.000, 0.009, 0.062, 0.228, 0.531, 1.000,
- 1.000, 0.531, 0.228, 0.062, 0.009, 0.000, 0.000, 0.000)],
- [:Exponential_window, 0.0, vct(0.000, 0.087, 0.181, 0.283, 0.394, 0.515, 0.646, 0.944,
- 0.944, 0.646, 0.515, 0.394, 0.283, 0.181, 0.087, 0.000)],
- [:Riemann_window, 0.0, vct(0.000, 0.139, 0.300, 0.471, 0.637, 0.784, 0.900, 1.000,
- 1.000, 0.900, 0.784, 0.637, 0.471, 0.300, 0.139, 0.000)],
- [:Kaiser_window, 2.5, vct(0.304, 0.426, 0.550, 0.670, 0.779, 0.871, 0.941, 1.000,
- 1.000, 0.941, 0.871, 0.779, 0.670, 0.550, 0.426, 0.304)],
- [:Cauchy_window, 2.5, vct(0.138, 0.173, 0.221, 0.291, 0.390, 0.532, 0.719, 1.000,
- 1.000, 0.719, 0.532, 0.390, 0.291, 0.221, 0.173, 0.138)],
- [:Poisson_window, 2.5, vct(0.082, 0.112, 0.153, 0.210, 0.287, 0.392, 0.535, 1.000,
- 1.000, 0.535, 0.392, 0.287, 0.210, 0.153, 0.112, 0.082)],
- [:Gaussian_window, 1.0, vct(0.607, 0.682, 0.755, 0.823, 0.882, 0.932, 0.969, 1.000,
- 1.000, 0.969, 0.932, 0.882, 0.823, 0.755, 0.682, 0.607)],
- [:Tukey_window, 0.0, vct(0.000, 0.038, 0.146, 0.309, 0.500, 0.691, 0.854, 1.000,
- 1.000, 0.854, 0.691, 0.500, 0.309, 0.146, 0.038, 0.000)],
- [:Hann_poisson_window, 0.0, vct(0.000, 0.038, 0.146, 0.309, 0.500, 0.691, 0.854, 1.000,
- 1.000, 0.854, 0.691, 0.500, 0.309, 0.146, 0.038, 0.000)],
- [:Samaraki_window, 0.0, vct(1.000, 0.531, 0.559, 0.583, 0.604, 0.620, 0.631, 0.638,
- 0.640, 0.638, 0.631, 0.620, 0.604, 0.583, 0.559, 0.531)],
- [:Ultraspherical_window, 0.0, vct(1.000, 0.033, 0.034, 0.035, 0.036, 0.036, 0.037, 0.037,
- 0.037, 0.037, 0.037, 0.036, 0.036, 0.035, 0.034, 0.033)],
- [:Dolph_chebyshev_window, 0.0, vct(1.000, 0.033, 0.034, 0.035, 0.036, 0.036, 0.037, 0.037,
- 0.037, 0.037, 0.037, 0.036, 0.036, 0.035, 0.034, 0.033)],
- [:Dolph_chebyshev_window, 1.0, vct(1.000, 0.274, 0.334, 0.393, 0.446, 0.491, 0.525, 0.546,
- 0.553, 0.546, 0.525, 0.491, 0.446, 0.393, 0.334, 0.274)]
+ [[:Hamming_window, 0.0,
+ vct(0.080, 0.115, 0.215, 0.364, 0.540, 0.716, 0.865, 1.000,
+ 1.000, 0.865, 0.716, 0.540, 0.364, 0.215, 0.115, 0.080)],
+ [:Rectangular_window, 0.0,
+ vct(1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000,
+ 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000)],
+ [:Hann_window, 0.0,
+ vct(0.000, 0.038, 0.146, 0.309, 0.500, 0.691, 0.854, 1.000,
+ 1.000, 0.854, 0.691, 0.500, 0.309, 0.146, 0.038, 0.000)],
+ [:Welch_window, 0.0,
+ vct(0.000, 0.234, 0.438, 0.609, 0.750, 0.859, 0.938, 1.000,
+ 1.000, 0.938, 0.859, 0.750, 0.609, 0.438, 0.234, 0.000)],
+ [:Connes_window, 0.0,
+ vct(0.000, 0.055, 0.191, 0.371, 0.562, 0.739, 0.879, 1.000,
+ 1.000, 0.879, 0.739, 0.562, 0.371, 0.191, 0.055, 0.000)],
+ [:Parzen_window, 0.0,
+ vct(0.000, 0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 1.000,
+ 1.000, 0.750, 0.625, 0.500, 0.375, 0.250, 0.125, 0.000)],
+ [:Bartlett_window, 0.0,
+ vct(0.000, 0.125, 0.250, 0.375, 0.500, 0.625, 0.750, 1.000,
+ 1.000, 0.750, 0.625, 0.500, 0.375, 0.250, 0.125, 0.000)],
+ [:Blackman2_window, 0.0,
+ vct(0.005, 0.020, 0.071, 0.177, 0.344, 0.558, 0.775, 1.000,
+ 1.000, 0.775, 0.558, 0.344, 0.177, 0.071, 0.020, 0.005)],
+ [:Blackman3_window, 0.0,
+ vct(0.000, 0.003, 0.022, 0.083, 0.217, 0.435, 0.696, 1.000,
+ 1.000, 0.696, 0.435, 0.217, 0.083, 0.022, 0.003, 0.000)],
+ [:Blackman4_window, 0.0,
+ vct(0.002, 0.002, 0.003, 0.017, 0.084, 0.263, 0.562, 1.000,
+ 1.000, 0.562, 0.263, 0.084, 0.017, 0.003, 0.002, 0.002)],
+ [:Blackman5_window, 0.0,
+ vct(0.000, 0.000, 0.003, 0.022, 0.097, 0.280, 0.574, 1.000,
+ 1.000, 0.574, 0.280, 0.097, 0.022, 0.003, 0.000, 0.000)],
+ [:Blackman6_window, 0.0,
+ vct(0.000, 0.000, 0.001, 0.011, 0.064, 0.223, 0.520, 1.000,
+ 1.000, 0.520, 0.223, 0.064, 0.011, 0.001, 0.000, 0.000)],
+ [:Blackman7_window, 0.0,
+ vct(0.000, 0.000, 0.000, 0.006, 0.042, 0.177, 0.471, 1.000,
+ 1.000, 0.471, 0.177, 0.042, 0.006, 0.000, 0.000, 0.000)],
+ [:Blackman8_window, 0.0,
+ vct(0.000, 0.000, 0.000, 0.003, 0.028, 0.141, 0.426, 1.000,
+ 1.000, 0.426, 0.141, 0.028, 0.003, 0.000, 0.000, 0.000)],
+ [:Blackman9_window, 0.0,
+ vct(0.000, 0.000, 0.000, 0.001, 0.018, 0.112, 0.385, 1.000,
+ 1.000, 0.385, 0.112, 0.018, 0.001, 0.000, 0.000, 0.000)],
+ [:Blackman10_window, 0.0,
+ vct(0.000, 0.000, 0.000, 0.001, 0.012, 0.089, 0.349, 1.000,
+ 1.000, 0.349, 0.089, 0.012, 0.001, 0.000, 0.000, 0.000)],
+ [:Rv2_window, 0.0,
+ vct(0.000, 0.001, 0.021, 0.095, 0.250, 0.478, 0.729, 1.000,
+ 1.000, 0.729, 0.478, 0.250, 0.095, 0.021, 0.001, 0.000)],
+ [:Rv3_window, 0.0,
+ vct(0.000, 0.000, 0.003, 0.029, 0.125, 0.330, 0.622, 1.000,
+ 1.000, 0.622, 0.330, 0.125, 0.029, 0.003, 0.000, 0.000)],
+ [:Rv4_window, 0.0,
+ vct(0.000, 0.000, 0.000, 0.009, 0.062, 0.228, 0.531, 1.000,
+ 1.000, 0.531, 0.228, 0.062, 0.009, 0.000, 0.000, 0.000)],
+ [:Exponential_window, 0.0,
+ vct(0.000, 0.087, 0.181, 0.283, 0.394, 0.515, 0.646, 0.944,
+ 0.944, 0.646, 0.515, 0.394, 0.283, 0.181, 0.087, 0.000)],
+ [:Riemann_window, 0.0,
+ vct(0.000, 0.139, 0.300, 0.471, 0.637, 0.784, 0.900, 1.000,
+ 1.000, 0.900, 0.784, 0.637, 0.471, 0.300, 0.139, 0.000)],
+ [:Kaiser_window, 2.5,
+ vct(0.304, 0.426, 0.550, 0.670, 0.779, 0.871, 0.941, 1.000,
+ 1.000, 0.941, 0.871, 0.779, 0.670, 0.550, 0.426, 0.304)],
+ [:Cauchy_window, 2.5,
+ vct(0.138, 0.173, 0.221, 0.291, 0.390, 0.532, 0.719, 1.000,
+ 1.000, 0.719, 0.532, 0.390, 0.291, 0.221, 0.173, 0.138)],
+ [:Poisson_window, 2.5,
+ vct(0.082, 0.112, 0.153, 0.210, 0.287, 0.392, 0.535, 1.000,
+ 1.000, 0.535, 0.392, 0.287, 0.210, 0.153, 0.112, 0.082)],
+ [:Gaussian_window, 1.0,
+ vct(0.607, 0.682, 0.755, 0.823, 0.882, 0.932, 0.969, 1.000,
+ 1.000, 0.969, 0.932, 0.882, 0.823, 0.755, 0.682, 0.607)],
+ [:Tukey_window, 0.0,
+ vct(0.000, 0.038, 0.146, 0.309, 0.500, 0.691, 0.854, 1.000,
+ 1.000, 0.854, 0.691, 0.500, 0.309, 0.146, 0.038, 0.000)],
+ [:Hann_poisson_window, 0.0,
+ vct(0.000, 0.038, 0.146, 0.309, 0.500, 0.691, 0.854, 1.000,
+ 1.000, 0.854, 0.691, 0.500, 0.309, 0.146, 0.038, 0.000)],
].each do |win, beta, vals|
Snd.catch do
res = make_fft_window(Module.const_get(win), 16, beta)
@@ -16457,35 +15125,57 @@ def test_08_08
end
end
end
- [[:Ultraspherical_window, 0.0, 0.0, :Dolph_chebyshev_window, 0.0, 0.0],
- [:Ultraspherical_window, 0.0, 1.0, :Samaraki_window, 0.0, 0.0],
- [:Ultraspherical_window, 0.5, 0.0, :Dolph_chebyshev_window, 0.5, 0.0],
- [:Ultraspherical_window, 0.5, 1.0, :Samaraki_window, 0.5, 0.0]
- ].each do |win1, beta1, alpha1, win2, beta2, alpha2|
- Snd.catch do
- val1 = make_fft_window(Module.const_get(win1), 16, beta1, alpha1)
- val2 = make_fft_window(Module.const_get(win2), 16, beta2, alpha2)
- unless vequal(val1, vals2)
- snd_display("%s/%s %s: %s %s?", win1, win2, beta1, val1, val2)
+ if $with_test_gsl
+ [[:Samaraki_window, 0.0,
+ vct(1.000, 0.531, 0.559, 0.583, 0.604, 0.620, 0.631, 0.638,
+ 0.640, 0.638, 0.631, 0.620, 0.604, 0.583, 0.559, 0.531)],
+ [:Ultraspherical_window, 0.0,
+ vct(1.000, 0.033, 0.034, 0.035, 0.036, 0.036, 0.037, 0.037,
+ 0.037, 0.037, 0.037, 0.036, 0.036, 0.035, 0.034, 0.033)],
+ [:Dolph_chebyshev_window, 0.0,
+ vct(1.000, 0.033, 0.034, 0.035, 0.036, 0.036, 0.037, 0.037,
+ 0.037, 0.037, 0.037, 0.036, 0.036, 0.035, 0.034, 0.033)],
+ [:Dolph_chebyshev_window, 1.0,
+ vct(1.000, 0.274, 0.334, 0.393, 0.446, 0.491, 0.525, 0.546,
+ 0.553, 0.546, 0.525, 0.491, 0.446, 0.393, 0.334, 0.274)]
+ ].each do |win, beta, vals|
+ Snd.catch do
+ res = make_fft_window(Module.const_get(win), 16, beta)
+ unless vequal(res, vals)
+ snd_display("%s: %s?", win, res)
+ end
end
end
- end
- val1 = dolph(16, 1.0)
- val2 = make_fft_window(Dolph_chebyshev_window, 16, 1.0)
- unless vequal(val1, val2)
- snd_display("dolph/dolph 1: %s %s?", val1, val2)
- end
- val1 = dolph_1(16, 1.0).to_vct
- val2 = make_fft_window(Dolph_chebyshev_window, 16, 1.0)
- unless vequal(val1, val2)
- snd_display("dolph_1/dolph 1: %s %s?", val1, val2)
- end
+ [[:Ultraspherical_window, 0.0, 0.0, :Dolph_chebyshev_window, 0.0, 0.0],
+ [:Ultraspherical_window, 0.0, 1.0, :Samaraki_window, 0.0, 0.0],
+ [:Ultraspherical_window, 0.5, 0.0, :Dolph_chebyshev_window, 0.5, 0.0],
+ [:Ultraspherical_window, 0.5, 1.0, :Samaraki_window, 0.5, 0.0]
+ ].each do |win1, beta1, alpha1, win2, beta2, alpha2|
+ Snd.catch do
+ val1 = make_fft_window(Module.const_get(win1), 16, beta1, alpha1)
+ val2 = make_fft_window(Module.const_get(win2), 16, beta2, alpha2)
+ unless vequal(val1, vals2)
+ snd_display("%s/%s %s: %s %s?", win1, win2, beta1, val1, val2)
+ end
+ end
+ end
+ val1 = dolph(16, 1.0)
+ val2 = make_fft_window(Dolph_chebyshev_window, 16, 1.0)
+ unless vequal(val1, val2)
+ snd_display("dolph/dolph 1: %s %s?", val1, val2)
+ end
+ val1 = dolph_1(16, 1.0).to_vct
+ val2 = make_fft_window(Dolph_chebyshev_window, 16, 1.0)
+ unless vequal(val1, val2)
+ snd_display("dolph_1/dolph 1: %s %s?", val1, val2)
+ end
+ end # $with_test_gsl
#
gen = make_env(:envelope, [0, 0, 1, 1, 2, 0], :scaler, 0.5, :length, 11)
gen1 = make_env(:envelope, [0, 0, 1, 1, 2, 0], :scaler, 0.5, :length, 11)
print_and_check(gen,
"env",
- "env linear, pass: 0 (dur: 11), index: 0, scaler: 0.5000, offset: 0.0000, data: [0.000 0.000 1.000 1.000 2.000 0.000]")
+ "env linear, pass: 0 (dur: 11), index: 0, scaler: 0.5000, offset: 0.0000, data: [0 0 1 1 2 0]")
unless env?(gen)
snd_display("%s not env?", gen)
end
@@ -16501,10 +15191,10 @@ def test_08_08
v0 = make_vct!(10) do env(gen) end
v1 = make_vct(10)
off = 123.0
- vct_map!(v1, lambda do | |
- off = gen1.offset
- env?(gen1) ? env(gen1) : -1.0
- end)
+ v1.map! do |x|
+ off = gen1.offset
+ env?(gen1) ? env(gen1) : -1.0
+ end
if fneq(off, 0.0)
snd_display("mus_offset opt: %s?", off)
end
@@ -16658,7 +15348,7 @@ def test_08_08
if fneq(res = env_interp(0.45, e), 0.6387)
snd_display("env_interp 0011 2 at 0.45: %s?", res)
end
- e = make_env([0, 0, 1, 1], :offset, 2.0)
+ e = make_env([0, 0, 1, 1], :length, 10, :offset, 2.0)
e.offset = 3.0
if fneq(e.offset, 3.0)
snd_display("set_mus_offset env: %s?", e.offset)
@@ -16793,7 +15483,6 @@ end
def test_08_09
gen = make_table_lookup(440.0, :wave, partials2wave([1, 1, 2, 1]))
gen1 = make_table_lookup(440.0, :wave, partials2wave([1, 1, 2, 1], make_vct(512)))
- gen2 = partials2wave([1, 1, 2, 1, 3, 1, 4, 1], false, true)
gen3 = make_table_lookup
gen4 = make_table_lookup(440.0, :wave, partials2wave([1, 1, 2, 1]))
print_and_check(gen,
@@ -16808,12 +15497,12 @@ def test_08_09
v0 = make_vct!(10) do table_lookup(gen, 0.0) end
v1 = make_vct!(10) do mus_apply(gen1, 0.0) end
v2 = make_vct(10)
- vct_map!(v2, lambda do | | table_lookup?(gen4) ? table_lookup(gen4) : -1.0 end)
+ v2.map! do |x| table_lookup?(gen4) ? table_lookup(gen4) : -1.0 end
unless vequal(v0, v2)
snd_display("map table_lookup: %s %s?", v0, v2)
end
gen4 = make_table_lookup(440.0, :wave, partials2wave([1, 1, 2, 1]))
- vct_map!(v2, lambda do | | table_lookup(gen4) end)
+ v2.map! do |x| table_lookup(gen4) end
unless vequal(v0, v2)
snd_display("map table_lookup (no fm): %s %s?", v0, v2)
end
@@ -16969,7 +15658,7 @@ def test_08_09
gen1 = make_polyshape(440.0)
print_and_check(gen,
"polyshape",
- "polyshape freq: 440.000Hz, phase: 0.000, coeffs[2]: [0.000 1.000]")
+ "polyshape freq: 440.000Hz, phase: 0.000, coeffs[2]: [0 1]")
if gen.length != 2
snd_display("polyshape length: %s?", gen.length)
end
@@ -16980,12 +15669,12 @@ def test_08_09
val
end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | polyshape?(gen1) ? polyshape(gen1, 1.0, 0.0) : -1.0 end)
+ v1.map! do |x| polyshape?(gen1) ? polyshape(gen1, 1.0, 0.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map polyshape: %s %s?", v0, v1)
end
gen1 = make_polyshape(440.0, :coeffs, partials2polynomial([1, 1]))
- vct_map!(v1, lambda do | | polyshape(gen1, 1.0) end)
+ v1.map! do |x| polyshape(gen1, 1.0) end
unless vequal(v0, v1)
snd_display("map polyshape (no fm): %s %s?", v0, v1)
end
@@ -17083,7 +15772,7 @@ def test_08_10
end
v0 = make_vct!(10) do wave_train(gen, 0.0) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | wave_train?(gen1) ? wave_train(gen1) : -1.0 end)
+ v1.map! do |x| wave_train?(gen1) ? wave_train(gen1) : -1.0 end
unless vequal(v0, v1)
snd_display("map wave_train: %s %s?", v0, v1)
end
@@ -17118,7 +15807,6 @@ def test_08_10
snd_display("mus_data wave_train: %s?", gen.data)
end
gen.data = make_vct(3)
- make_oscil.data = make_vct(3)
#
test_gen_equal(make_wave_train(440.0, 0.0, make_vct(20)),
make_wave_train(440.0, 0.0, make_vct(20)),
@@ -17157,37 +15845,37 @@ def test_08_10
end
#
ind = new_sound(:size, 10)
- if frames != 10
- snd_display("new_sound size 10: %s?", frames)
+ if framples != 10
+ snd_display("new_sound size 10: %s?", framples)
end
map_channel($init_channel, 7, 8)
- if frames != 15
- snd_display("map_channel 7 8: %s?", frames)
+ if framples != 15
+ snd_display("map_channel 7 8: %s?", framples)
end
map_channel($init_channel)
- if frames != 15
- snd_display("map_channel (no dur): %s?", frames)
+ if framples != 15
+ snd_display("map_channel (no dur): %s?", framples)
end
revert_sound(ind)
map_channel($init_channel, 9, 10)
- if frames != 19
- snd_display("map_channel 9 10: %s?", frames)
+ if framples != 19
+ snd_display("map_channel 9 10: %s?", framples)
end
if (res = edit_position(ind, 0)) > 2
snd_display("map_channel pad edits (1): %s?", res)
end
revert_sound(ind)
map_channel($init_channel, 10, 10)
- if frames != 20
- snd_display("map_channel 10 10: %s?", frames)
+ if framples != 20
+ snd_display("map_channel 10 10: %s?", framples)
end
if (res = edit_position(ind, 0)) > 2
snd_display("map_channel pad edits (2): %s?", res)
end
revert_sound(ind)
map_channel($init_channel, 20, 10)
- if frames != 30
- snd_display("map_channel 20 10: %s?", frames)
+ if framples != 30
+ snd_display("map_channel 20 10: %s?", framples)
end
if (res = edit_position(ind, 0)) > 2
snd_display("map_channel pad edits (3): %s?", res)
@@ -17196,38 +15884,6 @@ def test_08_10
if scan_channel(lambda do |y| false end, 30, 10)
snd_display("scan_channel past end?")
end
- ptree_channel($init_channel, 7, 8)
- if frames != 15
- snd_display("ptree_channel 7 8: %s?", frames)
- end
- ptree_channel($init_channel)
- if frames != 15
- snd_display("ptree_channel (no dur): %s?", frames)
- end
- revert_sound(ind)
- ptree_channel($init_channel, 9, 10)
- if frames != 19
- snd_display("ptree_channel 9 10: %s?", frames)
- end
- if (res = edit_position(ind, 0)) > 2
- snd_display("ptree_channel pad edits (1): %s?", res)
- end
- revert_sound(ind)
- ptree_channel($init_channel, 10, 10)
- if frames != 20
- snd_display("ptree_channel 10 10: %s?", frames)
- end
- if (res = edit_position(ind, 0)) > 2
- snd_display("ptree_channel pad edits (2): %s?", res)
- end
- revert_sound(ind)
- ptree_channel($init_channel, 20, 10)
- if frames != 30
- snd_display("ptree_channel 20 10: %s?", frames)
- end
- if (res = edit_position(ind, 0)) > 2
- snd_display("ptree_channel pad edits (3): %s?", res)
- end
close_sound(ind)
#
ind = new_sound(:size, 1000)
@@ -17426,21 +16082,21 @@ def test_08_10
print_and_check(gen, "readin", "readin oboe.snd[chan 0], loc: 1490, dir: 1")
v0 = make_vct!(10) do readin(gen) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | |
- if readin?(gen1)
- if gen1.channel.zero?
- readin(gen1)
- else
- 1.0
- end
- else
- if gen1.file_name == "oboe.snd"
- -1.0
- else
- -1.0
- end
- end
- end)
+ v1.map! do |x|
+ if readin?(gen1)
+ if gen1.channel.zero?
+ readin(gen1)
+ else
+ 1.0
+ end
+ else
+ if gen1.file_name == "oboe.snd"
+ -1.0
+ else
+ -1.0
+ end
+ end
+ end
unless vequal(v0, v1)
snd_display("map readin: %s %s?", v0, v1)
end
@@ -17544,7 +16200,7 @@ def test_08_10
unless mus_input?(gen)
snd_display("%s not input?", gen)
end
- if gen.length != frames(ind)
+ if gen.length != framples(ind)
snd_display("snd2sample length: %s?", gen.length)
end
if gen.file_name != (Dir.pwd + "/oboe.snd")
@@ -17581,7 +16237,7 @@ def test_08_10
unless mus_input?(gen)
snd_display("%s not input?", gen)
end
- if gen.length != frames(ind)
+ if gen.length != framples(ind)
snd_display("snd2sample length: %s?", gen.length)
end
if gen.file_name != (Dir.pwd + "/2.snd")
@@ -17597,26 +16253,29 @@ def test_08_10
end
def test_08_11
- gen = make_file2frame("oboe.snd")
- print_and_check(gen, "file->frame", "file->frame oboe.snd")
- unless file2frame?(gen)
- snd_display("%s not file2frame?", gen)
+ gen = make_file2frample("oboe.snd")
+ print_and_check(gen, "file->frample", "file->frample oboe.snd")
+ unless file2frample?(gen)
+ snd_display("%s not file2frample?", gen)
end
unless mus_input?(gen)
snd_display("%s not input?", gen)
end
if gen.length != 50828
- snd_display("file2frame length: %s?", gen.length)
+ snd_display("file2frample length: %s?", gen.length)
end
- v0 = make_vct!(10) do |i| frame_ref(file2frame(gen, 1490 + i, 0), 0) end
- unless file2frame?(gen)
- snd_display("%s not file2frame?", gen)
+ g1 = make_vct(gen.channels)
+ v0 = make_vct!(10) do |i|
+ file2frample(gen, 1490 + i, g1)[0]
+ end
+ unless file2frample?(gen)
+ snd_display("%s not file2frample?", gen)
end
if gen.file_name != "oboe.snd"
- snd_display("file2frame mus_file_name: %s?", gen.file_name)
+ snd_display("file2frample mus_file_name: %s?", gen.file_name)
end
if fneq(v0[1], -0.009) or fneq(v0[7], 0.029)
- snd_display("file2frame output: %s?", v0)
+ snd_display("file2frample output: %s?", v0)
end
#
delete_files("fmv.snd", "fmv1.snd", "fmv2.snd", "fmv3.snd")
@@ -17698,63 +16357,12 @@ def test_08_11
snd_display("mus_channels vct: %s?", res)
end
#
- gen = make_sound_data(4, 100)
- 10.times do |i|
- outa(i, 0.1, gen)
- outb(i, 0.2, gen)
- outc(i, 0.3, gen)
- outd(i, 0.4, gen)
- end
- 10.times do |i|
- outa(i, 0.01, gen)
- outb(i, 0.02, gen)
- outc(i, 0.03, gen)
- outd(i, 0.04, gen)
- end
- mus_close(gen)
- 10.times do |i|
- if fneq(res1 = ina(i, gen), 0.11) or
- fneq(res2 = inb(i, gen), 0.22) or
- fneq(res3 = in_any(i, 2, gen), 0.33) or
- fneq(res4 = in_any(i, 3, gen), 0.44)
- snd_display("4-chan sd out/in[%s]: %s %s %s %s?", i, res1, res2, res3, res4)
- end
- end
- if (res = mus_channels(gen)) != 4
- snd_display("mus_channels sd 4: %s?", res)
- end
- #
- gen = make_sound_data(4, 100)
- 10.times do |i|
- out_any(i, 0.1, 0, gen)
- out_any(i, 0.2, 1, gen)
- out_any(i, 0.3, 2, gen)
- out_any(i, 0.4, 3, gen)
- end
- 10.times do |i|
- out_any(i, 0.01, 0, gen)
- out_any(i, 0.02, 1, gen)
- out_any(i, 0.03, 2, gen)
- out_any(i, 0.04, 3, gen)
- end
- mus_close(gen)
- 10.times do |i|
- if fneq(res1 = in_any(i, 0, gen), 0.11) or
- fneq(res2 = in_any(i, 1, gen), 0.22) or
- fneq(res3 = in_any(i, 2, gen), 0.33) or
- fneq(res4 = in_any(i, 3, gen), 0.44)
- snd_display("4-chan sd out/in_any[%s]: %s %s %s %s?", i, res1, res2, res3, res4)
- end
- end
- #
gen = make_oscil(440.0)
- if (res = Snd.catch do outa(0, 0.1, gen) end).first != :wrong_type_arg
+ res = Snd.catch do outa(0, 0.1, gen) end
+ if res.first != :wrong_type_arg and
+ res.first != :mus_error
snd_display("outa -> oscil: %s", res.inspect)
end
- res = Snd.catch do outa(0, 0.1, false) end
- if (not number?(res.car)) or fneq(res.car, 0.1)
- snd_display("outa -> false: %s", res.inspect)
- end
#
gen = make_sample2file("fmv.snd", 4, Mus_lshort, Mus_riff)
print_and_check(gen, "sample->file", "sample->file fmv.snd")
@@ -17800,41 +16408,42 @@ def test_08_11
snd_display("make_sample2file bad type: %s", res.inspect)
end
#
- gen = make_frame2file("fmv1.snd", 2, Mus_bshort, Mus_next)
- print_and_check(gen, "frame->file", "frame->file fmv1.snd")
- unless frame2file?(gen)
- snd_display("%s not frame2file?", gen)
+ gen = make_frample2file("fmv1.snd", 2, Mus_bshort, Mus_next)
+ print_and_check(gen, "frample->file", "frample->file fmv1.snd")
+ unless frample2file?(gen)
+ snd_display("%s not frample2file?", gen)
end
unless mus_output?(gen)
snd_display("%s not output?", gen)
end
if gen.length != mus_file_buffer_size
- snd_display("frame2file length: %s?", gen.length)
+ snd_display("frample2file length: %s?", gen.length)
end
if gen.file_name != "fmv1.snd"
- snd_display("frame2file mus_file_name: %s?", gen.file_name)
+ snd_display("frample2file mus_file_name: %s?", gen.file_name)
end
gen.length = 4096
if gen.length != 4096
- snd_display("frame2file length: %s?", gen.length)
+ snd_display("frample2file length: %s?", gen.length)
end
gen.length = 8192
- fr0 = make_frame(2, 0.0, 0.0)
+ fr0 = make_vct(2, 0.0)
100.times do |i|
- frame_set!(fr0, 0, i * 0.001)
- frame_set!(fr0, 1, i * 0.010)
- frame2file(gen, i, fr0)
+ vct_set!(fr0, 0, i * 0.001)
+ vct_set!(fr0, 1, i * 0.010)
+ frample2file(gen, i, fr0)
end
mus_close(gen)
- gen = make_file2frame("fmv1.snd", 1024)
- val4 = file2frame(gen, 40)
- frout = make_frame(2)
- if fneq(frame_ref(val4, 0), 0.04) or fneq(frame_ref(val4, 1), 0.4)
- snd_display("frame2file output: %s?", val4)
- end
- file2frame(gen, 40, frout)
+ gen = make_file2frample("fmv1.snd", 1024)
+ fr0 = make_vct(gen.channels)
+ val4 = file2frample(gen, 40, fr0)
+ frout = make_vct(2)
+ if fneq(vct_ref(val4, 0), 0.04) or fneq(vct_ref(val4, 1), 0.4)
+ snd_display("frample2file output: %s?", val4)
+ end
+ file2frample(gen, 40, frout)
unless frout.eql?(val4)
- snd_display("frame2file output via frame: %s %s?", frout, val4)
+ snd_display("frample2file output via frame: %s %s?", frout, val4)
end
#
gen = make_sample2file("fmv2.snd", 4, Mus_bshort, Mus_aifc)
@@ -17894,8 +16503,8 @@ def test_08_11
if (res = mus_sound_chans("fmv.snd")) != 2
snd_display("sample2file chans: %s?", res)
end
- if (res = mus_sound_frames("fmv.snd")) != 10
- snd_display("sample2file frames: %s?", res)
+ if (res = mus_sound_framples("fmv.snd")) != 10
+ snd_display("sample2file framples: %s?", res)
end
if (res = mus_sound_samples("fmv.snd")) != 20
snd_display("sample2file samples: %s?", res)
@@ -17903,7 +16512,7 @@ def test_08_11
if (res = mus_sound_header_type("fmv.snd")) != Mus_next
snd_display("sample2file type: %s?", res)
end
- if (res = mus_sound_data_format("fmv.snd")) != Mus_bshort
+ if (res = mus_sound_sample_type("fmv.snd")) != Mus_bshort
snd_display("sample2file format: %s?", res)
end
if (res = mus_sound_comment("fmv.snd")) != "this is a comment"
@@ -17927,8 +16536,8 @@ def test_08_11
if (res = mus_sound_chans("fmv.snd")) != 2
snd_display("continue_sample2file chans: %s?", res)
end
- if (res = mus_sound_frames("fmv.snd")) != 15
- snd_display("continue_sample2file frames: %s?", res)
+ if (res = mus_sound_framples("fmv.snd")) != 15
+ snd_display("continue_sample2file framples: %s?", res)
end
if (res = mus_sound_samples("fmv.snd")) != 30
snd_display("continue_sample2file samples: %s?", res)
@@ -17936,7 +16545,7 @@ def test_08_11
if (res = mus_sound_header_type("fmv.snd")) != Mus_next
snd_display("continue_sample2file type: %s?", res)
end
- if (res = mus_sound_data_format("fmv.snd")) != Mus_bshort
+ if (res = mus_sound_sample_type("fmv.snd")) != Mus_bshort
snd_display("continue_sample2file format: %s?", res)
end
if (res = mus_sound_comment("fmv.snd")) != "this is a comment"
@@ -17957,75 +16566,72 @@ def test_08_11
#
delete_file("fmv.snd")
mus_sound_forget("fmv.snd")
- sf = make_frame2file("fmv.snd", 2, Mus_lfloat, Mus_riff, "this is a comment")
+ msg = "this is a comment"
+ sf = make_frample2file("fmv.snd", 2, Mus_lfloat, Mus_riff, msg)
10.times do |i|
- frame2file(sf, i, make_frame(2, i * 0.10, i * 0.01))
+ frample2file(sf, i, vct(i * 0.10, i * 0.01))
end
mus_close(sf)
if (res = mus_sound_chans("fmv.snd")) != 2
- snd_display("frame2file chans: %s?", res)
+ snd_display("frample2file chans: %s?", res)
end
- if (res = mus_sound_frames("fmv.snd")) != 10
- snd_display("frame2file frames: %s?", res)
+ if (res = mus_sound_framples("fmv.snd")) != 10
+ snd_display("frample2file framples: %s?", res)
end
if (res = mus_sound_samples("fmv.snd")) != 20
- snd_display("frame2file samples: %s?", res)
+ snd_display("frample2file samples: %s?", res)
end
if (res = mus_sound_header_type("fmv.snd")) != Mus_riff
- snd_display("frame2file type: %s?", res)
+ snd_display("frample2file type: %s?", res)
end
- if (res = mus_sound_data_format("fmv.snd")) != Mus_lfloat
- snd_display("frame2file format: %s?", res)
+ if (res = mus_sound_sample_type("fmv.snd")) != Mus_lfloat
+ snd_display("frample2file format: %s?", res)
end
- if (res = mus_sound_comment("fmv.snd")) != "this is a comment"
- snd_display("frame2file comment: %s?", res)
+ if (res = mus_sound_comment("fmv.snd")) != msg
+ snd_display("frample2file comment: %s?", res)
end
- rd = make_file2sample("fmv.snd")
- 10.times do |i|
- f0 = file2frame(rd, i)
- if f0.length != 2 or
- fneq(frame_ref(f0, 0), i * 0.10) or
- fneq(frame_ref(f0, 1), i * 0.01)
- snd_display("frame2file2frame at %s: %s?", i, f0)
- break
- end
+ rd = make_file2frample("fmv.snd")
+ f0 = vct(0, 0)
+ rd.length.times do |i|
+ file2frample(rd, i, f0)
+ snd_test_neq(f0.length, 2, "frample2file2frample at %d: f0.len %s", i, f0)
+ snd_test_neq(f0[0], i * 0.10, "frample2file2frample at %d: f0[0] %s", i, f0)
+ snd_test_neq(f0[1], i * 0.01, "frample2file2frample at %d: f0[1] %s", i, f0)
end
mus_close(rd)
- sf = continue_frame2file("fmv.snd")
+ sf = continue_frample2file("fmv.snd")
10.times do |i|
- frame2file(sf, i + 5, make_frame(2, i * -0.02, i * -0.01))
+ frample2file(sf, i + 5, vct(i * -0.02, i * -0.01))
end
mus_close(sf)
mus_sound_forget("fmv.snd")
if (res = mus_sound_chans("fmv.snd")) != 2
- snd_display("continue_frame2file chans: %s?", res)
+ snd_display("continue_frample2file chans: %s?", res)
end
- if (res = mus_sound_frames("fmv.snd")) != 15
- snd_display("continue_frame2file frames: %s?", res)
+ if (res = mus_sound_framples("fmv.snd")) != 15
+ snd_display("continue_frample2file framples: %s?", res)
end
if (res = mus_sound_samples("fmv.snd")) != 30
- snd_display("continue_frame2file samples: %s?", res)
+ snd_display("continue_frample2file samples: %s?", res)
end
if (res = mus_sound_header_type("fmv.snd")) != Mus_riff
- snd_display("continue_frame2file type: %s?", res)
+ snd_display("continue_frample2file type: %s?", res)
end
- if (res = mus_sound_data_format("fmv.snd")) != Mus_lfloat
- snd_display("continue_frame2file format: %s?", res)
+ if (res = mus_sound_sample_type("fmv.snd")) != Mus_lfloat
+ snd_display("continue_frample2file format: %s?", res)
end
if (res = mus_sound_comment("fmv.snd")) != "this is a comment"
- snd_display("continue_frame2file comment: %s?", res)
+ snd_display("continue_frample2file comment: %s?", res)
end
ind = open_sound("fmv.snd")
- unless vequal(c0 = channel2vct(0, 15, ind, 0),
- vct(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.58, 0.66,
- 0.74, 0.82, -0.1, -0.12, -0.14, -0.16, -0.18))
- snd_display("continue_frame2file (0): %s", c0)
- end
- unless vequal(c0 = channel2vct(0, 15, ind, 1),
- vct(0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.05, 0.05,
- 0.05, 0.05, -0.05, -0.06, -0.07, -0.08, -0.09))
- snd_display("continue_frame2file (1): %s", c0)
- end
+ c0 = channel2vct(0, 15, ind, 0)
+ c1 = channel2vct(0, 15, ind, 1)
+ v0 = vct(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.58, 0.66,
+ 0.74, 0.82, -0.1, -0.12, -0.14, -0.16, -0.18)
+ v1 = vct(0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.05, 0.05,
+ 0.05, 0.05, -0.05, -0.06, -0.07, -0.08, -0.09)
+ snd_test_neq(c0, v0, "continue_frample2file (0)")
+ snd_test_neq(c1, v1, "continue_frample2file (1)")
close_sound(ind)
delete_file("fmv.snd")
mus_sound_forget("fmv.snd")
@@ -18129,14 +16735,10 @@ def test_08_12
end
snd_test_neq(bad1, 0, "rand dist: down/up 1 %d/%d", down1, up1)
snd_test_neq(bad2, 0, "rand dist: down/up 2 %d/%d", down2, up2)
- if 2.5 * down1 > up1
- snd_display(snd_format(2.5 * down1, up1, ">",
- "rand dist: down/up/bad 1 %d/%d/%d", down1, up1, bad1))
- end
- if 2.5 * up2 > down2
- snd_display(snd_format(2.5 * up2, down2, ">",
- "rand dist: down/up/bad 2 %d/%d/%d", down2, up2, bad2))
- end
+ snd_test_gt(2.5 * down1, up1,
+ "rand dist: down/up/bad 1 %d/%d/%d", down1, up1, bad1)
+ snd_test_gt(2.5 * up2, down2,
+ "rand dist: down/up/bad 2 %d/%d/%d", down2, up2, bad2)
#
gen = make_rand_interp(4000.0)
print_and_check(gen, "rand-interp", gen.to_s)
@@ -18302,13 +16904,13 @@ def test_08_13
end
sum
end.call(10000)
- if res < 4.0
+ if res < 3.0
snd_display("mus_random not so random (chi)? %s", res)
end
res = lambda do |n|
hits = make_array(10, 0)
- gen = make_rand(22050.0)
- n.times do |i| hits[(5 + 5 * rand(gen, 0.0)).floor] += 1 end
+ gen = make_rand(22050.0, 5)
+ n.times do |i| hits[(5 + rand(gen, 0.0)).floor] += 1 end
sum = 0.0
pp = n / 10.0
hits.each do |val|
@@ -18316,7 +16918,7 @@ def test_08_13
end
sum
end.call(10000)
- if res < 4.0
+ if res < 3.5
snd_display("rand not so random (chi)? %s", res)
end
#
@@ -18352,7 +16954,7 @@ def test_08_14
gen2 = make_locsig(60.0, :channels, 4)
gen200 = make_locsig(200.0, :channels, 4)
gen3 = gen1
- fr0 = locsig(gen, 0, 1.0)
+ locsig(gen, 0, 1.0)
print_and_check(gen, "locsig", "locsig chans 2, outn: [0.667 0.333], interp: linear")
unless locsig?(gen)
snd_display("%s not locsig?", gen)
@@ -18391,17 +16993,17 @@ def test_08_14
unless vequal(mus_data(gen), vct(0.250, 0.333))
snd_display("locsig gen 0.25 outn: %s?", mus_data(gen))
end
- fr0 = locsig(gen, 0, 1.0)
+ locsig(gen, 0, 1.0)
locsig_set!(gen, 0, 0.5)
unless vequal(mus_data(gen), vct(0.500, 0.333))
snd_display("locsig gen 0.5 outn: %s?", mus_data(gen))
end
- fr0 = locsig(gen, 0, 1.0)
+ locsig(gen, 0, 1.0)
gen = make_locsig(300.0, 2.0, 0.1, :channels, 4)
unless vequal(mus_data(gen), vct(0.167, 0.000, 0.000, 0.333))
snd_display("locsig gen 300 outn: %s?", mus_data(gen))
end
- fr0 = locsig(gen, 0, 1.0)
+ locsig(gen, 0, 1.0)
move_locsig(gen1, 90.0, 1.0)
unless vequal(mus_data(gen1), vct(0.000, 1.000))
snd_display("locsig gen1 90 outn: %s?", mus_data(gen1))
@@ -18559,8 +17161,8 @@ def test_08_14
close_sound(ind)
end
#
- gen = make_frame2file("fmv4.snd", 2, Mus_bshort, Mus_next)
- rev = make_frame2file("fmv4.reverb", 1, Mus_bshort, Mus_next)
+ gen = make_frample2file("fmv4.snd", 2, Mus_bshort, Mus_next)
+ rev = make_frample2file("fmv4.reverb", 1, Mus_bshort, Mus_next)
lc = make_locsig(60.0, :reverb, 0.1, :channels, 2, :output, gen, :revout, rev)
100.times do |i| locsig(lc, i, 1.0) end
if fneq(res = locsig_reverb_ref(lc, 0), 0.1)
@@ -18589,8 +17191,8 @@ def test_08_14
snd_display("locsig direct: %s %s?", v0[0], v1[0])
end
#
- gen = make_frame2file("fmv4.snd", 4, Mus_bshort, Mus_next)
- rev = make_frame2file("fmv4.reverb", 4, Mus_bshort, Mus_next)
+ gen = make_frample2file("fmv4.snd", 4, Mus_bshort, Mus_next)
+ rev = make_frample2file("fmv4.reverb", 4, Mus_bshort, Mus_next)
lc = make_locsig(60.0, :reverb, 0.1, :channels, 4, :distance, 4.0, :output, gen, :revout, rev)
print_and_check(lc,
"locsig",
@@ -18642,9 +17244,6 @@ def test_08_14
print_and_check(make_locsig(-40, :channels, 2),
"locsig",
"locsig chans 2, outn: [1.000 0.000], interp: linear")
- print_and_check(make_locsig(160, :channels, 4, :output, SoundData.new(4, 10)),
- "locsig",
- "locsig chans 4, outn: [0.000 0.222 0.778 0.000], interp: linear")
print_and_check(make_locsig(0, :channels, 1, :output, Vct.new(10)),
"locsig",
"locsig chans 1, outn: [1.000], interp: linear")
@@ -18725,7 +17324,7 @@ def test_08_14
[0, 1, 2, 4].each do |rev_chans|
delete_file("test.reverb")
revfile = if rev_chans > 0
- make_frame2file("test.reverb", rev_chans, Mus_bshort, Mus_next)
+ make_frample2file("test.reverb", rev_chans, Mus_bshort, Mus_next)
else
false
end
@@ -18811,47 +17410,6 @@ def test_08_14
end
#
set_locsig_type(Mus_interp_linear)
- outp = make_sound_data(1, 10)
- gen = make_locsig(0.0, :output, outp)
- if (res = mus_channels(gen)) != 1
- snd_display("make_locsig->sd chans (1)", res)
- end
- 10.times do |i| locsig(gen, i, 1.0) end
- unless vequal(res = sound_data2vct(outp, 0), Vct.new(10, 1.0))
- snd_display("locsig->sd chan 0: %s?", res)
- end
- outp = make_sound_data(2, 10)
- gen = make_locsig(0.0, :output, outp)
- if (res = mus_channels(gen)) != 2
- snd_display("make_locsig->sd chans (2)", res)
- end
- 10.times do |i| locsig(gen, i, 1.0) end
- unless vequal(res = sound_data2vct(outp, 0), Vct.new(10, 1.0))
- snd_display("locsig->sd chan 0: %s?", res)
- end
- unless vequal(res = sound_data2vct(outp, 1), Vct.new(10, 0.0))
- snd_display("locsig->sd chan 1: %s?", res)
- end
- outp = make_sound_data(2, 10)
- gen = make_locsig(45.0, :output, outp)
- if (res = mus_channels(gen)) != 2
- snd_display("make_locsig->sd chans (2)", res)
- end
- 10.times do |i| locsig(gen, i, 1.0) end
- unless vequal(res = sound_data2vct(outp, 0), Vct.new(10, 0.5))
- snd_display("locsig->sd chan 0 (0.5): %s?", res)
- end
- unless vequal(res = sound_data2vct(outp, 1), Vct.new(10, 0.5))
- snd_display("locsig->sd chan 1 (0.5): %s?", res)
- end
- 10.times do |i| locsig(gen, i, 0.5) end
- unless vequal(res = sound_data2vct(outp, 0), Vct.new(10, 0.75))
- snd_display("locsig->sd chan 0 (0.75): %s?", res)
- end
- unless vequal(res = sound_data2vct(outp, 1), Vct.new(10, 0.75))
- snd_display("locsig->sd chan 1 (0.75): %s?", res)
- end
- #
outp = Vct.new(10)
gen = make_locsig(0.0, :output, outp)
if (res = mus_channels(gen)) != 1
@@ -18879,29 +17437,10 @@ def test_08_14
snd_display("locsig(2)->vct chan 0: %s?", outp)
end
#
- outp = make_sound_data(4, 10)
- gen = make_locsig(135.0, :output, outp)
- if (res = mus_channels(gen)) != 4
- snd_display("make_locsig->sd chans (4)", res)
- end
- 10.times do |i| locsig(gen, i, 1.0) end
- unless vequal(res = sound_data2vct(outp, 0), Vct.new(10, 0.0))
- snd_display("locsig(4)->sd chan 0 (0.5): %s?", res)
- end
- unless vequal(res = sound_data2vct(outp, 1), Vct.new(10, 0.5))
- snd_display("locsig(4)->sd chan 1 (0.5): %s?", res)
- end
- unless vequal(res = sound_data2vct(outp, 2), Vct.new(10, 0.5))
- snd_display("locsig(4)->sd chan 2 (0.5): %s?", res)
- end
- unless vequal(res = sound_data2vct(outp, 3), Vct.new(10, 0.0))
- snd_display("locsig(4)->sd chan 3 (0.5): %s?", res)
- end
- #
set_mus_array_print_length(8)
- outf1 = make_frame2file("fmv.snd", 1, Mus_bshort, Mus_next)
- outf4 = make_frame2file("fmv1.snd", 4, Mus_bshort, Mus_next)
- revf = make_frame2file("fmv2.snd", 1, Mus_bshort, Mus_next)
+ outf1 = make_frample2file("fmv.snd", 1, Mus_bshort, Mus_next)
+ outf4 = make_frample2file("fmv1.snd", 4, Mus_bshort, Mus_next)
+ revf = make_frample2file("fmv2.snd", 1, Mus_bshort, Mus_next)
start = 0
len = 1000
dur = 1.0
@@ -18938,13 +17477,13 @@ def test_08_14
print_and_check(gen1,
"move-sound",
"move-sound start: 0, end: 1000, out chans 1, rev chans: 0
- doppler delay line[32, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
- doppler env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
- global reverb env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
+ doppler delay line[32, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
+ doppler env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
+ global reverb env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
out_delays[1]:
- [0]: delay line[32, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
+ [0]: delay line[32, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
out_envs[1]:
- [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
+ [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
rev_envs: nil
out_map[1]: (0)
free: arrays: true, gens: false
@@ -18952,8 +17491,8 @@ def test_08_14
print_and_check(gen2,
"move-sound",
"move-sound start: 0, end: 1000, out chans 4, rev chans: 0
- doppler delay line[12, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
- doppler env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 10.000 1.000]
+ doppler delay line[12, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
+ doppler env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 10 1]
global reverb null
out_delays[4]:
[0]: nil
@@ -18961,10 +17500,10 @@ def test_08_14
[2]: nil
[3]: nil
out_envs[4]:
- [0]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000 2.000 0.000 3.000 0.000...(0: 0.000, 8: 4.000)]
- [1]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 0.000 2.000 1.000 3.000 0.000...(0: 0.000, 8: 4.000)]
- [2]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 0.000 2.000 0.000 3.000 1.000...(0: 0.000, 8: 4.000)]
- [3]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 0.000 2.000 0.000 3.000 0.000...(0: 0.000, 8: 4.000)]
+ [0]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1 2 0 3 0...(0: 0, 8: 4)]
+ [1]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 0 2 1 3 0...(0: 0, 8: 4)]
+ [2]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 0 2 0 3 1...(0: 0, 8: 4)]
+ [3]: env linear, pass: 0 (dur: 22050), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 0 2 0 3 0...(0: 0, 8: 4)]
rev_envs: nil
out_map[4]: (0 1 2 3)
free: arrays: true, gens: false
@@ -18972,15 +17511,15 @@ def test_08_14
print_and_check(gen3,
"move-sound",
"move-sound start: 0, end: 1000, out chans 1, rev chans: 1
- doppler delay line[32, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
- doppler env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
- global reverb env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
+ doppler delay line[32, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
+ doppler env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
+ global reverb env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
out_delays[1]:
- [0]: delay line[32, step]: [0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000...(0: 0.000, 0: 0.000)]
+ [0]: delay line[32, step]: [0 0 0 0 0 0 0 0...(0: 0, 0: 0)]
out_envs[1]:
- [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 0.000 1.000 1.000]
+ [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 0 1 1]
rev_envs[1]:
- [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0.000 1.000 1.000 1.000]
+ [0]: env linear, pass: 0 (dur: 1001), index: 0, scaler: 1.0000, offset: 0.0000, data: [0 1 1 1]
out_map[1]: (0)
free: arrays: true, gens: false
")
@@ -19038,45 +17577,6 @@ def test_08_14
end
def test_08_15
- rd = make_readin("oboe.snd", 0, 2000)
- gen = make_src(:srate, 2.0, :input, rd)
- gen1 = make_src(:srate, 2.0, :input, make_readin("oboe.snd", 0, 2000))
- gen2 = make_src(:srate, 0.0)
- print_and_check(gen, "src", "src width: 10, x: 0.000, incr: 2.000, sinc table len: 10000")
- v0 = Vct.new(10) do
- src(gen)
- end
- v1 = make_vct(10)
- vct_map!(v1, lambda do ||
- src?(gen1) ? src(gen1) : -1.0
- end)
- unless vequal(v0, v1)
- snd_display("run src: %s %s?", v0, v1)
- end
- unless src?(gen)
- snd_display("%s not src?", gen)
- end
- req1 = 0.001
- req2 = 0.021
- snd_test_neq(v0[1], 0.001, "src output v0[1]")
- snd_test_neq(v0[7], 0.021, "src output v0[7]")
- if fneq(gen.increment, 2.0)
- snd_display("src increment: %s?", gen.increment)
- end
- if fneq(gen2.increment, 0.0)
- snd_display("src 0.0 increment: %s?", gen2.increment)
- end
- if fneq(rd.increment, 1.0)
- snd_display("readin increment: %s?", rd.increment)
- end
- if gen.length != 10
- snd_display("src length: %s?", gen.length)
- end
- gold = gen
- gen = make_src(lambda do |dir| 0.0 end)
- if gen.eql? gold
- snd_display("src eql? %s %s?", gen, gold)
- end
if (res = Snd.catch do make_src(:width, -1) end).first != :out_of_range
snd_display("make_src bad width: %s", res.inspect)
end
@@ -19087,27 +17587,50 @@ def test_08_15
src(s1, 125.0)
src(s1, -25.0)
src(s1, -125.0)
- 10.times do |i| make_src(lambda do |y| 1.0 end, 1.5, :width, 5 + i * 10) end
- clear_sincs
+ 10.times do |i|
+ make_src(lambda do |y|
+ 1.0
+ end,
+ 1.5,
+ :width, 5 + i * 10)
+ end
#
ctr = 0.0
gen = make_src(:srate, 2.0, :input, lambda do |dir|
val = ctr
- ctr += 1
+ ctr += 1.0
val
end)
- v0 = make_vct!(10) do src(gen, 0.0) end
+ v0 = make_vct!(10) do
+ src(gen, 0.0)
+ end
ctr = 0.0
gen.reset
v0.each_with_index do |old_val, i|
- if fneq(old_val, new_val = src(gen, 0.0))
- snd_display("reset src %s: %s %s?", i, old_val, new_val)
- end
+ snd_test_neq(old_val, src(gen, 0.0), "reset src %d", i)
end
#
- gen = make_granulate(:expansion, 2.0)
+ so1 = lambda do |ss, pp|
+ src(ss, env(pp))
+ end
+ s1 = make_src(:srate, 2.0, :input, make_readin("oboe.snd", 0, 10000))
+ s2 = make_src(:srate, 2.0, :input, make_readin("oboe.snd", 0, 10000))
+ s3 = make_src(:srate, 2.0, :input, make_readin("oboe.snd", 0, 10000))
+ e1 = make_env([0, 1, 2, 0.5], :duration, 1000)
+ e2 = make_env([0, 1, 2, 0.5], :duration, 1000)
+ e3 = make_env([0, 1, 2, 0.5], :duration, 1000)
+ 100.times do |i|
+ x1 = src(s1, env(e1))
+ ex2 = env(e2)
+ x2 = src(s2, ex2)
+ x3 = so1.call(s3, e3)
+ snd_test_neq(x1, x2, "%d", i)
+ snd_test_neq(x1, x3, "%d", i)
+ end
+ #
+ gen = make_granulate(:expansion, 2.0,
+ :input, make_readin("oboe.snd", 0, 4000, 1, 2048))
gen1 = make_granulate(:expansion, 2.0)
- rd = make_readin("oboe.snd", 0, 4000, 1, 2048)
rd1 = make_readin(:file, "oboe.snd",
:channel, 0,
:start, 4000,
@@ -19117,12 +17640,12 @@ def test_08_15
"granulate",
"granulate expansion: 2.000 (551/1102), scaler: 0.600, length: 0.150 secs (3308 samps), ramp: 0.060")
v0 = make_vct!(1000) do
- granulate(gen, lambda do |dir| readin(rd) end)
+ granulate(gen)
end
v1 = make_vct(1000)
- vct_map!(v1, lambda do | |
- granulate?(gen1) ? granulate(gen1, lambda do |dir| readin(rd1) end) : -1.0
- end)
+ v1.map! do |x|
+ granulate?(gen1) ? granulate(gen1, lambda do |dir| readin(rd1) end) : -1.0
+ end
if (worst = (vct_peak(v0) - vct_peak(v1)).abs) > 0.01
snd_display("run granulate: %s?", worst)
end
@@ -19145,7 +17668,7 @@ def test_08_15
if fneq(gen.scaler, 0.6)
snd_display("granulate scaler: %s?", gen.scaler)
end
- if ffneq(gen.frequency, 0.05) # okay
+ if ffneq(gen.frequency, 0.05)
snd_display("granulate frequency: %s?", gen.frequency)
end
if gen.ramp != 1323
@@ -19170,7 +17693,7 @@ def test_08_15
snd_display("granulate set_length: %s?", gen.length)
end
gen.increment = 3.0
- if ffneq(gen.increment, 3.0) # okay
+ if ffneq(gen.increment, 3.0)
snd_display("granulate set_increment: %s?", gen.increment)
end
gen.location = 1
@@ -19182,10 +17705,9 @@ def test_08_15
snd_display("granulate set_frequency: %s?", gen.frequency)
end
#
- if (res = Snd.catch do make_granulate(lambda do |a, b| a end) end).first != :bad_arity
- snd_display("make_granulate bad func: %s", res.inspect)
- end
- if (res = Snd.catch do make_granulate(:hop, 35.0, :length, 35.0) end).first != :out_of_range
+ if (res = Snd.catch do
+ make_granulate(:hop, 35.0, :length, 35.0)
+ end).first != :out_of_range
snd_display("make_granulate bad sizes: %s", res.inspect)
end
#
@@ -19199,97 +17721,105 @@ def test_08_15
0
end)
map_channel(lambda do |y| granulate(grn) end)
- if (maxamp / mx) < 1.4 or (mx / maxamp) > 2.5
- snd_display("gran edit 2* (0): %s %s?", mx, maxamp)
+ if (maxamp() / mx) < 1.4 or (mx / maxamp()) > 2.5
+ snd_display("gran edit 2* (0): %s %s?", mx, maxamp())
end
undo_edit
rd = make_sampler(0)
grn = make_granulate(:expansion, 2.0,
- :input, lambda do |dir| rd.call end,
+ :input, lambda do |dir| read_sample(rd) end,
:edit, lambda do |g|
g.data.scale!(4.0)
0
end)
map_channel(lambda do |y| granulate(grn) end)
- if (maxamp / mx) < 3.0 or (mx / maxamp) > 6.0
- snd_display("gran edit 4* (0): %s %s?", mx, maxamp)
+ if (maxamp() / mx) < 3.0 or (mx / maxamp()) > 6.0
+ snd_display("gran edit 4* (0): %s %s?", mx, maxamp())
end
revert_sound(ind)
rd = make_sampler(0)
grn = make_granulate(:expansion, 2.0,
+ :input, lambda do |dir| read_sample(rd) end,
:edit, lambda do |g|
g.data.scale!(2.0)
0
end)
- map_channel(lambda do |y| granulate(grn, lambda do |dir| rd.call end) end)
- if (maxamp / mx) < 1.4 or (mx / maxamp) > 2.5
- snd_display("gran edit 2* (1): %s %s?", mx, maxamp)
+ map_channel(lambda do |y| granulate(grn) end)
+ if (maxamp() / mx) < 1.4 or (mx / maxamp()) > 2.5
+ snd_display("gran edit 2* (1): %s %s?", mx, maxamp())
end
undo_edit
rd = make_sampler(0)
grn = make_granulate(:expansion, 2.0,
+ :input, lambda do |dir| read_sample(rd) end,
:edit, lambda do |g|
g.data.scale!(4.0)
0
end)
- map_channel(lambda do |y| granulate(grn, lambda do |dir| rd.call end) end)
- if (maxamp / mx) < 3.0 or (mx / maxamp) > 6.0
- snd_display("gran edit 4* (1): %s %s?", mx, maxamp)
+ map_channel(lambda do |y| granulate(grn) end)
+ if (maxamp() / mx) < 2.9 or (mx / maxamp()) > 6.0
+ snd_display("gran edit 4* (1): %s %s?", mx, maxamp())
end
revert_sound(ind)
+ # XXX: grn = make_granulate(:expansion, 2.0, :input, make_sampler(0))
+ # Doesn't work with Ruby; make_sampler is not a procedure.
rd = make_sampler(0)
- grn = make_granulate(:expansion, 2.0)
- map_channel(lambda do |y|
- granulate(grn,
- lambda do |dir| rd.call end,
- lambda do |g|
- g.data.scale!(2.0)
- 0
- end)
- end)
- if (maxamp / mx) < 1.4 or (mx / maxamp) > 2.5
- snd_display("gran edit 2* (2): %s %s?", mx, maxamp)
+ input_fnc = lambda do |dir|
+ rd.call
+ end
+ edit_fnc = lambda do |g|
+ g.data.scale!(2.0)
+ 0
+ end
+ grn = make_granulate(:expansion, 2.0, :input, input_fnc, :edit, edit_fnc)
+ map_channel(lambda do |y| granulate(grn) end)
+ if (maxamp() / mx) < 1.4 or (mx / maxamp()) > 2.5
+ snd_display("gran edit 2* (2): %s %s?", mx, maxamp())
end
undo_edit
rd = make_sampler(0)
grn = make_granulate(:expansion, 2.0)
map_channel(lambda do |y|
- granulate(grn,
- lambda do |dir| rd.call end,
- lambda do |g|
- g.data.scale!(4.0)
- 0
- end)
- end)
- if (maxamp / mx) < 3.0 or (mx / maxamp) > 6.0
- snd_display("gran edit 4* (2): %s %s?", mx, maxamp)
+ granulate(grn,
+ lambda do |dir| rd.call end,
+ lambda do |g|
+ g.data.scale!(4.0)
+ 0
+ end)
+ end)
+ if (maxamp() / mx) < 3.0 or (mx / maxamp()) > 6.0
+ snd_display("gran edit 4* (2): %s %s?", mx, maxamp())
end
close_sound(ind)
ind = open_sound("oboe.snd")
- grn = make_granulate(:expansion, 2.0, :length, 0.01, :hop, 0.05)
rd = make_sampler(0)
- map_channel(lambda do |y| granulate(grn, lambda do |dir| rd.call end) end)
+ grn = make_granulate(:expansion, 2.0, :length, 0.01, :hop, 0.05,
+ :input, lambda do |dir| next_sample(rd) end)
+ map_channel(lambda do |y| granulate(grn) end)
if (res = maxamp) > 0.2
snd_display("trouble in granulate len 0.01 hop 0.05: %s?", res)
end
undo_edit
- grn = make_granulate(:expansion, 2.0, :length, 0.04, :hop, 0.05)
rd = make_sampler(0)
- map_channel(lambda do |y| granulate(grn, lambda do |dir| rd.call end) end)
+ grn = make_granulate(:expansion, 2.0, :length, 0.04, :hop, 0.05,
+ :input, lambda do |dir| next_sample(rd) end)
+ map_channel(lambda do |y| granulate(grn) end)
if (res = maxamp) > 0.2
snd_display("trouble in granulate len 0.04 hop 0.05: %s?", res)
end
undo_edit
- grn = make_granulate(:expansion, 2.0, :length, 0.01, :hop, 0.25)
rd = make_sampler(0)
- map_channel(lambda do |y| granulate(grn, lambda do |dir| rd.call end) end)
+ grn = make_granulate(:expansion, 2.0, :length, 0.01, :hop, 0.25,
+ :input, lambda do |dir| next_sample(rd) end)
+ map_channel(lambda do |y| granulate(grn) end)
if (res = maxamp) > 0.2
snd_display("trouble in granulate len 0.01 hop 0.25: %s?", res)
end
undo_edit
- grn = make_granulate(:expansion, 2.0, :length, 0.4, :hop, 0.5)
rd = make_sampler(0)
- map_channel(lambda do |y| granulate(grn, lambda do |dir| rd.call end) end)
+ grn = make_granulate(:expansion, 2.0, :length, 0.4, :hop, 0.5,
+ :input, lambda do |dir| next_sample(rd) end)
+ map_channel(lambda do |y| granulate(grn) end)
if (res = maxamp) > 0.2
snd_display("trouble in granulate len 0.4 hop 0.5: %s?", res)
end
@@ -19299,8 +17829,9 @@ end
def test_08_16
ind = new_sound(:size, 1000)
- gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.06)
snd_display("gran 0 max: %s?", res)
end
@@ -19319,8 +17850,9 @@ def test_08_16
snd_display("gran 0 data 85: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.002, :length, 0.001)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.002, :length, 0.001,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.06)
snd_display("gran 1 max: %s?", res)
end
@@ -19339,8 +17871,9 @@ def test_08_16
snd_display("gran 1 data 40: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.002, :length, 0.001, :ramp, 0.1)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.002, :length, 0.001, :ramp, 0.1,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.06)
snd_display("gran 2 max: %s?", res)
end
@@ -19359,8 +17892,9 @@ def test_08_16
snd_display("gran 2 data 40: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.002, :length, 0.001, :ramp, 0.5)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.002, :length, 0.001, :ramp, 0.5,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.06)
snd_display("gran 3 max: %s?", res)
end
@@ -19379,8 +17913,9 @@ def test_08_16
snd_display("gran 3 data 85: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.001, :ramp, 0.5)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.001, :ramp, 0.5,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.06)
snd_display("gran 4 max: %s?", res)
end
@@ -19399,8 +17934,9 @@ def test_08_16
snd_display("gran 4 data 85: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.001, :ramp, 0.25, :scaler, 1.0)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.001, :ramp, 0.25,
+ :scaler, 1.0, :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.1)
snd_display("gran 5 max: %s?", res)
end
@@ -19419,8 +17955,9 @@ def test_08_16
snd_display("gran 5 data 85: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.002, :ramp, 0.5, :scaler, 1.0)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.002, :ramp, 0.5,
+ :scaler, 1.0, :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.105)
snd_display("gran 6 max: %s?", res)
end
@@ -19439,8 +17976,9 @@ def test_08_16
snd_display("gran 6 data 85: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.005, :ramp, 0.5, :scaler, 1.0)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.005, :ramp, 0.5,
+ :scaler, 1.0, :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.264)
snd_display("gran 7 max: %s?", res)
end
@@ -19460,8 +17998,9 @@ def test_08_16
end
undo_edit
gen = make_granulate(:jitter, 0.0, :hop, 0.01, :length, 0.001, :ramp, 0.5,
- :scaler, 1.0, :expansion, 2.0)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ :scaler, 1.0, :expansion, 2.0,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.1)
snd_display("gran 8 max: %s?", res)
end
@@ -19481,8 +18020,9 @@ def test_08_16
end
undo_edit
gen = make_granulate(:jitter, 0.0, :hop, 0.01, :length, 0.001, :ramp, 0.5,
- :scaler, 1.0, :expansion, 0.5)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ :scaler, 1.0, :expansion, 0.5,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.1)
snd_display("gran 9 max: %s?", res)
end
@@ -19506,7 +18046,7 @@ def test_08_16
granulate(gen,
lambda do |dir| 0.1 end,
lambda do |g|
- g.data.map! do |val| val *= 2.0 end
+ g.data.scale!(2.0)
0
end)
end)
@@ -19528,7 +18068,8 @@ def test_08_16
snd_display("gran 10 data 85: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.005, :length, 0.002, :ramp, 0.0, :scaler, 1.0)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.005, :length, 0.002,
+ :ramp, 0.0, :scaler, 1.0)
forward = true
ctr = -0.5
incr = 0.001
@@ -19569,10 +18110,10 @@ def test_08_16
undo_edit
ctr = -0.5
incr = 0.001
- gen = make_granulate(:jitter, 0.0, :hop, 0.005, :length, 0.002, :ramp, 0.0, :scaler, 1.0,
+ gen = make_granulate(:jitter, 0.0, :hop, 0.005, :length, 0.002, :ramp, 0.0,
+ :scaler, 1.0,
:input, lambda do |dir|
ctr += incr
- ctr
end)
map_channel(lambda do |y| granulate(gen) end)
if (res = maxamp) > 0.6
@@ -19586,17 +18127,19 @@ def test_08_16
snd_display("gran 12 data: %s?", res)
end
unless vequal(res = channel2vct(100, 30),
- vct(0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
- 0.000, 0.000, -0.389, -0.388, -0.387, -0.386, -0.385, -0.384,
- -0.383, -0.382, -0.381, -0.380, -0.379, -0.378, -0.377, -0.376,
+ vct(0.0, 0.0, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000,
+ 0.0, 0.0, -0.389, -0.388, -0.387, -0.386, -0.385, -0.384,
+ -0.383, -0.382, -0.381, -0.38,
+ -0.379, -0.378, -0.377, -0.376,
-0.375, -0.374, -0.373, -0.372, -0.371, -0.370))
snd_display("gran 12 data 100: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.005, :ramp, 0.5, :scaler, 1.0,
+ gen = make_granulate(:jitter, 0.0, :hop, 0.001, :length, 0.005, :ramp, 0.5,
+ :scaler, 1.0,
:input, lambda do |dir| 0.1 end,
:edit, lambda do |g|
- g.data.map! do |val| val *= 2.0 end
+ g.data.scale!(2.0)
0
end)
map_channel(lambda do |y| granulate(gen) end)
@@ -19621,7 +18164,8 @@ def test_08_16
forward = true
ctr = -0.5
incr = 0.001
- gen = make_granulate(:jitter, 0.0, :hop, 0.005, :length, 0.002, :ramp, 0.0, :scaler, 1.0,
+ gen = make_granulate(:jitter, 0.0, :hop, 0.005, :length, 0.002, :ramp, 0.0,
+ :scaler, 1.0,
:input, lambda do |dir|
ctr += incr
ctr
@@ -19656,11 +18200,12 @@ def test_08_16
end
undo_edit
#
- gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001, :ramp, 0.0)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001, :ramp, 0.0,
+ :input, lambda do |dir| 0.1 end)
e = make_env(:envelope, [0, 0, 1, 0.5], :length, 1001)
base_ramp_len = mus_length(gen)
map_channel(lambda do |y|
- result = granulate(gen, lambda do |dir| 0.1 end)
+ result = granulate(gen)
set_mus_ramp(gen, (base_ramp_len * env(e)).round)
result
end)
@@ -19692,11 +18237,12 @@ def test_08_16
snd_display("granf 0 data 880: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001, :ramp, 0.0)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001, :ramp, 0.0,
+ :input, lambda do |dir| 0.1 end)
e = make_env(:envelope, [0, 1, 1, 0.25], :length, 1001)
base_hop_len = mus_hop(gen)
map_channel(lambda do |y|
- result = granulate(gen, lambda do |dir| 0.1 end)
+ result = granulate(gen)
set_mus_hop(gen, (base_hop_len * env(e)).round)
result
end)
@@ -19721,11 +18267,12 @@ def test_08_16
snd_display("granf 1 data 900: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001, :ramp, 0.0)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001, :ramp, 0.0,
+ :input, lambda do |dir| 0.1 end)
e = make_env(:envelope, [0, 1, 1, 0.25], :length, 1001)
base_freq = mus_frequency(gen)
map_channel(lambda do |y|
- result = granulate(gen, lambda do |dir| 0.1 end)
+ result = granulate(gen)
set_mus_frequency(gen, base_freq * env(e))
result
end)
@@ -19750,9 +18297,10 @@ def test_08_16
snd_display("granf 2 data 900: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.002, :length, 0.001, :ramp, 0.0, :scaler, 1.0)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.002, :length, 0.001, :ramp, 0.0,
+ :scaler, 1.0, :input, lambda do |dir| 0.1 end)
base_freq = mus_frequency(gen)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ map_channel(lambda do |y| granulate(gen) end)
if fneq(res = maxamp, 0.1)
snd_display("granf 3 max: %s?", res)
end
@@ -19764,11 +18312,12 @@ def test_08_16
snd_display("granf 3 data: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001, :ramp, 0.0, :scaler, 1.0)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.004, :length, 0.001, :ramp, 0.0,
+ :scaler, 1.0, :input, lambda do |dir| 0.1 end)
e = make_env(:envelope, [0, 1, 1, 0], :length, 1001)
base_freq = mus_frequency(gen)
map_channel(lambda do |y|
- result = granulate(gen, lambda do |dir| 0.1 end)
+ result = granulate(gen)
set_mus_scaler(gen, env(e))
result
end)
@@ -19797,11 +18346,12 @@ def test_08_16
snd_display("granf 4 data 900: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.006, :length, 0.001, :ramp, 0.0, :max_size, 2200)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.006, :length, 0.001, :ramp, 0.0,
+ :max_size, 2200, :input, lambda do |dir| 0.1 end)
e = make_env(:envelope, [0, 1, 1, 5], :length, 1001)
base_len = mus_length(gen)
map_channel(lambda do |y|
- result = granulate(gen, lambda do |dir| 0.1 end)
+ result = granulate(gen)
set_mus_length(gen, (base_len * env(e)).round)
result
end)
@@ -19833,11 +18383,12 @@ def test_08_16
snd_display("granf 5 data 800: %s?", res)
end
undo_edit
- gen = make_granulate(:jitter, 0.0, :hop, 0.006, :length, 0.005, :ramp, 0.0, :max_size, 2200)
+ gen = make_granulate(:jitter, 0.0, :hop, 0.006, :length, 0.005, :ramp, 0.0,
+ :max_size, 2200, :input, lambda do |dir| 0.1 end)
e = make_env(:envelope, [0, 1, 1, 0.2], :length, 1001)
base_len = mus_length(gen)
map_channel(lambda do |y|
- result = granulate(gen, lambda do |dir| 0.1 end)
+ result = granulate(gen)
set_mus_length(gen, (base_len * env(e)).round)
result
end)
@@ -19877,38 +18428,43 @@ def test_08_16
pts
end
gen = make_granulate(:jitter, 0.0, :hop, 0.01, :length, 0.001,
- :ramp, 0.5, :scaler, 1.0, :expansion, 0.5)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ :ramp, 0.5, :scaler, 1.0, :expansion, 0.5,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if [11, 231, 451, 671, 891] != (res = max_list.call)
snd_display("grn jitter 0 max: %s?", res)
end
undo_edit
gen = make_granulate(:jitter, 0.3, :hop, 0.01, :length, 0.001,
- :ramp, 0.5, :scaler, 1.0, :expansion, 0.5)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ :ramp, 0.5, :scaler, 1.0, :expansion, 0.5,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if [11, 231, 451, 671, 891] == (res = max_list.call)
snd_display("grn jitter 0.3 max: %s?", res)
end
old_vals = res
undo_edit
gen = make_granulate(:jitter, 0.3, :hop, 0.01, :length, 0.001,
- :ramp, 0.5, :scaler, 1.0, :expansion, 0.5)
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ :ramp, 0.5, :scaler, 1.0, :expansion, 0.5,
+ :input, lambda do |dir| 0.1 end)
+ map_channel(lambda do |y| granulate(gen) end)
if (res = max_list.call) == old_vals
snd_display("grn jitter 0.3 max: %s %s?", res, old_vals)
end
undo_edit
old_vals = false
gen = make_granulate(:jitter, 1.0, :hop, 0.01, :length, 0.001,
- :ramp, 0.5, :scaler, 1.0, :expansion, 0.5)
+ :ramp, 0.5, :scaler, 1.0, :expansion, 0.5,
+ :input, lambda do |dir| 0.1 end)
seed = gen.location
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ map_channel(lambda do |y| granulate(gen) end)
old_vals = max_list.call
undo_edit
gen = make_granulate(:jitter, 1.0, :hop, 0.01, :length, 0.001,
- :ramp, 0.5, :scaler, 1.0, :expansion, 0.5)
+ :ramp, 0.5, :scaler, 1.0, :expansion, 0.5,
+ :input, lambda do |dir| 0.1 end)
gen.location = seed
- map_channel(lambda do |y| granulate(gen, lambda do |dir| 0.1 end) end)
+ map_channel(lambda do |y| granulate(gen) end)
if (res = max_list.call) != old_vals
snd_display("grn jitter 1.0 max with seed: %s %s?", res, old_vals)
end
@@ -19916,16 +18472,10 @@ def test_08_16
fname = file_name(ind)
close_sound(ind)
delete_file(fname)
- if view_files_dialog(false)
- set_view_files_files(view_files_dialog(false), [])
- unless (res = view_files_files(view_files_dialog(false))).null?
- snd_display("set vf files list null: %s?", res)
- end
- end
end
def test_08_17
- ind = new_sound("tmp.snd", Mus_next, Mus_bfloat, 22050, 1, :size, 10000)
+ ind = new_sound("tmp.snd", 1, 22050, Mus_bfloat, Mus_next, :size, 10000)
gen = make_granulate(:expansion, 20.0,
:input, lambda do |dir| 0.01 end,
:length, 0.00995,
@@ -20000,13 +18550,9 @@ def test_08_17
snd_display("granulate ramped 4 data off: %s %s %s?", res1, res2, res3)
end
undo_edit
- ctr = 0
+ e = make_env([0, 0, 1, 1], :length, 10000)
gen = make_granulate(:expansion, 2.0,
- :input, lambda do |dir|
- val = ctr * 0.0001
- ctr += 1
- val
- end,
+ :input, lambda do |dir| env(e) end,
:length, 0.00995,
:hop, 0.01,
:ramp, 0.0,
@@ -20019,7 +18565,7 @@ def test_08_17
vals = count_matches(lambda do |y| y != 0.0 end)
mxoff = 0.0
mx = maxamp
- len = frames
+ len = framples
cur = 0.0
incr = mx / len
scan_channel(lambda do |y|
@@ -20034,13 +18580,9 @@ def test_08_17
snd_display("granulate ramped 5 mxoff: %s?", mxoff)
end
undo_edit
- ctr = 0
+ e = make_env([0, 0, 1, 1], :length, 10000)
gen = make_granulate(:expansion, 2.0,
- :input, lambda do |dir|
- val = ctr * 0.0001
- ctr += 1
- val
- end,
+ :input, lambda do |dir| env(e) end,
:length, 0.00995,
:hop, 0.01,
:ramp, 0.5,
@@ -20057,13 +18599,9 @@ def test_08_17
snd_display("granulate ramped 6 data: %s %s?", res1, res2)
end
undo_edit
- ctr = 0
+ e = make_env([0, 0, 1, 1], :length, 10000)
gen = make_granulate(:expansion, 2.0,
- :input, lambda do |dir|
- val = ctr * 0.0001
- ctr += 1
- val
- end,
+ :input, lambda do |dir| env(e) end,
:length, 0.00995,
:hop, 0.01,
:ramp, 0.25,
@@ -20080,13 +18618,9 @@ def test_08_17
snd_display("granulate ramped 7 data: %s %s?", res1, res2)
end
undo_edit
- ctr = 0
+ e = make_env([0, 0, 1, 1], :length, 10000)
gen = make_granulate(:expansion, 2.0,
- :input, lambda do |dir|
- val = ctr * 0.0001
- ctr += 1
- val
- end,
+ :input, lambda do |dir| env(e) end,
:length, 0.05,
:hop, 0.01,
:ramp, 0.25,
@@ -20094,11 +18628,11 @@ def test_08_17
:jitter, 0.0)
clm_channel(gen)
if fneq(maxamp, 0.201)
- snd_display("granulate ramped 8: %s?", maxamp)
+ snd_display("granulate ramped 7: %s?", maxamp)
end
mxoff = 0.0
mx = maxamp
- len = frames
+ len = framples
cur = 0.0
incr = mx / len
scan_channel(lambda do |y|
@@ -20110,16 +18644,12 @@ def test_08_17
false
end)
if mxoff > 0.01
- snd_display("granulate ramped 8 mxoff: %s?", mxoff)
+ snd_display("granulate ramped 7 mxoff: %s?", mxoff)
end
undo_edit
- ctr = 0
+ e = make_env([0, 0, 1, 1], :length, 10000)
gen = make_granulate(:expansion, 2.0,
- :input, lambda do |dir|
- val = ctr * 0.0001
- ctr += 1
- val
- end,
+ :input, lambda do |dir| env(e) end,
:length, 0.1,
:hop, 0.01,
:ramp, 0.1,
@@ -20127,11 +18657,11 @@ def test_08_17
:jitter, 0.0)
clm_channel(gen)
if fneq(maxamp, 0.501)
- snd_display("granulate ramped 9: %s?", maxamp)
+ snd_display("granulate ramped 8: %s?", maxamp)
end
mxoff = 0.0
mx = maxamp
- len = frames - 2000
+ len = framples - 2000
cur = sample(2000)
incr = (mx - cur) / len
scan_channel(lambda do |y|
@@ -20143,16 +18673,12 @@ def test_08_17
false
end, 2000)
if mxoff > 0.001
- snd_display("granulate ramped 9 mxoff: %s?", mxoff)
+ snd_display("granulate ramped 8 mxoff: %s?", mxoff)
end
undo_edit
- ctr = 0
+ e = make_env([0, 0, 1, 1], :length, 10000)
gen = make_granulate(:expansion, 2.0,
- :input, lambda do |dir|
- val = ctr * 0.0001
- ctr += 1
- val
- end,
+ :input, lambda do |dir| env(e) end,
:length, 0.4,
:hop, 0.01,
:ramp, 0.4,
@@ -20160,7 +18686,7 @@ def test_08_17
:jitter, 0.0)
clm_channel(gen)
if fneq(maxamp, 0.433)
- snd_display("granulate ramped 10: %s?", maxamp)
+ snd_display("granulate ramped 9: %s?", maxamp)
end
undo_edit
close_sound(ind)
@@ -20198,48 +18724,27 @@ def test_08_18
v1[n]
end)
end
- vct_map!(v21, lambda do | |
- if convolve?(gen1)
- convolve(gen1, lambda do |dir|
- n1 += 1
- v11[n1]
- end)
- else
- -1.0
- end
- end)
+ v21.map! do |x|
+ if convolve?(gen1)
+ convolve(gen1, lambda do |dir|
+ n1 += 1
+ v11[n1]
+ end)
+ else
+ -1.0
+ end
+ end
unless vequal(v2, v21)
snd_display("run gran: %s %s?", v2, v21)
end
if fneq(v2[0], 0.0) or fneq(v2[1], 1.0) or fneq(v2[4], 0.25) or fneq(v2[7], 0.143)
snd_display("convolve output: %s?", v2)
end
- if (res = Snd.catch do convolve(gen, lambda do |a, b| a end) end).first != :bad_arity
- snd_display("convolve bad func: %s", res.inspect)
- end
convolve_files("oboe.snd", "fyow.snd", 0.5, "fmv.snd")
if fneq(res = mus_sound_maxamp("fmv.snd")[1], 0.5)
snd_display("convolve_files: %s != 0.5?", res)
end
#
- fd = mus_sound_open_input("oboe.snd")
- chans = mus_sound_chans("oboe.snd")
- data = make_sound_data(chans, 2000)
- unless sound_data?(data)
- snd_display("%s not sound_data?", data)
- end
- if sound_data_chans(data) != 1
- snd_display("sound_data chans: %s?", data.chans)
- end
- if data.length != 2000
- snd_display("sound_data length: %s?", sound_data_length(data))
- end
- mus_sound_read(fd, 0, 1999, chans, data)
- mus_sound_close_input(fd)
- if fneq(res = data[0, 1497], 0.02893066)
- snd_display("mus_sound_read: %s?", res)
- end
- #
ind = new_sound("fmv.snd")
set_sample(1, 0.1)
save_sound(ind)
@@ -20248,8 +18753,8 @@ def test_08_18
end
close_sound(ind)
ind = open_sound("fmv.snd")
- if frames(ind, 0) != 2
- snd_display("save_sound 2 samps: %s?", frames(ind, 0))
+ if framples(ind, 0) != 2
+ snd_display("save_sound 2 samps: %s?", framples(ind, 0))
end
if fneq(sample(0), 0.0) or fneq(sample(1), 0.1)
snd_display("save_sound: %s %s?", sample(0), sample(1))
@@ -20262,8 +18767,8 @@ def test_08_18
end
close_sound(ind)
ind = open_sound("fmv.snd")
- if frames(ind, 0) != i + 1
- snd_display("save_sound %s samps: %s?", i + 1, frames(ind, 0))
+ if framples(ind, 0) != i + 1
+ snd_display("save_sound %s samps: %s?", i + 1, framples(ind, 0))
end
if fneq(sample(0), 0.0) or fneq(sample(1), 0.1) or fneq(sample(i), i * 0.1)
snd_display("save_sound %s: %s %s %s?", i, sample(0), sample(1), sample(i))
@@ -20300,12 +18805,6 @@ def test_08_18
end
close_sound(ind)
#
- if defined? mus_ssb_bank # not defined if --with-modules
- bands = make_array(3) do make_bandpass(hz2radians(500.0), hz2radians(600.0), 10) end
- ssbs = make_array(3) do make_ssb_am(100.0 + random(400.0)) end
- mus_ssb_bank(ssbs, bands, 0.1, 3)
- end
- #
ind = new_sound("test.snd", :srate, 22050, :channels, 1, :size, 1000)
ctr = 0
map_channel(lambda do |y|
@@ -20324,9 +18823,8 @@ def test_08_18
end
close_sound(ind)
#
- snd_test_neq($output, false, "$output")
- $output = false
- nind = new_sound("fmv.snd", Mus_aifc, Mus_bshort, 22050, 1, "this is a comment")
+ nind = new_sound("fmv.snd", 1, 22050, Mus_bshort, Mus_aifc,
+ "this is a comment")
with_time("fm_violin_1(0, 1, 440, 0.1)") do fm_violin_1(0, 1, 440, 0.1) end
play(nind, :wait, true)
save_sound(nind)
@@ -20355,13 +18853,13 @@ def test_08_18
unless sound?(nind)
snd_display("close_sound clobbered %s?", nind)
end
- fr = frames(nind, 0)
+ fr = framples(nind, 0)
10.times do
delete_samples(10, 100, nind, 0)
save_sound(nind)
end
- if frames(nind, 0) != fr - 1000
- snd_display("delete_samples: %s %s?", fr, frames(nind, 0))
+ if framples(nind, 0) != fr - 1000
+ snd_display("delete_samples: %s %s?", fr, framples(nind, 0))
end
revert_sound(nind)
close_sound(nind)
@@ -20372,10 +18870,10 @@ def test_08_18
mus_header_type_name(res1),
mus_header_type_name(res2))
end
- if (res1 = data_format(nind)) != (res2 = default_output_data_format)
- snd_display("new_sound default data_format: %s %s?",
- mus_data_format_name(res1),
- mus_data_format_name(res2))
+ if (res1 = sample_type(nind)) != (res2 = default_output_sample_type)
+ snd_display("new_sound default sample_type: %s %s?",
+ mus_sample_type_name(res1),
+ mus_sample_type_name(res2))
end
if (res1 = channels(nind)) != (res2 = default_output_chans)
snd_display("new_sound default chans: %s %s?", res1, res2)
@@ -20388,7 +18886,8 @@ def test_08_18
end
def test_08_19
- nind = new_sound("fmv.snd", Mus_nist, Mus_bshort, 22050, 1, "this is a comment")
+ nind = new_sound("fmv.snd", 1, 22050, Mus_bshort, Mus_nist,
+ "this is a comment")
set_sample(0, 1.0, nind)
start_progress_report(nind)
convolve_with("oboe.snd")
@@ -20422,9 +18921,10 @@ def test_08_19
revert_sound(nind)
close_sound(nind)
#
- nind = new_sound("fmv.snd", Mus_riff, Mus_lshort, 22050, 1, "this is a comment", 22050)
- if frames(nind) != 22050
- snd_display("new_sound initial_length: %s?", frames(nind))
+ nind = new_sound("fmv.snd", 1, 22050, Mus_lshort, Mus_riff,
+ "this is a comment", 22050)
+ if framples(nind) != 22050
+ snd_display("new_sound initial_length: %s?", framples(nind))
end
mix("pistol.snd")
map_chan(expsrc(2.0, nind))
@@ -20479,14 +18979,6 @@ def test_08_19
close_sound(nind)
end
-def mus_mix_1(outf, inf, outloc = 0, frms = false, inloc = 0, mx = false, envs = false)
- unless number?(frms)
- frms = mus?(inf) ? mus_length(inf) : mus_sound_frames(inf)
- end
- mus_mix(outf, inf, outloc, frms, inloc, mx, envs)
- mus?(outf) and mus_close(outf)
-end
-
def test_08_20
make_mix_output = lambda do |name, i|
if i == 0 or i == 1
@@ -20499,160 +18991,13 @@ def test_08_20
if i == 0 or i == 2
name
else
- make_file2frame(name)
- end
- end
- 4.times do |k|
- delete_files("fmv.snd", "fmv1.snd", "fmv2.snd", "fmv3.snd")
- v0 = make_vct(12)
- vct_fill!(v0, 0.1)
- array2file("fmv1.snd", v0, 12, 22050, 1)
- vct_fill!(v0, 0.2)
- array2file("fmv2.snd", v0, 12, 22050, 2)
- file2array("fmv2.snd", 0, 0, 12, v0)
- vct_fill!(v0, 0.3)
- array2file("fmv3.snd", v0, 12, 22050, 4)
- v0.map_with_index! do |val, i| i * 0.01 end
- array2file("fmv.snd", v0, 12, 22050, 1)
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("fmv1.snd", k))
- file2array("fmv.snd", 0, 0, 12, v0)
- v0.each_with_index do |val, i|
- if fneq(val, 0.1 + i * 0.01)
- snd_display("%s mus_mix(1->1): %s?", k, v0)
- break
- end
- end
- mus_mix_1(make_mix_output.call("fmv.snd", k),
- make_mix_input.call("fmv2.snd", k),
- 3, 9, 0, make_mixer(2, 0.3, 0.0, 0.7, 0.0))
- file2array("fmv.snd", 0, 0, 12, v0)
- if fneq(v0[0], 0.1) or fneq(v0[3], 0.33) or fneq(v0[9], 0.19)
- snd_display("%s mus_mix(2->1): %s?", k, v0)
- end
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("fmv3.snd", k))
- file2array("fmv.snd", 0, 0, 12, v0)
- if fneq(v0[0], 0.4) or fneq(v0[3], 0.33)
- snd_display("%s mus_mix(4->1): %s?", k, v0)
- end
- vf = make_array(1) do
- make_array(1) do
- make_env(:envelope, [0, 0, 1, 1], :length, 11)
- end
- end
- mus_mix_1(make_mix_output.call("fmv.snd", k),
- make_mix_input.call("fmv1.snd", k),
- 0, 12, 0, make_mixer(1, 1.0), vf)
- file2array("fmv.snd", 0, 0, 12, v0)
- if fneq(v0[0], 0.4) or fneq(v0[3], 0.36) or fneq(v0[9], 0.28)
- snd_display("%s mus_mix(env): %s?", k, v0)
- end
- mus_mix_1(make_mix_output.call("fmv.snd", k),
- make_mix_input.call("fmv2.snd", k),
- 0, 12, 0, make_mixer(2, 1.0, 1.0, 1.0, 1.0), vf)
- vf = make_array(2)
- vf1 = make_array(2)
- vf2 = make_array(2)
- vf[0] = vf1
- vf[1] = vf2
- vf1[0] = make_env(:envelope, [0, 0, 1, 1], :length, 10)
- vf2[1] = make_env(:envelope, [0, 0, 1, 1], :length, 10)
- mus_mix_1(make_mix_output.call("fmv.snd", k),
- make_mix_input.call("fmv2.snd", k),
- 0, 12, 0, make_mixer(2, 1.0, 1.0, 1.0, 1.0), vf)
- if (res = Snd.catch do
- vf[0] = make_oscil
- mus_mix_1(make_mix_output.call("fmv.snd", k),
- make_mix_input.call("fmv2.snd", k),
- 0, 12, 0, make_mixer(2, 1.0, 1.0, 1.0, 1.0), vf)
- end).first != :bad_type
- snd_display("%s mix w oscil-array: %s", k, res.inspect)
- end
- vf1[0] = make_env(:envelope, [0, 0, 1, 1], :length, 10)
- vf2[1] = make_env(:envelope, [0, 0, 1, 1], :length, 10)
- if (res = Snd.catch do
- vf1[0] = make_oscil
- vf2[1] = sqrt(-1.0)
- mus_mix_1(make_mix_output.call("fmv.snd", k),
- make_mix_input.call("fmv2.snd", k),
- 0, 12, 0, make_mixer(2, 1.0, 1.0, 1.0, 1.0), vf)
- end).first != :bad_type
- snd_display("%s mix w oscil-env: %s", k, res.inspect)
- end
- delete_file("fmv.snd")
- v0.map_with_index! do |val, i| i * 0.01 end
- array2file("fmv.snd", v0, 12, 22050, 4)
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("fmv1.snd", k))
- file2array("fmv.snd", 0, 0, 3, v0) # chan 0 start 0 len 3
- if fneq(v0[0], 0.1) or fneq(v0[2], 0.18)
- snd_display("%s mus_mix(1->4): %s?", k, v0)
- end
- mus_mix_1(make_mix_output.call("fmv.snd", k),
- make_mix_input.call("fmv2.snd", k),
- 0, 3, 0, make_mixer(2, 0.3, 0.0, 0.7, 0.0))
- file2array("fmv.snd", 0, 0, 3, v0)
- if fneq(v0[0], 0.3) or fneq(v0[2], 0.38)
- snd_display("%s mus_mix(2->4): %s?", k, v0)
- end
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("fmv3.snd", k), 0, 2, 0)
- file2array("fmv.snd", 0, 0, 3, v0)
- if fneq(v0[0], 0.6) or fneq(v0[2], 0.38)
- snd_display("%s mus_mix(4->4): %s?", k, v0)
+ make_file2frample(name)
end
- #
- delete_file("fmv.snd")
- v0 = make_vct(12)
- len = mus_sound_frames("oboe.snd")
- array2file("fmv.snd", v0, 12, 22050, 1)
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("oboe.snd", k))
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("oboe.snd", k),
- 0, len, 0, make_mixer(1, 0.5))
- egen = make_array(1)
- outv = make_array(1)
- outv[0] = egen
- egen[0] = make_env(:envelope, [0, 0, 1, 1], :length, len)
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("oboe.snd", k),
- 0, len, 0, false, outv)
- egen[0] = make_env(:envelope, [0, 1, 1, 0], :length, len)
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("oboe.snd", k),
- 0, len, 0, make_mixer(1, 1.0), outv)
- ind_oboe = open_sound("oboe.snd")
- ind_mix = open_sound("fmv.snd")
- unless vequal(res1 = channel2vct(1000, 10, ind_oboe),
- res2 = vct_scale!(channel2vct(1000, 10, ind_mix), 1.0 / 2.5))
- snd_display("%s mus_mix 1 chan:\n# %s\n# %s?", k, res1, res2)
- end
- close_sound(ind_oboe)
- close_sound(ind_mix)
- #
- delete_file("fmv.snd")
- v0 = make_vct(12)
- len = mus_sound_frames("2.snd")
- array2file("fmv.snd", v0, 12, 22050, 2)
- if (res = mus_sound_chans("fmv.snd")) != 2
- snd_display("%s array2file chans %s?", k, res)
- end
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("2.snd", k))
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("2.snd", k),
- 0, len, 0, make_mixer(2, 0.5, 0.0, 0.0, 0.5))
- egen0 = make_array(2)
- egen1 = make_array(2)
- outv = make_array(2)
- outv[0] = egen0
- outv[1] = egen1
- egen0[0] = make_env(:envelope, [0, 0, 1, 1], :length, len)
- egen1[1] = make_env(:envelope, [0, 0, 1, 1], :length, len)
- mus_mix_1(make_mix_output.call("fmv.snd", k), make_mix_input.call("2.snd", k),
- 0, len, 0, false, outv)
- ind_mix = open_sound("fmv.snd")
- if channels(ind_mix) != 2
- snd_display("%s fmv re-read chans %s %s?", k, mus_sound_chans("fmv.snd"), channels(ind_mix))
- end
- close_sound(ind_mix)
- delete_file("fmv.snd")
end
end
def test_08_21
+ Snd.sounds.apply(:close_sound)
gen = make_phase_vocoder(false, 512, 4, 256, 1.0, false, false, false)
if fneq((res = Snd.catch do phase_vocoder(gen) end).first, 0.0)
snd_display("simple no-in pv call: %s", res.inspect)
@@ -20661,8 +19006,9 @@ def test_08_21
snd_display("pv bad fft: %s?", res.inspect)
end
ind = open_sound("oboe.snd")
- pv = make_phase_vocoder(false, 512, 4, 128, 1.0, false, false, false)
rd = make_sampler(0)
+ pv = make_phase_vocoder(lambda do |dir| next_sample(rd) end,
+ 512, 4, 128, 1.0, false, false, false)
unless phase_vocoder?(pv)
snd_display("%s not phase_vocoder?", pv)
end
@@ -20675,7 +19021,7 @@ def test_08_21
snd_display("pv set outctr: %s?", res)
end
select_sound(ind)
- map_chan(lambda do |val| phase_vocoder(pv, lambda do |dir| next_sample(rd) end) end)
+ map_chan(lambda do |val| phase_vocoder(pv) end)
phase_vocoder_amp_increments(pv)[0] = 0.1
if fneq(res = phase_vocoder_amp_increments(pv)[0], 0.1)
snd_display("set_phase_vocoder_amp_increments: %s?", res)
@@ -20700,9 +19046,11 @@ def test_08_21
free_sampler(rd)
#
lastphases = make_vct(512)
- pv = make_phase_vocoder(false, 512, 4, 128, 1.0,
+ rd = make_sampler(0)
+ pv = make_phase_vocoder(lambda do |dir| next_sample(rd) end,
+ 512, 4, 128, 1.0,
false,
- lambda { |v|
+ lambda do |v|
n = mus_length(v)
d = mus_hop(v)
freqs = phase_vocoder_freqs(v)
@@ -20711,45 +19059,50 @@ def test_08_21
(n / 2).times do |k|
phasediff = freqs[k] - lastphases[k]
lastphases[k] = freqs[k]
- while phasediff > PI
+ if phasediff > PI
phasediff -= TWO_PI
- end
- while phasediff < -PI
- phasediff += TWO_PI
+ else
+ if phasediff < -PI
+ phasediff += TWO_PI
+ end
end
freqs[k] = 0.5 * (pscl * phasediff + k * kscl)
end
false
- },
+ end,
false)
- rd = make_sampler(0)
- map_chan(lambda do |val| phase_vocoder(pv, lambda do |dir| next_sample(rd) end) end)
+ map_chan(lambda do |val| phase_vocoder(pv) end)
undo_edit(1)
free_sampler(rd)
#
- pv = make_phase_vocoder(false, 512, 4, (128 * 2.0).to_i, 1.0, false, false, false)
rd = make_sampler(0)
- len = (2.0 * frames(ind)).to_i
- data = make_vct!(len) do phase_vocoder(pv, lambda do |dir| next_sample(rd) end) end
+ pv = make_phase_vocoder(lambda do |dir| next_sample(rd) end,
+ 512, 4, 128 * 2, 1.0, false, false, false)
+ len = 1000
+ data = make_vct!(len) do
+ phase_vocoder(pv)
+ end
set_samples(0, len, data)
undo_edit(1)
free_sampler(rd)
#
incalls = outcalls = 0
- pv = make_phase_vocoder(false,
+ rd = make_sampler(0)
+ pv = make_phase_vocoder(lambda do |dir| next_sample(rd) end,
512, 4, (128 * 2.0).to_i, 1.0,
- lambda { |v, infunc|
+ lambda do |v, infunc|
incalls += 1
true
- },
+ end,
false,
- lambda { |v|
+ lambda do |v|
outcalls += 1
0.0
- })
- rd = make_sampler(0)
- len = (2.0 * frames(ind)).to_i
- data = make_vct!(len) do phase_vocoder(pv, lambda do |dir| next_sample(rd) end) end
+ end)
+ len = 1000
+ data = make_vct!(len) do
+ phase_vocoder(pv)
+ end
set_samples(0, len, data)
undo_edit(1)
free_sampler(rd)
@@ -20757,23 +19110,27 @@ def test_08_21
snd_display("phase_vocoder incalls: %s, outcalls: %s?", incalls, outcalls)
end
set_mus_location(pv, mus_location(pv))
- if (res = Snd.catch do phase_vocoder(pv, lambda do |a, b| a end) end).first != :bad_arity
- snd_display("phase_vocoder bad input func: %s", res.inspect)
- end
if (res = Snd.catch do
- make_phase_vocoder(false, 512, 4, 256, 1.0, lambda do |a, b, c| false end, false, false)
+ make_phase_vocoder(false,
+ 512, 4, 256, 1.0,
+ lambda do |a, b, c| false end,
+ false,
+ false)
end).first != :bad_arity
snd_display("make_phase_vocoder bad analyze func: %s", res.inspect)
end
if (res = Snd.catch do
- make_phase_vocoder(false, 512, 4, 256, 1.0,
+ make_phase_vocoder(false,
+ 512, 4, 256, 1.0,
lambda do |a, b| 0.0 end,
- lambda do |a, b, c| false end, false)
+ lambda do |a, b, c| false end,
+ false)
end).first != :bad_arity
snd_display("make_phase_vocoder bad edit func: %s", res.inspect)
end
if (res = Snd.catch do
- make_phase_vocoder(false, 512, 4, 256, 1.0,
+ make_phase_vocoder(false,
+ 512, 4, 256, 1.0,
lambda do |a, b| 0.0 end,
lambda do |a| false end,
lambda do |a, b| 0 end)
@@ -20845,13 +19202,13 @@ def test_08_22
gen = make_ssb_am(440.0)
gen1 = make_ssb_am(440.0)
print_and_check(gen,
- "ssb-am",
- "ssb-am shift: up, sin/cos: 439.999975 Hz (0.000000 radians), order: 41",
- "ssb-am shift: up, sin/cos: 440.000000 Hz (0.000000 radians), order: 41",
- "ssb-am shift: up, sin/cos: 439.999969 Hz (0.000000 radians), order: 41")
+ "ssb-am",
+ "ssb-am shift: up, sin/cos: 439.999975 Hz (0.000000 radians), order: 41",
+ "ssb-am shift: up, sin/cos: 440.000000 Hz (0.000000 radians), order: 41",
+ "ssb-am shift: up, sin/cos: 439.999969 Hz (0.000000 radians), order: 41")
v0 = make_vct!(10) do ssb_am(gen, 0.0) end
v1 = make_vct(10)
- vct_map!(v1, lambda do | | ssb_am?(gen1) ? ssb_am(gen1, 0.0) : -1.0 end)
+ v1.map! do |x| ssb_am?(gen1) ? ssb_am(gen1, 0.0) : -1.0 end
unless vequal(v0, v1)
snd_display("map ssb_am: %s %s?", v0, v1)
end
@@ -20886,7 +19243,11 @@ def test_08_22
o2 = make_ssb_am_1(400.0)
100.times do |i|
inval = sin(0.1 * i)
- snd_test_neq(ssb_am_1(o2, inval), ssb_am(o1, inval), "ssb_am (up) at %d", i)
+ req = ssb_am(o1, inval)
+ res = ssb_am_1(o2, inval)
+ if snd_test_neq(res, req, "ssb_am (up) at %d", i)
+ break
+ end
end
#
o1 = make_ssb_am(400.0)
@@ -20894,21 +19255,33 @@ def test_08_22
100.times do |i|
inval = sin(0.1 * i)
fmval = sin(0.2 * i)
- snd_test_neq(ssb_am_1(o2, inval, fmval), ssb_am(o1, inval, fmval), "ssb_am + fm (up) at %d", i)
+ req = ssb_am(o1, inval, fmval)
+ res = ssb_am_1(o2, inval, fmval)
+ if snd_test_neq(res, req, "ssb_am + fm (up) at %d", i)
+ break
+ end
end
#
o1 = make_ssb_am(-100.0)
o2 = make_ssb_am_1(-100.0)
100.times do |i|
inval = random(1.0)
- snd_test_neq(ssb_am_1(o2, inval), ssb_am(o1, inval), "ssb_am (down) at %d", i)
+ req = ssb_am(o1, inval)
+ res = ssb_am_1(o2, inval)
+ if snd_test_neq(res, req, "ssb_am (down) at %d", i)
+ break
+ end
end
#
o1 = make_ssb_am(1000.0, 100)
o2 = make_ssb_am_1(1000.0, 100)
100.times do |i|
inval = random(1.0)
- snd_test_neq(ssb_am_1(o2, inval), ssb_am(o1, inval), "ssb_am (down) at %d", i)
+ req = ssb_am(o1, inval)
+ res = ssb_am_1(o2, inval)
+ if snd_test_neq(res, req, "ssb_am (down) at %d", i)
+ break
+ end
end
#
index = open_sound("pistol.snd")
@@ -20916,15 +19289,11 @@ def test_08_22
convolve_with("oboe.snd", false)
scl = maxamp
convolve_with("oboe.snd", scl, index, 0, 0)
- if ffneq(maxamp, scl) # okay
- snd_display("convolve_with amps: %s %s?", maxmap, scl)
- end
+ snd_test_any_neq(maxamp, scl, :ffequal?, "convolve_with amps")
close_sound(index)
reader = make_sampler(0, "pistol.snd")
10.times do |i|
- if fneq(data[i], next_sample(reader))
- snd_display("external reader trouble")
- end
+ snd_test_neq(data[i], next_sample(reader), "external reader trouble")
end
free_sampler(reader)
#
@@ -20932,53 +19301,43 @@ def test_08_22
iv = vct(0.1, 0.05, -0.2, 0.15, -1.5, 0.1, 0.01, 0.001, 0.0, 0.0)
tv = vct(0.1, 0.1, 0.2, 0.2, 1.5, 1.5, 1.5, 1.5, 0.1, 0.01)
ov = Vct.new(10) do |i| moving_max(gen, iv[i]) end
- unless vequal(tv, ov)
- snd_display("moving_max: %s %s", ov, tv)
- end
+ snd_test_neq(ov, tv, "moving_max")
g1 = make_moving_max(10)
1000.times do |i|
- if fneq(val = moving_max(g1, random(1.0)), pk = g1.data.peak)
- snd_display("moving_max[%s]: %s %s?", i, pk, val)
- end
+ snd_test_neq(moving_max(g1, random(1.0)), g1.data.peak, "moving_max[%d]", i)
end
#
- data = vct(1.0, 0.0, -1.1, 1.1001, 0.1, -1.1, 1.0, 1.0, 0.5, -0.01, 0.02, 0.0, 0.0, 0.0, 0.0)
+ data = vct(1, 0, -1.1, 1.1001, 0.1, -1.1, 1, 1, 0.5, -0.01, 0.02, 0, 0, 0, 0)
g = make_moving_max(3)
odata = Vct.new(15) do |i| moving_max(g, data[i]) end
- unless vequal(odata, vct(1, 1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1, 1, 0.5, 0.02, 0.02, 0, 0))
- snd_display("moving_max odata: %s?", odata)
- end
+ req = vct(1, 1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1, 1, 0.5, 0.02, 0.02, 0, 0)
+ snd_test_neq(odata, req, "moving_max")
if odata[4] == odata[7]
- snd_display("moving_max 0.0001 offset?")
+ snd_test_eq(odata[4], odata[7], "moving_max 0.0001 offset")
end
#
- odata = Vct.new(15, 0.0)
data = vct(0.1, -0.2, 0.3, 0.4, -0.5, 0.6, 0.7, 0.8, -0.9, 1.0, 0.0, 0.0)
g = make_moving_sum(3)
+ odata = Vct.new(15, 0.0)
data.each_with_index do |x, i| odata[i] = moving_sum(g, x) end
- unless vequal(odata, vct(0.1, 0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 1.9, 1, 0, 0, 0))
- snd_display("moving_sum odata: %s?", odata)
- end
+ req = vct(0.1, 0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 1.9, 1, 0, 0, 0)
+ snd_test_neq(odata, req, "moving_sum")
#
- odata = Vct.new(15, 0.0)
g = make_moving_rms(4)
+ odata = Vct.new(15, 0.0)
data.each_with_index do |x, i| odata[i] = moving_rms(g, x) end
- unless vequal(odata,
- vct(0.05, 0.112, 0.187, 0.274, 0.367, 0.464, 0.561,
- 0.66, 0.758, 0.857, 0.783, 0.673, 0, 0, 0))
- snd_display("moving_rms odata: %s?", odata)
- end
+ req = vct(0.05, 0.112, 0.187, 0.274, 0.367, 0.464, 0.561,
+ 0.66, 0.758, 0.857, 0.783, 0.673, 0, 0, 0)
+ snd_test_neq(odata, req, "moving_rms")
#
- odata = Vct.new(15, 0.0)
g = make_moving_length(4)
+ odata = Vct.new(15, 0.0)
data.each_with_index do |x, i| odata[i] = moving_length(g, x) end
- unless vequal(odata,
- vct(0.1, 0.224, 0.374, 0.548, 0.735, 0.927, 1.122,
- 1.319, 1.517, 1.715, 1.565, 1.345, 0, 0, 0))
- snd_display("moving_length odata: %s?", odata)
- end
+ req = vct(0.1, 0.224, 0.374, 0.548, 0.735, 0.927, 1.122,
+ 1.319, 1.517, 1.715, 1.565, 1.345, 0, 0, 0)
+ snd_test_neq(odata, req, "moving_length")
#
- 10.times do |i| data[i] = 0.5 - random(1.0) end
+ 10.times do |i| data[i] = mus_random(0.5) end
g = make_moving_length(4)
data.each_with_index do |x, i| odata[i] = moving_length(g, x) end
k = 0
@@ -20989,13 +19348,11 @@ def test_08_22
sum += data[i + j] * data[i + j]
end
end
- if fneq(odata[k], sqrt(sum))
- snd_display("moving_length ran: %s %s?", odata[k], sqrt(sum))
- end
+ snd_test_neq(odata[k], sqrt(sum), "moving_length ran")
k += 1
end
#
- 10.times do |i| data[i] = 0.5 - random(1.0) end
+ 10.times do |i| data[i] = mus_random(0.5) end
g = make_moving_sum(4)
data.each_with_index do |x, i| odata[i] = moving_sum(g, x) end
k = 0
@@ -21006,13 +19363,11 @@ def test_08_22
sum += data[i + j].abs
end
end
- if fneq(odata[k], sum)
- snd_display("moving_sum ran: %s %s?", odata[k], sum)
- end
+ snd_test_neq(odata[k], sum, "moving_sum ran")
k += 1
end
#
- 10.times do |i| data[i] = 0.5 - random(1.0) end
+ 10.times do |i| data[i] = mus_random(0.5) end
g = make_moving_rms(4)
data.each_with_index do |x, i| odata[i] = moving_rms(g, x) end
k = 0
@@ -21023,9 +19378,7 @@ def test_08_22
sum = sum + data[i + j] * data[i + j]
end
end
- if fneq(odata[k], sqrt(sum / 4.0))
- snd_display("moving_rms ran: %s %s?", odata[k], sqrt(sum / 4.0))
- end
+ snd_test_neq(odata[k], sqrt(sum / 4.0), "moving_rms ran")
k += 1
end
#
@@ -21034,11 +19387,13 @@ def test_08_22
close_sound(ind)
#
argslist = make_array(16) do [:frequency, 440.0] end.flatten
- [:make_wave_train, :make_polyshape, :make_delay, :make_moving_average, :make_comb,
- :make_filtered_comb, :make_notch,
- :make_rand, :make_rand_interp, :make_table_lookup, :make_env,
- :make_readin, :make_locsig, :make_granulate, :make_convolve, :make_phase_vocoder].each do |make|
- if (res = Snd.catch do argslist.apply(:snd_func, make) end).first != :mus_error
+ [:make_wave_train, :make_polyshape, :make_delay,
+ :make_moving_average, :make_comb, :make_filtered_comb,
+ :make_notch, :make_rand, :make_rand_interp, :make_table_lookup,
+ :make_env, :make_readin, :make_locsig, :make_granulate,
+ :make_convolve, :make_phase_vocoder].each do |make|
+ res = Snd.catch do argslist.apply(:snd_func, make) end
+ if res.first != :mus_error
snd_display("long arglist to %s: %s", make, res.inspect)
end
end
@@ -21092,55 +19447,42 @@ def test_08_22
end
end
end
- f1 = make_frame(2, 0.1, 0.2)
- f2 = make_frame(2, 0.3, 0.5)
- f3 = make_frame(2, 0, 0)
- f4 = frame_add(f1, f2, f3)
- if f3 != f4
- snd_display("frame_add data !=: %s %s?", f3, f4)
- end
- f4 = frame_multiply(f1, f2, f3)
- if f3 != f4
- snd_display("frame_multiply data !=: %s %s?", f3, f4)
- end
end
def test_08_23
- [[:all_pass, false, 0.0, false],
- [:asymmetric_fm, false, 0.0, false],
+ [[:all_pass, false, 0.0, false],
+ [:asymmetric_fm, false, 0.0, false],
[:moving_average, false, 1.0, false],
- [:comb, false, 0.0, false],
- [:convolve, [:filter, vct(0, 1, 2)], lambda { |dir| 0.0 }, false],
- [:delay, false, 0.0, false],
- [:env, [:envelope, [0, 1, 1, 0]], false, false],
- [:filter, [:xcoeffs, vct(0, 1, 2)], 0.0, false],
- [:filter, [:ycoeffs, vct(0, 1, 2)], 0.0, false],
- [:filter, [:xcoeffs, vct(1, 2, 3), :ycoeffs, vct(0, 1, 2)], 0.0, false],
- [:fir_filter, [:xcoeffs, vct(0, 1, 2)], 0.0, false],
- [:formant, false, 0.0, false],
- [:frame, [3], 0, lambda { |gen, ind| frame_ref(gen, ind) }, false],
- [:granulate, false, lambda { |dir| 0.0 }, false],
- [:iir_filter, [:ycoeffs, vct(0, 1, 2)], 0.0, false],
- [:locsig, false, 0.0, lambda { |gen, a| locsig(gen, 0, a) }],
- [:mixer, [3, 3], 0, lambda { |gen, a| mixer_ref(gen, a, 0) }],
- [:notch, false, 0.0, false],
- [:one_pole, false, 0.0, false],
- [:one_zero, false, 0.0, false],
- [:oscil, false, 0.0, false],
- [:pulse_train, false, 0.0, false],
- [:rand, false, 0.0, false],
- [:rand_interp, false, 0.0, false],
- [:sawtooth_wave, false, 0.0, false],
- [:square_wave, false, 0.0, false],
- [:src, false, lambda { |dir| 0.0 }, lambda { |gen, a| src(gen, 0.0, a) }],
- [:table_lookup, false, 0.0, false],
- [:triangle_wave, false, 0.0, false],
- [:two_pole, false, 0.0, false],
- [:two_zero, false, 0.0, false],
- [:wave_train, false, 0.0, false],
- [:polyshape, false, 0.0, false],
- [:phase_vocoder, false, lambda { |dir| 0.0 }, false],
- [:ssb_am, false, 0.0, false]].each do |name_sym, make_args, arg, run_func|
+ [:comb, false, 0.0, false],
+ [:convolve, [:filter, vct(0, 1, 2)], lambda { |dir| 0.0 }, false],
+ [:delay, false, 0.0, false],
+ [:env, [:length, 11, :envelope, [0, 1, 1, 0]], false, false],
+ [:filter, [:xcoeffs, vct(0, 1, 2)], 0.0, false],
+ [:filter, [:ycoeffs, vct(0, 1, 2)], 0.0, false],
+ [:filter, [:xcoeffs, vct(1, 2, 3), :ycoeffs, vct(0, 1, 2)], 0.0, false],
+ [:fir_filter, [:xcoeffs, vct(0, 1, 2)], 0.0, false],
+ [:formant, false, 0.0, false],
+ [:granulate, false, lambda { |dir| 0.0 }, false],
+ [:iir_filter, [:ycoeffs, vct(0, 1, 2)], 0.0, false],
+ [:locsig, false, 0.0, lambda { |gen, a| locsig(gen, 0, a) }],
+ [:notch, false, 0.0, false],
+ [:one_pole, false, 0.0, false],
+ [:one_zero, false, 0.0, false],
+ [:oscil, false, 0.0, false],
+ [:pulse_train, false, 0.0, false],
+ [:rand, false, 0.0, false],
+ [:rand_interp, false, 0.0, false],
+ [:sawtooth_wave, false, 0.0, false],
+ [:square_wave, false, 0.0, false],
+ [:src, false, lambda { |dir| 0.0 }, lambda { |gen, a| src(gen, 0.0, a) }],
+ [:table_lookup, false, 0.0, false],
+ [:triangle_wave, false, 0.0, false],
+ [:two_pole, false, 0.0, false],
+ [:two_zero, false, 0.0, false],
+ [:wave_train, false, 0.0, false],
+ [:polyshape, false, 0.0, false],
+ [:phase_vocoder, false, lambda { |dir| 0.0 }, false],
+ [:ssb_am, false, 0.0, false]].each do |name_sym, make_args, arg, run_func|
gen = if make_args
snd_func(format("make_%s", name_sym), *make_args)
else
@@ -21150,9 +19492,13 @@ def test_08_23
snd_display("%s: %s?", name_sym, gen)
end
tag = if proc?(run_func)
- Snd.catch do arg ? run_func.call(gen, arg) : run_func.call(gen) end.first
+ Snd.catch do
+ arg ? run_func.call(gen, arg) : run_func.call(gen)
+ end.first
else
- Snd.catch do arg ? snd_func(name_sym, gen, arg) : snd_func(name_sym, gen) end.first
+ Snd.catch do
+ arg ? snd_func(name_sym, gen, arg) : snd_func(name_sym, gen)
+ end.first
end
if (not number?(tag)) and (not frame?(tag))
snd_display("%s (make_gen, gen, gen? test): %s %s?", name_sym, arg, tag)
@@ -21206,42 +19552,49 @@ def test_08_23
set_tag != :wrong_type_arg and
set_tag != :no_method_error
snd_display("%s.%s= tag: %s set_tag: %s?",
- name_sym, func_sym.to_s[4..-1], tag.inspect, set_tag.inspect)
+ name_sym,
+ func_sym.to_s[4..-1],
+ tag.inspect,
+ set_tag.inspect)
end
end
end
end
#
- functions = [[:all_pass, false, false],
- [:asymmetric_fm, false, false],
- [:moving_average, false, false],
- [:comb, false, false],
- [:filtered_comb, [:filter, make_one_zero(0.5, 0.5)], false],
- [:convolve, [:filter, vct(0, 1, 2), :input, lambda { |dir| 1.0 }], false],
- [:delay, false, false],
- [:env, [:envelope, [0, 1, 1, 0], :length, 11], lambda { |gen, ignored| env(gen) }],
- [:filter, [:xcoeffs, vct(0, 1, 2)], false],
- [:filter, [:ycoeffs, vct(0, 1, 2)], false],
- [:filter, [:xcoeffs, vct(1, 2, 3), :ycoeffs, vct(0, 1, 2)], false],
- [:fir_filter, [:xcoeffs, vct(0, 1, 2)], false],
- [:formant, [:radius, 0.1, :frequency, 440.0], false],
- [:granulate, [:input, lambda { |dir| 1.0 }], false],
- [:iir_filter, [:xcoeffs, vct(0, 1, 2)], false],
- [:locsig, false, lambda { |gen, a| locsig(gen, 0, 1.0) }],
- [:notch, false, false],
- [:one_pole, [0.3, 0.7], false],
- [:one_zero, [0.5, 0.5], false],
- [:oscil, false, false],
- [:pulse_train, false, false],
- [:sawtooth_wave, false, false],
- [:square_wave, false, false],
- [:table_lookup, [:wave, make_vct(128, 0.1)], false],
- [:triangle_wave, false, false],
- [:two_pole, [0.1, 0.3, 0.6], false],
- [:two_zero, [0.1, 0.3, 0.5], false],
- [:polyshape, [:frequency, 440.0, :partials, [1, 1]], false],
- [:phase_vocoder, [lambda { |dir| 1.0 }], false],
- [:ssb_am, false, false]]
+ functions = [
+ [:all_pass, false, false],
+ [:asymmetric_fm, false, false],
+ [:moving_average, false, false],
+ [:comb, false, false],
+ [:filtered_comb, [:filter, make_one_zero(0.5, 0.5)], false],
+ [:convolve,
+ [:filter, vct(0, 1, 2), :input, lambda { |dir| 1.0 }], false],
+ [:delay, false, false],
+ [:env,
+ [:envelope, [0, 1, 1, 0], :length, 11],
+ lambda { |gen, ignored| env(gen) }],
+ [:filter, [:xcoeffs, vct(0, 1, 2)], false],
+ [:filter, [:ycoeffs, vct(0, 1, 2)], false],
+ [:filter, [:xcoeffs, vct(1, 2, 3), :ycoeffs, vct(0, 1, 2)], false],
+ [:fir_filter, [:xcoeffs, vct(0, 1, 2)], false],
+ [:formant, [:radius, 0.1, :frequency, 440.0], false],
+ [:granulate, [:input, lambda { |dir| 1.0 }], false],
+ [:iir_filter, [:xcoeffs, vct(0, 1, 2)], false],
+ [:locsig, false, lambda { |gen, a| locsig(gen, 0, 1.0) }],
+ [:notch, false, false],
+ [:one_pole, [0.3, 0.7], false],
+ [:one_zero, [0.5, 0.5], false],
+ [:oscil, false, false],
+ [:pulse_train, false, false],
+ [:sawtooth_wave, false, false],
+ [:square_wave, false, false],
+ [:table_lookup, [:wave, make_vct(128, 0.1)], false],
+ [:triangle_wave, false, false],
+ [:two_pole, [0.1, 0.3, 0.6], false],
+ [:two_zero, [0.1, 0.3, 0.5], false],
+ [:polyshape, [:frequency, 440.0, :partials, [1, 1]], false],
+ [:phase_vocoder, [lambda { |dir| 1.0 }], false],
+ [:ssb_am, false, false]]
functions.each do |name_sym, make_args, run_func|
gen = if make_args
snd_func(format("make_%s", name_sym), *make_args)
@@ -21259,22 +19612,25 @@ def test_08_23
mus_reset(gen)
unless proc?(run_func)
not_zero = false
- first_val = k.zero? ? snd_func(name_sym, gen, 1.0) : mus_apply(gen, 1.0, 0.0)
+ first_val = k.zero? ?
+ snd_func(name_sym, gen, 1.0) : mus_apply(gen, 1.0, 0.0)
if data[0] != 0.0
not_zero = true
end
if fneq(data[0], first_val)
- snd_display("[%s] %s: 0 %s %s?", k.zero? ? :run : :apply, name_sym, data[0], first_val)
+ snd_display("[%s] %s: 0 %s %s?",
+ k.zero? ? :run : :apply, name_sym, data[0], first_val)
end
(1...10).each do |i|
old_val = data[i]
- new_val = k.zero? ? snd_func(name_sym, gen, 0.0) : mus_apply(gen, 0.0, 0.0)
+ new_val = k.zero? ?
+ snd_func(name_sym, gen, 0.0) : mus_apply(gen, 0.0, 0.0)
if old_val != 0.0
not_zero = true
end
if fneq(old_val, new_val)
snd_display("[%s] %s: %s %s %s?",
- k.zero? ? :run : :apply, name_sym, i, old_val, new_val)
+ k.zero? ? :run : :apply, name_sym, i, old_val, new_val)
end
end
unless not_zero
@@ -21298,7 +19654,6 @@ def test_08_23
sqrt(-1.0),
make_delay(32),
lambda do || true end,
- make_sound_data(2, 3),
0,
1,
-1,
@@ -21342,36 +19697,40 @@ def test_08_23
end
def test_08_24
- random_args = [2.0 ** 21.5,
- 2.0 ** -18.0,
- 1.5,
- "/hiho",
- [0, 1],
- 1234,
- # FIXME
- # make_vct(3) removed from list because:
- # if $all_args is true
- # 0x08096617 in print_vct (obj=Cannot access memory at address 0xbf003038)
- # make_vct(3),
- make_color_with_catch(0.1, 0.2, 0.3),
- sqrt(-1.0),
- make_delay(32),
- lambda do || 0.0 end,
- lambda do |dir| 1.0 end,
- lambda do |a, b, c| 1.0 end,
- 0,
- 1,
- -1,
- false,
- true,
- 0.0,
- 1.0,
- -1.0,
- []]
+ random_args = [
+ 2.0 ** 21.5,
+ 2.0 ** -18.0,
+ 1.5,
+ "/hiho",
+ [0, 1],
+ 1234,
+ make_vct(3),
+ make_color_with_catch(0.1, 0.2, 0.3),
+ [0, 1],
+ Rational(3, 4),
+ Complex(0, 1), #sqrt(-1.0),
+ make_delay(32),
+ lambda do || 0.0 end,
+ lambda do |dir| 1.0 end,
+ lambda do |a, b, c| 1.0 end,
+ 0,
+ 1,
+ -1,
+ false,
+ true,
+ key_to_int(?c),
+ 0.0,
+ 1.0,
+ -1.0,
+ [],
+ 32,
+ [1, 2]]
random_gen = lambda do |*args|
[:make_all_pass,
:make_asymmetric_fm,
:make_moving_average,
+ :make_moving_max,
+ :make_moving_norm,
:make_table_lookup,
:make_triangle_wave,
:make_comb,
@@ -21382,15 +19741,13 @@ def test_08_24
:make_filtered_comb,
:make_fir_filter,
:make_formant,
- :make_frame,
:make_iir_filter,
:make_locsig,
- :make_mixer,
:make_notch,
:make_one_pole,
+ :make_one_pole_all_pass,
:make_one_zero,
:make_oscil,
- :make_ppolar,
:make_pulse_train,
:make_rand,
:make_rand_interp,
@@ -21401,20 +19758,16 @@ def test_08_24
:make_two_pole,
:make_two_zero,
:make_wave_train,
- :make_zpolar,
:make_ssb_am].each do |make_func|
- if mus_generator?(gen = Snd.catch do
- snd_func(make_func, *args)
- end.first)
+ gen = Snd.catch do snd_func(make_func, *args) end.first
+ if mus_generator?(gen)
random_args.each do |arg|
- Snd.catch do
- gen.run(arg)
- end
+ Snd.catch do gen.call(arg) end
end
end
end
end
- random_gen.call([])
+ random_gen.call()
random_args.each do |arg1|
random_gen.call(arg1)
random_args.each do |arg2|
@@ -21441,7 +19794,6 @@ def test_08
test_08_04
test_08_05
test_08_06
- test_08_07
test_08_08
test_08_09
test_08_10
@@ -21464,7 +19816,7 @@ end
# ---------------- test 09: mix ----------------
def test_09_00
- new_index = new_sound("hiho.wave", Mus_next, Mus_bshort, 22050, 1)
+ new_index = new_sound("hiho.wave", 1, 22050, Mus_bshort, Mus_next)
select_sound(new_index)
if res = find_mix(0, new_index, 0)
snd_display("found non-existent mix: %s?", res)
@@ -21660,9 +20012,9 @@ def test_09_00
end
def test_09_02
- ind = new_sound("fmv.snd", Mus_next, Mus_bshort, 22050, 1, "mix tests")
+ ind = new_sound("fmv.snd", 1, 22050, Mus_bshort, Mus_next, "mix tests")
insert_silence(0, 20, ind)
- indout = new_sound("test.snd", Mus_next, Mus_bshort, 22050, 1, "mix tests")
+ indout = new_sound("test.snd", 1, 22050, Mus_bshort, Mus_next, "mix tests")
insert_silence(0, 10, indout)
set_sample(2, 0.5, indout, 0)
set_sample(5, 0.25, indout, 0)
@@ -21704,7 +20056,7 @@ def test_09_02
snd_display("mix 1->1 at 0 tag: %s?", tag)
end
undo_edit
- indout = new_sound("test.snd", Mus_next, Mus_bshort, 22050, 2, "mix tests")
+ indout = new_sound("test.snd", 2, 22050, Mus_bshort, Mus_next, "mix tests")
insert_silence(0, 10, indout, 0)
insert_silence(0, 10, indout, 1)
set_sample(2, 0.5, indout, 0)
@@ -21739,7 +20091,7 @@ def test_09_02
undo_edit
close_sound(ind)
#
- ind = new_sound("fmv.snd", Mus_next, Mus_bshort, 22050, 2, "mix tests")
+ ind = new_sound("fmv.snd", 2, 22050, Mus_bshort, Mus_next, "mix tests")
insert_silence(0, 20, ind, 0)
insert_silence(0, 20, ind, 1)
tag = mix("test.snd", 0, true).car
@@ -21778,7 +20130,7 @@ def test_09_02
end
undo_edit(1, ind, 1)
set_sync(1, ind)
- tag = mix("test.snd", 0, true).car
+ mix("test.snd", 0, true).car
samps0 = channel2vct(0, 20, ind, 0)
samps1 = channel2vct(0, 20, ind, 1)
v = make_vct(20)
@@ -21793,22 +20145,6 @@ def test_09_02
snd_display("mix 1->1 (7): %s %s?", samps1, v)
end
undo_edit
- set_cursor(5, ind)
- tag = mix("test.snd", cursor, true).car
- samps0 = channel2vct(0, 20, ind, 0)
- samps1 = channel2vct(0, 20, ind, 1)
- v = make_vct(20)
- v[7] = 0.5
- v[10] = 0.25
- unless vequal(samps0, v)
- snd_display("mix 1->1 (8): %s %s?", samps0, v)
- end
- v[7] = 0.95
- v[10] = 0.125
- unless vequal(samps1, v)
- snd_display("mix 1->1 (9): %s %s?", samps1, v)
- end
- undo_edit
close_sound(ind)
delete_files("test.snd", "fmv.snd")
#
@@ -22040,50 +20376,8 @@ def test_09_03
snd_display("mix_amp no-op: %s %s?", mix_amp_env(id), res)
end
close_sound(ind)
- #
- if $with_test_motif
- ind = open_sound("oboe.snd")
- mix1 = mix_vct([0.1, 0.2, 0.3].to_vct, 120, ind, 0, true, "origin!")
- mix2 = mix_vct([0.1, 0.2, 0.3].to_vct, 1200, ind, 0, true)
- mix3 = mix_vct([0.1, 0.2, 0.3].to_vct, 12000, ind, 0, true)
- unless mixes(ind, 0) == [mix1, mix2, mix3]
- snd_display("mixes: %s %s?", mixes(ind, 0), [mix1, mix2, mix3])
- end
- unless mixes == [[[mix1, mix2, mix3]]]
- snd_display("mixes all: %s %s?", mixes, [[[mix1, mix2, mix3]]])
- end
- view_mixes_dialog
- set_mix_dialog_mix(mix1)
- mixd = dialog_widgets[16]
- if widget?(nxt = Snd.catch(:no_such_widget) do find_child(mixd, "Next") end.first)
- if widget?(prev = Snd.catch(:no_such_widget) do find_child(mixd, "Previous") end.first)
- force_event
- if (not RXtIsSensitive(nxt)) or RXtIsSensitive(prev)
- snd_display("mix_dialog next/previous: %s %s %s %s?",
- nxt, RXtIsSensitive(nxt), prev, RXtIsSensitive(prev))
- end
- click_button(nxt)
- force_event
- click_button(nxt)
- force_event
- if RXtIsSensitive(nxt) or (not RXtIsSensitive(prev))
- snd_display("mix_dialog next/previous: %s %s %s %s?",
- nxt, RXtIsSensitive(nxt), prev, RXtIsSensitive(prev))
- end
- click_button(prev)
- force_event
- click_button(prev)
- force_event
- else
- snd_display("find_child cannot find Previous: %s?", prev.inspect)
- end
- else
- snd_display("find_child cannot find Next: %s?", nxt.inspect)
- end
- close_sound(ind)
- end
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1, "lock mix tests", 300)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next, "lock mix tests", 300)
mix1 = mix_vct(Vct.new(10, 0.5), 10)
set_mix_amp(mix1, 0.0)
if fneq(res = maxamp(ind, 0), 0.0)
@@ -22116,7 +20410,7 @@ def test_09_04
set_with_mix_tags(true)
ind = open_sound("oboe.snd")
mx = mix_vct(Vct.new(100, 0.1), 1000)
- fr = mus_sound_frames("1a.snd")
+ fr = mus_sound_framples("1a.snd")
[[lambda do pad_channel(0, 100) end, 1100, false, :pad0],
[lambda do pad_channel(0, 2000) end, 3000, false, :pad20],
[lambda do pad_channel(800, 100) end, 1100, false, :pad800],
@@ -22267,10 +20561,10 @@ def data_max(beg, fin)
maxval = 0.0
Snd.sounds.each do |snd|
channels(snd).times do |chn|
- scan_chan(lambda do |data|
- maxval = [maxval, data.abs].max
- false
- end, 0, false, snd, chn)
+ scan_channel(lambda do |data|
+ maxval = [maxval, data.abs].max
+ false
+ end, 0, false, snd, chn)
end
end
maxval
@@ -22279,26 +20573,28 @@ end
def data_max2(beg, fin, snd)
maxval = 0.0
channels(snd).times do |chn|
- scan_chan(lambda do |data|
- maxval = [maxval, data.abs].max
- false
- end, 0, false, snd, chn)
+ scan_channel(lambda do |data|
+ maxval = [maxval, data.abs].max
+ false
+ end, 0, false, snd, chn)
end
maxval
end
def data_max1(beg, fin, snd, chn)
maxval = 0.0
- scan_chan(lambda do |data|
- maxval = [maxval, data.abs].max
- false
- end, beg, fin, snd, chn)
+ scan_channel(lambda do |data|
+ maxval = [maxval, data.abs].max
+ false
+ end, beg, fin, snd, chn)
maxval
end
def test_10_00
- ind0 = new_sound("fmv.snd", Mus_aifc, Mus_bshort, 22050, 2, "this is a comment")
- ind1 = new_sound("fmv1.snd", Mus_aifc, Mus_bshort, 22050, 1, "this is a comment")
+ ind0 = new_sound("fmv.snd", 2, 22050, Mus_bshort, Mus_aifc,
+ "this is a comment")
+ ind1 = new_sound("fmv1.snd", 1, 22050, Mus_bshort, Mus_aifc,
+ "this is a comment")
v0 = make_array(10, 1.0)
set_sync(123, ind0)
set_sync(123, ind1)
@@ -22362,7 +20658,8 @@ def test_10_00
close_sound(ind0)
close_sound(ind1)
#
- ind0 = new_sound("fmv.snd", Mus_aifc, Mus_bshort, 22050, 1, "this is a comment")
+ ind0 = new_sound("fmv.snd", 1, 22050, Mus_bshort, Mus_aifc,
+ "this is a comment")
v0 = Vct.new(10, 0.1)
old5 = sample(5, ind0)
insert_samples(10, 10, v0, ind0)
@@ -22389,8 +20686,10 @@ def test_10_00
end
close_sound(ind0)
#
- ind0 = new_sound("fmv.snd", Mus_aifc, Mus_bshort, 22050, 2, "this is a comment")
- ind1 = new_sound("fmv1.snd", Mus_next, Mus_bshort, 22050, 1, "this is a comment")
+ ind0 = new_sound("fmv.snd", 2, 22050, Mus_bshort, Mus_aifc,
+ "this is a comment")
+ ind1 = new_sound("fmv1.snd", 1, 22050, Mus_bshort, Mus_next,
+ "this is a comment")
insert_samples(0, 10, make_array(10, 1.00), ind0, 0)
insert_samples(0, 10, make_array(10, 0.10), ind0, 1)
insert_samples(0, 10, make_array(10, 0.01), ind1, 0)
@@ -22417,7 +20716,8 @@ def test_10_00
end
def test_10_01
- ind0 = new_sound("fmv.snd", Mus_aifc, Mus_bshort, 22050, 2, "this is a comment")
+ ind0 = new_sound("fmv.snd", 2, 22050, Mus_bshort, Mus_aifc,
+ "this is a comment")
mix("oboe.snd")
m1 = add_mark(100)
delete_sample(10)
@@ -22623,10 +20923,10 @@ def test_10_01
end
close_sound(fd)
fd = open_sound("oboe.snd")
- m1 = add_mark(1000)
- m2 = add_mark(2500)
- m3 = add_mark(frames - 4000)
- ms = marks(fd, 0)
+ add_mark(1000)
+ add_mark(2500)
+ add_mark(framples - 4000)
+ marks(fd, 0)
src_sound(-0.5)
unless (res1 = marks(fd, 0)) == (res2 = marks(fd, 0, 0).reverse)
snd_display("src rev marks: %s %s?", res1.inspect, res2.inspect)
@@ -22815,8 +21115,8 @@ def test_10_02
if selection_position != 123
snd_display("selection_position 123: %s?", selection_position)
end
- if selection_frames != 112
- snd_display("selection_frames 112: %s?", selection_frames)
+ if selection_framples != 112
+ snd_display("selection_framples 112: %s?", selection_framples)
end
end
m1 = add_mark(1000, ind, 0)
@@ -22832,8 +21132,8 @@ def test_10_02
if selection_position != 1000
snd_display("selection_position 1000: %s?", selection_position)
end
- if selection_frames != 1001
- snd_display("selection_frames 1001: %s?", selection_frames)
+ if selection_framples != 1001
+ snd_display("selection_framples 1001: %s?", selection_framples)
end
end
set_selection_member?(false, true)
@@ -22842,7 +21142,7 @@ def test_10_02
end
set_selection_member?(true, ind, 0)
set_selection_position(2000, ind, 0)
- set_selection_frames(1234, ind, 0)
+ set_selection_framples(1234, ind, 0)
snap_marks
unless mark?(m1 = find_mark(2000, ind, 0))
snd_display("snap_marks start: %s?", Snd.marks(ind, 0).map do |m| mark_sample(m) end)
@@ -22850,9 +21150,9 @@ def test_10_02
unless mark?(m2 = find_mark(2000 + 1234, ind, 0))
snd_display("snap_marks end: %s?", Snd.marks(ind, 0).map do |m| mark_sample(m) end)
end
- set_selection_position(frames(ind, 0) + 1234, ind, 0)
- if (res = selection_position(ind, 0)) != frames(ind) - 1
- snd_display("selection_position past eof: %s %s?", res, frames(ind) - 1)
+ set_selection_position(framples(ind, 0) + 1234, ind, 0)
+ if (res = selection_position(ind, 0)) != framples(ind) - 1
+ snd_display("selection_position past eof: %s %s?", res, framples(ind) - 1)
end
revert_sound(ind)
src_sound([0, 0.5, 1, 1.75665])
@@ -22886,7 +21186,7 @@ def test_10_02
end
case random(15)
when 0
- beg = random(frames)
+ beg = random(framples)
dur = [1, random(100)].max
insert_silence(beg, dur)
if current_marks and (not current_marks.empty?)
@@ -22919,7 +21219,7 @@ def test_10_02
snd_display("scaling changed mark locations: %s %s?", res, current_samples)
end
when 4
- set_sample(random(frames - 1), 0.5)
+ set_sample(random(framples - 1), 0.5)
unless (res = Snd.marks(ind, 0)) == current_marks
snd_display("set_sample changed marks: %s %s?", res, current_marks)
end
@@ -22927,7 +21227,7 @@ def test_10_02
snd_display("set_sample changed mark location: %s %s?", res, current_samples)
end
when 5
- beg = random(frames)
+ beg = random(framples)
dur = [1, random(100)].max
len = beg + dur
delete_samples(beg, dur)
@@ -22960,7 +21260,7 @@ def test_10_02
end
end
when 8
- rate = (frames > 200000) ? 2.0 : 0.5
+ rate = (framples > 200000) ? 2.0 : 0.5
src_channel(rate)
if current_marks and (not current_marks.empty?)
current_marks.zip(current_samples) do |id, old_loc|
@@ -22980,15 +21280,15 @@ def test_10_02
unless mark?(id)
snd_display("reverse_channel clobbered mark: %s?", id)
else
- if ((frames - old_loc) - (res = mark_sample(id))).abs > 2
+ if ((framples - old_loc) - (res = mark_sample(id))).abs > 2
snd_display("reverse_channel moved mark: %s %s %s (%s)?",
- id, old_loc, frames - old_loc, res)
+ id, old_loc, framples - old_loc, res)
end
end
end
end
else
- add_mark(random(frames - 1))
+ add_mark(random(framples - 1))
end
end
close_sound(ind)
@@ -23038,9 +21338,9 @@ def test_10_02
$draw_mark_hook.add_hook!("snd-test") do |id| true end
m0 = add_mark(4321)
m1 = add_mark(1234)
- dur = frames(ind) / srate(ind).to_f
+ dur = framples(ind) / srate(ind).to_f
pad_marks([m0, m1], 0.01)
- if fneq(res = frames(ind) / srate(ind).to_f, dur + 0.02)
+ if fneq(res = framples(ind) / srate(ind).to_f, dur + 0.02)
snd_display("pad_marks: %s %s?", dur, res)
end
if mark_sample(m0) != 4763 and mark_sample(m0) != 4761
@@ -23054,9 +21354,9 @@ def test_10_02
#
ind = open_sound("oboe.snd")
if res = find_mark(12345)
- snd_display("find_mark when no mark: %s?", res)
+ snd_display("find_mark when no marks: %s?", res)
end
- m0 = add_mark(123, ind, 0)
+ add_mark(123, ind, 0)
delete_sample(0)
m1 = add_mark(23, ind, 0)
set_mark_name(m1, "23")
@@ -23089,7 +21389,7 @@ def test_10_02
snd_display("cannot find 11th mark?")
end
if (m12 = find_mark("23", ind, 0, 2))
- snd_display("found 12th mark: %s %s %s?", m12, mark_sample(m12, 2), mark_name(m12, 2))
+ snd_display("found 12th mark: %s %s %s?", m12, mark_sample(m12, 2), mark_name(m12))
end
set_mark_name(m1, false)
close_sound(ind)
@@ -23236,10 +21536,12 @@ def test_10_02
(m2 and mark_sync(m2) == mark_sync(m3)) or
mark_sync(m3) != mark_sync(m4) or
mark_sync(m3) != mark_sync(m5)
- snd_display("save_marks 2a 20... syncs: %s %s %s?",mark_sync(m3),mark_sync(m4), mark_sync(m5))
+ snd_display("save_marks 2a 20... syncs: %s %s %s?",
+ mark_sync(m3),mark_sync(m4), mark_sync(m5))
end
else
- snd_display("save_marks 2a 20...: %s %s %s?", m3.inspect, m4.inspect, m5.inspect)
+ snd_display("save_marks 2a 20...: %s %s %s?",
+ m3.inspect, m4.inspect, m5.inspect)
end
delete_file("test.marks")
close_sound(ind)
@@ -23250,7 +21552,9 @@ def test_10_02
add_mark(345, ind, 0, false, 1)
add_mark(456, ind, 0, "a mark", 2)
add_mark(567, ind, 0, false, 1)
- $output_comment_hook.add_hook!("mark2string") do |str| marks2string(selected_sound) end
+ $output_comment_hook.add_hook!("mark2string") do |str|
+ marks2string(selected_sound)
+ end
save_sound_as("tst.snd")
new_file_name = file_name(ind)
close_sound(ind)
@@ -23300,10 +21604,10 @@ def test_10_02
add_mark(20)
add_mark(30)
mark_explode
- if File.exists?("mark-0.snd")
+ if File.exist?("mark-0.snd")
ind1 = open_sound("mark-0.snd")
- if frames(ind1, 0) != 10
- snd_display("mark-0 frames: %s?", frames(ind1, 0))
+ if framples(ind1, 0) != 10
+ snd_display("mark-0 framples: %s?", framples(ind1, 0))
end
unless vequal(res = channel2vct, Vct.new(10, 0.1))
snd_display("mark-0 vals: %s?", res)
@@ -23313,10 +21617,10 @@ def test_10_02
else
snd_display("mark_explode did not write mark-0.snd?")
end
- if File.exists?("mark-1.snd")
+ if File.exist?("mark-1.snd")
ind1 = open_sound("mark-1.snd")
- if frames(ind1, 0) != 10
- snd_display("mark-1 frames: %s?", frames(ind1, 0))
+ if framples(ind1, 0) != 10
+ snd_display("mark-1 framples: %s?", framples(ind1, 0))
end
unless vequal(res = channel2vct, Vct.new(10, 0.4))
snd_display("mark-1 vals: %s?", res)
@@ -23326,10 +21630,10 @@ def test_10_02
else
snd_display("mark_explode did not write mark-1.snd?")
end
- if File.exists?("mark-2.snd")
+ if File.exist?("mark-2.snd")
ind1 = open_sound("mark-2.snd")
- if frames(ind1, 0) != 10
- snd_display("mark-2 frames: %s?", frames(ind1, 0))
+ if framples(ind1, 0) != 10
+ snd_display("mark-2 framples: %s?", framples(ind1, 0))
end
unless vequal(res = channel2vct, Vct.new(10, 0.8))
snd_display("mark-2 vals: %s?", res)
@@ -23339,7 +21643,7 @@ def test_10_02
else
snd_display("mark_explode did not write mark-2.snd?")
end
- if File.exists?("mark-3.snd")
+ if File.exist?("mark-3.snd")
snd_display("mark_explode wrote too many files?")
delete_file("mark-3.snd")
end
@@ -23349,7 +21653,6 @@ def test_10_02
end
def test_10
- clear_sincs
test_10_00
test_10_01 if $with_test_gui # load("s61.rb") -> set_transform_size(0)
test_10_02
@@ -23369,7 +21672,6 @@ def test_11
enved_dialog
color_orientation_dialog
transform_dialog
- view_files_dialog
view_regions_dialog
Snd.catch do edit_header_dialog() end
open_file_dialog(false)
@@ -23401,13 +21703,15 @@ def test_11
unless array?(res = snd_urls)
snd_display("snd_urls: %s?", res.inspect)
end
- str2 = snd_help(:open_sound)
+ # XXX: snd_help(:open_sound) => "keyword"
+ # str2 = snd_help(:open_sound) => "keyword"
+ str2 = snd_help(:open_sound.to_s)
str3 = snd_help("open_sound")
unless string_equal_ignore_white_space(str2, str3)
- snd_display("snd_help open_sound: %s %s?", str2, str3)
+ snd_display("snd_help open_sound: expected %s, got %s?", str2, str3)
end
str1 = "(enved-base): envelope editor exponential base value (1.0)"
- str2 = snd_help(:enved_base)
+ str2 = snd_help(:enved_base.to_s)
str3 = snd_help("enved_base")
unless string_equal_ignore_white_space(str1, str2)
snd_display("snd_help :enved_base: expected %s, got %s", str1, str2)
@@ -23416,11 +21720,11 @@ def test_11
snd_display("snd_help \"enved_base\": expected %s, got %s", str1, str3)
end
old_val = Hamming_window
- str1 = snd_help(:Hamming_window)
+ str1 = snd_help(:Hamming_window.to_s)
str2 = snd_help("Hamming_window")
if (not string_equal_ignore_white_space(str1, str2)) or
- (not string_equal_ignore_white_space(str1, "A raised cosine"))
- snd_display("snd_help Hamming_window: %s %s?", str1, str2)
+ (not string_equal_ignore_white_space(str1, "A raised cosine"))
+ snd_display("snd_help Hamming_window: expected %s, got %s?", str1, str2)
end
if (not number?(Hamming_window)) or Hamming_window != old_val
snd_display("snd_help clobbered out-of-module variable: %s %s?", old_val, Hamming_window)
@@ -23437,28 +21741,6 @@ def test_11
help_dialog(fnc, snd_help(fnc, false))
end
end
- #
- set_show_indices(true)
- ind = open_sound("oboe.snd")
- if sound_widgets(ind).length < 4
- snd_display("sound_widgets: %s?", sound_widgets(ind))
- end
- report_in_minibuffer("hi there", ind)
- if (res = widget_text(sound_widgets(ind)[3])) != "hi there"
- snd_display("report_in_minibuffer: %s?", res)
- end
- if (res = widget_text(sound_widgets(ind)[3])) != "hi there"
- snd_display("report_in_minibuffer 1: %s?", res)
- end
- if (res = widget_text(main_widgets[1]))
- snd_display("widget text should be false: %s?", res)
- end
- if (not (res1 = widget_text(sound_widgets(ind)[1]))) or
- res1 != (res2 = format("%s: %s", sound2integer(ind), short_file_name(ind)))
- snd_display("name text: %s %s?", res1, res2)
- end
- clear_minibuffer
- close_sound(ind)
set_show_indices(false)
#
define_envelope("test_ramp", [0, 0, 1, 1])
@@ -23469,113 +21751,13 @@ def test_11
if $test_ramp != [0, 1, 1, 0]
snd_display("re-define-envelope $test_ramp: %s?", $test_ramp)
end
- #
- dialog = view_files_dialog(false)
- vfamp = view_files_amp(dialog)
- vfs = view_files_speed(dialog)
- vfsort = view_files_sort
- vfsort1 = view_files_sort(dialog)
- vfe = view_files_amp_env(dialog)
- vffiles = view_files_files(dialog)
- vfsel = view_files_selected_files(dialog)
- selected_file = false
- if fneq(vfamp, 1.0)
- snd_display("vf amp: %s", vfamp)
- end
- if fneq(vfs, 1.0)
- snd_display("vf speed: %s", vfs)
- end
- if vfsort != 0
- snd_display("vf sort: %s?", vfsort)
- end
- if vfsort1 != 0
- snd_display("vf sort(d): %s?", vfsort1)
- end
- if vfe != [0.0, 1.0, 1.0, 1.0]
- snd_display("vf amp env: %s", vfe)
- end
- unless array?(vffiles) or vffiles.nil?
- snd_display("vf selected files: %s", vffiles.inspect)
- end
- unless array?(vfsel) or vfsel.nil?
- snd_display("vf selected files: %s", vfsel.inspect)
- end
- if (res1 = view_files_speed_style(dialog)) != (res2 = speed_control_style)
- snd_display("vf speed_style def: %s %s", res1, res2)
- end
- old_val = view_files_amp(dialog)
- set_view_files_amp(dialog, 0.5)
- if fneq(res = view_files_amp(dialog), 0.5)
- snd_display("set vf amp: %s", res)
- end
- set_view_files_amp(dialog, old_val)
- old_val = view_files_speed(dialog)
- set_view_files_speed(dialog, 0.5)
- if fneq(res = view_files_speed(dialog), 0.5)
- snd_display("set vf speed: %s", res)
- end
- set_view_files_speed(dialog, old_val)
- old_val = view_files_speed_style(dialog)
- set_view_files_speed_style(dialog, Speed_control_as_ratio)
- if (res = view_files_speed_style(dialog)) != Speed_control_as_ratio
- snd_display("vf speed_style set: %s", res)
- end
- set_view_files_speed_style(dialog, old_val)
-
- old_val = view_files_sort(dialog)
- set_view_files_sort(dialog, 2)
- if (res = view_files_sort()) != 0
- snd_display("vf global sort after local set: %s?", res)
- end
- if (res = view_files_sort(dialog)) != 2
- snd_display("vf local sort after local set: %s?", res)
- end
- set_view_files_sort(4)
- if (res = view_files_sort()) != 4
- snd_display("vf global sort after global set: %s?", res)
- end
- if (res = view_files_sort(dialog)) != 2
- snd_display("vf local sort after global set: %s?", res)
- end
- set_view_files_sort(dialog, old_val)
- old_val = view_files_files(dialog)
- set_view_files_files(dialog, ["oboe.snd", "1a.snd", "pistol.snd", "storm.snd"])
- res = view_files_files(dialog)
- if (!res.member?("1a.snd") and !res.member?(cwd + "1a.snd")) or
- (!res.member?("pistol.snd") and !res.member?(cwd + "pistol.snd")) or
- res.length != 4
- snd_display("vf files set: %s", res)
- end
- old_sel = view_files_selected_files(dialog)
- $view_files_select_hook.reset_hook!
- $view_files_select_hook.add_hook!("test 11") do |w, file|
- unless string?(file)
- snd_display("vf select hook arg: %s", file)
- end
- unless w
- snd_display("vf select hook dialog: %s", w)
- end
- selected_file = file
- end
- set_view_files_selected_files(dialog, ["1a.snd"])
- if !string?(selected_file) or
- (selected_file != "1a.snd" and selected_file != cwd + "1a.snd")
- snd_display("vf set_selected_file select hook arg: %s", selected_file)
- end
- if view_files_selected_files(dialog) != ["1a.snd"] and
- view_files_selected_files(dialog) != [cwd + "1a.snd"]
- snd_display("vf selected_files set: %s", view_files_selected_files(dialog).inspect)
- end
- $view_files_select_hook.reset_hook!
- set_view_files_files(dialog, old_val)
- set_view_files_selected_files(dialog, old_sel)
end
end
# ---------------- test 12: extensions ----------------
def spectral_difference(snd1, snd2)
- size = [frames(snd1), frames(snd2)].max
+ size = [framples(snd1), framples(snd2)].max
pow2 = (log(size) / log(2)).ceil
fftlen = (2 ** pow2).to_i
fdr1 = channel2vct(0, fftlen, snd1, 0)
@@ -23612,9 +21794,9 @@ def test_12
#Snd.catch(:mus_error) do
Snd.catch do
mus_sound_chans(dir).between?(1, 255) and
- mus_sound_data_format(dir) >= 0 and
+ mus_sound_sample_type(dir) >= 0 and
mus_sound_srate(dir) > 0 and
- mus_sound_frames(dir) >= 0 and
+ mus_sound_framples(dir) >= 0 and
sf_dir_files.push(dir)
end
end
@@ -23643,8 +21825,10 @@ def test_12
if len.zero? or random(1.0) > 0.5
name = sf_dir_files[random(sf_dir_files.length).floor]
ht = Snd.catch(:all, 0) do mus_sound_header_type(name) end.first
- df = Snd.catch(:all, 0) do mus_sound_data_format(name) end.first
- fd = if ht == Mus_raw or ht == Mus_unsupported or df == Mus_unknown
+ df = Snd.catch(:all, 0) do mus_sound_sample_type(name) end.first
+ fd = if ht == Mus_raw or
+ ht == Mus_unknown_header or
+ df == Mus_unknown_sample
-1
else
Snd.catch(:all, -1) do view_sound(name) end.first or -1
@@ -23668,19 +21852,17 @@ def test_12
sounds.inspect, Snd.sounds.map do |s| short_file_name(s) end)
end
fd = open_raw_sound(:file, $sf_dir + "addf8.nh",
- :channels, 1, :srate, 8012, :data_format, Mus_mulaw)
- if data_format(fd) != Mus_mulaw
- snd_display("open_raw_sound: %s?", mus_data_format_name(data_format(fd)))
+ :channels, 1, :srate, 8012, :sample_type, Mus_mulaw)
+ if sample_type(fd) != Mus_mulaw
+ snd_display("open_raw_sound: %s?", mus_sample_type_name(sample_type(fd)))
end
close_sound(fd)
#
$bad_header_hook.reset_hook!
- with_time("test_spectral_difference(oboe.snd, oboe.g723_24, 20)") do
- test_spectral_difference("oboe.snd", $sf_dir + "oboe.g723_24", 20.0)
- end
test_spectral_difference($sf_dir + "o2.wave", $sf_dir + "o2_dvi.wave", 10.0)
test_spectral_difference($sf_dir + "wood.riff", $sf_dir + "wood.sds", 4.0)
- test_spectral_difference($sf_dir + "nist-10.wav", $sf_dir + "nist-shortpack.wav", 1.0)
+ test_spectral_difference($sf_dir + "nist-10.wav",
+ $sf_dir + "nist-shortpack.wav", 1.0)
$bad_header_hook.add_hook!("snd-test") do |n| true end
#
# dangling readers (overall)
@@ -23831,7 +22013,7 @@ def test_12
end
end
end
- if File.exists?("s24.snd") and
+ if File.exist?("s24.snd") and
(ffiles != [$sf_dir + "s24.snd"] or
sfiles != [$sf_dir + "s24.snd"])
snd_display("map|for_each_sound_file(s): %s %s?", ffiles, sfiles)
@@ -23993,7 +22175,6 @@ def test_13_00
if $with_test_gui
add_to_menu(mb, "not here", lambda do | | snd_display("oops") end)
remove_from_menu(mb,"not here")
- add_to_menu(3, "Denoise", lambda do | | report_in_minibuffer("denoise") end)
end
$help_hook.reset_hook!
hi = snd_help(:cursor_position)
@@ -24007,13 +22188,9 @@ def test_13_00
"hiho:" + b
end
ho = snd_help(:cursor_position)
- # FIXME
- # HI has one char more than HO:
- # HI: cursor_postion(:optional, snd, chn):
- # HO: (cursor-postion :optional snd chn):
- # That's why +4 instead of +5 like in snd-test.scm.
- if ho.length != (hi.length + 4)
- snd_display("length $help_hook\n\t<[%s]%s>\n\t<[%s]%s>?", hi.length, hi, ho.length, ho)
+ if ho.length != hi.length
+ snd_display("length $help_hook\n\t<[%s]%s>\n\t<[%s]%s>?",
+ hi.length, hi, ho.length, ho)
end
$help_hook.reset_hook!
$help_hook.add_hook!("snd-test") do |a, b| false end
@@ -24023,7 +22200,7 @@ def test_13_00
end
$help_hook.reset_hook!
#
- fr = frames(fd)
+ fr = framples(fd)
chn = chans(fd)
sr = srate(fd)
mx = maxamp(fd)
@@ -24031,12 +22208,10 @@ def test_13_00
if (res = edit_fragment) != ["(cp)", "set", 0, 50828]
snd_display("copyfile: %s?", res)
end
- if fr != frames(fd) or chn != chans(fd) or fneq(mx, maxamp(fd)) or fneq(sr, srate(fd))
- snd_display("copyfile (1): %s %s %s %s?", frames(fd), chans(fd), srate(fd), maxamp(fd))
+ if fr != framples(fd) or chn != chans(fd) or fneq(mx, maxamp(fd)) or fneq(sr, srate(fd))
+ snd_display("copyfile (1): %s %s %s %s?", framples(fd), chans(fd), srate(fd), maxamp(fd))
end
eds = edits
- add_file_to_view_files_list("oboe.snd")
- add_directory_to_view_files_list(".")
select_all
copyfile(true)
if (res = edit_fragment) != ["(cp)", "set", 0, 50828]
@@ -24045,8 +22220,8 @@ def test_13_00
if (res = edits) != [eds[0] + 1, eds[1]]
snd_display("copyfile (select eds): %s %s?", eds, res)
end
- if fr != frames(fd) or chn != chans(fd) or fneq(mx, maxamp(fd)) or fneq(sr, srate(fd))
- snd_display("copyfile (2): %s %s %s %s?", frames(fd), chans(fd), srate(fd), maxamp(fd))
+ if fr != framples(fd) or chn != chans(fd) or fneq(mx, maxamp(fd)) or fneq(sr, srate(fd))
+ snd_display("copyfile (2): %s %s %s %s?", framples(fd), chans(fd), srate(fd), maxamp(fd))
end
#
set_transform_size(256, fd, 0)
@@ -24115,14 +22290,14 @@ def test_13_00
end
$initial_graph_hook.reset_hook!
set_selection_position(1000, fd, 1)
- set_selection_frames(10, fd, 1)
+ set_selection_framples(10, fd, 1)
set_selection_member?(true, fd, 1)
if selection_member?(fd, 0)
snd_display("chan 0 is selection_member?")
end
2.times do |chn|
set_selection_position(1000, fd, chn)
- set_selection_frames(10, fd, chn)
+ set_selection_framples(10, fd, chn)
set_selection_member?(true, fd, chn)
end
scale_selection_to([0.5, 0.25].to_vct)
@@ -24159,43 +22334,6 @@ def test_13_00
key(key_to_int(?p), 0, ind)
set_selection_member?(false, true)
revert_sound(ind)
- set_search_procedure(ind, lambda do |n4| n4 > 0.1 end)
- key(key_to_int(?a), 4, ind, 0)
- if cursor(ind, 0).nonzero?
- snd_display("C-a cursor: %s?", cursor(ind, 0))
- end
- key(key_to_int(?s), 4, ind, 0)
- key(key_to_int(?s), 4, ind, 0)
- if cursor(ind, 0) != 4423
- snd_display("search_procedure C-s C-s cursor: %s?", cursor(ind, 0))
- end
- set_search_procedure(ind, lambda do |n| n > 0.2 end)
- set_cursor(0, ind, 0)
- key(key_to_int(?s), 4, ind, 0)
- key(key_to_int(?s), 4, ind, 0)
- if cursor(ind, 0).nonzero?
- snd_display("search_procedure C-s C-s cursor failed: %s?", cursor(ind, 0))
- end
- snd = chn = 0
- edit_hook(ind, 0).reset_hook!
- edit_hook(ind, 0).add_hook!("snd-test") do | | snd + chn end
- edit_hook(ind, 0).reset_hook!
- after_edit_hook(ind, 0).reset_hook!
- after_edit_hook(ind, 0).add_hook!("snd-test") do | | snd + chn end
- after_edit_hook(ind, 0).reset_hook!
- undo_hook(ind, 0).reset_hook!
- undo_hook(ind, 0).add_hook!("snd-test") do | | snd + chn end
- undo_hook(ind, 0).reset_hook!
- calls = 0
- undo_hook(ind, 0).add_hook!("snd-test") do | | calls += 1 end
- delete_sample(0, ind, 0)
- undo_edit(1)
- redo_edit(1)
- revert_sound(ind)
- if calls != 3
- snd_display("undo_hook called %s times (3)?", calls)
- end
- undo_hook(ind, 0).reset_hook!
close_sound(ind)
end
@@ -24210,11 +22348,11 @@ def test_13_01
$open_raw_sound_hook.remove_hook!("snd-hook")
if (res = [chans(ind),
srate(ind),
- data_format(ind),
- frames(ind)]) != [1, 22050, Mus_bshort, 23808]
+ sample_type(ind),
+ framples(ind)]) != [1, 22050, Mus_bshort, 23808]
snd_display("open_raw: %s?", res)
end
- set_search_procedure(ind, lambda do |n| n > 0.2 end)
+ set_search_procedure(lambda do |n| n > 0.2 end)
close_sound(ind)
end
save_as_dialog = true
@@ -24227,7 +22365,7 @@ def test_13_01
save_as_dialog = dial
end
ind = open_sound("oboe.snd")
- save_sound_as("test.snd", ind, Mus_raw)
+ save_sound_as("test.snd", ind, :header_type, Mus_raw)
close_sound(ind)
$open_raw_sound_hook.reset_hook!
$after_save_as_hook.reset_hook!
@@ -24250,7 +22388,7 @@ def test_13_01
[2, 44100, Mus_mulaw]
end
ind = open_sound("test.snd")
- if (res = [header_type(ind), data_format(ind), chans(ind), srate(ind), frames(ind)]) \
+ if (res = [header_type(ind), sample_type(ind), chans(ind), srate(ind), framples(ind)]) \
!= [Mus_raw, Mus_mulaw, 2, 44100, 50828]
snd_display("$open_raw_sound_hook 1: %s?", res)
end
@@ -24262,7 +22400,7 @@ def test_13_01
[1, 22050, Mus_lint]
end
ind = open_sound("test.snd")
- if (res = [header_type(ind), data_format(ind), chans(ind), srate(ind), frames(ind)]) \
+ if (res = [header_type(ind), sample_type(ind), chans(ind), srate(ind), framples(ind)]) \
!= [Mus_raw, Mus_lint, 1, 22050, 50828 / 2]
snd_display("$open_raw_sound_hook 2: %s?", res)
end
@@ -24272,7 +22410,7 @@ def test_13_01
[2]
end
ind = open_sound("test.snd")
- if (res = [header_type(ind), data_format(ind), chans(ind), srate(ind)]) \
+ if (res = [header_type(ind), sample_type(ind), chans(ind), srate(ind)]) \
!= [Mus_raw, Mus_lint, 2, 22050]
snd_display("$open_raw_sound_hook 3: %s?", res)
end
@@ -24282,8 +22420,8 @@ def test_13_01
[1, 22050, Mus_bshort, 120, 320]
end
ind = open_sound("test.snd")
- if (res = [header_type(ind), data_format(ind), chans(ind), srate(ind),
- data_location(ind), data_size(ind), frames(ind)]) \
+ if (res = [header_type(ind), sample_type(ind), chans(ind), srate(ind),
+ data_location(ind), data_size(ind), framples(ind)]) \
!= [Mus_raw, Mus_bshort, 1, 22050, 120, 320, 160]
snd_display("$open_raw_sound_hook 4: %s?", res)
end
@@ -24377,10 +22515,12 @@ def test_13_01
cursor
end
$after_transform_hook.add_hook!("snd-test") do |snd, chn, scale|
- if transform_graph?(snd, chn) and transform_graph_type(snd, chn) == Graph_once
- report_in_minibuffer((2 * transform2vct(snd, chn).peak / transform_size(snd, chn)).to_s, snd)
- end
abf = true
+ if transform_graph?(snd, chn) and
+ transform_graph_type(snd, chn) == Graph_once
+ num = (2.0 * transform2vct(snd, chn).peak / transform_size(snd, chn)).to_s
+ status_report(num, snd)
+ end
false
end
set_transform_graph?(true, ind, 0)
@@ -24445,10 +22585,10 @@ def test_13_01
#
spl = stl = ph = ph1 = false
$start_playing_hook.add_hook!("snd-test") do |snd|
+ spl = true
unless snd.eql?(ind)
snd_display("$start_playing_hook: %s not %s?", snd, ind)
end
- spl = true
false
end
$stop_playing_hook.add_hook!("snd-test") do |snd|
@@ -24470,15 +22610,6 @@ def test_13_01
set_reverb_control_feedback(reverb_control_feedback)
ph = true
end
- $dac_hook.add_hook!("snd-test") do |n|
- unless sound_data?(n)
- snd_display("$dac_hook data: %s?", n)
- end
- if sound_data_length(n) < 128 and sound_data_length(n) != 64
- snd_display("$dac_hook data length: %s?", sound_data_length(n))
- end
- ph1 = true
- end
set_expand_control?(true, ind)
set_reverb_control?(true, ind)
play(ind, :wait, true)
@@ -24493,14 +22624,10 @@ def test_13_01
unless ph
snd_display("$play_hook not called?")
end
- unless ph1
- snd_display("$dac_hook not called?")
- end
$start_playing_hook.reset_hook!
$start_playing_selection_hook.reset_hook!
$stop_playing_hook.reset_hook!
$play_hook.reset_hook!
- $dac_hook.reset_hook!
$play_hook.add_hook!("snd-test") do |n|
set_expand_control_hop(0.02)
set_expand_control_length(0.02)
@@ -24509,7 +22636,7 @@ def test_13_01
set_reverb_control_lowpass(0.02)
set_reverb_control_feedback(0.02)
end
- play(ind, :wait, true)
+ # play(ind, :wait, true)
$play_hook.reset_hook!
$start_playing_hook.add_hook!("snd-test") do |snd| true end
play("4.aiff")
@@ -24527,46 +22654,7 @@ def test_13_01
end
$stop_playing_selection_hook.reset_hook!
set_selection_creates_region(old_reg)
- ctr = 0
- $dac_hook.add_hook!("snd-test") do |n|
- ctr += 1
- stop_playing
- end
play(ind, :wait, true)
- if ctr > 2
- snd_display("stop_playing: %s?", ctr)
- end
- $dac_hook.reset_hook!
- #
- pl = make_player(ind, 0)
- ctr = 0
- unless player?(pl)
- snd_display("make_player: %s?", pl)
- end
- if (not players) # players returs nil if empty
- snd_display("players: %s?", players.inspect)
- end
- $dac_hook.add_hook!("snd-test") do |n|
- ctr += 1
- if player?(pl)
- stop_player(pl)
- else
- if ctr == 1
- snd_display("player messed up")
- end
- end
- end
- add_player(pl)
- start_playing(1, 22050, false)
- if ctr > 2
- snd_display("stop_player: %s?", ctr)
- end
- $dac_hook.reset_hook!
- pl = make_player(ind, 0)
- free_player(pl)
- if player?(pl)
- snd_display("free_player: %s?", pl)
- end
#
e0 = e1 = u0 = u1 = a0 = a1 = false
edit_hook(ind, 0).add_hook!("snd-test-1") do | | e0 = true end
@@ -24613,31 +22701,48 @@ def test_13_01
after_edit_hook(ind, 0).reset_hook!
after_edit_hook(other, 0).reset_hook!
#
- se = sw = me = false
- $snd_warning_hook.reset_hook!
$snd_error_hook.reset_hook!
+ $snd_warning_hook.reset_hook!
$mus_error_hook.reset_hook!
- $snd_warning_hook.add_hook!("snd-test") do |msg| sw = true end
- $snd_error_hook.add_hook!("snd-test") do |msg| se = true end
- $mus_error_hook.add_hook!("snd-test") do |type, msg| me = true end
+ se = false
+ sw = false
+ me = false
+ se_msg = "se_msg"
+ sw_msg = "sw_msg"
+ me_msg = "me_msg"
+ $snd_error_hook.add_hook!("snd-test") do |msg|
+ se_msg = msg
+ se = true
+ end
+ $snd_warning_hook.add_hook!("snd-test") do |msg|
+ sw_msg = msg
+ sw = true
+ end
+ $mus_error_hook.add_hook!("snd-test") do |type, msg|
+ me_msg = msg
+ me = true
+ end
snd_error("uhoh")
snd_warning("hiho")
mus_sound_samples("/bad/baddy")
unless se
- snd_display("$snd_error_hook not called?")
+ snd_display("$snd_error_hook not called (%s != uhoh)?", se_msg)
end
unless sw
- snd_display("$snd_warning_hook not called?")
+ snd_display("$snd_warning_hook not called (%s != hiho)?", sw_msg)
end
unless me
- snd_display("$mus_error_hook not called?")
+ snd_display("$mus_error_hook not called (%s)?", me_msg)
end
$snd_error_hook.reset_hook!
$snd_warning_hook.reset_hook!
$mus_error_hook.reset_hook!
- $snd_error_hook.add_hook!("snd-test") do |msg| se = msg; true end
+ $snd_error_hook.add_hook!("snd-test") do |msg|
+ se = msg
+ true
+ end
snd_error("not an error")
- if (not string?(se)) or se != "not an error"
+ if se != "not an error"
snd_display("$snd_error_hook saw: %s?", se)
end
#
@@ -24663,7 +22768,7 @@ def test_13_01
unless sh
snd_display("$save_hook not called?")
end
- if File.exists?("baddy.snd")
+ if File.exist?("baddy.snd")
snd_display("$save_hook did not cancel save?")
delete_file("baddy.snd")
end
@@ -24683,17 +22788,6 @@ def test_13_01
end
def test_13_02
- $print_hook.add_hook!("snd-test") do |str|
- if str[0] == ?[ and (print_length == 30 and
- str != "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ...]" or
- print_length == 12 and
- str != "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ...]")
- snd_display("array abbreviation: %s?", str)
- end
- false
- end
- snd_print(make_array(128, 1))
- $print_hook.reset_hook!
unless $with_test_alsa
in1 = open_sound("oboe.snd")
in2 = open_sound("2.snd")
@@ -24907,7 +23001,7 @@ def test_13_02
channels(snd).times do |chn|
src_channel(srate(snd).to_f / sr, 0, false, snd, chn)
end
- save_sound_as(fname, snd, :header_type, type, :data_format, fmt, :srate, sr, :comment, com)
+ save_sound_as(fname, snd, :header_type, type, :sample_type, fmt, :srate, sr, :comment, com)
channels(snd).times do |chn| undo_edit(1, snd, chn) end
hook_called = true
true
@@ -24964,7 +23058,8 @@ def test_13_02
set_clipping(true)
set_mus_clipping(true)
$clip_hook.reset_hook!
- index = new_sound("test.snd", Mus_next, Mus_bshort, 22050, 1, "clip-hook test", 10)
+ index = new_sound("test.snd", 1, 22050, Mus_bshort, Mus_next,
+ "clip-hook test", 10)
map_channel(lambda do |y| mus_random(0.999) end)
set_sample(2, 1.0001)
set_sample(4, -1.0)
@@ -25041,11 +23136,11 @@ def test_channel(func)
end
def duration(snd)
- frames(snd) / srate(snd).to_f
+ framples(snd) / srate(snd).to_f
end
def safe_make_selection(beg, fin, snd)
- len = frames(snd)
+ len = framples(snd)
old_choice = selection_creates_region()
set_selection_creates_region(true)
if len > 1
@@ -25079,7 +23174,7 @@ def test_14
if $with_test_gui
cur_dir_files = []
sound_files_in_directory(".").each do |f|
- if Snd.catch(:all, 0) do mus_sound_frames(f) end.first > 0
+ if Snd.catch(:all, 0) do mus_sound_framples(f) end.first > 0
cur_dir_files.push(f)
end
end
@@ -25092,8 +23187,8 @@ def test_14
open_files = []
cur_dir_files.each do |name|
ht = mus_sound_header_type(name)
- df = mus_sound_data_format(name)
- len = mus_sound_frames(name)
+ df = mus_sound_sample_type(name)
+ len = mus_sound_framples(name)
if ht != Mus_raw and len.nonzero? and df != -1
case mus_sound_chans(name)
when 1
@@ -25116,7 +23211,6 @@ def test_14
revert_sound(snd)
end
end
- clear_sincs
files = Snd.sounds.length
delete_file("s61.rb")
Snd.sounds.each do |s|
@@ -25139,7 +23233,7 @@ def test_14
if len.zero?
name = cur_dir_files[random(cur_dir_files.length)]
ht = mus_sound_header_type(name)
- df = mus_sound_data_format(name)
+ df = mus_sound_sample_type(name)
fd = (ht == Mus_raw or df == -1) ? -1 : view_sound(name)
if number?(fd) and fd != -1
open_files.push(fd)
@@ -25160,7 +23254,7 @@ def test_14
end
choose_fd = lambda do Snd.sounds[random(Snd.sounds.length)] end
curfd = choose_fd.call
- curloc = [0, [1200, frames(curfd, 0)].min].max
+ curloc = [0, [1200, framples(curfd, 0)].min].max
old_marks = Snd.marks(curfd, 0).length
if (dur = duration(curfd)) > 0.0
set_x_bounds([0.0, [dur, 1.0].min], curfd)
@@ -25176,11 +23270,11 @@ def test_14
end
set_cursor(curloc, curfd, 0)
cl = cursor(curfd, 0)
- if cl != curloc and (res = frames(curfd, 0)) > curloc
- snd_display("cursor %s != %s (frames: %s)?", cl, curloc, res)
+ if cl != curloc and (res = framples(curfd, 0)) > curloc
+ snd_display("cursor %s != %s (framples: %s)?", cl, curloc, res)
curloc = cursor(curfd, 0)
end
- if curloc >= frames(curfd, 0)
+ if curloc >= framples(curfd, 0)
curloc = 0
end
id = Snd.catch(:all, -1) do add_mark(curloc, curfd) end.car
@@ -25216,7 +23310,7 @@ def test_14
if duration(curfd) > 1.2
set_x_bounds([1.0, 1.1], curfd)
end
- if frames(curfd) > 25
+ if framples(curfd) > 25
add_mark(10, curfd)
add_mark(20, curfd)
key(key_to_int(?m), 0, curfd)
@@ -25232,19 +23326,15 @@ def test_14
end
end
revert_sound
- select_all
+ old_settings = selection_creates_region()
+ set_selection_creates_region(true)
+ reg = select_all()
Snd.catch do
- if region?(0) and selection?
+ if region?(reg) and selection?()
r1 = region_rms(regions.first)
r2 = selection_rms
- r3 = selection_rms
- r4 = region_rms(regions.first)
- if fneq(r1, r4)
- snd_display("region_rms: %s %s?", r1, r4)
- end
- if fneq(r2, r3)
- snd_display("selection_rms: %s %s?", r2, r3)
- end
+ snd_test_neq(r1, r2, "region_rms")
+ set_selection_creates_region(old_settings)
end
end
Snd.catch do
@@ -25252,16 +23342,16 @@ def test_14
play(regions[2], :wait, true)
end
end
- Snd.catch do mix_region(regions[2]) end
- frames < 100000 and play(selected_sound, :wait, true)
+ Snd.catch do
+ mix_region(regions[2])
+ end
+ framples < 100000 and play(selected_sound, :wait, true)
scale_to(0.1, choose_fd.call)
scale_by(2.0, choose_fd.call)
save_controls
set_amp_control(0.5)
test_panel(:amp_control)
restore_controls
- report_in_minibuffer("hi")
- append_to_minibuffer("ho")
Snd.catch do
cfd = choose_fd.call
safe_make_selection(1000, 2000, cfd)
@@ -25324,12 +23414,15 @@ def test_14
open_files.length > 1 and revert_sound(open_files[1])
end
#
- if frames > 1
- make_region(0, frames)
+ frms = framples()
+ if frms > 1 and frms < 10000
+ make_region(0, frms)
convolve_selection_with("fyow.snd", 0.5)
- frames < 100000 and play(selected_sound, :wait, true)
+ play(selected_sound, :wait, true)
+ end
+ if frms > 1 and frms < 10000
+ convolve_with("fyow.snd", 0.25)
end
- convolve_with("fyow.snd", 0.25)
insert_sound("oboe.snd")
$graph_hook.reset_hook!
$after_transform_hook.reset_hook!
@@ -25339,7 +23432,12 @@ def test_14
select_sound(ind)
[[lambda { |beg| insert_sound("2a.snd", beg) }, lambda { |beg| insert_sound("4a.snd", beg) }],
[lambda { |beg| reverse_sound }, lambda { |beg| reverse_sound }],
- [lambda { |beg| convolve_with("2a.snd", 0.5) }, lambda { |beg| src_sound(2.0) }],
+ [lambda { |beg|
+ if framples(ind) < 10000
+ convolve_with("2a.snd", 0.5)
+ else
+ scale_by(2.0)
+ end }, lambda { |beg| src_sound(2.0) }],
[lambda { |beg| env_sound([0, 0, 1, 1, 2, 0]) }, lambda { |beg| env_sound([0, 0, 1, 1]) }],
[lambda { |beg| smooth_sound }, lambda { |beg| insert_silence(beg, 100) }]
].each do |func, func1|
@@ -25356,23 +23454,23 @@ def test_14
revert_sound(ind)
end
delete_samples(0, 1000, ind, 0)
- func.call(2 * frames(ind, 0))
+ func.call(2 * framples(ind, 0))
delete_samples(0, 1000, ind, 0)
- func1.call(2 * frames(ind, 0))
+ func1.call(2 * framples(ind, 0))
revert_sound(ind)
if channels(ind) > 1
delete_samples(0, 1000, ind, 1)
- func.call(2 * frames(ind, 1))
+ func.call(2 * framples(ind, 1))
delete_samples(0, 1000, ind, 1)
- func1.call(2 * frames(ind, 1))
+ func1.call(2 * framples(ind, 1))
revert_sound(ind)
end
end
#
ind = open_sound("z.snd")
restore_controls
- if frames(ind).nonzero?
- snd_display("frames z.snd: %s?", frames(ind))
+ if framples(ind).nonzero?
+ snd_display("framples z.snd: %s?", framples(ind))
end
if samples != false
snd_display("samples of empty file (z): %s?", samples)
@@ -25465,7 +23563,7 @@ def test_14
#
zz = view_sound("z.snd")
select_sound(zz)
- md = mix("4.aiff").car
+ mix("4.aiff").car
add_mark(0)
add_mark(1200)
delete_marks
@@ -25474,7 +23572,7 @@ def test_14
if (res = edit_position(zz)).nonzero?
snd_display("revert_sound edit_position: %s?", res)
end
- s8_snd = (File.exists?("s8.snd") ? "s8.snd" : "oboe.snd")
+ s8_snd = (File.exist?("s8.snd") ? "s8.snd" : "oboe.snd")
as_one_edit_rb do
mix(s8_snd, 24000)
reg = select_all
@@ -25512,9 +23610,7 @@ def test_14
insert_region(reg, 80000)
end
end
- if (res = edit_position) != editctr + 1
- snd_display("as_one_edit s8: %s -> %s?", editctr, res)
- end
+ snd_test_neq(edit_position(), editctr + 1, "as_one_edit s8")
revert_sound(s8)
close_sound(s8)
#
@@ -25522,26 +23618,24 @@ def test_14
if channels(cfd) > 1
uval = random(3)
set_channel_style(uval, cfd)
- if (res = channel_style(cfd)) != uval
- snd_display("channel_style: %s %s?", uval, res)
- end
- end
- src_sound(2.5, 1.0, cfd)
- src_sound(-2.5, 1.0, cfd)
- src_sound(0.5, 1.0, cfd)
- revert_sound(cfd)
- src_sound(-0.5, 1.0, cfd)
- src_sound([0, 0.5, 1, 1.5], 1.0, cfd)
- if frames(cfd) > 0
- src_sound(make_env(:envelope, [0, 0.5, 1, 1.5], :length, frames(cfd)), 1.0, cfd)
+ snd_test_neq(channel_style(cfd), uval, "channel_style")
end
- revert_sound(cfd)
- filter_sound([0, 1, 0.2, 0, 0.5, 1, 1, 0], 20, cfd)
- filter_sound([0, 0, 0.1, 0, 0.11, 1, 0.12, 0, 1, 0], 2048, cfd)
- env_sound([0, 0, 0.5, 1, 1, 0], 0, frames(cfd), 1.0, cfd)
- insert_sample(1200, 0.1, cfd)
- if fneq(res = sample(1200, cfd), 0.1)
- snd_display("insert_sample(looped): %s?", res)
+ if framples(cfd) < 200000
+ src_sound(2.5, 1.0, cfd)
+ src_sound(-2.5, 1.0, cfd)
+ src_sound(0.5, 1.0, cfd)
+ revert_sound(cfd)
+ src_sound(-0.5, 1.0, cfd)
+ src_sound([0, 0.5, 1, 1.5], 1.0, cfd)
+ if framples(cfd) > 0
+ src_sound(make_env([0, 0.5, 1, 1.5], :length, framples(cfd)), 1.0, cfd)
+ end
+ revert_sound(cfd)
+ filter_sound([0, 1, 0.2, 0, 0.5, 1, 1, 0], 20, cfd)
+ filter_sound([0, 0, 0.1, 0, 0.11, 1, 0.12, 0, 1, 0], 2048, cfd)
+ env_sound([0, 0, 0.5, 1, 1, 0], 0, framples(cfd), 1.0, cfd)
+ insert_sample(1200, 0.1, cfd)
+ snd_test_neq(sample(1200, cfd), 0.1, "insert_sample(looped)")
end
revert_sound(cfd)
#
@@ -25553,7 +23647,7 @@ def test_14
set_speed_control(2.0)
test_panel(:speed_control)
apply_controls
- frames < 100000 and play(selected_sound, :wait, true)
+ framples < 100000 and play(selected_sound, :wait, true)
if fneq(res1 = reverb_control_decay(cfd), res2 = reverb_control_decay)
snd_display("reverb_control_decay local: %s, global: %s?", res1, res2)
end
@@ -25564,13 +23658,13 @@ def test_14
test_panel(:reverb_control_lowpass)
test_panel(:reverb_control_feedback)
apply_controls
- frames < 100000 and play(selected_sound, :wait, true)
+ framples < 100000 and play(selected_sound, :wait, true)
set_contrast_control?(true)
set_contrast_control(0.5)
test_panel(:contrast_control)
test_panel(:contrast_control_amp)
apply_controls
- frames < 100000 and play(selected_sound, :wait, true)
+ framples < 100000 and play(selected_sound, :wait, true)
set_expand_control?(true)
set_expand_control(2.5)
test_panel(:expand_control)
@@ -25578,18 +23672,18 @@ def test_14
test_panel(:expand_control_hop)
test_panel(:expand_control_ramp)
apply_controls
- frames < 100000 and play(selected_sound, :wait, true)
+ framples < 100000 and play(selected_sound, :wait, true)
set_filter_control?(true)
set_filter_control_order(40)
test_panel(:filter_control_order)
set_filter_control_envelope([0, 0, 0.1, 1, 0.2, 0, 1, 0])
filter_control_envelope
apply_controls
- frames < 100000 and play(selected_sound, :wait, true)
+ framples < 100000 and play(selected_sound, :wait, true)
set_amp_control(1.5)
test_panel(:amp_control)
apply_controls
- frames < 100000 and play(selected_sound, :wait, true)
+ framples < 100000 and play(selected_sound, :wait, true)
swap_channels(cfd, 0, cfd2, 0)
set_amp_control(0.75, true)
test_panel(:amp_control)
@@ -25621,8 +23715,8 @@ def test_14
snd_display("set_expand_control_ramp 0.025, true: %s?", res)
end
clone = clone_sound_as("/tmp/cloned.snd", cfd2)
- if frames(cfd2) != frames(clone)
- snd_display("clone frames: %s %s?", frames(cfd2), frames(clone))
+ if framples(cfd2) != framples(clone)
+ snd_display("clone framples: %s %s?", framples(cfd2), framples(clone))
end
close_sound(clone)
delete_file("/tmp/cloned.snd")
@@ -25659,15 +23753,18 @@ def test_14
undo_edit(2)
undo_hook.reset_hook!
edit_hook.reset_hook!
- $snd_error_hook.reset_hook!
- $snd_warning_hook.reset_hook!
+ sw_msg = "sw_msg"
$snd_warning_hook.add_hook!("snd-test") do |msg|
+ sw_msg = msg
if msg != "hiho"
snd_display("$snd_warning_hook: %s?", msg)
end
true
end
snd_warning("hiho")
+ if sw_msg != "hiho"
+ snd_display("$snd_warning_hook not called (%s != hiho)?", sw_msg)
+ end
$snd_error_hook.reset_hook!
$snd_warning_hook.reset_hook!
if proc? $my_snd_error_hook
@@ -25683,7 +23780,7 @@ def test_14
test_channel(:transform_graph?)
test_channel(:time_graph?)
test_channel(:lisp_graph?)
- test_channel(:frames)
+ test_channel(:framples)
test_channel(:cursor)
test_channel(:cursor_size)
test_channel(:cursor_style)
@@ -25717,7 +23814,9 @@ def test_14
set_x_bounds([0.1, 0.2])
set_transform_type($fourier_transform)
set_x_bounds([0.1, 0.2])
- $lisp_graph_hook.add_hook!("display_energy") do |snd, chn| display_energy(snd, chn) end
+ $lisp_graph_hook.add_hook!("display_energy") do |snd, chn|
+ display_energy(snd, chn)
+ end
$graph_hook.reset_hook!
if channels() == 2
$graph_hook.add_hook!("correlate") do |snd, chn, y0, y1|
@@ -25732,7 +23831,7 @@ def test_14
buffer = Vct.new(128)
position = 0
current_sample = 0
- chan_samples = frames
+ chan_samples = framples
map_chan_rb do |y|
old_y = buffer[position]
sum_of_squares = (sum_of_squares + y * y) - old_y * old_y
@@ -25764,7 +23863,7 @@ def test_14
#
maxval1 = maxamp + 0.01
unless every_sample? do |y| y < maxval1 end
- res = scan_chan(lambda do |y| y >= maxval1 end)
+ res = scan_channel(lambda do |y| y >= maxval1 end)
snd_display("%s, every_sample?: %s %s [%s: %s]?",
short_file_name, maxval1, res, cursor, sample(cursor))
edit_position.times do |i|
@@ -25781,8 +23880,8 @@ def test_14
end
10.times do |i|
Snd.sounds.each do |snd|
- if frames(snd) > 0
- dur = (frames(snd) / srate(snd).to_f).floor.to_f
+ if framples(snd) > 0
+ dur = (framples(snd) / srate(snd).to_f).floor.to_f
start = [0.0, [dur - 0.1, random(dur)].min].max
if dur > 0.0
set_x_bounds([start, [start + 0.1, dur].min], snd, 0)
@@ -25810,10 +23909,8 @@ def test_14
[:with_tracking_cursor, false, false, true],
[:cursor_size, false, 15, 25],
[:cursor_style, false, Cursor_cross, Cursor_line],
- [:tracking_cursor_style, false, Cursor_cross, Cursor_line],
+ [:tracking_cursor_style, false, Cursor_line, Cursor_cross],
[:clipping, false, false, true],
- [:default_output_chans, false, 1, 8],
- [:default_output_srate, false, 22050, 44100],
[:dot_size, false, 1, 10],
[:enved_base, false, 0.01, 100.0],
[:enved_clip?, false, false, true],
@@ -25835,13 +23932,12 @@ def test_14
[:fft_with_phases, false, false, true],
[:transform_size, false, 16, 128],
[:transform_graph_type, false, Graph_once, Graph_as_spectrogram],
- [:fft_window, false, 0, Dolph_chebyshev_window],
[:transform_graph?, true, false, true],
[:filter_control_in_dB, true, false, true],
[:filter_control_in_hz, true, false, true],
[:filter_control_order, true, 2, 400],
[:filter_control?, true, false, true],
- [:graph_cursor, false, 0, 35],
+ # [:graph_cursor, false, 0, 35],
[:time_graph_style, false, 0, 4],
[:lisp_graph_style, false, 0, 4],
[:transform_graph_style, false, 0, 4],
@@ -25852,7 +23948,6 @@ def test_14
[:log_freq_start, false, 50.0, 5.0],
[:selection_creates_region, false, false, true],
[:transform_normalization, false, Dont_normalize, Normalize_globally],
- [:view_files_sort, false, 0, 3],
[:play_arrow_size, false, 2, 32],
[:print_length, false, 2, 32],
[:region_graph_style, false, Graph_lines, Graph_lollipops],
@@ -25912,7 +24007,6 @@ def test_14
end
end
end
- # save_options("hiho.rb")
if transform_type != $fourier_transform
set_transform_graph?(false, true, true)
set_transform_size([transform_size, 128].min)
@@ -26034,7 +24128,7 @@ end
def test_selection(ind, beg, len, scaler)
set_selection_member?(true, ind, 0)
set_selection_position(beg)
- set_selection_frames(len)
+ set_selection_framples(len)
scale_selection_by(scaler)
diff = 0.0
pos = edit_position(ind, 0)
@@ -26066,7 +24160,7 @@ end
def test_selection_to(ind, beg, len, maxval)
set_selection_member?(true, ind, 0)
set_selection_position(beg)
- set_selection_frames(len)
+ set_selection_framples(len)
scale_selection_to(maxval)
newmax = 0.0
new_reader = make_sampler(beg, ind, 0)
@@ -26108,9 +24202,9 @@ end
def test_15_00
snds = match_sound_files do |file|
- File.exists?(file) and # for $tests > 1
- mus_sound_header_type(file) != Mus_raw and
- mus_sound_chans(file) == 1
+ File.exist?(file) and # for $tests > 1
+ mus_sound_header_type(file) != Mus_raw and
+ mus_sound_chans(file) == 1
end
if snds.length > 0
obi = open_sound(snds.first)
@@ -26118,34 +24212,38 @@ def test_15_00
snd_display("all_chans (1): %s?", all_chans)
end
snds1 = match_sound_files do |file|
- File.exists?(file) and # for $tests > 1
- mus_sound_chans(file) == 2
+ File.exist?(file) and # for $tests > 1
+ mus_sound_chans(file) == 2
end
if snds1.length > 0
s2i = open_sound(snds1.first)
- if all_chans != [[obi, s2i, s2i], [0, 0, 1]] and all_chans != [[s2i, s2i, obi], [0, 1, 0]]
- snd_display("all_chans (2): %s?", all_chans)
- end
- if finfo("oboe.snd") != "oboe.snd: chans: 1, srate: 22050, Sun/Next, big endian short (16 bits), len: 2.305"
- snd_display("finfo: %s?", finfo("oboe.snd"))
- end
+ res = all_chans
+ req1 = [[obi, s2i, s2i], [0, 0, 1]]
+ req2 = [[s2i, s2i, obi], [0, 1, 0]]
+ if res != req1 and res != req2
+ snd_test_neq(res, req1, "all_chans (2a)")
+ snd_test_neq(res, req2, "all_chans (2b)")
+ end
+ res = finfo("oboe.snd")
+ req = "oboe.snd: chans: 1, srate: 22050, Sun/Next, big endian short (16 bits), len: 2.305"
+ snd_test_neq(res, req, "finfo")
close_sound(s2i)
else
snd_display("No sound file found for s2i: %s", snds1)
end
close_sound(obi)
else
- snd_display("No sound file found obi: %s", snds)
- end
- if all_chans != [[], []]
- snd_display("all_chans (3): %s?", all_chans)
+ snd_display("No sound file found obi: %p", snds)
end
+ res = all_chans
+ req = [[], []]
+ snd_test_neq(res, req, "all_chans(0) (3)")
obi = open_sound("oboe.snd")
set_cursor(1000, obi)
- if locate_zero(0.001) != 1050
- snd_display("locate_zero: %s?", locate_zero(0.001))
+ snd_test_neq(locate_zero(0.001), 1050, "locate_zero")
+ $graph_hook.add_hook!("auto_dot") do |snd, chn, y0, y1|
+ auto_dot(snd, chn, y0, y1)
end
- $graph_hook.add_hook!("auto_dot") do |snd, chn, y0, y1| auto_dot(snd, chn, y0, y1) end
$graph_hook.add_hook!("superimpose_ffts") do |snd, chn, y0, y1|
superimpose_ffts(snd, chn, y0, y1)
end
@@ -26153,14 +24251,12 @@ def test_15_00
update_graphs
#
snds = match_sound_files do |file|
- File.exists?(file) and # for $tests > 1
- mus_sound_chans(file) == 2
+ File.exist?(file) and # for $tests > 1
+ mus_sound_chans(file) == 2
end
if snds.length > 0
s2i = open_sound(snds.first)
- if channels(s2i) != 2
- snd_display("match 2 got %s with %s chans", short_file_name(s2i), channels(s2i))
- end
+ snd_test_neq(channels(s2i), 2, "match 2 got %s", short_file_name(s2i))
update_graphs
$graph_hook.remove_hook!("auto_dot")
$graph_hook.remove_hook!("superimpose_ffts")
@@ -26168,103 +24264,101 @@ def test_15_00
select_sound(obi)
m1 = add_mark(100, obi, 0)
first_mark_in_window_at_left
- if (res = left_sample(obi, 0) - 100).abs > 1
- snd_display("first_mark_in_window_at_left: %s %s?", res, mark_sample(m1))
- end
+ res = left_sample(obi, 0) - 100
+ snd_test_gt(res, 1, "first_mark_in_window_at_left %s", mark_sample(m1))
delete_mark(m1)
close_sound(s2i)
else
- snd_display("No sound file found: %s", snds)
+ $graph_hook.remove_hook!("auto_dot")
+ $graph_hook.remove_hook!("superimpose_ffts")
+ snd_display("No sound file found: %p", snds)
end
safe_make_selection(1000, 2000, obi)
- unless selection?
- make_selection(1000, 2000, obi, 0)
- end
delete_selection_and_smooth
- if (res = edit_fragment(0, obi, 0)) != ["", "init", 0, 50828]
- snd_display("edit_fragment (0): %s?", res)
- end
- if (res = edit_fragment(1, obi, 0)) != ["delete_samples(1000, 1001", "delete", 1000, 1001]
- snd_display("edit_fragment (1): %s?", res)
- end
- if (res = edit_fragment(2, obi, 0)) != ["delete_selection_and_smooth(", "set", 968, 64]
- snd_display("edit_fragment (2): %s?", res)
- end
- samp100 = sample(1100, obi, 0)
- select_sound(obi)
- safe_make_selection(1000, 2000, obi)
- unless selection?
- make_selection(1000, 2000, obi, 0)
- end
- eval_over_selection do |val| 2.0 * val end
- nsamp100 = sample(1100, obi, 0)
- if fneq(2.0 * samp100, nsamp100)
- snd_display("eval_over_selection: %s %s [%s %s]?",
- samp100, nsamp100, selection_position, selection_frames)
- end
- m2 = add_mark(1000, obi, 0)
- m3 = add_mark(2000, obi, 0)
- unless (res = marks(obi, 0)).eql?([m2, m3])
- snd_display("add_mark: %s %s?", res, [m2, m3])
- end
- set_left_sample(950, obi, 0)
- eval_between_marks do |val| 2.0 * val end
- msamp100 = sample(1100, obi, 0)
- if fneq(2.0 * nsamp100, msamp100)
- snd_display("eval_between_marks: %s %s?", nsamp100, msamp100)
- end
- revert_sound(obi)
+ res = edit_fragment(0, obi, 0)
+ req = ["", "init", 0, 50828]
+ snd_test_neq(res, req, "edit_fragment (0)")
+ res = edit_fragment(1, obi, 0)
+ req = ["delete_samples(1000, 1001", "delete", 1000, 1001]
+ snd_test_neq(res, req, "edit_fragment (1)")
+ res = edit_fragment(2, obi, 0)
+ req = ["delete-selection-and-smooth", "set", 968, 64]
+ snd_test_neq(res, req, "edit_fragment (2)")
#
maxa = maxamp(obi)
normalized_mix("pistol.snd", 1000, 0, obi, 0)
nmaxa = maxamp(obi)
- if fneq(maxa, nmaxa)
- snd_display("normalized_mix: %s %s?", maxa, nmaxa)
- end
+ snd_test_neq(nmaxa, maxa, "normalized_mix")
revert_sound(obi)
snds = match_sound_files do |file|
- File.exists?(file) and # for $tests > 1
- mus_sound_chans(file) == 2 and
- mus_sound_frames(file) > 1000
+ File.exist?(file) and # for $tests > 1
+ mus_sound_chans(file) == 2 and
+ mus_sound_framples(file) > 1000
end
if snds.length > 0
s2i = open_sound(snds.first)
- if channels(s2i) != 2
- snd_display("match_sound_files: 2+1000 got %s with %s chans?",
- short_file_name(s2i), channels(s2i))
- end
+ res = channels(s2i)
+ snd_test_neq(res, 2,
+ "match_sound_files: 2+1000 got %s with", short_file_name(s2i))
o1 = sample(1000, obi, 0)
s1 = sample(1000, s2i, 0)
s2 = sample(1000, s2i, 1)
- do_all_chans("double all samples") do |val| (val ? (2.0 * val) : false) end
+ do_all_chans("double all samples") do |val|
+ (val ? (2.0 * val) : false)
+ end
o11 = sample(1000, obi, 0)
s11 = sample(1000, s2i, 0)
s21 = sample(1000, s2i, 1)
- if fneq(2.0 * o1, o11) or fneq(2.0 * s1, s11) or fneq(2.0 * s2, s21)
- snd_display("do_all_chans: %s?", [o1, s1, s2, o11, s11, s21])
+ reso1 = 2.0 * o1
+ ress1 = 2.0 * s1
+ ress2 = 2.0 * s2
+ if fneq(reso1, o11) or fneq(ress1, s11) or fneq(ress2, s21)
+ snd_test_neq(reso1, o11, "do_all_chans (a)")
+ snd_test_neq(ress1, s11, "do_all_chans (b)")
+ snd_test_neq(ress2, s21, "do_all_chans (c)")
end
update_graphs
m1 = maxamp(obi, 0)
m2 = maxamp(s2i, 0)
m3 = maxamp(s2i, 1)
- mc = [[obi, 0], [s2i, 0], [s2i, 1]].map do |snd, chn| maxamp(snd, chn) end
+ mc = [[obi, 0], [s2i, 0], [s2i, 1]].map do |snd, chn|
+ maxamp(snd, chn)
+ end
if fneq(m1, mc[0]) or fneq(m2, mc[1]) or fneq(m3, mc[2])
- snd_display("map maxamp: %s %s %s %s?", m1, m2, m3, mc)
+ snd_test_neq(m1, mc[0], "map maxamp (a)")
+ snd_test_neq(m2, mc[1], "map maxamp (b)")
+ snd_test_neq(m3, mc[2], "map maxamp (c)")
end
set_sync(1, obi)
set_sync(1, s2i)
- do_chans("*2") do |val| (val ? (2.0 * val) : false) end
- mc1 = [[obi, 0], [s2i, 0], [s2i, 1]].map do |snd, chn| maxamp(snd, chn) end
- if fneq(2.0 * m1, mc1[0]) or fneq(2.0 * m2, mc1[1]) or fneq(2.0 * m3, mc1[2])
- snd_display("do_chans: %s %s?", mc, mc1)
+ do_chans("*2") do |val|
+ (val ? (2.0 * val) : false)
+ end
+ mc1 = [[obi, 0], [s2i, 0], [s2i, 1]].map do |snd, chn|
+ maxamp(snd, chn)
+ end
+ resm1 = 2.0 * m1
+ resm2 = 2.0 * m2
+ resm3 = 2.0 * m3
+ if fneq(resm1, mc1[0]) or fneq(resm2, mc1[1]) or fneq(resm3, mc1[2])
+ snd_test_neq(resm1, mc1[0], "do_chans (a)")
+ snd_test_neq(resm2, mc1[1], "do_chans (b)")
+ snd_test_neq(resm3, mc1[2], "do_chans (c)")
end
set_sync(0, obi)
set_sync(0, s2i)
select_sound(s2i)
- do_sound_chans("/2") do |val| (val ? (0.5 * val) : false) end
- mc2 = [[obi, 0], [s2i, 0], [s2i, 1]].map do |snd, chn| maxamp(snd, chn) end
- if fneq(2.0 * m1, mc2[0]) or fneq(m2, mc2[1]) or fneq(m3, mc2[2])
- snd_display("do_sound_chans: %s %s %s?", mc, mc1, mc2)
+ do_sound_chans("/2") do |val|
+ (val ? (0.5 * val) : false)
+ end
+ mc2 = [[obi, 0], [s2i, 0], [s2i, 1]].map do |snd, chn|
+ maxamp(snd, chn)
+ end
+ m1 *= 2.0
+ if fneq(m1, mc2[0]) or fneq(m2, mc2[1]) or fneq(m3, mc2[2])
+ snd_test_neq(m1, mc2[0], "do_sound_chans (a)")
+ snd_test_neq(m2, mc2[1], "do_sound_chans (b)")
+ snd_test_neq(m3, mc2[2], "do_sound_chans (c)")
end
if every_sample? do |val| val > 0.5 end
snd_display("every_sample? (0)?")
@@ -26273,13 +24367,13 @@ def test_15_00
snd_display("every_sample? (1)?")
end
select_sound(obi)
- bins = sort_samples(32)
- snd_test_neq(bins[1], 4504, "sort_samples")
+ res = sort_samples(32)[1]
+ snd_test_neq(res, 4504, "sort_samples")
revert_sound(s2i)
revert_sound(obi)
set_sync(3, obi)
set_sync(3, s2i)
- half_way = (0.5 * frames(obi)).floor
+ half_way = (0.5 * framples(obi)).floor
o1 = sample(half_way, obi, 0)
s1 = sample(half_way, s2i, 0)
s2 = sample(half_way, s2i, 1)
@@ -26290,19 +24384,33 @@ def test_15_00
place_sound(obi, s2i, 45.0)
s31 = sample(half_way, s2i, 0)
s32 = sample(half_way, s2i, 1)
- if fneq(s1 + 0.5 * o1, s21) or fneq(s2 + 0.5 * o1, s22) or fneq(s21, s31) or fneq(s22, s32)
- snd_display("place_soundL %s?", [o1, s1, s2, s21, s22, s31, s32])
+ res1 = s1 + 0.5 * o1
+ res2 = s2 + 0.5 * o1
+ if fneq(res1, s21) or fneq(res2, s22) or fneq(s21, s31) or fneq(s22, s32)
+ snd_test_neq(res1, s21, "place_sound (a)")
+ snd_test_neq(res2, s22, "place_sound (b)")
+ snd_test_neq(s21, s31, "place_sound (c)")
+ snd_test_neq(s22, s32, "place_sound (d)")
end
revert_sound(s2i)
revert_sound(obi)
set_sync(0, obi)
set_sync(0, s2i)
- if fneq(res1 = compand.call(0.0), 0.0) or
- fneq(res2 = compand.call(1.0), 1.0) or
- fneq(res3 = compand.call(0.1), 0.2) or
- fneq(res4 = compand.call(0.99), 0.997) or
- fneq(res5 = compand.call(0.95), 0.984)
- snd_display("compand: %s?", [res1, res2, res3, res4, res5])
+ res1 = compand.call(0.0)
+ res2 = compand.call(1.0)
+ res3 = compand.call(0.1)
+ res4 = compand.call(0.99)
+ res5 = compand.call(0.95)
+ if fneq(res1, 0.0) or
+ fneq(res2, 1.0) or
+ fneq(res3, 0.2) or
+ fneq(res4, 0.997) or
+ fneq(res5, 0.984)
+ snd_test_neq(res1, 0.0, "compand (a)")
+ snd_test_neq(res2, 1.0, "compand (b)")
+ snd_test_neq(res3, 0.2, "compand (c)")
+ snd_test_neq(res4, 0.997, "compand (d)")
+ snd_test_neq(res5, 0.984, "compand (e)")
end
close_sound(obi)
revert_sound(s2i)
@@ -26316,25 +24424,28 @@ def test_15_00
Snd.sounds.each do |snd|
channels(snd).times do |chn|
if selection_member?(snd, chn)
- snd_display("%s[%s] at %s?", short_file_name(snd), chn, selection_position(snd, chn))
+ snd_display("%s[%s] at %s?",
+ short_file_name(snd), chn, selection_position(snd, chn))
end
end
end
end
- if selection_srate != srate(s2i)
- snd_display("selection_srate: %s %s?", selection_srate, srate(s2i))
- end
+ res = selection_srate
+ req = srate(s2i)
+ snd_test_neq(res, req, "selection_srate")
if selection_chans == 2
swap_selection_channels
- if fneq(s1, sample(1000, s2i, 1)) or fneq(s2, sample(1000, s2i, 0))
- snd_display("swap_selection_channels: %s?",
- [s1, s2, sample(1000, s2i, 1), sample(1000, s2i, 0)])
+ res1 = sample(1000, s2i, 1)
+ res2 = sample(1000, s2i, 0)
+ if fneq(res1, s1) or fneq(res2, s2)
+ snd_test_neq(res1, s1, "swap_selection_channels (a)")
+ snd_test_neq(res2, s2, "swap_selection_channels (b)")
end
end
revert_sound(s2i)
close_sound(s2i)
else
- snd_display("No sound file found s2i: %s", snds)
+ snd_display("No sound file found s2i: %p", snds)
end
#
obi = open_sound("oboe.snd")
@@ -26349,9 +24460,9 @@ def test_15_00
snd_display("make_region regions: %s?", regions.inspect)
end
revert_sound(obi)
- oldlen = frames(obi)
+ oldlen = framples(obi)
env_sound_interp([0, 0, 1, 1, 2, 0], 2.0, obi, 0)
- newlen = frames(obi)
+ newlen = framples(obi)
if (2 * oldlen - newlen).abs > 3
snd_display("env_sound_interp: %s %s?", oldlen, newlen)
end
@@ -26359,37 +24470,23 @@ def test_15_00
#
revert_sound(obi)
granulated_sound_interp([0, 0, 1, 0.1, 2, 1], 1.0, 0.2, [0, 0, 1, 1, 2, 0])
- if edit_position(obi, 0) != 1
- snd_display("granulated_sound_interp no-op 1?")
- end
- if (res = maxamp(obi, 0)) < 0.15
- snd_display("granulated_sound_interp 1 maxamp: %s?", res)
- end
- if (res = frames(obi, 0) - 50828) > 1000
- snd_display("granulated_sound_interp 1 frames: %s?", res)
- end
+ snd_test_neq(edit_position(obi, 0), 1, "granulated_sound_interp no-op 1")
+ snd_test_lt(maxamp(obi, 0), 0.15, "granulated_sound_interp 1 maxamp")
+ res = (framples(obi, 0) - 50828).abs
+ snd_test_gt(res, 1000, "granulated_sound_interp 1 framples")
revert_sound(obi)
granulated_sound_interp([0, 0, 1, 1], 2.0)
- if edit_position(obi, 0) != 1
- snd_display("granulated_sound_interp no-op 2?")
- end
- if (res = maxamp(obi, 0)) < 0.15
- snd_display("granulated_sound_interp 2 maxamp: %s?", res)
- end
- if (res = frames(obi, 0) - 101656) > 1000
- snd_display("granulated_sound_interp 2 frames: %s?", res)
- end
+ snd_test_neq(edit_position(obi, 0), 1, "granulated_sound_interp no-op 2")
+ snd_test_lt(maxamp(obi, 0), 0.145, "granulated_sound_interp 2 maxamp")
+ res = (framples(obi, 0) - 101656).abs
+ snd_test_gt(res, 1000, "granulated_sound_interp 2 framples")
revert_sound(obi)
- granulated_sound_interp([0, 0, 1, 0.1, 2, 1], 1.0, 0.2, [0, 0, 1, 1, 2, 0], 0.02)
- if edit_position(obi, 0) != 1
- snd_display("granulated_sound_interp no-op 3?")
- end
- if (res = maxamp(obi, 0)) < 0.2
- snd_display("granulated_sound_interp 3 maxamp: %s?", res)
- end
- if (res = frames(obi, 0) - 50828) > 1000
- snd_display("granulated_sound_interp 3 frames: %s?", res)
- end
+ granulated_sound_interp([0, 0, 1, 0.1, 2, 1], 1.0, 0.2,
+ [0, 0, 1, 1, 2, 0], 0.02)
+ snd_test_neq(edit_position(obi, 0), 1, "granulated_sound_interp no-op 3")
+ snd_test_lt(maxamp(obi, 0), 0.2, "granulated_sound_interp 3 maxamp")
+ res = (framples(obi, 0) - 50828).abs
+ snd_test_gt(res, 1000, "granulated_sound_interp 3 framples")
close_sound(obi)
end
@@ -26399,79 +24496,81 @@ def test_15_01
env_sound([0, 0, 1, 1])
osc = make_oscil(:frequency, 1000.0, :initial_phase, PI + HALF_PI)
reader = make_sound_interp(0, ind, 0)
- len = frames(ind, 0) - 1
- map_channel_rb do |val| sound_interp(reader, len * (0.5 + 0.5 * oscil(osc))) end
- unless vequal(res = channel2vct,
- vct(0.000, 0.020, 0.079, 0.172, 0.291, 0.427, 0.569, 0.706, 0.825, 0.919,
- 0.979, 1.000, 0.981, 0.923, 0.831, 0.712, 0.576, 0.434, 0.298, 0.177))
- snd_display("sound_interp: %s?", res)
+ len = framples(ind, 0) - 1
+ map_channel_rb do |val|
+ sound_interp(reader, len * (0.5 + 0.5 * oscil(osc)))
end
+ snd_test_neq(channel2vct(),
+ vct(0.000, 0.020, 0.079, 0.172, 0.291, 0.427, 0.569, 0.706,
+ 0.825, 0.919, 0.979, 1.000, 0.981, 0.923, 0.831, 0.712,
+ 0.576, 0.434, 0.298, 0.177),
+ "sound_interp")
undo_edit
osc = make_oscil(:frequency, 0.5, :initial_phase, PI + HALF_PI)
reader = make_sound_interp(0, ind, 0)
- len = frames(ind, 0) - 1
- map_channel(lambda do |val| sound_interp(reader, len * (0.5 + 0.5 * oscil(osc))) end)
+ len = framples(ind, 0) - 1
+ map_channel(lambda do |val|
+ sound_interp(reader, len * (0.5 + 0.5 * oscil(osc)))
+ end)
undo_edit
env_sound_interp([0, 0, 1, 1])
snd_test_neq(channel2vct(),
- vct(0.000, 0.053, 0.105, 0.158, 0.211, 0.263, 0.316, 0.368, 0.421, 0.474,
- 0.526, 0.579, 0.632, 0.684, 0.737, 0.789, 0.842, 0.895, 0.947, 1.000),
+ vct(0.000, 0.053, 0.105, 0.158, 0.211, 0.263, 0.316, 0.368,
+ 0.421, 0.474, 0.526, 0.579, 0.632, 0.684, 0.737, 0.789,
+ 0.842, 0.895, 0.947, 1.000),
"env_sound_interp no change")
undo_edit
env_sound_interp([0, 0, 1, 0.95, 2, 0], 2.0)
snd_test_neq(channel2vct(),
- vct(0.000, 0.050, 0.100, 0.150, 0.200, 0.250, 0.300, 0.350, 0.400, 0.450,
- 0.500, 0.550, 0.600, 0.650, 0.700, 0.750, 0.800, 0.850, 0.900, 0.950,
- 1.000, 0.950, 0.900, 0.850, 0.800, 0.750, 0.700, 0.650, 0.600, 0.550,
- 0.500, 0.450, 0.400, 0.350, 0.300, 0.250, 0.200, 0.150, 0.100, 0.050),
+ vct(0.000, 0.050, 0.100, 0.150, 0.200, 0.250, 0.300, 0.350,
+ 0.400, 0.450, 0.500, 0.550, 0.600, 0.650, 0.700, 0.750,
+ 0.800, 0.850, 0.900, 0.950, 1.000, 0.950, 0.900, 0.850,
+ 0.800, 0.750, 0.700, 0.650, 0.600, 0.550, 0.500, 0.450,
+ 0.400, 0.350, 0.300, 0.250, 0.200, 0.150, 0.100, 0.050),
"env_sound_interp twice len and back")
revert_sound(ind)
set_sample(10, 0.5)
remove_clicks
- if fneq(sample(10), 0.0)
- snd_display("remove_clicks: %s?", sample(10))
- end
+ snd_test_neq(sample(10), 0.0, "remove_clicks")
undo_edit
val = scan_channel(search_for_click)
- if val != 11
- snd_display("search_for_click: %s?", val)
- end
+ snd_test_neq(val, 11, "search_for_click")
close_sound(ind)
#
id = open_sound("oboe.snd")
- fr = frames(id, 0)
+ fr = framples(id, 0)
mx = maxamp(id, 0)
- set_frames(25000, id, 0)
- if (res = frames(id, 0)) != 25000
- snd_display("set_frames 25000: %s?", res)
+ set_framples(25000, id, 0)
+ if (res = framples(id, 0)) != 25000
+ snd_display("set_framples 25000: %s?", res)
end
if (res = edit_position(id, 0)) != 1
- snd_display("set_frames 25000 edit: %s?", res)
+ snd_display("set_framples 25000 edit: %s?", res)
end
- set_frames(75000, id, 0)
- if (res = frames(id, 0)) != 75000
- snd_display("set_frames 75000: %s?", res)
+ set_framples(75000, id, 0)
+ if (res = framples(id, 0)) != 75000
+ snd_display("set_framples 75000: %s?", res)
end
if (res = edit_position(id, 0)) != 2
- snd_display("set_frames 75000 edit: %s?", res)
+ snd_display("set_framples 75000 edit: %s?", res)
end
if fneq(res = sample(30000, id, 0), 0.0)
- snd_display("set_frames 75000 zeros: %s?", res)
+ snd_display("set_framples 75000 zeros: %s?", res)
end
- set_frames(0, id, 0)
- if (res = frames(id, 0)) != 0
- snd_display("set_frames 0: %s?", res)
+ set_framples(0, id, 0)
+ if (res = framples(id, 0)) != 0
+ snd_display("set_framples 0: %s?", res)
end
- set_frames(100, id, 0)
- if (res = frames(id, 0)) != 100
- snd_display("set_frames 100: %s?", res)
+ set_framples(100, id, 0)
+ if (res = framples(id, 0)) != 100
+ snd_display("set_framples 100: %s?", res)
end
revert_sound
if fneq(res = sample(30000, id, 0), -0.0844)
- snd_display("revert from set_frames: %s?", res)
+ snd_display("revert from set_framples: %s?", res)
end
- if (res = frames(id, 0)) != fr
- snd_display("revert set_frames: %s != %s?", res, fr)
+ if (res = framples(id, 0)) != fr
+ snd_display("revert set_framples: %s != %s?", res, fr)
end
set_maxamp(0.5, id, 0)
if fneq(res = maxamp(id, 0), 0.5)
@@ -26554,16 +24653,17 @@ def test_15_01
if (res = (sound_properties(id) or []).length) != len + 2
snd_display("sound_properties: %s?", res)
end
- if (res = Snd.catch do map_channel(lambda do |y| "hiho" end) end).first != :bad_type
- snd_display("map_channel bad val: %s", res.inspect)
- end
+ # XXX: S7 has here :wrong_type_arg
+ # XXX: Ruby has still :bad_type
+ res = Snd.catch do map_channel(lambda do |y| "hiho" end) end
+ snd_test_neq(res.first, :bad_type, "map_channel bad val")
close_sound(id)
#
id = open_sound("oboe.snd")
prefix_it(1000, id)
key(key_to_int(?x), 4, id)
key(key_to_int(?b), 4, id)
- if (left = left_sample(id)) != 0
+ if (left = left_sample(id)) != 1000
snd_display("u1000: %s?", left)
end
prefix_it(0, id)
@@ -26658,9 +24758,9 @@ def test_15_01
close_sound(id)
#
snds = match_sound_files do |file|
- File.exists?(file) and # for $tests > 1
+ File.exist?(file) and # for $tests > 1
mus_sound_chans(file) >= 2 and
- mus_sound_frames(file) > 1000
+ mus_sound_framples(file) > 1000
end
if snds.length > 0
id = open_sound(snds.first)
@@ -26688,15 +24788,15 @@ def test_15_01
end
def f3neq(a, b)
- fneq_err(a, b, 10) # okay
+ fneq_err(a, b, 10)
end
def f4neq(a, b)
- fneq_err(a, b, 1) # okay
+ fneq_err(a, b, 1)
end
def f5neq(a, b)
- fneq_err(a, b, 0.05 * [a, b].max) # okay
+ fneq_err(a, b, 0.05 * [a, b].max)
end
def test_15_02
@@ -26842,7 +24942,7 @@ def test_15_02
set_with_background_processes(false)
ind = open_sound("1a.snd")
player = make_player(ind, 0)
- len = frames(ind, 0)
+ len = framples(ind, 0)
incr = dac_size
e = make_env(:envelope, [0, 0, 1, 1], :length, (len.to_f / incr).floor + 1)
samp = 0
@@ -26875,12 +24975,12 @@ def test_15_02
if (not (res1 = selection_member?(ind, 0))) or (not (res2 = selection_member?(ind)))
snd_display("selection_member? %s %s %s?", res1, res2, selection?)
end
- if (res = selection_frames) != 1
- snd_display("initial selection_frames: %s?", res)
+ if (res = selection_framples) != 1
+ snd_display("initial selection_framples: %s?", res)
end
- set_selection_frames(1200)
- if (res = selection_frames) != 1200
- snd_display("selection_frames 1200: %s?", res)
+ set_selection_framples(1200)
+ if (res = selection_framples) != 1200
+ snd_display("selection_framples 1200: %s?", res)
end
delete_selection
if selection?
@@ -26893,27 +24993,27 @@ def test_15_02
if (not (res1 = selection_member?(ind, 0))) or (not (res2 = selection_member?(ind)))
snd_display("selection_member? after undo %s %s %s?", res1, res2, selection?)
end
- if (res1 = selection_frames) != 1200 or (res2 = selection_position) != 0
+ if (res1 = selection_framples) != 1200 or (res2 = selection_position) != 0
snd_display("selection after undo: [0, 1200] [%s, %s]?", res2, res1)
end
set_selection_position(1000)
- if (res1 = selection_frames) != 200 or (res2 = selection_position) != 1000
+ if (res1 = selection_framples) != 200 or (res2 = selection_position) != 1000
snd_display("selection after undo: [1000, 200] [%s, %s]?", res2, res1)
end
reverse_selection
- if (res1 = selection_frames) != 200 or (res2 = selection_position) != 1000
+ if (res1 = selection_framples) != 200 or (res2 = selection_position) != 1000
snd_display("selection after reverse: [1000, 200] [%s, %s]?", res2, res1)
end
- old_frames = frames(ind)
+ old_framples = framples(ind)
src_selection(0.5)
- if (frames(ind) - (200 + old_frames)).abs > 5 or
- ((res = selection_frames) - 400).abs > 5
+ if (framples(ind) - (200 + old_framples)).abs > 5 or
+ ((res = selection_framples) - 400).abs > 5
snd_display("selection after src 0.5: [1000, 400] [%s, %s]?", res, selection_position)
end
undo_edit
redo_edit
- if (frames(ind) - (200 + old_frames)).abs > 5 or
- ((res = selection_frames) - 400).abs > 5
+ if (framples(ind) - (200 + old_framples)).abs > 5 or
+ ((res = selection_framples) - 400).abs > 5
snd_display("selection after src 0.5 with undo/redo: [1000, 400] [%s, %s]?",
res, selection_position)
end
@@ -26922,7 +25022,8 @@ def test_15_02
#
# src-duration tests
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1, "src-* tests", 10000)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next,
+ "src-* tests", 10000)
osc = make_oscil(:frequency, 500)
if fneq(res1 = src_duration([0, 1, 1, 2]), 0.693147180559945) or
fneq(res2 = src_duration([0, 2, 1, 1]), src_duration([0, 1, 1, 2])) or
@@ -26962,7 +25063,7 @@ def test_15_02
# src_sound
src_lists1.each do |sr, dur|
src_sound(sr, 1.0, ind, 0)
- if fneq(res = frames(ind, 0) / 10000.0, dur)
+ if fneq(res = framples(ind, 0) / 10000.0, dur)
snd_display("src_sound %s: %s (%s)?", sr, res, dur)
end
vals = freq_peak(0, ind, 8192)
@@ -26973,7 +25074,7 @@ def test_15_02
end
src_lists2.each do |e, f0, f1|
src_sound(e, 1.0, ind, 0)
- if fneq(res1 = frames(ind, 0) / 10000.0, res2 = src_duration(e))
+ if fneq(res1 = framples(ind, 0) / 10000.0, res2 = src_duration(e))
snd_display("src_sound (env) %s: %s (%s)?", e, res1, res2)
end
vals = freq_peak(0, ind, 256)
@@ -26987,8 +25088,8 @@ def test_15_02
undo_edit
end
src_lists2.each do |e, f0, f1|
- src_sound(make_env(:envelope, e, :length, frames), 1.0, ind, 0)
- if fneq(res1 = frames(ind, 0) / 10000.0, res2 = src_duration(e))
+ src_sound(make_env(:envelope, e, :length, framples), 1.0, ind, 0)
+ if fneq(res1 = framples(ind, 0) / 10000.0, res2 = src_duration(e))
snd_display("src_sound (make_env) %s: %s (%s)?", e, res1, res2)
end
vals = freq_peak(0, ind, 256)
@@ -27004,7 +25105,7 @@ def test_15_02
# src_channel
src_lists1.each do |sr, dur|
src_channel(sr)
- if fneq(res = frames(ind, 0) / 10000.0, dur)
+ if fneq(res = framples(ind, 0) / 10000.0, dur)
snd_display("src_channel %s: %s (%s)?", sr, res, dur)
end
vals = freq_peak(0, ind, 8192)
@@ -27015,7 +25116,7 @@ def test_15_02
end
src_lists2.each do |e, f0, f1|
src_channel(e)
- if fneq(res1 = frames(ind, 0) / 10000.0, res2 = src_duration(e))
+ if fneq(res1 = framples(ind, 0) / 10000.0, res2 = src_duration(e))
snd_display("src_channel (env) %s: %s (%s)?", e, res1, res2)
end
vals = freq_peak(0, ind, 256)
@@ -27030,7 +25131,7 @@ def test_15_02
end
src_lists1.each do |sr, dur|
src_channel(sr, 1000, 2500)
- if f4neq(res1 = frames(ind, 0), (res2 = 7500 + dur * 2500))
+ if f4neq(res1 = framples(ind, 0), (res2 = 7500 + dur * 2500))
snd_display("src_channel section: %s %s?", res1, res)
end
vals = freq_peak(0, ind, 512)
@@ -27049,7 +25150,7 @@ def test_15_02
end
src_lists3.each do |e|
src_channel(make_env(:envelope, e, :length, 2501), 1000, 2500)
- if f3neq(res1 = frames(ind, 0), (res2 = 7500 + src_duration(e) * 2500))
+ if f3neq(res1 = framples(ind, 0), (res2 = 7500 + src_duration(e) * 2500))
snd_display("src_channel section (make_env duration) %s: %s (%s %s)?",
e, src_duration(e), res1, res2)
end
@@ -27067,7 +25168,7 @@ def test_15_02
make_selection(1000, 3500, ind, 0)
src_lists1.each do |sr, dur|
src_selection(sr)
- if f3neq(res1 = frames(ind, 0), (res2 = 7500 + dur * 2500))
+ if f3neq(res1 = framples(ind, 0), (res2 = 7500 + dur * 2500))
snd_display("src_selection section: %s %s?", res1, res)
end
vals = freq_peak(0, ind, 512)
@@ -27086,7 +25187,7 @@ def test_15_02
end
src_lists3.each do |e|
src_selection(make_env(:envelope, e, :length, 2501))
- if f3neq(res1 = frames(ind, 0), (res2 = 7500 + src_duration(e) * 2500))
+ if f3neq(res1 = framples(ind, 0), (res2 = 7500 + src_duration(e) * 2500))
snd_display("src_selection section (make_env duration) %s: %s (%s %s)?",
e, src_duration(e), res1, res2)
end
@@ -27102,7 +25203,7 @@ def test_15_02
end
src_lists3.each do |e|
src_selection(e)
- if f3neq(res1 = frames(ind, 0), (res2 = 7500 + src_duration(e) * 2500))
+ if f3neq(res1 = framples(ind, 0), (res2 = 7500 + src_duration(e) * 2500))
snd_display("src_selection section (env duration) %s: %s (%s %s)?",
e, src_duration(e), res1, res2)
end
@@ -27156,28 +25257,16 @@ def test_15_03
delete_file("hi.snd")
#
ind = open_sound("oboe.snd")
- len = frames(ind)
+ len = framples(ind)
set_cursor(1200, ind)
key(key_to_int(?u), 4, ind)
key(key_to_int(?1), 0, ind)
key(key_to_int(?0), 0, ind)
key(key_to_int(?0), 0, ind)
key(key_to_int(?o), 4, ind)
- if frames(ind) != 100 + len
- snd_display("C-o len: %s?", frames)
- end
- if $with_test_gui
- reader = make_sampler(1200, ind)
- 100.times do |i|
- if fneq(val = next_sample(reader), 0.0)
- snd_display("C-o[%s]: %s?", i, val)
- end
- end
- if (res = sampler_position(reader)) != 1300
- snd_display("reader position: %s?", res)
- end
- free_sampler(reader)
- end
+ snd_test_neq(framples(ind), 100 + len, "C-o len")
+ data = channel2vct(1200, 100, ind)
+ snd_test_neq(vct_peak(data), 0.0, "C-o")
revert_sound(ind)
set_cursor(1200, ind)
key(key_to_int(?u), 4, ind)
@@ -27185,18 +25274,9 @@ def test_15_03
key(key_to_int(?0), 0, ind)
key(key_to_int(?0), 0, ind)
key(key_to_int(?z), 4, ind)
- if frames(ind) != len
- snd_display("C-z len: %s?", frames)
- end
- if $with_test_gui
- reader = make_sampler(1200, ind)
- 100.times do |i|
- if fneq(val = next_sample(reader), 0.0)
- snd_display("C-z[%s]: %s?", i, val)
- end
- end
- free_sampler(reader)
- end
+ snd_test_neq(framples(ind), len, "C-z len")
+ data = channel2vct(1200, 100, ind)
+ snd_test_neq(vct_peak(data), 0.0, "C-z")
set_cursor(0, ind)
key(key_to_int(?u), 4, ind)
key(key_to_int(?3), 0, ind)
@@ -27213,18 +25293,9 @@ def test_15_03
key(key_to_int(?.), 0, ind)
key(key_to_int(?0), 0, ind)
key(key_to_int(?o), 4, ind)
- if frames(ind) != srate(ind) + len
- snd_display("C-o 1.0 len: %s?", frames)
- end
- if $with_test_gui
- reader = make_sampler(1200, ind)
- srate(ind).times do |i|
- if fneq(val = next_sample(reader), 0.0)
- snd_display("C-o 1.0[%s]: %s?", i, val)
- end
- end
- free_sampler(reader)
- end
+ snd_test_neq(framples(ind), len + srate(ind), "C-o 1.0 len")
+ data = channel2vct(1200, 100, ind)
+ snd_test_neq(vct_peak(data), 0.0, "C-o 1.0")
revert_sound(ind)
set_cursor(1200, ind)
key(key_to_int(?u), 4, ind)
@@ -27232,18 +25303,9 @@ def test_15_03
key(key_to_int(?.), 0, ind)
key(key_to_int(?0), 0, ind)
key(key_to_int(?z), 4, ind)
- if frames(ind) != len
- snd_display("C-z 1.0 len: %s?", frames)
- end
- if $with_test_gui
- reader = make_sampler(1200, ind)
- srate(ind).times do |i|
- if fneq(val = next_sample(reader), 0.0)
- snd_display("C-z 1.0[%s]: %s?", i, val)
- end
- end
- free_sampler(reader)
- end
+ snd_test_neq(framples(ind), len, "C-z 1.0 len")
+ data = channel2vct(1200, srate(ind), ind)
+ snd_test_neq(vct_peak(data), 0.0, "C-z 1.0")
close_sound(ind)
#
ind = open_sound("2.snd")
@@ -27255,8 +25317,8 @@ def test_15_03
(not (res2 = selection_member?(ind, 1))) or
(res3 = selection_position(ind, 0)) != 0 or
(res4 = selection_position(ind, 1)) != 0 or
- (res5 = selection_frames(ind, 0)) != frames(ind, 0) or
- (res6 = selection_frames(ind, 1)) != frames(ind, 1)
+ (res5 = selection_framples(ind, 0)) != framples(ind, 0) or
+ (res6 = selection_framples(ind, 1)) != framples(ind, 1)
snd_display("sync selection via <-: %s %s %s %s %s %s?", res1, res2, res3, res4, res5, res6)
end
key(key_to_int(?\s), 4)
@@ -27265,8 +25327,8 @@ def test_15_03
(not (res2 = selection_member?(ind, 1))) or
(res3 = selection_position(ind, 0)) != 0 or
(res4 = selection_position(ind, 1)) != 0 or
- (res5 = selection_frames(ind, 0)) != frames(ind, 0) or
- (res6 = selection_frames(ind, 1)) != frames(ind, 1)
+ (res5 = selection_framples(ind, 0)) != framples(ind, 0) or
+ (res6 = selection_framples(ind, 1)) != framples(ind, 1)
snd_display("sync selection via ->: %s %s %s %s %s %s?", res1, res2, res3, res4, res5, res6)
end
set_cursor(0, ind, 1)
@@ -27294,7 +25356,7 @@ def test_15_03
unless selection?
snd_display("no selection from 1 samp region?")
end
- if (res = selection_frames) != 1
+ if (res = selection_framples) != 1
snd_display("1 samp selection: %s samps?", res)
end
scale_selection_to(1.0)
@@ -27304,23 +25366,23 @@ def test_15_03
revert_sound(ind)
id = make_region(500, 1000)
src_selection(0.5)
- if ((res = region_frames(id)) - 500).abs > 1
- snd_display("region_frames after src_selection: %s?", res)
+ if ((res = region_framples(id)) - 500).abs > 1
+ snd_display("region_framples after src_selection: %s?", res)
end
reg_mix_id = mix_region(id, 1500, ind, 0).car
- if (res1 = mix_length(reg_mix_id)) != (res2 = region_frames(id))
+ if (res1 = mix_length(reg_mix_id)) != (res2 = region_framples(id))
snd_display("mix_region: %s != %s?", res1, res2)
end
if (res = mix_home(reg_mix_id)) != [ind, 0, false, 0]
snd_display("mix_region mix_home %s [%s, 0, false, 0]?", res, ind)
end
sel_mix_id = mix_selection(2500, ind, 0).car
- if (res1 = mix_length(sel_mix_id)) != (res2 = selection_frames)
- snd_display("mix_selection frames: %s != %s?", res1, res2)
+ if (res1 = mix_length(sel_mix_id)) != (res2 = selection_framples)
+ snd_display("mix_selection framples: %s != %s?", res1, res2)
end
if ((res1 = mix_length(reg_mix_id)) * 2 - (res2 = mix_length(sel_mix_id))).abs > 3
snd_display("mix selection and region: %s %s %s %s?",
- res1, res2, region_frames(id), selection_frames)
+ res1, res2, region_framples(id), selection_framples)
end
if (res = mix_home(reg_mix_id)) != [ind, 0, false, 0]
snd_display("mix_selection mix_home %s [%s, 0, false, 0]?", res, ind)
@@ -27332,7 +25394,7 @@ def test_15_03
revert_sound(ind)
close_sound(ind)
#
- if File.exists?("storm.snd")
+ if File.exist?("storm.snd")
ind = open_sound("storm.snd")
set_sinc_width(10)
with_time("src_sound(1.3)") do src_sound(1.3) end
@@ -27352,7 +25414,7 @@ def test_15_03
ramp_channel(0.0, 1.0)
close_sound(ind)
end
- if File.exists?("1a.snd") and $all_args
+ if File.exist?("1a.snd") and $all_args
ind = open_sound("1a.snd")
with_time("rubber_sound(1.25)") do rubber_sound(1.25) end
close_sound(ind)
@@ -27360,12 +25422,7 @@ def test_15_03
oboe = open_sound("oboe.snd")
a4 = open_sound("4.aiff")
sr = srate(oboe)
- fr = frames(oboe, 0)
- typ = header_type(oboe)
- frm = data_format(oboe)
- loc = data_location(oboe)
- com = comment(oboe)
- save_sound_as("test.aif", oboe, Mus_aifc)
+ save_sound_as("test.aif", oboe, :header_type, Mus_aifc)
oboe_aif = open_sound("test.aif")
if (res = header_type(oboe_aif)) != Mus_aifc
snd_display("oboe_aif header: %s?", mus_header_type_name(res))
@@ -27382,11 +25439,11 @@ def test_15_03
if (res = data_location(oboe_aif)) != 28
snd_display("set_data_location: %s?", res)
end
- set_data_format(oboe_aif, Mus_mulaw)
- if (res = data_format(oboe_aif)) != Mus_mulaw
- snd_display("set_data_format: %s?", mus_data_format_name(res))
+ set_sample_type(oboe_aif, Mus_mulaw)
+ if (res = sample_type(oboe_aif)) != Mus_mulaw
+ snd_display("set_sample_type: %s?", mus_sample_type_name(res))
end
- save_sound_as("test.aif", oboe_aif, Mus_aifc, Mus_bshort, 22050, 0)
+ save_sound_as("test.aif", oboe_aif, 22050, Mus_bshort, Mus_aifc, 0)
close_sound(oboe_aif)
delete_file("test.aif")
set_selected_sound(a4)
@@ -27539,7 +25596,7 @@ def test_15_04
make_selection(5, 9, ind, 0)
scale_selection_to(0.5)
insert_selection(15, ind)
- if (res = frames(ind)) != 25
+ if (res = framples(ind)) != 25
snd_display("insert_selection 5: %s?", res)
end
unless vequal(res = channel2vct(0, 25),
@@ -27559,7 +25616,10 @@ def test_15_04
old_type = transform_type
old_norm = transform_normalization
old_grf = transform_graph_type
- v = Vct.new(2000) do |i| sin(i * 2.0 * (PI / 10)) end
+ e = make_env([0, 0, 1, 2000 * 0.2 * PI], :length, 2001)
+ v = Vct.new(2000) do |i|
+ sin(env(e))
+ end
vct2channel(v, 0, 2000, ind, 0)
set_transform_size(256, ind)
set_transform_type($fourier_transform)
@@ -27569,7 +25629,7 @@ def test_15_04
set_transform_graph?(true)
make_selection(0, 200)
set_show_selection_transform(true)
- set_selection_frames(300)
+ set_selection_framples(300)
update_transform_graph
if vct?(data = transform2vct)
pk = data.peak
@@ -27610,7 +25670,7 @@ end
def undo_env(snd, chn)
if (len = (edits(snd, chn) or []).first) > 0
1.upto(len) do |i|
- if (ed = edit_fragment(i, snd, chn)) and (ed[1] == "env" or ed[1] == "ptree")
+ if (ed = edit_fragment(i, snd, chn)) and ed[1] == "env"
set_edit_position(i - 1, snd, chn)
return true
end
@@ -27626,15 +25686,15 @@ def opt_test(choice)
curchn = random(channels(cursnd))
cur_maxamps = []
cur_edits = []
- cur_frames = []
+ cur_framples = []
all_chans_zipped.each do |s, c|
cur_maxamps << maxamp(s, c)
cur_edits << edit_position(s, c)
- cur_frames << frames(s, c)
+ cur_framples << framples(s, c)
end
cur_amp = maxamp(cursnd, curchn)
cur_edit = edit_position(cursnd, curchn)
- cur_frame = frames(cursnd, curchn)
+ cur_frame = framples(cursnd, curchn)
snd_lst, chn_lst = all_chans
case choice
when 0 # scale_channel
@@ -27646,8 +25706,8 @@ def opt_test(choice)
snd_display("scale_channel %s[%s] edit pos: %s %s?",
short_file_name(cursnd), curchn, res, cur_edit)
end
- if (res = frames(cursnd, curchn)) != cur_frame
- snd_display("scale_channel %s[%s] frames: %s %s?",
+ if (res = framples(cursnd, curchn)) != cur_frame
+ snd_display("scale_channel %s[%s] framples: %s %s?",
short_file_name(cursnd), curchn, res, cur_frame)
end
if fneq(res1 = maxamp(cursnd, curchn), res2 = scaler * cur_amp)
@@ -27658,13 +25718,13 @@ def opt_test(choice)
snd_display("scale_channel %s[%s] cur_samp: %s %s?",
short_file_name(cursnd), curchn, res1, res2)
end
- snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_frames) do |s, c, amp, ed, fr|
+ snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_framples) do |s, c, amp, ed, fr|
if (not s == cursnd and c == curchn)
if (res = edit_position(s, c)) != ed
snd_display("scale_channel %s[%s] wrong edit pos: %s %s?", short_file_name(s), c, res, ed)
end
- if (res = frames(s, c)) != fr
- snd_display("scale_channel %s[%s] wrong frames: %s %s?", short_file_name(s), c, res, fr)
+ if (res = framples(s, c)) != fr
+ snd_display("scale_channel %s[%s] wrong framples: %s %s?", short_file_name(s), c, res, fr)
end
if fneq(res = maxamp(s, c), amp)
snd_display("scale_channel %s[%s] wrong maxamp: %s %s?", short_file_name(s), c, res, amp)
@@ -27675,13 +25735,13 @@ def opt_test(choice)
maxscl = cur_maxamps.max
scaler = (maxscl < 1.0) ? (random(1.0) + 1.0) : (random(0.5) + 0.5)
scale_by(scaler, cursnd, curchn)
- snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_frames) do |s, c, amp, ed, fr|
+ snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_framples) do |s, c, amp, ed, fr|
if (sync(cursnd) == 0 and (s != cursnd or c != curchn)) or (sync(s) != sync(cursnd))
if (res = edit_position(s, c)) != ed
snd_display("scale_by %s[%s] wrong edit pos: %s %s?", short_file_name(s), c, res, ed)
end
- if (res = frames(s, c)) != fr
- snd_display("scale_by %s[%s] wrong frames: %s %s?", short_file_name(s), c, res, fr)
+ if (res = framples(s, c)) != fr
+ snd_display("scale_by %s[%s] wrong framples: %s %s?", short_file_name(s), c, res, fr)
end
if fneq(res = maxamp(s, c), amp)
snd_display("scale_by %s[%s] wrong maxamp: %s %s?", short_file_name(s), c, res, amp)
@@ -27690,11 +25750,12 @@ def opt_test(choice)
if (res = edit_position(s, c)) != ed + 1 and res != ed
snd_display("scale_by %s[%s] wrong edit pos: %s %s?", short_file_name(s), c, res, ed + 1)
end
- if (res = frames(s, c)) != fr
- snd_display("scale_by %s[%s] wrong frames: %s %s?", short_file_name(s), c, res, fr)
+ if (res = framples(s, c)) != fr
+ snd_display("scale_by %s[%s] wrong framples: %s %s?", short_file_name(s), c, res, fr)
end
if fneq(res1 = maxamp(s, c), res2 = amp * scaler)
- snd_display("scale_by %s[%s] wrong maxamp: %s %s?", short_file_name(s), c, res1, res2)
+ snd_display("scale_by %s[%s] wrong maxamp: %s %s?",
+ short_file_name(s), c, res1, res2)
end
end
end
@@ -27706,7 +25767,7 @@ def opt_test(choice)
0.step(pts - 1, 2) do |i|
e[i] = x
if random(3) > 0
- y = random(2.0) - 1.0
+ y = mus_random(1.0)
end
e[i + 1] = y
if y.abs > maxpt
@@ -27717,14 +25778,14 @@ def opt_test(choice)
if undo_env(cursnd, curchn)
cur_maxamps = []
cur_edits = []
- cur_frames = []
+ cur_framples = []
all_chans_zipped.each do |s, c|
cur_maxamps << maxamp(s, c)
cur_edits << edit_position(s, c)
- cur_frames << frames(s, c)
+ cur_framples << framples(s, c)
cur_amp = maxamp(cursnd, curchn)
cur_edit = edit_position(cursnd, curchn)
- cur_frame = frames(cursnd, curchn)
+ cur_frame = framples(cursnd, curchn)
end
end
env_channel(e, 0, cur_frame, cursnd, curchn)
@@ -27732,8 +25793,8 @@ def opt_test(choice)
snd_display("env_channel %s[%s] edit pos: %s %s?",
short_file_name(cursnd), curchn, res, cur_edit + 1)
end
- if (res = frames(cursnd, curchn)) != cur_frame
- snd_display("env_channel %s[%s] frames: %s %s?",
+ if (res = framples(cursnd, curchn)) != cur_frame
+ snd_display("env_channel %s[%s] framples: %s %s?",
short_file_name(cursnd), curchn, res, cur_frame)
end
if (res1 = maxamp(cursnd, curchn)) - 0.01 > (res2 = maxpt * cur_amp)
@@ -27741,13 +25802,13 @@ def opt_test(choice)
short_file_name(cursnd), curchn, res1, res2, e)
Snd.throw(:mus_error, "env_channel maxamp", short_file_name(cursnd))
end
- snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_frames) do |s, c, amp, ed, fr|
+ snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_framples) do |s, c, amp, ed, fr|
unless s == cursnd and c == curchn
if (res = edit_position(s, c)) != ed
snd_display("env_channel %s[%s] wrong edit pos: %s %s?", short_file_name(s), c, res, ed)
end
- if (res = frames(s, c)) != fr
- snd_display("env_channel %s[%s] wrong frames: %s %s?", short_file_name(s), c, res, fr)
+ if (res = framples(s, c)) != fr
+ snd_display("env_channel %s[%s] wrong framples: %s %s?", short_file_name(s), c, res, fr)
end
if fneq(res = maxamp(s, c), amp)
snd_display("env_channel %s[%s] wrong maxamp: %s %s?", short_file_name(s), c, res, amp)
@@ -27762,7 +25823,7 @@ def opt_test(choice)
0.step(pts - 1, 2) do |i|
e[i] = x
if random(3) > 0
- y = random(2.0) - 1.0
+ y = mus_random(1.0)
end
e[i + 1] = y
if y.abs > maxpt
@@ -27771,7 +25832,7 @@ def opt_test(choice)
x += 0.01 + random(1.0)
end
recalc = false
- minfr = cur_frames.min
+ minfr = cur_framples.min
beg = random((minfr / 2.0).floor)
all_chans_zipped.each do |s, c|
unless (sync(cursnd) == 0 and (s != cursnd or c != curchn)) or sync(s) != sync(cursnd)
@@ -27781,24 +25842,24 @@ def opt_test(choice)
if recalc
cur_maxamps = []
cur_edits = []
- cur_frames = []
+ cur_framples = []
all_chans_zipped.each do |s, c|
cur_maxamps << maxamp(s, c)
cur_edits << edit_position(s, c)
- cur_frames << frames(s, c)
+ cur_framples << framples(s, c)
end
cur_amp = maxamp(cursnd, curchn)
cur_edit = edit_position(cursnd, curchn)
- cur_frame = frames(cursnd, curchn)
+ cur_frame = framples(cursnd, curchn)
end
env_sound(e, beg, [pts, minfr - beg].max, 1.0, cursnd, curchn)
- snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_frames) do |s, c, amp, ed, fr|
+ snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_framples) do |s, c, amp, ed, fr|
if (sync(cursnd) == 0 and (s != cursnd or c != curchn)) or sync(s) != sync(cursnd)
if (res = edit_position(s, c)) != ed
snd_display("env_sound %s[%s] wrong edit pos: %s %s?", short_file_name(s), c, res, ed)
end
- if (res = frames(s, c)) != fr
- snd_display("env_sound %s[%s] wrong frames: %s %s?", short_file_name(s), c, res, fr)
+ if (res = framples(s, c)) != fr
+ snd_display("env_sound %s[%s] wrong framples: %s %s?", short_file_name(s), c, res, fr)
end
if fneq(res = maxamp(s, c), amp)
snd_display("env_sound %s[%s] wrong maxamp: %s %s?", short_file_name(s), c, res, amp)
@@ -27807,8 +25868,8 @@ def opt_test(choice)
if (res = edit_position(s, c)) != ed + 1 and res != ed
snd_display("env_sound %s[%s] edit pos: %s %s?", short_file_name(s), c, res, ed + 1)
end
- if (res = frames(s, c)) != fr
- snd_display("env_sound %s[%s] frames: fr %s orig_fr %s?", short_file_name(s), c, res, fr)
+ if (res = framples(s, c)) != fr
+ snd_display("env_sound %s[%s] framples: fr %s orig_fr %s?", short_file_name(s), c, res, fr)
end
end
end
@@ -27816,14 +25877,14 @@ def opt_test(choice)
maxscl = cur_maxamps.max
scaler = (maxscl < 1.0) ? (random(1.0) + 1.0) : (random(0.5) + 0.5)
scale_sound_by(scaler, 1000, 1000, cursnd)
- snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_frames) do |s, c, amp, ed, fr|
+ snd_lst.zip(chn_lst, cur_maxamps, cur_edits, cur_framples) do |s, c, amp, ed, fr|
if s != cursnd
if (res = edit_position(s, c)) != ed
snd_display("scale_sound_by %s[%s] wrong edit pos: %s %s?",
short_file_name(s), c, res, ed)
end
- if (res = frames(s, c)) != fr
- snd_display("scale_sound_by %s[%s] wrong frames: %s %s?", short_file_name(s), c, res, fr)
+ if (res = framples(s, c)) != fr
+ snd_display("scale_sound_by %s[%s] wrong framples: %s %s?", short_file_name(s), c, res, fr)
end
if fneq(res = maxamp(s, c), amp)
snd_display("scale_sound_by %s[%s] wrong maxamp: %s %s?", short_file_name(s), c, res, amp)
@@ -27833,8 +25894,8 @@ def opt_test(choice)
snd_display("scale_sound_by %s[%s] wrong edit pos: %s %s?",
short_file_name(s), c, res, ed + 1)
end
- if (res = frames(s, c)) != fr
- snd_display("scale_sound_by %s[%s] wrong frames: %s %s?", short_file_name(s), c, res, fr)
+ if (res = framples(s, c)) != fr
+ snd_display("scale_sound_by %s[%s] wrong framples: %s %s?", short_file_name(s), c, res, fr)
end
end
end
@@ -27843,73 +25904,23 @@ def opt_test(choice)
undo_edit(random(pos), cursnd, curchn)
end
when 6
- if (len = frames(cursnd, curchn)) > 10000
+ if (len = framples(cursnd, curchn)) > 10000
delete_samples(random((len / 2).floor), random(100) + 10, cursnd, curchn)
end
when 7
- set_samples(random(frames(cursnd, curchn) + 100), random(100) + 10,
+ set_samples(random(framples(cursnd, curchn) + 100), random(100) + 10,
Vct.new(10, 1.0), cursnd, curchn)
when 8
- insert_samples(random(frames(cursnd, curchn) + 100), random(100) + 10,
+ insert_samples(random(framples(cursnd, curchn) + 100), random(100) + 10,
Vct.new(10, 1.0), cursnd, curchn)
when 9
- add_mark(random(frames(cursnd, curchn)), cursnd, curchn)
+ add_mark(random(framples(cursnd, curchn)), cursnd, curchn)
when 10
mix_vct(Vct.new(random(100) + 10, random(1.0)),
- random(frames(cursnd, curchn) + 100), cursnd, curchn)
+ random(framples(cursnd, curchn) + 100), cursnd, curchn)
when 11
- pad_channel(random(frames(cursnd, curchn) + 100), random(100) + 10, cursnd, curchn)
+ pad_channel(random(framples(cursnd, curchn) + 100), random(100) + 10, cursnd, curchn)
when 12
- beg = random(frames(cursnd, curchn) - 210)
- dur = random(200) + 10
- preader0 = make_sampler(beg + dur - 1, cursnd, curchn, -1)
- reader0 = make_sampler(beg, cursnd, curchn)
- ptree_channel(lambda do |y| y * 2.0 end, beg, dur, cursnd, curchn, false, true)
- preader1 = make_sampler(beg + dur - 1, cursnd, curchn, -1)
- reader1 = make_sampler(beg, cursnd, curchn)
- dur.times do |i|
- pval0 = preader0.call
- val0 = reader0.call
- pval1 = preader1.call
- val1 = reader1.call
- if fneq(val0 * 2.0, val1) or fneq(pval0 * 2.0, pval1)
- snd_display("read ptree at %s: %s %s %s %s (%s %s %s %s): %s?",
- i, val0 * 2.0, val1, pval0 * 2.0, pval1,
- reader0, reader1, preader0, preader1,
- safe_display_edits(cursnd, curchn))
- Snd_throw(:mus_error, "read ptree at", i)
- end
- end
- when 13
- scale_channel(0.5, random(frames(cursnd, curchn) - 100), random(100) + 10, cursnd, curchn)
- when 14
- beg = random(frames(cursnd, curchn) - 200)
- scale_channel(0.5, beg, random(100) + 10, cursnd, curchn)
- scale_channel(0.5, beg + 10, random(100) + 10, cursnd, curchn)
- when 15
- beg = random(frames(cursnd, curchn) - 200)
- scale_channel(0.5, beg, random(100) + 10, cursnd, curchn)
- scale_channel(2.0, beg, random(100) + 10, cursnd, curchn)
- when 16
- beg = random(frames(cursnd, curchn) - 200)
- pad_channel(beg, random(100) + 10, cursnd, curchn)
- pad_channel(beg + 10, random(100) + 10, cursnd, curchn)
- when 17
- beg = random(frames(cursnd, curchn) - 200)
- pad_channel(beg, random(100) + 10, cursnd, curchn)
- pad_channel(beg, random(100) + 10, cursnd, curchn)
- when 18
- beg = random(frames(cursnd, curchn) - 200)
- delete_sample(beg, cursnd, curchn)
- delete_sample(beg + random(100), cursnd, curchn)
- when 19
- beg = random(frames(cursnd, curchn) + 200)
- set_sample(beg, 0.1, cursnd, curchn)
- set_sample(beg + random(100), 0.2, cursnd, curchn)
- when 20
- beg = random(frames(cursnd, curchn) - 200)
- ramp_channel(random(2.0) - 1.0, random(2.0) - 1.0, beg, random(100) + 10, cursnd, curchn)
- when 21
pts = random(8) + 1
maxpt = 0.0
x = y = 0.0
@@ -27917,7 +25928,7 @@ def opt_test(choice)
0.step(pts - 1, 2) do |i|
e[i] = x
if random(3) > 0
- y = random(2.0) - 1.0
+ y = mus_random(1.0)
end
e[i + 1] = y
if y.abs > maxpt
@@ -27925,7 +25936,7 @@ def opt_test(choice)
end
x += 0.01 + random(1.0)
end
- beg = random(frames(cursnd, curchn) - 300)
+ beg = random(framples(cursnd, curchn) - 300)
dur = random(200) + 80
reader0 = make_sampler(beg, cursnd, curchn)
env_channel(e, beg, dur, cursnd, curchn)
@@ -27945,6 +25956,35 @@ def opt_test(choice)
Snd_throw(:mus_error, "read env off at", i)
end
end
+ when 13
+ scale_channel(0.5, random(framples(cursnd, curchn) - 100), random(100) + 10, cursnd, curchn)
+ when 14
+ beg = random(framples(cursnd, curchn) - 200)
+ scale_channel(0.5, beg, random(100) + 10, cursnd, curchn)
+ scale_channel(0.5, beg + 10, random(100) + 10, cursnd, curchn)
+ when 15
+ beg = random(framples(cursnd, curchn) - 200)
+ scale_channel(0.5, beg, random(100) + 10, cursnd, curchn)
+ scale_channel(2.0, beg, random(100) + 10, cursnd, curchn)
+ when 16
+ beg = random(framples(cursnd, curchn) - 200)
+ pad_channel(beg, random(100) + 10, cursnd, curchn)
+ pad_channel(beg + 10, random(100) + 10, cursnd, curchn)
+ when 17
+ beg = random(framples(cursnd, curchn) - 200)
+ pad_channel(beg, random(100) + 10, cursnd, curchn)
+ pad_channel(beg, random(100) + 10, cursnd, curchn)
+ when 18
+ beg = random(framples(cursnd, curchn) - 200)
+ delete_sample(beg, cursnd, curchn)
+ delete_sample(beg + random(100), cursnd, curchn)
+ when 19
+ beg = random(framples(cursnd, curchn) + 200)
+ set_sample(beg, 0.1, cursnd, curchn)
+ set_sample(beg + random(100), 0.2, cursnd, curchn)
+ when 20
+ beg = random(framples(cursnd, curchn) - 200)
+ ramp_channel(random(2.0) - 1.0, random(2.0) - 1.0, beg, random(100) + 10, cursnd, curchn)
end
end
@@ -27997,7 +26037,7 @@ end
def vequal_at(v0, v1)
v0.each_with_index do |val, i|
- if fneq_err(val, v1[i], 0.001) # okay
+ if fneq_err(val, v1[i], 0.001)
return [i, val, v1[i]]
end
end
@@ -28052,23 +26092,23 @@ def check_edit_tree(expected_tree, expected_vals, name)
end
def reversed_read(snd, chn)
- len = frames(snd, chn)
+ len = framples(snd, chn)
sf = make_sampler(len - 1, snd, chn, -1)
Vct.new(len) do read_sample(sf) end.reverse
end
def init_sound(val, dur, chns)
- ind = new_sound("test.snd", Mus_next, Mus_bshort, 22050, chns)
+ ind = new_sound("test.snd", chns, 22050, Mus_bshort, Mus_next)
chns.times do |chn|
insert_silence(0, dur, ind, chn)
- map_channel(lambda do |y| val end, 0, frames, ind, chn)
+ map_channel(lambda do |y| val end, 0, framples, ind, chn)
end
ind
end
def check_back_and_forth(ind, name, v)
happy = true
- unless vequal(res = channel2vct(0, frames, ind, 0), v)
+ unless vequal(res = channel2vct(0, framples, ind, 0), v)
happy = false
snd_display_prev_caller("%s forth: %s %s?", name, res, v)
end
@@ -28080,51 +26120,59 @@ def check_back_and_forth(ind, name, v)
end
def check_both_chans(ind, name, f0, f1)
- if (c0 = scan_channel(f0, 0, frames, ind, 0))
+ if (c0 = scan_channel(f0, 0, framples, ind, 0))
snd_display_prev_caller("%s swap c0: %s?", name, c0)
end
- if (c1 = scan_channel(f1, 0, frames, ind, 1))
+ if (c1 = scan_channel(f1, 0, framples, ind, 1))
snd_display_prev_caller("%s swap c1: %s?", name, c1)
end
end
def test_16_00
oboe = open_sound("oboe.snd")
- [[lambda { scale_channel(2.0, 0, 0, oboe) }, :scale_channel],
- [lambda { env_channel(make_env([0, 0, 1, 1], :length, 123), 0, 0, oboe) }, :env_channel],
- [lambda { clm_channel(make_oscil, 0, 0, oboe) }, :clm_channel],
- [lambda { vct2channel(make_vct(3), 0, 0, oboe) }, :vct2channel],
- [lambda { smooth_channel(0, 0, oboe) }, :smooth_channel],
- [lambda { pad_channel(0, 0, oboe) }, :pad_channel],
- [lambda { src_channel(2.0, 0, 0, oboe) }, :src_channel],
- [lambda { mix_channel("pistol.snd", 0, 0, oboe) }, :mix_channel],
- [lambda { insert_channel("pistol.snd", 0, 0, oboe) }, :insert_channel],
- [lambda { reverse_channel(0, 0, oboe) }, :reverse_channel],
- [lambda { scale_sound_by(2.0, 0, 0, oboe) }, :scale_sound_by],
- [lambda { env_sound([0, 0, 1, 1], 0, 0, oboe) }, :env_sound],
- [lambda { set_samples(0, 0, Vct.new(3), oboe) }, :set_samples],
- [lambda { smooth_sound(0, 0, oboe) }, :smooth_soundxs],
- [lambda { insert_silence(0, 0, oboe) }, :insert_silence]].each do |func, name|
+ [[lambda do scale_channel(2.0, 0, 0, oboe) end, :scale_channel],
+ [lambda do
+ env_channel(make_env([0, 0, 1, 1], :length, 123), 0, 0, oboe)
+ end, :env_channel],
+ [lambda do clm_channel(make_oscil, 0, 0, oboe) end, :clm_channel],
+ [lambda do vct2channel(make_vct(3), 0, 0, oboe) end, :vct2channel],
+ [lambda do smooth_channel(0, 0, oboe) end, :smooth_channel],
+ [lambda do pad_channel(0, 0, oboe) end, :pad_channel],
+ [lambda do src_channel(2.0, 0, 0, oboe) end, :src_channel],
+ [lambda do mix_channel("pistol.snd", 0, 0, oboe) end, :mix_channel],
+ [lambda do insert_channel("pistol.snd", 0, 0, oboe) end, :insert_channel],
+ [lambda do reverse_channel(0, 0, oboe) end, :reverse_channel],
+ [lambda do scale_sound_by(2.0, 0, 0, oboe) end, :scale_sound_by],
+ [lambda do env_sound([0, 0, 1, 1], 0, 0, oboe) end, :env_sound],
+ [lambda do set_samples(0, 0, Vct.new(3), oboe) end, :set_samples],
+ [lambda do smooth_sound(0, 0, oboe) end, :smooth_soundxs],
+ [lambda do
+ insert_silence(0, 0, oboe)
+ end, :insert_silence]].each do |func, name|
func.call
if (res = edit_position(oboe)) != 0
snd_display("dur: 0 %s: %s %s?", name, res, edit_fragment)
end
end
- [[lambda { scale_channel(2.0, -1, 123, oboe) }, :scale_channel],
- [lambda { env_channel(make_env([0, 0, 1, 1], :length, 123), -1, 123, oboe) }, :env_channel],
- [lambda { clm_channel(make_oscil, -1, 123, oboe) }, :clm_channel],
- [lambda { vct2channel(make_vct(3), -1, 123, oboe) }, :vct2channel],
- [lambda { smooth_channel(-1, 123, oboe) }, :smooth_channel],
- [lambda { pad_channel(-1, 123, oboe) }, :pad_channel],
- [lambda { src_channel(2.0, -1, 123, oboe) }, :src_channel],
- [lambda { mix_channel("pistol.snd", -1, 123, oboe) }, :mix_channel],
- [lambda { insert_channel("pistol.snd", -1, 123, oboe) }, :insert_channel],
- [lambda { reverse_channel(-1, 123, oboe) }, :reverse_channel],
- [lambda { scale_sound_by(2.0, -1, 123, oboe) }, :scale_sound_by],
- [lambda { env_sound([0, 0, 1, 1], -1, 123, oboe) }, :env_sound],
- [lambda { set_samples(-1, 123, Vct.new(3), oboe) }, :set_samples],
- [lambda { smooth_sound(-1, 123, oboe) }, :smooth_soundxs],
- [lambda { insert_silence(-1, 123, oboe) }, :insert_silence]].each do |func, name|
+ [[lambda do scale_channel(2.0, -1, 123, oboe) end, :scale_channel],
+ [lambda do
+ env_channel(make_env([0, 0, 1, 1], :length, 123), -1, 123, oboe)
+ end, :env_channel],
+ [lambda do clm_channel(make_oscil, -1, 123, oboe) end, :clm_channel],
+ [lambda do vct2channel(make_vct(3), -1, 123, oboe) end, :vct2channel],
+ [lambda do smooth_channel(-1, 123, oboe) end, :smooth_channel],
+ [lambda do pad_channel(-1, 123, oboe) end, :pad_channel],
+ [lambda do src_channel(2.0, -1, 123, oboe) end, :src_channel],
+ [lambda do mix_channel("pistol.snd", -1, 123, oboe) end, :mix_channel],
+ [lambda do insert_channel("pistol.snd", -1, 123, oboe) end, :insert_channel],
+ [lambda do reverse_channel(-1, 123, oboe) end, :reverse_channel],
+ [lambda do scale_sound_by(2.0, -1, 123, oboe) end, :scale_sound_by],
+ [lambda do env_sound([0, 0, 1, 1], -1, 123, oboe) end, :env_sound],
+ [lambda do set_samples(-1, 123, Vct.new(3), oboe) end, :set_samples],
+ [lambda do smooth_sound(-1, 123, oboe) end, :smooth_soundxs],
+ [lambda do
+ insert_silence(-1, 123, oboe)
+ end, :insert_silence]].each do |func, name|
if (res = Snd.catch do func.call end).first != :no_such_sample
snd_display("%s beg -1 -> %s", name, res.inspect)
end
@@ -28132,44 +26180,54 @@ def test_16_00
snd_display("beg: -1 %s: %s %s?", name, res, edit_fragment)
end
end
- [[lambda { scale_channel(2.0, 12345678, 123, oboe) }, :scale_channel],
- [lambda { env_channel(make_env([0, 0, 1, 1], :length, 123), 12345678, 123, oboe) }, :env_channel],
- [lambda { smooth_channel(12345678, 123, oboe) }, :smooth_channel],
- [lambda { src_channel(2.0, 12345678, 123, oboe) }, :src_channel],
- [lambda { reverse_channel(12345678, 123, oboe) }, :reverse_channel]].each do |func, name|
+ [[lambda do scale_channel(2.0, 12345678, 123, oboe) end, :scale_channel],
+ [lambda do
+ env_channel(make_env([0, 0, 1, 1], :length, 123), 12345678, 123, oboe)
+ end, :env_channel],
+ [lambda do smooth_channel(12345678, 123, oboe) end, :smooth_channel],
+ [lambda do src_channel(2.0, 12345678, 123, oboe) end, :src_channel],
+ [lambda do
+ reverse_channel(12345678, 123, oboe)
+ end, :reverse_channel]].each do |func, name|
func.call
if (res = edit_position(oboe)) != 0
snd_display("beg: 12345678 %s: %s %s?", name, res, edit_fragment)
end
end
pos = 0
- [[lambda { scale_channel(2.0, 0, 123, oboe, 0) }, :scale_channel],
- [lambda { env_channel(make_env([0, 0, 1, 1], :length, 123), 0, 123, oboe, 0) }, :env_channel],
- [lambda { clm_channel(make_oscil, 0, 123, oboe, 0) }, :clm_channel],
- [lambda { vct2channel(make_vct(3), 0, 123, oboe, 0) }, :vct2channel],
- [lambda { smooth_channel(0, 123, oboe, 0) }, :smooth_channel],
- [lambda { pad_channel(0, 123, oboe, 0) }, :pad_channel],
- [lambda { src_channel(2.0, 0, 123, oboe, 0) }, :src_channel],
- [lambda { mix_channel("pistol.snd", 0, 123, oboe, 0) }, :mix_channel],
- [lambda { insert_channel("pistol.snd", 0, 123, oboe, 0) }, :insert_channel],
- [lambda { reverse_channel(0, 123, oboe, 0) }, :reverse_channel],
+ [[lambda do scale_channel(2.0, 0, 123, oboe, 0) end, :scale_channel],
+ [lambda do
+ env_channel(make_env([0, 0, 1, 1], :length, 123), 0, 123, oboe, 0)
+ end, :env_channel],
+ [lambda do clm_channel(make_oscil, 0, 123, oboe, 0) end, :clm_channel],
+ [lambda do vct2channel(make_vct(3), 0, 123, oboe, 0) end, :vct2channel],
+ [lambda do smooth_channel(0, 123, oboe, 0) end, :smooth_channel],
+ [lambda do pad_channel(0, 123, oboe, 0) end, :pad_channel],
+ [lambda do src_channel(2.0, 0, 123, oboe, 0) end, :src_channel],
+ [lambda do mix_channel("pistol.snd", 0, 123, oboe, 0) end, :mix_channel],
+ [lambda do
+ insert_channel("pistol.snd", 0, 123, oboe, 0)
+ end, :insert_channel],
+ [lambda do reverse_channel(0, 123, oboe, 0) end, :reverse_channel],
[let(rd = make_sampler(0),
- make_src(:srate, 2.0, :input, lambda { |dir| rd.call })) { |rd, sr|
- lambda { clm_channel(sr, 0, 12345, oboe, 0) }
- }, "clm_channel src"],
+ make_src(:srate, 2.0,
+ :input, lambda do |dir| rd.call end)) do |rd, sr|
+ lambda do clm_channel(sr, 0, 12345, oboe, 0) end
+ end, "clm_channel src"],
[let(rd = make_sampler(0),
- make_granulate(:expansion, 2.0, :input, lambda { |dir| rd.call })) { |rd, gr|
- lambda { clm_channel(gr, 0, 12345, oboe, 0) }
- }, "clm_channel granulate"],
+ make_granulate(:expansion, 2.0,
+ :input, lambda do |dir| rd.call end)) do |rd, gr|
+ lambda do clm_channel(gr, 0, 12345, oboe, 0) end
+ end, "clm_channel granulate"],
[let(rd = make_sampler(0),
- flt = [1, 0, 0, 0].to_vct,
- make_convolve(:input, lambda { |dir| rd.call }, :filter, flt)) { |rd, flt, cv|
- lambda { clm_channel(cv, 0, 12345, oboe, 0) }
- }, "clm_channel convolve"],
+ make_convolve(:input, lambda do |dir| rd.call end,
+ :filter, vct(1, 0, 0))) do |rd, cv|
+ lambda do clm_channel(cv, 0, 12345, oboe, 0) end
+ end, "clm_channel convolve"],
[let(rd = make_sampler(0),
- make_phase_vocoder(:input, lambda { |dir| rd.call })) { |rd, pv|
- lambda { clm_channel(pv, 0, 12345, oboe, 0) }
- }, "clm_channel phase_vocoder"]].each do |func, name|
+ make_phase_vocoder(:input, lambda do |dir| rd.call end)) do |rd, pv|
+ lambda do clm_channel(pv, 0, 12345, oboe, 0) end
+ end, "clm_channel phase_vocoder"]].each do |func, name|
func.call
if (res = edit_position(oboe)) != pos += 1
snd_display("%s[%s]: %s %s?", name, pos, res, edit_fragment)
@@ -28177,34 +26235,24 @@ def test_16_00
end
#
revert_sound(oboe)
- edpos_fnc = lambda do |hi| false end
- [[lambda { scale_channel(2.0, 0, 123, oboe, 0, edpos_fnc) }, :scale_channel],
- [lambda { env_channel(make_env([0, 0, 1, 1], :length, 123), 0, 123, oboe, 0, edpos_fnc)}, :env_channel],
- [lambda { clm_channel(make_oscil, 0, 123, oboe, 0, edpos_fnc) }, :clm_channel],
- [lambda { vct2channel(make_vct(3), 0, 123, oboe, 0, edpos_fnc) }, :vct2channel],
- [lambda { smooth_channel(0, 123, oboe, 0, edpos_fnc) }, :smooth_channel],
- [lambda { pad_channel(0, 123, oboe, 0, edpos_fnc) }, :pad_channel],
- [lambda { src_channel(2.0, 0, 123, oboe, 0, edpos_fnc) }, :src_channel],
- [lambda { mix_channel("pistol.snd", 0, 123, oboe, 0, edpos_fnc) }, :mix_channel],
- [lambda { insert_channel("pistol.snd", 0, 123, oboe, 0, edpos_fnc) }, :insert_channel],
- [lambda { reverse_channel(0, 123, oboe, 0, edpos_fnc) }, :reverse_channel]].each do |func, name|
- if (res = Snd.catch do func.call end).first != :bad_arity
- snd_display("bad edpos_func %s: %s", name, res.inspect)
- end
- if (res = edit_position(oboe)) != 0
- snd_display("edpos:func %s: %s %s?", name, res, edit_fragment)
- end
- end
- [[lambda { scale_channel(2.0, 0, 123, oboe, 0, 123) }, :scale_channel],
- [lambda { env_channel(make_env([0, 0, 1, 1], :length, 123), 0, 123, oboe, 0, 123)}, :env_channel],
- [lambda { clm_channel(make_oscil, 0, 123, oboe, 0, 123) }, :clm_channel],
- [lambda { vct2channel(make_vct(3), 0, 123, oboe, 0, 123) }, :vct2channel],
- [lambda { smooth_channel(0, 123, oboe, 0, 123) }, :smooth_channel],
- [lambda { pad_channel(0, 123, oboe, 0, 123) }, :pad_channel],
- [lambda { src_channel(2.0, 0, 123, oboe, 0, 123) }, :src_channel],
- [lambda { mix_channel("pistol.snd", 0, 123, oboe, 0, 123) }, :mix_channel],
- [lambda { insert_channel("pistol.snd", 0, 123, oboe, 0, 123) }, :insert_channel],
- [lambda { reverse_channel(0, 123, oboe, 0, 123) }, :reverse_channel]].each do |func, name|
+ [[lambda do scale_channel(2.0, 0, 123, oboe, 0, 123) end, :scale_channel],
+ [lambda do
+ env_channel(make_env([0, 0, 1, 1], :length, 123), 0, 123, oboe, 0, 123)
+ end, :env_channel],
+ [lambda do clm_channel(make_oscil, 0, 123, oboe, 0, 123) end, :clm_channel],
+ [lambda do vct2channel(make_vct(3), 0, 123, oboe, 0, 123) end, :vct2channel],
+ [lambda do smooth_channel(0, 123, oboe, 0, 123) end, :smooth_channel],
+ [lambda do pad_channel(0, 123, oboe, 0, 123) end, :pad_channel],
+ [lambda do src_channel(2.0, 0, 123, oboe, 0, 123) end, :src_channel],
+ [lambda do
+ mix_channel("pistol.snd", 0, 123, oboe, 0, 123)
+ end, :mix_channel],
+ [lambda do
+ insert_channel("pistol.snd", 0, 123, oboe, 0, 123)
+ end, :insert_channel],
+ [lambda do
+ reverse_channel(0, 123, oboe, 0, 123)
+ end, :reverse_channel]].each do |func, name|
if (res = Snd.catch do func.call end).first != :no_such_edit
snd_display("bad edpos %s: %s", name, res.inspect)
end
@@ -28216,17 +26264,17 @@ def test_16_00
oldv = channel2vct(1000, 10, oboe)
mix_channel("oboe.snd", 0)
oldv.scale!(2.0)
- unless (res = channel2vct(1000, 10, oboe), oldv)
+ unless vequal(res = channel2vct(1000, 10, oboe), oldv)
snd_display("mix_channel at 0: %s %s?", oldv, res)
end
revert_sound(oboe)
oldv.scale!(0.5)
insert_channel("oboe.snd", 0)
- unless (res = channel2vct(1000, 10, oboe), oldv)
+ unless vequal(res = channel2vct(1000, 10, oboe), oldv)
snd_display("insert_channel at 0: %s %s?", oldv, res)
end
- if (res1 = frames(oboe, 0)) != (res2 = frames(oboe, 0, 0)) * 2
- snd_display("insert_channel frames: %s %s?", res1, res2)
+ if (res1 = framples(oboe, 0)) != (res2 = framples(oboe, 0, 0)) * 2
+ snd_display("insert_channel framples: %s %s?", res1, res2)
end
revert_sound(oboe)
close_sound(oboe)
@@ -28235,25 +26283,24 @@ end
def funcs_equal?(name, func0, func1, oboe0, oboe1)
func0.call(false, false, oboe0)
func1.call(false, false, oboe1)
- unless vequal(res1 = channel2vct(1000, 100, oboe0), res2 = channel2vct(1000, 100, oboe1))
- snd_display("%s via false:\n# %s\n# %s?", res1, res2)
- end
+ res1 = channel2vct(1000, 100, oboe0)
+ res2 = channel2vct(1000, 100, oboe1)
+ snd_test_neq(channel2vct(1000, 100, oboe0), channel2vct(1000, 100, oboe1),
+ "%s via false", name)
revert_sound(oboe0)
revert_sound(oboe1)
select_sound(oboe0)
func0.call
select_sound(oboe1)
func1.call
- unless vequal(res1 = channel2vct(1000, 100, oboe0), res2 = channel2vct(1000, 100, oboe1))
- snd_display("%s via none:\n# %s\n# %s?", res1, res2)
- end
+ snd_test_neq(channel2vct(1000, 100, oboe0), channel2vct(1000, 100, oboe1),
+ "%s via none", name)
revert_sound(oboe0)
revert_sound(oboe1)
- func0.call(0, frames(oboe0), oboe0)
- func1.call(0, frames(oboe1), oboe1)
- unless vequal(res1 = channel2vct(1000, 100, oboe0), res2 = channel2vct(1000, 100, oboe1))
- snd_display("%s via 0 frames:\n# %s\n# %s?", res1, res2)
- end
+ func0.call(0, framples(oboe0), oboe0)
+ func1.call(0, framples(oboe1), oboe1)
+ snd_test_neq(channel2vct(1000, 100, oboe0), channel2vct(1000, 100, oboe1),
+ "%s via 0 framples", name)
revert_sound(oboe0)
revert_sound(oboe1)
end
@@ -28265,8 +26312,8 @@ def test_16_01
ind = new_sound("fmv.snd")
v0 = Vct.new(20, 1.0)
vct2channel(v0)
- if frames != 20
- snd_display("vct2channel new 20: %s?", frames)
+ if framples != 20
+ snd_display("vct2channel new 20: %s?", framples)
end
if fneq(maxamp, 1.0)
snd_display("vct 1->new: %s?", maxamp)
@@ -28315,16 +26362,16 @@ def test_16_01
#
set_x_axis_style(X_axis_as_percentage)
ind = open_sound("2.snd")
- fr = frames
+ fr = framples
m0 = maxamp(ind, 0)
m1 = maxamp(ind, 1)
set_sync(64, ind)
insert_sound("2.snd")
insert_sound("2.snd")
- if frames != fr * 3
- snd_display("2.snd 3x = %s %s?", fr, frames)
+ if framples != fr * 3
+ snd_display("2.snd 3x = %s %s?", fr, framples)
end
- if (res1 = frames(ind, 0)) != (res2 = frames(ind, 1))
+ if (res1 = framples(ind, 0)) != (res2 = framples(ind, 1))
snd_display("insert synced: %s %s?", res1, res2)
end
swap_channels
@@ -28340,8 +26387,8 @@ def test_16_01
if (res = short_file_name(new_snd)) != "test.snd"
snd_display("mono_files2stereo filename: %s?", res)
end
- if (res = frames(new_snd)) != 50828
- snd_display("mono_files2stereo frames: %s?", res)
+ if (res = framples(new_snd)) != 50828
+ snd_display("mono_files2stereo framples: %s?", res)
end
close_sound(new_snd)
#
@@ -28372,7 +26419,7 @@ def test_16_01
},
lambda { |*args|
snd = (args[2] or selected_sound)
- len = (args[1] and number?(args[1])) ? args[1] : (frames(snd) - 1)
+ len = (args[1] and number?(args[1])) ? args[1] : (framples(snd) - 1)
env_channel(make_env(:envelope, [0, 0, 1, 1], :length, len), *args)
},
oboe0, oboe1)
@@ -28460,80 +26507,86 @@ def test_16_01
set_x_axis_style(X_axis_in_seconds)
#
[1, 2, 4].each do |out_chans|
- ind = new_sound("new.snd", Mus_next, Mus_bfloat, 22050, out_chans, "edpos testing")
+ ind = new_sound("new.snd", out_chans, 22050, Mus_bfloat, Mus_next,
+ "edpos testing")
mx = Snd.sounds.map do |s| sync(s) end.max
set_sync(mx + 1, ind)
["2a.snd", "1a.snd", "4a.snd"].each do |in_snd|
- [lambda { |posfunc|
+ [lambda do |posfunc|
chn = [random(out_chans + 1), out_chans - 1].min
- unless vequal(res = channel2vct(0, frames(ind, chn), ind, chn, 0), [0.0].to_vct)
+ res = channel2vct(0, framples(ind, chn), ind, chn, 0)
+ unless vequal(res, vct(0.0))
snd_display("start bad: %s?", res)
end
set_sample(0, 0.1, ind, chn)
- unless vequal(res = channel2vct(0, frames(ind, chn), ind, chn), [0.1].to_vct)
+ res = channel2vct(0, framples(ind, chn), ind, chn)
+ unless vequal(res, vct(0.1))
snd_display("set bad: %s?", res)
end
pad_channel(0, 1, ind, chn, posfunc.call)
if proc?(pos = posfunc.call)
pos = pos.call(ind, chn)
end
- data = channel2vct(0, frames(ind, chn), ind, chn)
- if (pos.zero? and (not vequal(data, [0.0, 0.0].to_vct))) or
- ((pos == Current_edit_position or pos == edit_position(ind, chn)) and
- (not vequal(data, [0.0, 0.1].to_vct))) or
- (pos == edit_position(ind, chn) - 1 and
- (not vequal(data, [0.0, 0.0].to_vct)))
+ data = channel2vct(0, framples(ind, chn), ind, chn)
+ if (pos.zero? and (not vequal(data, vct(0.0, 0.0)))) or
+ ((pos == Current_edit_position or
+ pos == edit_position(ind, chn)) and
+ (not vequal(data, vct(0.0, 0.1)))) or
+ (pos == edit_position(ind, chn) - 1 and
+ (not vequal(data, vct(0.0, 0.0))))
snd_display("pos[%s]: edpos %s of %s, pad result[%s, %s]: %s?",
chn, pos,
edit_position(ind, chn),
- frames(ind, chn, pos),
- frames(ind, chn),
+ framples(ind, chn, pos),
+ framples(ind, chn),
data)
end
if channels(ind) > 1
channels(ind).times do |i|
next if chn == i
- unless vequal(res = channel2vct(0, frames(ind, i), ind, i), [0.0].to_vct)
+ res = channel2vct(0, framples(ind, i), ind, i)
+ unless vequal(res, vct(0.0))
snd_display("pad[%s / %s] empty: %s?", i, chn, data)
end
end
end
- },
- lambda { |posfunc|
+ end,
+ lambda do |posfunc|
chn = [random(out_chans + 1), out_chans - 1].min
set_sample(0, 0.1, ind, chn)
- set_sample(0, sample(0, ind, chn, posfunc.call()) * 2.0, ind, chn, posfunc.call())
+ set_sample(0, sample(0, ind, chn, posfunc.call()) * 2.0,
+ ind, chn, posfunc.call())
if proc?(pos = posfunc.call)
pos = pos.call(ind, chn)
end
- data = channel2vct(0, frames(ind, chn), ind, chn)
- if (pos.zero? and (not vequal(data, [0.0].to_vct))) or
- ((pos == Current_edit_position or pos == edit_position(ind, chn)) and
- (not vequal(data, [0.2].to_vct))) or
- (pos == edit_position(ind, chn) - 1 and
- (not vequal(data, [0.0].to_vct)))
+ data = channel2vct(0, framples(ind, chn), ind, chn)
+ if (pos.zero? and (not vequal(data, vct(0.0)))) or
+ ((pos == Current_edit_position or
+ pos == edit_position(ind, chn)) and
+ (not vequal(data, vct(0.2)))) or
+ (pos == edit_position(ind, chn) - 1 and
+ (not vequal(data, vct(0.0))))
snd_display("pos[%s]: edpos %s of %s, set *2 result[%s, %s]: %s?",
chn, pos,
edit_position(ind, chn),
- frames(ind, chn, pos),
- frames(ind, chn),
+ framples(ind, chn, pos),
+ framples(ind, chn),
data)
end
if channels(ind) > 1
channels(ind).times do |i|
next if chn == i
- unless vequal(res = channel2vct(0, frames(ind, i), ind, i), [0.0].to_vct)
+ res = channel2vct(0, framples(ind, i), ind, i)
+ unless vequal(res, vct(0.0))
snd_display("scale[%s / %s] empty: %s?", i, chn, data)
end
end
end
- }].each do |func|
- [lambda { Current_edit_position },
- lambda { 0 },
- lambda { lambda { |s, c| edit_position(s, c) - 1 } },
- lambda { lambda { |s, c| edit_position(s, c) } },
- lambda { lambda { |s, c| Current_edit_position } },
- lambda { lambda { |s, c| 0 } }].each do |edpos|
+ end].each do |func|
+ [lambda do Current_edit_position end,
+ lambda do 0 end,
+ lambda do edit_position(ind, 0) - 1 end,
+ lambda do edit_position(ind, 0) end].each do |edpos|
func.call(edpos)
revert_sound(ind)
end
@@ -28544,17 +26597,19 @@ def test_16_01
#
ind = open_sound("oboe.snd")
map_channel(lambda do |y| false end)
- if frames(ind) != 0
- snd_display("map_channel false frames: %s?", frames(ind))
+ if framples(ind) != 0
+ snd_display("map_channel false framples: %s?", framples(ind))
end
if edits(ind) == [0, 0]
snd_display("map_channel false edits backed up")
end
undo_edit(1, ind)
- if frames(ind) == 0
- snd_display("map_channel false frames after undo: %s?", frames(ind))
+ if framples(ind) == 0
+ snd_display("map_channel false framples after undo: %s?", framples(ind))
end
- if (res = Snd.catch do map_channel(lambda do |y| "hiho" end) end).first != :bad_type
+ if (res = Snd.catch do
+ map_channel(lambda do |y| "hiho" end)
+ end).first != :bad_type
snd_display("map_channel bad_type: %s", res.inspect)
end
ctr = 0
@@ -28580,10 +26635,10 @@ def test_16_01
end
revert_sound(ind)
del = make_delay(1000)
- len = frames
+ len = framples
clm_channel(del, 0, len, ind, 0, 0, 2000)
- if frames(ind) != len + 2000
- snd_display("clm_channel overlap length: %s %s?", len, frames)
+ if framples(ind) != len + 2000
+ snd_display("clm_channel overlap length: %s %s?", len, framples)
end
if edit_tree != [[0, 1, 0, 52827, 1.0, 0.0, 0.0, 0], [52828, -2, 0, 0, 0.0, 0.0, 0.0, 0]]
snd_display("clm_channel overlaps: %s?", edit_tree)
@@ -28627,7 +26682,7 @@ def test_16_01
reverse_channel(0, false, ind, 0, 1)
amp = 0.0
loc = 0
- ctr = frames - 1
+ ctr = framples - 1
scan_channel(lambda { |y|
if y.abs > amp
amp = y.abs
@@ -28642,7 +26697,7 @@ def test_16_01
reverse_channel(0, false, ind, 0, 2)
amp = 0.0
loc = 0
- ctr = frames - 1
+ ctr = framples - 1
scan_channel(lambda { |y|
if y.abs > amp
amp = y.abs
@@ -28674,7 +26729,7 @@ end
def test_16_02
mus_clipping and set_mus_clipping(false)
clipping and set_clipping(false)
- ind = new_sound("fmv.snd", Mus_next, Mus_bfloat, 22050, 1,"edit trees")
+ ind = new_sound("fmv.snd", 1, 22050, Mus_bfloat, Mus_next, "edit trees")
select_sound(ind)
select_channel(0)
check_edit_tree([[0, 0, 0, 0, 0.0, 0.0, 0.0, 1],
@@ -28723,7 +26778,7 @@ def test_16_02
[100, -2, 0, 0, 0.0, 0.0, 0.0, 0]],
vals, "env_channel(15, 10) b")
set_selection_position(5)
- set_selection_frames(10)
+ set_selection_framples(10)
scale_selection_to(0.5)
5.upto(14) do |i| vals[i] *= 0.5 end
check_edit_tree([[0, 1, 0, 4, 1.0, 0.0, 0.0, 0],
@@ -28802,7 +26857,7 @@ def test_16_02
snd_display("selection_maxamp after: %s?", res)
end
set_selection_position(50)
- set_selection_frames(10)
+ set_selection_framples(10)
scale_selection_by(0.1)
if fneq(res = selection_maxamp, 0.1)
snd_display("re-selection_maxamp: %s?", res)
@@ -28932,7 +26987,7 @@ def test_16_02
[100, -2, 0, 0, 0.0, 0.0, 0.0, 0]],
vals, "back set via map_channel")
set_selection_position(20)
- set_selection_frames(70)
+ set_selection_framples(70)
env_selection([0, 0, 1, 1])
if fneq(res = selection_maxamp(ind, 0), 1.0)
snd_display("selection_maxamp after env_selection: %s?", res)
@@ -29272,7 +27327,7 @@ def test_16_02
end
def test_16_03
- ind = new_sound("fmv.snd", Mus_next, Mus_bfloat, 22050, 1, "envd edit trees")
+ ind = new_sound("fmv.snd", 1, 22050, Mus_bfloat, Mus_next, "envd edit trees")
vals = Vct.new(10000, 1.0)
select_sound(ind)
select_channel(0)
@@ -29432,8 +27487,8 @@ def test_16_03
if fneq(sample(0), -1.0)
snd_display("sample at end: %s?", sample(0))
end
- if frames != 1
- snd_display("length at end: %s?", frames)
+ if framples != 1
+ snd_display("length at end: %s?", framples)
end
check_edit_tree([[0, 2, 0, 0, 1.0, 0.0, 0.0, 0],
[1, -2, 0, 0, 0.0, 0.0, 0.0, 0]],
@@ -29562,7 +27617,7 @@ end
def test_16_04
[10, 10000].each do |dur|
i1 = new_sound
- i2 = new_sound("fmv1.snd", Mus_next, Mus_bfloat, 44100, 2)
+ i2 = new_sound("fmv1.snd", 2, 44100, Mus_bfloat, Mus_next)
v = Vct.new(dur, 1.0)
vct2channel(v, 0, dur, i1)
vct2channel(v, 0, dur, i2, 0)
@@ -29571,9 +27626,10 @@ def test_16_04
set_sync(1, i2)
env_sound([0, 0, 1, 1])
check_envs(:ramps,
- lambda { |s, c| make_sampler(0, s, c) },
- lambda { |s, c| make_env(:envelope, [0, 0, 1, 1], :length, dur) },
- dur, i1, i2)
+ lambda do |s, c| make_sampler(0, s, c) end,
+ lambda do |s, c|
+ make_env(:envelope, [0, 0, 1, 1], :length, dur)
+ end, dur, i1, i2)
reverse_sound
check_envs(:rev_ramps,
lambda { |s, c| make_sampler(0, s, c) },
@@ -29640,7 +27696,7 @@ def test_16_04
end
#
data = ["1a.snd", "oboe.snd", "storm.snd"].map do |sound|
- if File.exists?(sound)
+ if File.exist?(sound)
ind = view_sound(sound)
set_squelch_update(true, ind)
tms = [lambda { scale_channel(2.0) },
@@ -29661,7 +27717,7 @@ def test_16_04
end
end
if $VERBOSE
- snd_info(" scl rev env map ptree scn pad wrt clm mix src")
+ snd_info(" scl rev env map scn pad wrt clm mix src")
str = ""
data[0].each do |x| str << "%6.2f" % x end
snd_info(" 1a: %s", str)
@@ -29673,7 +27729,7 @@ def test_16_04
snd_info(" storm: %s", str)
end
#
- ind = new_sound("fmv.snd", Mus_next, Mus_bfloat)
+ ind = new_sound("fmv.snd", :header_type, Mus_next, :sample_type, Mus_bfloat)
set_sinc_width(10)
pad_channel(0, 1000, ind)
set_sample(100, 0.5)
@@ -29815,9 +27871,9 @@ def test_16_04
[lambda { |beg, dur| src_channel(0.5, beg, dur) }, 0, 1000, 52829],
[lambda { |beg, dur| insert_silence(beg, dur) }, 0, 1000, 53829]
].each do |func, beg, dur, len|
- old_len = frames(ind)
+ old_len = framples(ind)
func.call(beg, dur)
- if (res = frames(ind)) != len
+ if (res = framples(ind)) != len
snd_display("(%s %s %s) with %s: %s (%s)?", func, beg, dur, old_len, res, len)
end
end
@@ -29828,9 +27884,9 @@ def test_16_04
[62000, 1, 62001],
[62000, 2, 62003],
[62004, 1, 62005]].each do |beg, dur, len|
- old_len = frames(ind)
+ old_len = framples(ind)
pad_channel(beg, dur)
- if (res = frames(ind)) != len
+ if (res = framples(ind)) != len
snd_display("(pad_channel %s %s) with %s: %s (%s)?", beg, dur, old_len, res, len)
end
end
@@ -29846,36 +27902,37 @@ def test_16_04
[lambda { |beg, dur| insert_silence(beg, dur) }, 1000, 54028],
[lambda { |beg, dur| env_sound([0, 0, 1, 1], beg, dur) }, 1000, 54028]
].each do |func, dur, len|
- old_len = frames(ind)
+ old_len = framples(ind)
func.call(old_len + 100, dur)
- if (res = frames(ind)) != len
+ if (res = framples(ind)) != len
snd_display("(%s %s) with %s: %s (%s)?", func, dur, old_len, res, len)
end
end
revert_sound(ind)
+ len = (1.25 * framples()).floor
100.times do
case random(10)
when 0
- pad_channel(random(1.25 * frames), random(1000))
+ pad_channel(random(len), random(1000))
when 1
- env_channel([0, 0, 1, 1, 2, 0], random(1.25 * frames), random(1000))
+ env_channel([0, 0, 1, 1, 2, 0], random(len), random(1000))
when 2
- env_sound([0, 0, 1, 1, 2, 0], random(1.25 * frames), random(1000))
+ env_sound([0, 0, 1, 1, 2, 0], random(len), random(1000))
when 3
- scale_channel(random(1.0), random(1.25 * frames), random(1000))
+ scale_channel(random(1.0), random(len), random(1000))
when 4
- scale_sound_by(random(1.0), random(1.25 * frames), random(1000))
+ scale_sound_by(random(1.0), random(len), random(1000))
when 5
- src_channel(random(0.2) + 0.9, random(1.25 * frames), random(1000))
+ src_channel(random(0.2) + 0.9, random(len), random(1000))
when 6
- ramp_channel(random(1.0), random(1.0), random(1.25 * frames), random(1000))
+ ramp_channel(random(1.0), random(1.0), random(len), random(1000))
when 7
- reverse_channel(random(1.25 * frames), random(1000))
+ reverse_channel(random(len), random(1000))
when 8
dur = [2, random(100)].max
- vct2channel(Vct.new(dur), random(1.25 * frames), dur)
+ vct2channel(Vct.new(dur), random(len), dur)
when 9
- map_channel(lambda { |y| y * 2 }, random(0.5 * frames), random(1000))
+ map_channel(lambda { |y| y * 2 }, random((0.5 * framples()).floor), random(1000))
end
end
close_sound(ind)
@@ -29905,39 +27962,24 @@ def test_16_05
#
ind = init_sound(0.5, 10, 2)
save_sound(ind)
- scale_channel(2.0, 0, frames, ind, 1)
+ scale_channel(2.0, 0, framples, ind, 1)
swap_channels
check_both_chans(ind, "1", lambda { |y| fneq(y, 1.0) }, lambda { |y| fneq(y, 0.5) })
undo_edit(1, ind, 0)
undo_edit(2, ind, 1)
- scale_channel(0.5, 0, frames, ind, 0)
- scale_channel(2.0, 0, frames, ind, 1)
+ scale_channel(0.5, 0, framples, ind, 0)
+ scale_channel(2.0, 0, framples, ind, 1)
swap_channels
check_both_chans(ind, "2", lambda { |y| fneq(y, 1.0) }, lambda { |y| fneq(y, 0.25) })
undo_edit(2, ind, 0)
undo_edit(2, ind, 1)
delete_samples(2, 3, ind, 0)
- env_channel([0, 0, 1, 1, 2, 0], 0, frames(ind, 1), ind, 1)
+ env_channel([0, 0, 1, 1, 2, 0], 0, framples(ind, 1), ind, 1)
swap_channels
- if (res = frames(ind, 1)) != 11
- snd_display("frames swapped: %s?", res)
- end
- unless vequal(res = channel2vct(0, frames(ind, 0), ind, 0),
- vct(0.000, 0.100, 0.200, 0.300, 0.400, 0.500, 0.400, 0.300, 0.200, 0.100, 0.000))
- snd_display("swapped env: %s", res)
- end
undo_edit(2, ind, 0)
undo_edit(2, ind, 1)
delete_samples(2, 7, ind, 0)
swap_channels(ind, 0, ind, 1, 5, 4)
- unless vequal(res = channel2vct(0, 10, ind, 0),
- vct(0.500, 0.500, 0.500, 0.500, 0.000, 0.500, 0.500, 0.500, 0.500, 0.000))
- snd_display("partial swap 1: %s?", res)
- end
- unless vequal(res = channel2vct(0, 10, ind, 1),
- vct(0.500, 0.500, 0.500, 0.500, 0.500, 0.000, 0.000, 0.000, 0.000, 0.500))
- snd_display("partial swap 2: %s?", res)
- end
revert_sound(ind)
m0 = add_mark(3, ind, 0)
m1 = add_mark(4, ind, 1)
@@ -29986,9 +28028,9 @@ def test_16_05
delete_file("test.snd")
#
ind = init_sound(0.5, 10, 4)
- scale_channel(0.5, 0, frames, ind, 1)
- scale_channel(0.25, 0, frames, ind, 2)
- scale_channel(0.125, 0, frames, ind, 3)
+ scale_channel(0.5, 0, framples, ind, 1)
+ scale_channel(0.25, 0, framples, ind, 2)
+ scale_channel(0.125, 0, framples, ind, 3)
swap_channels(ind, 1, ind, 2)
maxs = maxamp(ind, true)
if fneq(maxs[0], 0.5) or
@@ -30072,39 +28114,61 @@ def test_16_05
close_sound(ind)
#
if $all_args
- [[:scale_channel, lambda { |snd, i| scale_channel(i * 0.01) }],
- [:set_sample, lambda { |snd, i| set_sample(i, 0.5) }],
- [:env_channel, lambda { |snd, i| env_channel([0, 0, 1, 1]) }],
- [:env_channel_with_base, lambda { |snd, i| env_channel_with_base([0, 0, 1, 1], 32.0) }],
- [:env_channel_with_base, lambda { |snd, i| env_channel_with_base([0, 0, 1, 1], 0.0) }],
- [:delete_sample, lambda { |snd, i| delete_sample(i * 10) }],
- [:insert_sample, lambda { |snd, i| insert_sample(i * 10, 0.5) }],
- [:pad_channel, lambda { |snd, i| pad_channel(i * 10, i * 10) }],
- [:mix_no_tag, lambda { |snd, i| mix("pistol.snd", 10 * i, 0, snd, 0, false) }],
- [:mix_tag, lambda { |snd, i| mix("pistol.snd", 10 * i, 0, snd, 0, true) }],
- [:mix_scale_to, lambda { |snd, i|
- mx = mix("pistol.snd", 100 * i).car
- set_mix_amp(mx, 0.01)
- }],
- [:mix_amp, lambda { |snd, i| mix("pistol.snd", 100 * i); scale_to(0.5)}],
- [:src_sound_1, lambda { |snd, i| src_sound(2.0); undo_edit }],
- [:src_sound_2, lambda { |snd, i| src_sound(2.01); undo_edit }],
- [:filter_channel_1, lambda { |snd, i| filter_channel(vct(0.25, 0.5, 0.25, 0.1), 4) }],
- [:filter_channel_2, lambda { |snd, i| filter_channel(vct(0.25, 0.5, 0.5, 0.25), 4) }],
- [:filter_channel_3, lambda { |snd, i|
- filter_channel(vct(0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.1, 0.1), 10)
- }],
- [:filter_channel_4, lambda { |snd, i|
- filter_channel(vct(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1), 10)
- }],
- [:clm_channel, lambda { |snd, i| clm_channel(make_two_zero(0.5, 0.5)) }],
- [:reverse_channel, lambda { |snd, i| reverse_channel(i * 10, i * 100) }]].each do |name, func|
- ["1.snd", "oboe.snd", "1a.snd"].each do |sound|
+ [[:scale_channel,
+ lambda do |snd, i| scale_channel(i * 0.01) end],
+ [:set_sample,
+ lambda do |snd, i| set_sample(i, 0.5) end],
+ [:env_channel,
+ lambda do |snd, i| env_channel([0, 0, 1, 1]) end],
+ [:env_channel_with_base,
+ lambda do |snd, i| env_channel_with_base([0, 0, 1, 1], 32.0) end],
+ [:env_channel_with_base,
+ lambda do |snd, i| env_channel_with_base([0, 0, 1, 1], 0.0) end],
+ [:delete_sample,
+ lambda do |snd, i| delete_sample(i * 10) end],
+ [:insert_sample,
+ lambda do |snd, i| insert_sample(i * 10, 0.5) end],
+ [:pad_channel,
+ lambda do |snd, i| pad_channel(i * 10, i * 10) end],
+ [:mix_no_tag,
+ lambda do |snd, i| mix("pistol.snd", 10 * i, 0, snd, 0, false) end],
+ [:mix_tag,
+ lambda do |snd, i| mix("pistol.snd", 10 * i, 0, snd, 0, true) end],
+ [:mix_scale_to,
+ lambda do |snd, i| set_mix_amp(mix("pistol.snd", 100 * i).car, 0.01) end],
+ [:mix_amp,
+ lambda do |snd, i| mix("pistol.snd", 100 * i); scale_to(0.5) end],
+ [:src_sound_1,
+ lambda do |snd, i| src_sound(2.0); undo_edit end],
+ [:src_sound_2,
+ lambda do |snd, i| src_sound(2.01); undo_edit end],
+ [:filter_channel_1,
+ lambda do |snd, i| filter_channel(vct(0.25, 0.5, 0.25, 0.1), 4) end],
+ [:filter_channel_2,
+ lambda do |snd, i| filter_channel(vct(0.25, 0.5, 0.5, 0.25), 4) end],
+ [:filter_channel_3,
+ lambda do |snd, i|
+ filter_channel(vct(0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.1, 0.1), 10)
+ end],
+ [:filter_channel_4,
+ lambda do |snd, i|
+ filter_channel(vct(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1), 10)
+ end],
+ [:clm_channel,
+ lambda do |snd, i| clm_channel(make_two_zero(0.5, 0.5)) end],
+ [:reverse_channel,
+ lambda do |snd, i|
+ reverse_channel(i * 10, i * 100)
+ end]].each do |name, func|
+ ["1.snd", "oboe.snd", "1a.snd"].each do |sound|
ind = open_sound(sound)
with_time do
set_squelch_update(true, ind, 0)
with_time(format("%s() [%s]", name, sound)) do
- 256.times do |i| func.call(ind, i) end
+ 256.times do |i|
+ revert_sound(ind) if (i % 10).zero?
+ func.call(ind, i)
+ end
end
revert_sound(ind)
set_squelch_update(false, ind, 0)
@@ -30126,27 +28190,33 @@ end
# ---------------- test 17: dialogs and graphics ----------------
-def arrow2right(x, y, size, snd, chn)
+add_help(:arrow2right,
+ "arrow2right(x, y, size, snd, chn, cr) \
+draw an arrow pointing (from the left) at the point [x, y]")
+
+def arrow2right(x, y, size, snd, chn, cr)
size2 = size * 2
fill_polygon([x, y,
x - size2, y - size,
x - size2, y + size,
x, y],
- snd, chn)
+ snd, chn, Time_graph, cr)
fill_rectangle(x - 4 * size, (y - 0.4 * size).floor,
size2, (0.8 * size).floor,
- snd, chn)
+ snd, chn, Time_graph, false, cr)
end
def test_17
if $with_test_gui
- $after_graph_hook.add_hook!(get_func_name) do |snd, chn| display_previous_edits(snd, chn) end
+ $after_graph_hook.add_hook!(get_func_name, &method(:display_previous_edits).to_proc)
$lisp_graph_hook.add_hook!(get_func_name) do |snd, chn|
lambda do | |
+ cr = make_cairo(channel_widgets(snd, chn)[0])
draw_string("hi",
x2position(0.5, snd, chn, Lisp_graph),
y2position(0.5, snd, chn, Lisp_graph),
- snd, chn)
+ snd, chn, Lisp_graph, cr)
+ free_cairo(cr)
end
end
ind = open_sound("oboe.snd")
@@ -30161,16 +28231,16 @@ def test_17
draw_bass_clef(100, 100, 100, 0, ind, 0)
update_time_graph(ind, 0)
draw_fermata(200, 100, 60, 0, ind, 0)
- draw_line(100, 100, 200, 200, ind, 0)
- draw_fermata(200, 100, 60, 0, ind, 0)
- draw_dot(300, 300, 10, ind, 0)
- draw_string("hiho", 20, 20, ind, 0)
- draw_dots([25, 25, 50, 50, 100, 100], 10, ind, 0)
- arrow2right(100, 50, 10, ind, 0)
- fill_rectangle(20, 20, 100, 100, ind, 0)
+ cr = make_cairo(channel_widgets(ind, 0)[0])
+ draw_line(100, 100, 200, 200, ind, 0, Time_graph, cr)
+ draw_dot(300, 300, 10, ind, 0, Time_graph, cr)
+ draw_string("hiho", 20, 20, ind, 0, Time_graph, cr)
+ draw_dots([25, 25, 50, 50, 100, 100], 10, ind, 0, Time_graph, cr)
+ arrow2right(100, 50, 10, ind, 0, cr)
+ fill_rectangle(20, 20, 100, 100, ind, 0, Time_graph, false, cr)
+ free_cairo(cr)
make_bezier(0, 0, 20, 20, 40, 30, 60, 10, 10)
update_time_graph(ind, 0)
- fill_rectangle(20, 20, 100, 100, ind, 0, Time_graph, true)
$after_graph_hook.reset_hook!
$lisp_graph_hook.reset_hook!
#
@@ -30219,8 +28289,6 @@ end
# ---------------- test 19: save and restore ----------------
-$after_save_state_hook_var = 0
-
def local_neq?(a, b)
if float?(a) or float?(b)
fneq(a, b)
@@ -30263,13 +28331,6 @@ def test_19_00
end
true
end
- $after_save_state_hook.reset_hook!
- $after_save_state_hook.add_hook!("snd-test") do |fname|
- File.open(File.expand_path(fname), "a+") do |f|
- f.printf("\n# from %s in %s", get_func_name, __FILE__)
- f.printf("\n$after_save_state_hook_var = 1234\n")
- end
- end
delete_file(save_state_file)
save_state(save_state_file)
# save_options("test.temp")
@@ -30277,8 +28338,8 @@ def test_19_00
Snd.regions.apply(:forget_region)
load(save_state_file)
ind = find_sound("oboe.snd")
- if fneq_err(old_bounds[0], x_bounds(ind, 0)[0], 0.05) or # okay
- fneq_err(old_bounds[1], x_bounds(ind, 0)[1], 0.05) # okay
+ if fneq_err(old_bounds[0], x_bounds(ind, 0)[0], 0.05) or
+ fneq_err(old_bounds[1], x_bounds(ind, 0)[1], 0.05)
snd_display("save bounds: %s?", x_bounds(ind, 0))
end
if marks(ind, 0).length != 1
@@ -30308,9 +28369,6 @@ def test_19_00
snd_display("channel_property saved: 3.14 -> %s?", res.inspect)
end
close_sound(ind)
- if $after_save_state_hook_var != 1234
- snd_display("$after_save_state_hook_var: %s?", $after_save_state_hook_var)
- end
$before_save_state_hook.reset_hook!
$after_save_state_hook.reset_hook!
if (res = Snd.catch(:cannot_save, 12345) do save_state("/bad/bad.save") end).first != 12345
@@ -30346,14 +28404,14 @@ def test_19_00
snd_display("save_edit_history 5: %s?", res)
end
save_edit_history("hiho.rb", nind, 0)
- scale_sound_to(1.0, 0, frames(nind, 0), nind, 0)
+ scale_sound_to(1.0, 0, framples(nind, 0), nind, 0)
eds = edit_position(nind, 0)
val = insert_sound("zero.snd")
if val.nonzero? or eds != edit_position(nind, 0)
snd_display("insert_sound zero.snd, was an edit? %s %s %s", val, eds, edit_position(nind, 0))
end
revert_sound(nind)
- scale_sound_to(0.5, 0, frames(nind, 0), nind, 0)
+ scale_sound_to(0.5, 0, framples(nind, 0), nind, 0)
if fneq(res = maxamp(nind, 0), 0.5)
snd_display("scale_sound_to(0.5): %s?", res)
end
@@ -30378,54 +28436,6 @@ def test_19_00
snd_display("IO.readlines (file2string): %s?", res)
end
close_sound(nind)
- #
- ind = open_sound("oboe.snd")
- set_speed_control(Rational(2, 3).to_f, ind)
- set_filter_control_envelope([0.0, 0.0, 1.0, 1.0], ind)
- set_sound_property(:hi, 12345, ind)
- insert_samples(0, 100, Vct.new(100, 0.1), ind, 0)
- $save_state_hook.reset_hook!
- $save_state_hook.add_hook!("snd-test") do |fname| "savehook.snd" end
- save_state("s61.rb")
- close_sound(ind)
- if File.exists?("savehook.snd")
- load("s61.rb")
- ind = find_sound("oboe.snd")
- if sound?(ind)
- if fneq(res = speed_control(ind), Rational(2, 3).to_f)
- snd_display("save_state w/hook speed: %s?", res)
- end
- if (res = sound_property(:hi, ind)) != 12345
- snd_display("save_state w/hook property hi: %s?", res)
- end
- if (res = filter_control_envelope(ind)) != [0.0, 0.0, 1.0, 1.0]
- snd_display("save_state w/hook filter env: %s?", res)
- end
- $save_state_hook.reset_hook!
- $save_state_hook.add_hook!("snd-test") do |fname|
- snd_display("bogus $save_state_hook call!")
- "edit-list-to-function-saved.snd"
- end
- func = edit_list2function(ind, 0)
- if File.exists?("edit-list-to-function-saved.snd")
- snd_display("edit_list2function called $save_state_hook")
- delete_file("edit-list-to-function-saved.snd")
- end
- save_edit_history("save-edit-history-saved.rb", ind, 0)
- if File.exists?("edit-list-to-function-saved.snd")
- snd_display("save_edit_history called $save_state_hook")
- delete_file("edit-list-to-function-saved.snd")
- end
- delete_files("save-edit-history-saved.rb", "savehook.snd")
- close_sound(ind)
- else
- snd_display("save_state after hook restored but no sound?")
- end
- else
- snd_display("$save_state_hook redirect failed: %s?", $save_state_hook.inspect)
- end
- delete_file("s61.rb")
- $save_state_hook.reset_hook!
#
add_sound_file_extension("ogg")
add_sound_file_extension("OGG")
@@ -30481,9 +28491,9 @@ def test_19_00
close_sound(ind)
delete_file("t1.rb")
#
- ind = new_sound("fmv.snd", Mus_next, Mus_bshort, 22050, 8,
+ ind = new_sound("fmv.snd", 8, 22050, Mus_bshort, Mus_next,
"this is an 8-channel save-state test")
- ind1 = new_sound("fmv1.snd", Mus_next, Mus_bshort, 22050, 2,
+ ind1 = new_sound("fmv1.snd", 2, 22050, Mus_bshort, Mus_next,
"this is an 2-channel save-state test")
set_sample(10, 0.1, ind, 0)
set_sample(10, 0.2, ind, 1)
@@ -30527,12 +28537,7 @@ def test_19_00
set_transform_normalization(Dont_normalize, ind, 0)
set_graph_style(Graph_filled, ind, 0)
set_transform_graph_type(Graph_as_spectrogram, ind, 0)
- unless $with_test_gtk
- # FIXME
- # doesn't work with GTK
- # snd-ruby-xg -noinit snd-test.rb 19 ==> hangs on load("s61.rb") below
- set_time_graph_type(Graph_as_wavogram, ind, 0)
- end
+ set_time_graph_type(Graph_as_wavogram, ind, 0)
set_x_axis_style(X_axis_as_percentage, ind, 0)
set_speed_control_style(Speed_control_as_semitone, ind, 0)
set_cursor(1234, ind, 0)
@@ -30788,7 +28793,7 @@ def test_19_01
if fneq(sample(10), 0.5)
snd_display("insert_sample save_state: %s?", channel2vct(5, 10, ind, 0))
end
- if (res = frames(ind, 0)) != 101
+ if (res = framples(ind, 0)) != 101
snd_display("insert_sample save_state len: %s?", res)
end
}],
@@ -30797,7 +28802,7 @@ def test_19_01
if fneq(sample(10), 0.0)
snd_display("delete_sample save_state: %s?", channel2vct(5, 10, ind, 0))
end
- if (res = frames(ind, 0)) != 99
+ if (res = framples(ind, 0)) != 99
snd_display("delete_sample save_state len: %s?", res)
end
}],
@@ -30806,7 +28811,7 @@ def test_19_01
if fneq(sample(10), 0.5)
snd_display("set_sample save_state: %s?", channel2vct(5, 10, ind, 0))
end
- if (res = frames(ind, 0)) != 100
+ if (res = framples(ind, 0)) != 100
snd_display("set_sample save_state len: %s?", res)
end
}],
@@ -30815,7 +28820,7 @@ def test_19_01
if fneq(sample(10), 0.25)
snd_display("scl sample save_state: %s?", channel2vct(5, 10, ind, 0))
end
- if (res = frames(ind, 0)) != 100
+ if (res = framples(ind, 0)) != 100
snd_display("scl sample save_state len: %s?", res)
end
if (res = edit_position(ind, 0)) != 2
@@ -30824,7 +28829,7 @@ def test_19_01
}],
[lambda { |ind| vct2channel(Vct.new(10, 0.5), 10, 5, ind, 0); pad_channel(12, 5, ind, 0) },
lambda { |ind|
- if (res = frames(ind, 0)) != 105
+ if (res = framples(ind, 0)) != 105
snd_display("pad sample save_state len: %s?", res)
end
if (res = edit_position(ind, 0)) != 2
@@ -30837,7 +28842,7 @@ def test_19_01
}],
[lambda { |ind| map_channel(lambda { |y| 1.0 }); env_channel([0, 0, 1, 1], 0, 11, ind, 0) },
lambda { |ind|
- if (res = frames(ind, 0)) != 100
+ if (res = framples(ind, 0)) != 100
snd_display("env sample save_state len: %s?", res)
end
if (res = edit_position(ind, 0)) != 2
@@ -30857,7 +28862,7 @@ def test_19_01
})
},
lambda { |ind|
- if (res = frames(ind, 0)) != 50
+ if (res = framples(ind, 0)) != 50
snd_display("map false save_state len: %s?", res)
end
if (res = edit_position(ind, 0)) != 1
@@ -30945,7 +28950,7 @@ def test_19_01
})
snd_display("as_one_edit save_state 5: %s?", res)
end
- if (res = frames(ind, 0)) != 97
+ if (res = framples(ind, 0)) != 97
snd_display("save_state backup del+insert len: %s?", res)
end
}],
@@ -30967,7 +28972,7 @@ def test_19_01
if (res = edit_position(ind, 0)) != 5
snd_display("embed save_state edpos: %s?", res)
end
- if (res = frames(ind, 0)) != 87
+ if (res = framples(ind, 0)) != 87
snd_display("embed save_state len: %s?", res)
end
unless vequal(res = channel2vct(0, 25, ind, 0),
@@ -30978,7 +28983,8 @@ def test_19_01
}]].each_with_index do |args, i|
func = args[0]
test = args[1]
- ind = new_sound("test.snd", Mus_next, Mus_bfloat, 22050, 1, "mono save-state tests", 100)
+ ind = new_sound("test.snd", 1, 22050, Mus_bfloat, Mus_next,
+ "mono save-state tests", 100)
func.call(ind)
delete_file("s61.rb")
save_state("s61.rb")
@@ -30999,7 +29005,7 @@ def test_19_02
#
ind = open_sound("oboe.snd")
mx0 = maxamp
- frs = frames
+ frs = framples
# simple scale
scale_channel(2.0)
if fneq(res = maxamp, 2 * mx0)
@@ -31034,7 +29040,7 @@ def test_19_02
revert_sound(ind)
# simple delete
delete_samples(10, 100)
- if (res = frames) != frs - 100
+ if (res = framples) != frs - 100
snd_display("edit_list2function delete: %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
@@ -31044,12 +29050,12 @@ def test_19_02
snd_display("edit_list2function 2: %s", res)
end
func.call(ind, 0)
- if (res = frames) != frs - 200
+ if (res = framples) != frs - 200
snd_display("edit_list2function called (2): %s %s?", frs, res)
end
revert_sound(ind)
delete_sample(100)
- if (res = frames) != frs - 1
+ if (res = framples) != frs - 1
snd_display("edit_list2function delete (2a): %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
@@ -31059,13 +29065,13 @@ def test_19_02
snd_display("edit_list2function 2a: %s", res)
end
func.call(ind, 0)
- if (res = frames) != frs - 2
+ if (res = framples) != frs - 2
snd_display("edit_list2function called (2a): %s %s?", frs, res)
end
revert_sound(ind)
# simple zero pad
pad_channel(10, 100)
- if (res = frames) != frs + 100
+ if (res = framples) != frs + 100
snd_display("edit_list2function pad: %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
@@ -31075,12 +29081,12 @@ def test_19_02
snd_display("edit_list2function 3: %s", res)
end
func.call(ind, 0)
- if (res = frames) != frs + 200
+ if (res = framples) != frs + 200
snd_display("edit_list2function called (3): %s %s?", frs, res)
end
revert_sound(ind)
insert_silence(10, 100)
- if (res = frames) != frs + 100
+ if (res = framples) != frs + 100
snd_display("edit_list2function pad (3a): %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
@@ -31090,7 +29096,7 @@ def test_19_02
snd_display("edit_list2function 3a: %s", res)
end
func.call(ind, 0)
- if (res = frames) != frs + 200
+ if (res = framples) != frs + 200
snd_display("edit_list2function called (3a): %s %s?", frs, res)
end
revert_sound(ind)
@@ -31203,7 +29209,7 @@ def test_19_02
snd_display("edit_list2function 7e edpos: %s?", res)
end
revert_sound(ind)
- env_sound([0, 0, 1, 1, 2, 0], 0, frames, 32.0)
+ env_sound([0, 0, 1, 1, 2, 0], 0, framples, 32.0)
snd_test_neq(maxamp(), 0.146, "edit_list2function 7f max")
unless proc?(func = edit_list2function)
snd_display("edit_list2function 7f: %s", func)
@@ -31215,7 +29221,7 @@ def test_19_02
func.call(ind, 0)
snd_test_neq(maxamp(), 0.146, "edit_list2function called (7f)")
revert_sound(ind)
- env_sound([0, 0, 1, 1, 2, 1, 3, 0], 0, frames, 0.0)
+ env_sound([0, 0, 1, 1, 2, 1, 3, 0], 0, framples, 0.0)
if fneq(res = sample(4000), 0.0)
snd_display("edit_list2function env 7g: %s?", res)
end
@@ -31231,10 +29237,9 @@ def test_19_02
snd_display("edit_list2function called (7g): %s?", res)
end
revert_sound(ind)
- # simple ptree skipped
# simple 1 sample insert
insert_sample(100, 0.1)
- if (res = frames) != frs + 1
+ if (res = framples) != frs + 1
snd_display("edit_list2function insert_sample: %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
@@ -31247,20 +29252,20 @@ def test_19_02
unless vequal(res = channel2vct(99, 4), vct(0.0, 0.1, 0.1, 0.0))
snd_display("edit_list2function func 9: %s?", res)
end
- if (res = frames) != frs + 2
+ if (res = framples) != frs + 2
snd_display("edit_list2function called (9): %s %s?", frs, res)
end
revert_sound(ind)
# insert_samples with data
insert_samples(0, 100, Vct.new(100, 0.1))
- if (res = frames) != frs + 100
+ if (res = framples) != frs + 100
snd_display("edit_list2function insert_samples (100): %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
snd_display("edit_list2function 9a: %s", func)
end
func.call(ind, 0)
- if (res = frames) != frs + 200
+ if (res = framples) != frs + 200
snd_display("edit_list2function insert_samples (200): %s %s?", frs, res)
end
unless vequal(res = channel2vct(0, 5), vct(0.1, 0.1, 0.1, 0.1, 0.1))
@@ -31269,14 +29274,14 @@ def test_19_02
revert_sound(ind)
# set_samples with data
set_samples(0, 100, Vct.new(100, 0.1))
- if (res = frames) != frs
+ if (res = framples) != frs
snd_display("edit_list2function set_samples (1): %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
snd_display("edit_list2function 9b: %s", func)
end
func.call(ind, 0)
- if (res = frames) != frs
+ if (res = framples) != frs
snd_display("edit_list2function set_samples (2): %s %s?", frs, res)
end
unless vequal(res = channel2vct(0, 5), vct(0.1, 0.1, 0.1, 0.1, 0.1))
@@ -31286,8 +29291,8 @@ def test_19_02
# simple 1 sample set
val = sample(100)
set_sample(100, 0.1)
- if (res = frames) != frs
- snd_display("edit_list2function set_sample frames: %s %s?", frs, res)
+ if (res = framples) != frs
+ snd_display("edit_list2function set_sample framples: %s %s?", frs, res)
end
if fneq(res = sample(100), 0.1)
snd_display("edit_list2function set_sample val: %s %s?", val, res)
@@ -31308,10 +29313,10 @@ def test_19_02
snd_display("edit_list2function func 10: %s?", res)
end
revert_sound(ind)
- pfrs = mus_sound_frames("pistol.snd")
+ pfrs = mus_sound_framples("pistol.snd")
insert_sound("pistol.snd", 1000)
- if (res = frames) != frs + pfrs
- snd_display("edit_list2function insert_sound frames: %s %s?", frs, res)
+ if (res = framples) != frs + pfrs
+ snd_display("edit_list2function insert_sound framples: %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
snd_display("edit_list2function 10a: %s", func)
@@ -31321,14 +29326,14 @@ def test_19_02
end
revert_sound(ind)
func.call(ind, 0)
- if (res = frames) != frs + pfrs
+ if (res = framples) != frs + pfrs
snd_display("edit_list2function called (10a): %s %s?", frs, res)
end
revert_sound(ind)
- pfrs = mus_sound_frames("pistol.snd")
+ pfrs = mus_sound_framples("pistol.snd")
insert_samples(1000, pfrs, "pistol.snd")
- if (res = frames) != frs + pfrs
- snd_display("edit_list2function insert_samples frames: %s %s?", frs, res)
+ if (res = framples) != frs + pfrs
+ snd_display("edit_list2function insert_samples framples: %s %s?", frs, res)
end
unless proc?(func = edit_list2function)
snd_display("edit_list2function 11: %s", func)
@@ -31340,7 +29345,7 @@ def test_19_02
end
revert_sound(ind)
func.call(ind, 0)
- if (res = frames) != frs + pfrs
+ if (res = framples) != frs + pfrs
snd_display("edit_list2function called (11): %s %s?", frs, res)
end
revert_sound(ind)
@@ -31438,7 +29443,8 @@ def test_19_02
env_channel([0, 0, 1, 1, 2, 0])
func = edit_list2function
close_sound(ind)
- ind = new_sound("tmp.snd", Mus_next, Mus_bfloat, 22050, 1, :size, 20, :comment, false)
+ ind = new_sound("tmp.snd", 1, 22050, Mus_bfloat, Mus_next,
+ :size, 20, :comment, false)
map_channel(lambda do |y| 1.0 end)
func.call(ind, 0)
unless vequal(res = channel2vct,
@@ -31504,8 +29510,8 @@ def test_19_02
revert_sound(ind)
# src
src_sound(2.0)
- if (frames - 25415).abs > 2
- snd_display("edit_list2function 18 len: %s?", frames)
+ if (framples - 25415).abs > 2
+ snd_display("edit_list2function 18 len: %s?", framples)
end
unless proc?(func = edit_list2function)
snd_display("edit_list2function 18: %s", func)
@@ -31515,12 +29521,12 @@ def test_19_02
end
revert_sound(ind)
func.call(ind, 0)
- if (frames - 25415).abs > 2
- snd_display("edit_list2function 18 re-len: %s?", frames)
+ if (framples - 25415).abs > 2
+ snd_display("edit_list2function 18 re-len: %s?", framples)
end
revert_sound(ind)
src_channel(2.0, 1000, 500)
- frs = frames
+ frs = framples
unless proc?(func = edit_list2function)
snd_display("edit_list2function 18a: %s", func)
end
@@ -31529,12 +29535,12 @@ def test_19_02
end
revert_sound(ind)
func.call(ind, 0)
- if frames != frs
- snd_display("edit_list2function 18a re-len: %s?", frames)
+ if framples != frs
+ snd_display("edit_list2function 18a re-len: %s?", framples)
end
revert_sound(ind)
src_sound([0, 1, 1, 2, 2, 1])
- frs = frames
+ frs = framples
unless proc?(func = edit_list2function)
snd_display("edit_list2function 18b: %s", func)
end
@@ -31543,12 +29549,12 @@ def test_19_02
end
revert_sound(ind)
func.call(ind, 0)
- if frames != frs
- snd_display("edit_list2function 18b re-len: %s?", frames)
+ if framples != frs
+ snd_display("edit_list2function 18b re-len: %s?", framples)
end
revert_sound(ind)
src_channel([0, 1, 1, 2], 1000, 500)
- frs = frames
+ frs = framples
unless proc?(func = edit_list2function)
snd_display("edit_list2function 18c: %s", func)
end
@@ -31557,8 +29563,8 @@ def test_19_02
end
revert_sound(ind)
func.call(ind, 0)
- if frames != frs
- snd_display("edit_list2function 18c re-len: %s?", frames)
+ if framples != frs
+ snd_display("edit_list2function 18c re-len: %s?", framples)
end
revert_sound(ind)
# filter-channel
@@ -31605,12 +29611,6 @@ def test_19_02
"Proc.new {|snd, chn| env_sound_interp([0, 0, 1, 1, 2, 0], 2.0, snd, chn) }"],
[lambda { add_notes([["1a.snd"], ["pistol.snd", 1.0, 2.0]]) },
"Proc.new {|snd, chn| add_notes([[\"1a.snd\"], [\"pistol.snd\", 1.0, 2.0]], snd, chn) }"],
- [lambda { compand_channel },
- "Proc.new {|snd, chn| compand_channel(0, false, snd, chn) }"],
- [lambda { smooth_channel_via_ptree },
- "Proc.new {|snd, chn| smooth_channel_via_ptree(0, false, snd, chn) }"],
- [lambda { ring_modulate_channel(300) },
- "Proc.new {|snd, chn| ring_modulate_channel(300, 0, false, snd, chn) }"],
[lambda { filtered_env([0, 0, 1, 1, 2, 0]) },
"Proc.new {|snd, chn| filtered_env([0, 0, 1, 1, 2, 0], snd, chn) }"],
[lambda { reverse_by_blocks(0.1) },
@@ -32422,8 +30422,7 @@ def test_lgamma
res1 = lgamma(x)
res2 = gammln(x)
if array?(res1)
- # FIXME
- # Ruby 1.9 returns an array
+ # XXX: Ruby 1.9+ returns an array
res1 = res1[0]
end
snd_test_neq(res1, res2, "lgamma(%1.1f)", x)
@@ -32547,7 +30546,6 @@ def corr(x, y, n, m)
end
def cross_correlate_3(rl1, rl2, fftlen)
- fftlen2 = fftlen / 2
fftscale = 1.0 / fftlen
im1 = Vct.new(fftlen)
im2 = Vct.new(fftlen)
@@ -32555,7 +30553,6 @@ def cross_correlate_3(rl1, rl2, fftlen)
fft(rl2, im2, 1)
tmprl = rl1.dup
tmpim = im1.dup
- data3 = Vct.new(fftlen)
tmprl *= rl2
tmpim *= im2
im2 *= rl1
@@ -32566,7 +30563,7 @@ def cross_correlate_3(rl1, rl2, fftlen)
end
def automorph(a, b, c, d, snd = false, chn = false)
- len = frames(snd, chn)
+ len = framples(snd, chn)
pow2 = (log(len) / log(2)).ceil.to_i
fftlen = (2 ** pow2).round
fftscale = 1.0 / fftlen
@@ -33400,20 +31397,6 @@ def test_20_01
end
close_sound(ind)
#
- if defined? gsl_dht
- add_transform("Hankel", "Hankel", 0.0, 1.0,
- lambda do |n, rd|
- v = make_vct!(n) do rd.call end
- gsl_dht(n, v, 1.0, 1.0)
- end)
- n = 16
- v = make_vct(n, 1.0)
- gsl_dht(n, v, 1.0, 1.0)
- if (res = Snd.catch do gsl_dht(-1, Vct.new(3), 1.0, 1.0) end).first != :out_of_range
- snd_display("gsl_dht bad size: %s?", res.inspect)
- end
- end
- #
ind1 = open_sound("oboe.snd")
set_time_graph_style(Graph_lollipops, ind1, 0)
graph2ps("aaa.eps")
@@ -33421,47 +31404,21 @@ def test_20_01
set_transform_graph_type(Graph_as_sonogram, ind1, 0)
set_transform_size(256)
update_transform_graph
- size = transform_frames(ind1, 0)
+ size = transform_framples(ind1, 0)
if number?(size) or size.length != 3
- snd_display("transform_frames of sonogram: %s?", size)
+ snd_display("transform_framples of sonogram: %s?", size)
end
graph2ps("aaa.eps")
- if $with_test_gui
- Snd.catch do
- unless (ax = axis_info(ind1, 0, Transform_graph))
- snd_display("axis_info Transform_graph?")
- end
- if $with_test_motif
- cwid = channel_widgets(ind1, 0).first
- focus_widget(cwid)
- click_event(cwid, 0, 0, (0.5 * (ax[10] + ax[12])).floor, (0.5 * (ax[11] + ax[13])).floor)
- force_event
- end
- end
- end
old_colormap = colormap
set_colormap(integer2colormap(0))
update_transform_graph
set_transform_graph_type(Graph_as_spectrogram, ind1, 0)
update_transform_graph
graph2ps("aaa.eps")
- if $with_test_gui
- Snd.catch do
- unless (ax = axis_info(ind1, 0, Transform_graph))
- snd_display("axis_info Transform_graph?")
- end
- if $with_test_motif
- cwid = channel_widgets(ind1, 0).first
- focus_widget(cwid)
- click_event(cwid, 0, 0, (0.5 * (ax[10] + ax[12])).floor, (0.5 * (ax[11] + ax[13])).floor)
- force_event
- end
- end
- end
set_colormap(old_colormap)
close_sound(ind1)
#
- ind = new_sound("test.snd", Mus_next, Mus_bfloat)
+ ind = new_sound("test.snd", :header_type, Mus_next, :sample_type, Mus_bfloat)
pad_channel(0, 1000)
set_transform_graph_type(Graph_once, ind, 0)
set_show_transform_peaks(true, ind, 0)
@@ -33498,13 +31455,7 @@ def test_20_01
set_transform_graph_type(Graph_as_sonogram, ind, 0)
set_fft_log_magnitude(false, ind, 0)
update_transform_graph
- unless $with_test_gtk
- # FIXME
- # doens't work with GTK
- # Assertion failed: (! surface->finished), function _cairo_surface_begin_modification, file cairo-surface.c, line 385.
- # Abort (core dumped)
- graph2ps("aaa.eps")
- end
+ graph2ps("aaa.eps")
set_with_gl(false)
set_spectrum_end(0.2, ind, 0)
set_transform_graph_type(Graph_as_spectrogram, ind, 0)
@@ -33521,9 +31472,9 @@ def test_20_02
1.000, 0.963, 0.860, 0.709, 0.536, 0.366, 0.221, 0.113),
"dolph 16 2.5 (dsp.rb)")
v = Vct.new(8)
- v0 = Vct.new(8) do |i| v[i] = random(2.0) - 1.0 end
+ v0 = Vct.new(8) do |i| v[i] = mus_random(1.0) end
v = dht(dht(v)).scale(1.0 / 8.0)
- snd_test_any_neq(v, v0, :vvequal?, "dht twice") # okay
+ snd_test_any_neq(v, v0, :vvequal?, "dht twice")
v.fill 0.0
v[1] = 1.0
snd_test_neq(dht(v), vct(1, 1.414, 1, 0, -1, -1.414, -1, 0), "dht of pulse")
@@ -33549,7 +31500,7 @@ def test_20_02
close_sound(ind)
#
ind = open_sound("1a.snd")
- frms = frames(ind)
+ frms = framples(ind)
valf = find_sine(440.0, 0, frms, ind).first
valg = 2 * (goertzel(440.0, 0, frms, ind) / frms)
valf1 = find_sine(100.0, 0, frms, ind).first
@@ -33598,15 +31549,15 @@ def test_20_02
undo_edit
spectral_polynomial(vct(0, 1), ind, 0)
snd_test_neq(maxamp(), 0.493, "spectral_polynomial 0 mx")
- snd_test_neq(frames(ind, 0), 41623, "spectral_polynomial 0 len")
+ snd_test_neq(framples(ind, 0), 41623, "spectral_polynomial 0 len")
undo_edit
spectral_polynomial(vct(0, 0.5, 0.5), ind, 0)
snd_test_neq(maxamp(), 0.493, "spectral_polynomial 1 mx")
- snd_test_neq(frames(ind, 0), 41623 * 2, "spectral_polynomial 1 len")
+ snd_test_neq(framples(ind, 0), 41623 * 2, "spectral_polynomial 1 len")
undo_edit
spectral_polynomial(vct(0, 0, 0, 1), ind, 0)
snd_test_neq(maxamp(), 0.493, "spectral_polynomial 2 mx")
- snd_test_neq(frames(ind, 0), 41623 * 3, "spectral_polynomial 2 len")
+ snd_test_neq(framples(ind, 0), 41623 * 3, "spectral_polynomial 2 len")
close_sound(ind)
#
vals = scentroid("oboe.snd")
@@ -33665,7 +31616,7 @@ def test_20_02
gen = make_oscil(440)
map_chan(lambda { |y| oscil(gen) })
down_oct(2)
- snd_test_neq(frames(), 200, "down_oct new len")
+ snd_test_neq(framples(), 200, "down_oct new len")
r1 = make_sampler(0, ind, 0, 1, 1)
r2 = make_sampler(0, ind, 0, 1, 2)
200.times do |i|
@@ -33738,9 +31689,7 @@ def test_20_02
end
false
end)
- if mxdiff > 0.003
- snd_display(snd_format(mxdiff, 0.003, ">", "automorph rotation"))
- end
+ snd_test_gt(mxdiff, 0.003, "automorph rotation")
close_sound(ind)
end
@@ -33780,7 +31729,10 @@ def display_samps_in_red(snd, chn)
offset = [0, 1000 - left].max
new_data = data.subseq(offset, offset + samps)
set_foreground_color(red, snd, chn)
- graph_data(new_data, snd, chn, Copy_context, [1000, left].max, [2000, right].min)
+ cr = make_cairo(channel_widgets(snd, chn)[0])
+ graph_data(new_data, snd, chn, Copy_context,
+ [1000, left].max, [2000, right].min, Graph_lines, cr)
+ free_cairo(cr)
set_foreground_color(old_color, snd, chn)
when Array
low_data = data[0]
@@ -33794,24 +31746,33 @@ def display_samps_in_red(snd, chn)
new_low_data = low_data.subseq(left_bin, right_bin)
new_high_data = high_data.subseq(left_bin, right_bin)
set_foreground_color(red, snd, chn)
- graph_data([new_low_data, new_high_data], snd, chn, Copy_context, left_bin, right_bin)
+ cr = make_cairo(channel_widgets(snd, chn)[0])
+ graph_data([new_low_data, new_high_data], snd, chn, Copy_context,
+ left_bin, right_bin, Graph_lines, cr)
+ free_cairo(cr)
set_foreground_color(old_color, snd, chn)
end
end
+rescue
+ snd_display("draw error in %s", get_func_name)
end
-def show_hiho(snd, chn)
+def show_greeting(snd, chn)
ls = left_sample(snd, chn)
rs = right_sample(snd, chn)
if ls < 1000 and rs > 1000
pos = x2position(1000.0 / srate(snd), snd, chn)
old_color = foreground_color(snd, chn)
+ cr = make_cairo(channel_widgets(snd, chn)[0])
set_foreground_color(make_color_with_catch(0.75, 0.75, 0.75), snd, chn)
- fill_rectangle(pos, 10, 50, 20, snd, chn)
+ fill_rectangle(pos, 10, 50, 20, snd, chn, Time_graph, false, cr)
set_foreground_color(make_color_with_catch(1, 0, 0), snd, chn)
- draw_string("hiho", pos + 5, 24, snd, chn)
+ draw_string("hi!", pos + 5, 24, snd, chn, Time_graph, cr)
set_foreground_color(old_color, snd, chn)
+ free_cairo(cr)
end
+rescue
+ snd_display("draw error in %s", get_func_name)
end
def st_equal?(a, b)
@@ -33826,7 +31787,8 @@ def st_vequal_2(a, b)
vequal(a[0], b[0]) and vequal(a[1], b[1])
end
-def test_sound_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, set_p, chan, global)
+def test_sound_func_1(func, ind_1, ind_2, new_val,
+ eq_func, leq_func, set_p, chan, global)
old_val = snd_func(func)
old_vals = snd_func(func, true)
old_default = snd_func(func, false)
@@ -33835,10 +31797,12 @@ def test_sound_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, set_p, cha
sel_snd = selected_sound()
unsel_snd = sel_snd == ind_1 ? ind_2 : ind_1
caller = chan ? "channel" : "sound"
- snd_test_any_neq(old_val, old_default, eq_func, "%s sound_func: no arg false", func)
+ snd_test_any_neq(old_val, old_default, eq_func,
+ "%s sound_func: no arg false", func)
unless method(leq_func).call(old_vals, [old_1, old_2]) or
- method(leq_func).call(old_vals, [old_2, old_1])
- snd_display(snd_format_neq(old_vals, [old_1, old_2], "%s sound_func true", func))
+ method(leq_func).call(old_vals, [old_2, old_1])
+ s = snd_format_neq(old_vals, [old_1, old_2], "%s sound_func true", func)
+ snd_display_prev_caller(s)
end
if set_p
set_snd_func(func, new_val)
@@ -33848,12 +31812,16 @@ def test_sound_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, set_p, cha
snd_test_any_neq(res1, new_val, eq_func, "set_%s no arg", func)
snd_test_any_neq(res1, res2, eq_func, "set_%s no arg sel", func)
if (global and (not method(eq_func).call(res1, res3))) or
- (not global and method(eq_func).call(res1, res3))
- snd_display(snd_format_neq(res1, res3, "set_%s no arg unsel", func))
+ ((not global) and method(eq_func).call(res1, res3))
+ s = snd_format_neq(res1, res3, "set_%s no arg unsel", func)
+ snd_display_prev_caller(s)
end
res1 = snd_func(func, true)
- unless method(leq_func).call(res1, [res2, res3]) or method(leq_func).call(res1, [res3, res2])
- snd_display(snd_format_neq(res1, [res2, res3], "set_%s %s_func true", func, caller))
+ unless method(leq_func).call(res1, [res2, res3]) or
+ method(leq_func).call(res1, [res3, res2])
+ s = snd_format_neq(res1, [res2, res3],
+ "set_%s %s_func true", func, caller)
+ snd_display_prev_caller(s)
end
set_snd_func(func, old_val)
if set_p == :swap
@@ -33861,13 +31829,21 @@ def test_sound_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, set_p, cha
else
set_snd_func(func, new_val, ind_1)
end
- snd_test_any_neq(snd_func(func, ind_1), new_val, eq_func, "set_%s arg", func)
- snd_test_any_eq(snd_func(func, ind_2), new_val, eq_func, "set_%s arg (2)", func)
- res1 = snd_func(func, true)
- res2 = snd_func(func, ind_1)
- res3 = snd_func(func, ind_2)
- unless method(leq_func).call(res1, [res2, res3]) or method(leq_func).call(res1, [res3, res2])
- snd_display(snd_format_neq(res1, [res2, res3], "set_%s %s_func arg", func, caller))
+ res0 = snd_func(func, true)
+ res1 = snd_func(func, ind_1)
+ res2 = snd_func(func, ind_2)
+ unless method(eq_func).call(res1, new_val)
+ s = snd_format_neq(res1, new_val, "set_%s arg", func)
+ snd_display_prev_caller(s)
+ end
+ if method(eq_func).call(res2, new_val)
+ s = snd_format_eq(res2, new_val, "set_%s arg (2)", func)
+ snd_display_prev_caller(s)
+ end
+ unless method(leq_func).call(res0, [res1, res2]) or
+ method(leq_func).call(res0, [res2, res1])
+ s = snd_format_neq(res0, [res1, res2], "set_%s %s_func arg", func, caller)
+ snd_display_prev_caller(s)
end
if set_p == :swap
set_snd_func(func, ind_1, old_1)
@@ -33876,12 +31852,23 @@ def test_sound_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, set_p, cha
set_snd_func(func, old_1, ind_1)
set_snd_func(func, new_val, true)
end
- res1 = snd_func(func, true)
- res2 = snd_func(func, ind_1)
- res3 = snd_func(func, ind_2)
- snd_test_any_neq(res1, [new_val, new_val], leq_func, "set_%s %s_func arg true", func, caller)
- snd_test_any_neq(res2, new_val, eq_func, "set_%s %s_func arg true", func, caller)
- snd_test_any_neq(res3, new_val, eq_func, "set_%s %s_func arg true (2)", func, caller)
+ res0 = snd_func(func, true)
+ res1 = snd_func(func, ind_1)
+ res2 = snd_func(func, ind_2)
+ unless method(leq_func).call(res0, [new_val, new_val])
+ s = snd_format_neq(res0, [new_val, new_val],
+ "set_%s %s_func arg true", func, caller)
+ snd_display_prev_caller(s)
+ end
+ unless method(eq_func).call(res1, new_val)
+ s = snd_format_neq(res1, new_val, "set_%s %s_func arg true", func, caller)
+ snd_display_prev_caller(s)
+ end
+ unless method(eq_func).call(res2, new_val)
+ s = snd_format_neq(res2, new_val,
+ "set_%s %s_func arg true (2)", func, caller)
+ snd_display_prev_caller(s)
+ end
if set_p == :swap
set_snd_func(func, ind_1, old_1)
set_snd_func(func, ind_2, old_2)
@@ -33889,14 +31876,21 @@ def test_sound_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, set_p, cha
set_snd_func(func, old_1, ind_1)
set_snd_func(func, old_2, ind_2)
end
- res2 = snd_func(func, ind_1)
- res3 = snd_func(func, ind_2)
- snd_test_any_neq(res2, old_1, eq_func, "set_%s arg true old", func)
- snd_test_any_neq(res3, old_2, eq_func, "set_%s arg true old (2)", func)
+ res1 = snd_func(func, ind_1)
+ res2 = snd_func(func, ind_2)
+ unless method(eq_func).call(res1, old_1)
+ s = snd_format_neq(res1, old_1, "set_%s arg true old", func)
+ snd_display_prev_caller(s)
+ end
+ unless method(eq_func).call(res2, old_2)
+ s = snd_format_neq(res2, old_2, "set_%s arg true old (2)", func)
+ snd_display_prev_caller(s)
+ end
end
end
-def test_channel_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, set_p, global)
+def test_channel_func_1(func, ind_1, ind_2, new_val,
+ eq_func, leq_func, set_p, global)
old_1_0 = snd_func(func, ind_1, 0)
old_2_0 = snd_func(func, ind_2, 0)
old_2_1 = snd_func(func, ind_2, 1)
@@ -33904,29 +31898,74 @@ def test_channel_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, set_p, g
old_2_all = snd_func(func, ind_2, true)
old_all_0 = snd_func(func, true, 0)
old_all_all = snd_func(func, true, true)
- snd_test_any_neq(old_1_0, old_1_all[0], eq_func, "%s channel_func: old 1/true", func)
- snd_test_any_neq(old_2_0, old_2_all[0], eq_func, "%s channel_func: old 2-1/true", func)
- snd_test_any_neq(old_2_1, old_2_all[1], eq_func, "%s channel_func: old 2-2/true", func)
- snd_test_any_neq(old_1_all, [old_1_0], leq_func, "%s channel_func true", func)
- snd_test_any_neq(old_2_all, [old_2_0, old_2_1], leq_func, "%s channel_func true", func)
+ unless method(eq_func).call(old_1_0, old_1_all[0])
+ s = snd_format_neq(old_1_0, old_1_all[0],
+ "%s channel_func: old 1/true", func)
+ snd_display_prev_caller(s)
+ end
+ unless method(eq_func).call(old_2_0, old_2_all[0])
+ s = snd_format_neq(old_2_0, old_2_all[0],
+ "%s channel_func: old 2-1/true", func)
+ snd_display_prev_caller(s)
+ end
+ unless method(eq_func).call(old_2_1, old_2_all[1])
+ s = snd_format_neq(old_2_1, old_2_all[1],
+ "%s channel_func: old 2-2/true", func)
+ snd_display_prev_caller(s)
+ end
+ unless method(leq_func).call(old_1_all, [old_1_0])
+ s = snd_format_neq(old_1_all, [old_1_0], "%s channel_func true", func)
+ snd_display_prev_caller(s)
+ end
+ unless method(leq_func).call(old_2_all, [old_2_0, old_2_1])
+ s = snd_format_neq(old_2_all, [old_2_0, old_2_1],
+ "%s channel_func true", func)
+ snd_display_prev_caller(s)
+ end
unless ((method(leq_func).call(old_all_all[0], old_1_all) or
method(leq_func).call(old_all_all[0], old_2_all)) and
(method(leq_func).call(old_all_all[1], old_1_all) or
(method(leq_func).call(old_all_all[1], old_2_all))))
- snd_display(snd_format_neq(old_all_all[0], old_1_all, "%s channel_func true true", func))
+ s = snd_format_neq(old_all_all[0], old_1_all,
+ "%s channel_func true true", func)
+ snd_display_prev_caller(s)
end
if set_p
set_snd_func(func, new_val, ind_1, 0)
- snd_test_any_neq(snd_func(func, ind_1, 0), new_val, eq_func, "set_%s channel_func", func)
- snd_test_any_eq(snd_func(func, ind_2, 0), new_val, eq_func, "set_%s 2 channel_func", func)
+ res1 = snd_func(func, ind_1, 0)
+ res2 = snd_func(func, ind_2, 1)
+ unless method(eq_func).call(res1, new_val)
+ s = snd_format_neq(res1, new_val, "set_%s channel_func", func)
+ snd_display_prev_caller(s)
+ end
+ if method(eq_func).call(res2, new_val)
+ s = snd_format_eq(res2, new_val, "set_%s 2 channel_func", func)
+ snd_display_prev_caller(s)
+ end
set_snd_func(func, old_1_0, ind_1, 0)
set_snd_func(func, new_val, ind_2, 1)
- snd_test_any_eq(snd_func(func, ind_1, 0), new_val, eq_func, "set_%s (2) channel_func", func)
- snd_test_any_neq(snd_func(func, ind_2, 1), new_val, eq_func, "set_%s (2) 2 channel_func", func)
+ res1 = snd_func(func, ind_1, 0)
+ res2 = snd_func(func, ind_2, 1)
+ if method(eq_func).call(res1, new_val)
+ s = snd_format_eq(res1, new_val, "set_%s (2) channel_func", func)
+ snd_display_prev_caller(s)
+ end
+ unless method(eq_func).call(res2, new_val)
+ s = snd_format_neq(res2, new_val, "set_%s (2) 2 channel_func", func)
+ snd_display_prev_caller(s)
+ end
set_snd_func(func, new_val, ind_2, 0)
set_snd_func(func, old_2_0, ind_2, true)
- snd_test_any_neq(snd_func(func, ind_2, 0), old_2_0, eq_func, "set_%s (true 0) 2 channel_func", func)
- snd_test_any_neq(snd_func(func, ind_2, 1), old_2_0, eq_func, "set_%s (true 1) 2 channel_func", func)
+ res1 = snd_func(func, ind_2, 0)
+ res2 = snd_func(func, ind_2, 1)
+ unless method(eq_func).call(res1, old_2_0)
+ s = snd_format_neq(res1, old_2_0, "set_%s (true 0) 2 channel_func", func)
+ snd_display_prev_caller(s)
+ end
+ unless method(eq_func).call(res2, old_2_0)
+ s = snd_format_neq(res2, old_2_0, "set_%s (true 1) 2 channel_func", func)
+ snd_display_prev_caller(s)
+ end
set_snd_func(func, old_2_0, ind_2, 0)
set_snd_func(func, old_2_1, ind_2, 1)
end
@@ -33951,7 +31990,7 @@ def test_21_00
unless channels_eql?(ind1, 0, ind2, 0)
snd_display("channels_eql? of copy")
end
- pad_channel(frames(ind2, 0), 100)
+ pad_channel(framples(ind2, 0), 100)
if channels_equal?(ind1, 0, ind2, 0)
snd_display("channels_equal? of pad")
end
@@ -33977,9 +32016,7 @@ def test_21_00
display_db(ind1, 0)
display_samps_in_red(ind1, 0)
update_time_graph
- Snd.catch(:all, lambda do |*args| snd_display("show_hiho trouble: %s", args) end) do
- show_hiho(ind1, 0)
- end
+ show_greeting(ind1, 0)
update_time_graph
color_samples(highlight_color, 0, 100, ind1, 0)
update_time_graph
@@ -33987,10 +32024,31 @@ def test_21_00
update_time_graph
$with_test_motif and show_disk_space(ind1)
update_time_graph
+ revert_sound(ind1)
+ make_selection(10000, 20000, ind1, 0)
+ if selection?
+ show_selection
+ vals = x_bounds(ind1, 0)
+ if vals.length == 2
+ snd_test_neq(vals[0], 10000.0 / srate(ind1), "show_selection")
+ snd_test_neq(vals[1], 20000.0 / srate(ind1), "show_selection")
+ end
+ else
+ snd_display("make_selection for show failed?")
+ end
+ $graph_hook.add_hook!("test-21-zoom-spectrum", &method(:zoom_spectrum).to_proc)
+ set_transform_graph?(true, ind1, 0)
+ ind3 = open_sound("pistol.snd")
+ overlay_sounds(ind2, ind1, ind3)
+ update_time_graph(ind2, 0)
+ $after_graph_hook.reset_hook!
+ close_sound(ind3)
+ samples_via_colormap(ind1, 0)
close_sound(ind1)
+ $graph_hook.remove_hook!("test-21-zoom-spectrum")
close_sound(ind2)
#
- ind = new_sound("tmp.snd", Mus_next, Mus_bfloat, 22050, 1, :size, 50)
+ ind = new_sound("tmp.snd", 1, 22050, Mus_bfloat, Mus_next, :size, 50)
set_sample(3, 1.0)
filter_channel(vct(0.5, 1.0, 0.5), 3)
unless vequal(res = channel2vct(0, 10), vct(0, 0, 0, 0.5, 1, 0.5, 0, 0, 0, 0))
@@ -34014,7 +32072,7 @@ def test_21_00
undo_edit
close_sound(ind)
#
- ind = new_sound("tmp.snd", Mus_next, Mus_bfloat, 22050, 1, false, 100)
+ ind = new_sound("tmp.snd", 1, 22050, Mus_bfloat, Mus_next, false, 100)
set_sample(10, 0.5)
filter_sound(vct(1, 0, 1), 3)
unless vequal(res = channel2vct(5, 10), vct(0, 0, 0, 0, 0, 0.5, 0, 0.5, 0, 0))
@@ -34108,7 +32166,7 @@ def test_21_00
undo_edit
close_sound(ind)
#
- ind = new_sound("tmp.snd", Mus_next, Mus_bfloat, 22050, 2, false, 100)
+ ind = new_sound("tmp.snd", 2, 22050, Mus_bfloat, Mus_next, false, 100)
set_sample(10, 0.5)
set_sample(5, -0.5, ind, 1)
set_sync(1, ind)
@@ -34174,7 +32232,7 @@ def test_21_00
undo_edit(1, ind, 1)
close_sound(ind)
#
- ind = new_sound("tmp.snd", Mus_next, Mus_bshort, 22050, 1, :size, 100)
+ ind = new_sound("tmp.snd", 1, 22050, Mus_bshort, Mus_next, :size, 100)
set_sample(10, 0.5)
set_sample(20, -0.5)
scale_to(1.0)
@@ -34185,7 +32243,7 @@ def test_21_00
snd_display("scale_to 1.0 Mus_bshort (20): %s?", sample(20))
end
close_sound(ind)
- ind = new_sound("tmp.snd", Mus_next, Mus_byte, 22050, 1, :size, 100)
+ ind = new_sound("tmp.snd", 1, 22050, Mus_byte, Mus_next, :size, 100)
set_sample(10, 0.5)
set_sample(20, -0.5)
scale_to(1.0)
@@ -34214,13 +32272,15 @@ def test_21_00
set_spectro_hop(4)
set_fft_window_alpha(0.0)
set_fft_window_beta(0.0)
- ind_1 = new_sound("test-1.snd", Mus_next, Mus_bfloat, 22050, 1, "mono testing", 100)
- ind_2 = new_sound("test-2.snd", Mus_aifc, Mus_bshort, 44100, 2, "stereo testing", 300)
+ ind_1 = new_sound("test-1.snd", 1, 22050, Mus_lfloat, Mus_next,
+ "mono testing", 100)
+ ind_2 = new_sound("test-2.snd", 2, 44100, Mus_bshort, Mus_aifc,
+ "stereo testing", 300)
[[:srate, 48000, :st_equal?, :st_eql?, :swap],
- [:data_format, Mus_byte, :st_equal?, :st_eql?, :swap],
+ [:sample_type, Mus_byte, :st_equal?, :st_eql?, :swap],
[:data_location, 123, :st_equal?, :st_eql?, :swap],
[:data_size, 12348, :st_equal?, :st_eql?, :swap],
- [:frames, 12348, :st_equal?, :st_eql?, true],
+ [:framples, 12348, :st_equal?, :st_eql?, true],
[:sync, 2, :st_equal?, :st_eql?, true],
[:channels, 0, :st_equal?, :st_eql?, false],
[:chans, 0, :st_equal?, :st_eql?, false],
@@ -34240,7 +32300,8 @@ def test_21_00
[:short_file_name, nil, :st_equal?, :st_eql?, false],
[:comment, nil, :st_equal?, :st_eql?, false]
].each do |func, new_val, eq_func, leq_func, settable|
- test_sound_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, settable, false, false)
+ test_sound_func_1(func, ind_1, ind_2, new_val,
+ eq_func, leq_func, settable, false, false)
end
save_controls(true)
restore_controls(true)
@@ -34252,8 +32313,10 @@ def test_21_00
#
# snd chn cases
#
- ind_1 = new_sound("test-1.snd", Mus_next, Mus_bfloat, 22050, 1, "mono testing", 100)
- ind_2 = new_sound("test-2.snd", Mus_aifc, Mus_bshort, 44100, 2, "stereo testing", 300)
+ ind_1 = new_sound("test-1.snd", 1, 22050, Mus_bfloat, Mus_next,
+ "mono testing", 100)
+ ind_2 = new_sound("test-2.snd", 2, 44100, Mus_bshort, Mus_aifc,
+ "stereo testing", 300)
set_sample(1, 0.1, ind_1, 0)
set_sample(2, 0.2, ind_2, 0)
set_sample(3, 0.3, ind_2, 1)
@@ -34277,11 +32340,10 @@ def test_21_00
[:cursor, 50, :st_equal?, :st_eql?, true, false],
[:cursor_style, 1, :st_equal?, :st_eql?, true, true],
[:cursor_size, 10, :st_equal?, :st_eql?, true, true],
- [:frames, 50, :st_equal?, :st_eql?, true, false],
+ [:framples, 50, :st_equal?, :st_eql?, true, false],
[:zero_pad, 1, :st_equal?, :st_eql?, true, true],
[:wavelet_type, 1, :st_equal?, :st_eql?, true, true],
- # FIXME see below
- # [:time_graph_type, Graph_as_wavogram, :st_equal?, :st_eql?, true, true],
+ [:time_graph_type, Graph_as_wavogram, :st_equal?, :st_eql?, true, true],
[:wavo_hop, 10, :st_equal?, :st_eql?, true, true],
[:wavo_trace, 10, :st_equal?, :st_eql?, true, true],
[:transform_size, 64, :st_equal?, :st_eql?, true, true],
@@ -34305,15 +32367,11 @@ def test_21_00
[:fft_log_magnitude, true, :st_equal?, :st_eql?, true, true],
[:show_mix_waveforms, false, :st_equal?, :st_eql?, true, true],
[:with_verbose_cursor, true, :st_equal?, :st_eql?, true, true]]
- unless $with_test_gtk
- # FIXME
- # doesn't work with GTK
- # set_time_graph_type(Graph_as_wavogram) ==> hangs or even segfaults
- vals += [[:time_graph_type, Graph_as_wavogram, :st_equal?, :st_eql?, true, true]]
- end
vals.each do |func, new_val, eq_func, leq_func, settable, global|
- test_sound_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, settable, true, global)
- test_channel_func_1(func, ind_1, ind_2, new_val, eq_func, leq_func, settable, global)
+ test_sound_func_1(func, ind_1, ind_2, new_val,
+ eq_func, leq_func, settable, true, global)
+ test_channel_func_1(func, ind_1, ind_2, new_val,
+ eq_func, leq_func, settable, global)
end
update_time_graph(true, true)
update_transform_graph(true, true)
@@ -34324,13 +32382,14 @@ def test_21_00
snd_display("sounds after close_sound(false) twice: %s?", sounds)
end
#
- ind_1 = new_sound("test-1.snd", Mus_next, Mus_bfloat, 22050, 1, "mono testing", 100)
- ind_2 = new_sound("test-2.snd", Mus_aifc, Mus_bshort, 44100, 2, "stereo testing", 300)
+ ind_1 = new_sound("test-1.snd", 1, 22050, Mus_bfloat, Mus_next,
+ "mono testing", 100)
+ ind_2 = new_sound("test-2.snd", 2, 44100, Mus_bshort, Mus_aifc,
+ "stereo testing", 300)
# test_sound_func_2
[[:filter_control_in_dB, true, :st_eql?, :st_eql?],
[:filter_control_in_hz, true, :st_eql?, :st_eql?],
[:show_controls, true, :st_eql?, :st_eql?],
- [:with_tracking_cursor, true, :st_eql?, :st_eql?],
[:speed_control_tones, 14, :st_equal?, :st_eql?],
[:speed_control_style, Speed_control_as_semitone, :st_equal?, :st_eql?],
[:filter_control_order, 14, :st_equal?, :st_eql?],
@@ -34401,45 +32460,6 @@ def test_21_00
close_sound(true)
end
-def test_21_01
- file_copy("2a.snd", "test.snd")
- ind = open_sound("test.snd")
- clear_listener
- 2500.times do |i|
- k = random(200) + 1
- s = case random(5)
- when 1
- 4
- when 2
- 8
- when 3
- 12
- else
- 0
- end
- if k > 127
- k = key_to_int(?x)
- s = 4
- end
- if random(1.0) > 0.99
- clear_listener
- end
- if k == key_to_int(?e) or k == key_to_int(?E)
- snd_simulate_keystroke(ind, 0, key_to_int(?g), 0)
- end
- snd_simulate_keystroke(ind, random(channels(ind)), k, s)
- if sound?(ind) and frames(ind, 0) > 1000000
- close_sound(ind)
- file_copy("2a.snd", "test.snd")
- end
- unless sound?(ind)
- ind = open_sound("test.snd")
- end
- end
- clear_listener
- close_sound(ind)
-end
-
def test_21_02
set_remember_sound_state(true)
ind = open_sound("oboe.snd")
@@ -34559,7 +32579,7 @@ def test_21_02
mx = maxamp(ind, 0)
chns = channels(ind)
sr = srate(ind)
- fr = frames(ind, 0)
+ fr = framples(ind, 0)
with_local_hook($update_hook,
lambda do |orig_ind|
lambda do |new_ind|
@@ -34573,7 +32593,7 @@ def test_21_02
snd_test_neq(maxamp(ind, 0), mx, "update_sound looped maxamp %d", i)
snd_test_neq(chans(ind), chns, "update_sound looped chans")
snd_test_neq(srate(ind), sr, "update_sound looped srate")
- snd_test_neq(frames(ind), fr, "update_sound looped frames")
+ snd_test_neq(framples(ind), fr, "update_sound looped framples")
end
old_ind = open_sound("oboe.snd")
diff = 0.0
@@ -34594,8 +32614,8 @@ def test_21_02
ind = open_sound("oboe.snd")
data = channel2vct
5.times do |i|
- array2file("test.snd", data, frames(ind), 22050, 1)
- file2array("test.snd", 0, 0, frames, data)
+ array2file("test.snd", data, framples(ind), 22050, 1)
+ file2array("test.snd", 0, 0, framples, data)
diff = 0.0
ctr = 0
scan_channel(lambda do |y|
@@ -34627,7 +32647,7 @@ def test_21_02
delete_files("test.snd", "fmv.snd")
rdin = false
rdout = false
- len = mus_sound_frames("oboe.snd")
+ len = mus_sound_framples("oboe.snd")
types = [Mus_riff, Mus_aifc, Mus_next, Mus_nist, Mus_ircam]
forms = [Mus_lshort, Mus_bshort, Mus_b24int, Mus_l24int, Mus_bint]
file_copy("oboe.snd", "fmv.snd")
@@ -34673,7 +32693,7 @@ def test_21_02
env_sound([0, 2, 1, 2])
end],
["env_channel", lambda do
- env_channel(make_env([0, 1, 1, 1], :scaler, 2.0, :length, frames))
+ env_channel(make_env([0, 1, 1, 1], :scaler, 2.0, :length, framples))
end],
["clm_channel", lambda do
clm_channel(make_one_zero(:a0, 2.0, :a1, 0.0))
@@ -34697,13 +32717,6 @@ def test_21_02
mix("temp.snd", 0)
delete_file("temp.snd")
end],
- ["sound_data", lambda do
- sd = vct2sound_data(channel2vct())
- frames.times do |i|
- sd[0, i] *= 2.0
- end
- set_samples(0, frames, sd.to_vct)
- end],
["convolve", lambda do
flt = Vct.new(8)
flt[0] = 2.0
@@ -34712,7 +32725,7 @@ def test_21_02
map_channel(lambda do |y| convolve(cnv, lambda do |dir| read_sample(sf) end) end)
end],
["fft", lambda do
- len = frames
+ len = framples
fsize = 2 ** (log(len) / log(2)).ceil
rl = channel2vct(0, fsize)
im = Vct.new(fsize)
@@ -34756,7 +32769,6 @@ end
def test_21
test_21_00 if $with_test_gui
- test_21_01
test_21_02
end
@@ -34764,16 +32776,11 @@ end
require "clm-ins"
-class Instrument
- # v.rb
- alias fm_violin fm_violin_rb
- alias jc_reverb jc_reverb_rb
- # clm-ins.rb
- alias nrev nrev_rb
-end
-
-def bigbird_2(start, dur, freq, freqskew, amp, freq_envelope, amp_envelope, partials)
- gls_env = make_env(:envelope, freq_envelope, :scaler, hz2radians(freqskew), :duration, dur)
+def bigbird_2(start, dur, freq,
+ freqskew, amp, freq_envelope, amp_envelope, partials)
+ gls_env = make_env(:envelope, freq_envelope,
+ :scaler, hz2radians(freqskew),
+ :duration, dur)
os = make_oscil(:frequency, freq)
amp_env = make_env(:envelope, amp_envelope, :scaler, amp, :duration, dur)
coeffs = partials2polynomial(normalize_partials(partials))
@@ -34783,7 +32790,9 @@ def bigbird_2(start, dur, freq, freqskew, amp, freq_envelope, amp_envelope, part
end
def bird_2(start, dur, freq, freqskew, amp, freq_envelope, amp_envelope)
- gls_env = make_env(:envelope, freq_envelope, :scaler, hz2radians(freqskew), :duration, dur)
+ gls_env = make_env(:envelope, freq_envelope,
+ :scaler, hz2radians(freqskew),
+ :duration, dur)
os = make_oscil(:frequency, freq)
amp_env = make_env(:envelope, amp_envelope, :scaler, amp, :duration, dur)
run_instrument(start, dur) do
@@ -34847,22 +32856,23 @@ end
def step_src
rd = make_sampler(0)
os = make_oscil(2205)
- sr = make_src(:srate, 0.0)
+ sr = make_src(:srate, 0.0, :input, lambda do |dir| read_sample(rd) end)
incr = 2.0 + oscil(os)
- tempfile = with_sound(:output, snd_tempnam,
- :srate, srate,
+ tempfile = with_sound(:output, snd_tempnam(),
+ :srate, srate(),
:comment, get_func_name) do
samp = 0
until sampler_at_end?(rd)
- out_any(samp, src(sr, incr, lambda do |dir| read_sample(rd) end), 0, $output)
+ out_any(samp, src(sr, incr), 0, $output)
if (samp % 2205).zero?
incr = 2.0 + oscil(os)
end
samp += 1
end
end.output
- len = mus_sound_frames(tempfile)
- set_samples(0, len - 1, tempfile, false, false, true, get_func_name, 0, false, true)
+ len = mus_sound_framples(tempfile)
+ set_samples(0, len - 1, tempfile, false, false, true,
+ get_func_name, 0, false, true)
end
# optkey returns an array of values or, if array length is 1, returns
@@ -34901,7 +32911,7 @@ end
def test_23_00
set_mus_srate($clm_srate = 22050)
set_default_output_srate(22050)
- with_sound(:reverb, :nrev) do
+ with_sound(:reverb, :nrev, :play, false) do
fmt1 = [0, 1200, 100, 1000]
fmt2 = [0, 2250, 100, 1800]
fmt3 = [0, 4500, 100, 4500]
@@ -34970,7 +32980,7 @@ end
def test_23_01
set_mus_srate($clm_srate = 22050)
set_default_output_srate(22050)
- with_sound(:srate, 22050) do
+ with_sound(:srate, 22050, :play, false) do
fm_violin(0, 0.01, 440, 0.1, :noise_amount, 0.0)
pluck(0.05, 0.01, 330, 0.1, 0.95, 0.95)
maraca(0.1, 0.1)
@@ -35059,10 +33069,12 @@ def test_23_01
[0, 0, 25, 1, 75, 1, 100, 0], 0.75, 1.0, 0, 0, 0, 0, 1, 0, 0, 220,
[0, 0, 25, 1, 75, 1, 100, 0], 0, 0, 0, 0,
[0, 0, 100, 0], 0, 0, 0, 0, [0, 0, 100, 0])
+ clm_expsrc(14.75, 2.5, "oboe.snd", 2.0, 1.0, 1.0)
scratch(15.0, "now.snd", 1.5, [0.0, 0.5, 0.25, 1.0])
two_tab(15, 1, 440, 0.1)
- exp_snd("fyow.snd", 15, 3, 1, [0, 1, 1, 3], 0.4, 0.15, [0, 2, 1, 0.5], 0.05)
- exp_snd("oboe.snd", 16, 3, 1, [0, 1, 1, 3], 0.4, 0.15, [0, 2, 1, 0.5], 0.2)
+ exp_snd("fyow.snd", 15, 1.5, 1, [0, 1, 1, 3], 0.4, 0.15,
+ [0, 2, 1, 0.5], 0.05)
+ exp_snd("oboe.snd", 16, 1, 1, [0, 1, 1, 3], 0.4, 0.15, [0, 2, 1, 0.5], 0.2)
gran_synth(15.5, 1, 300, 0.0189, 0.03, 0.4)
spectra(16, 1, 440, 0.1,
[1, 0.4, 2, 0.2, 3, 0.2, 4, 0.1, 6, 0.1],
@@ -35076,7 +33088,7 @@ def test_23_01
false, false,
500, 0.995, 0.1, 1000, 0.995, 0.1, 2000, 0.995, 0.1)
bes_fm(18, 1, 440, 10.0, 1.0, 4.0)
- graph_eq("oboe.snd")
+ graph_eq("oboe.snd", 19, 1)
end
if sound?(ind = find_sound("test.snd"))
close_sound(ind)
@@ -35104,13 +33116,14 @@ def test_23_02
Mus_bfloat,
Mus_bdouble,
Mus_ldouble].each do |type|
- ind = find_sound(with_sound(:data_format, type) do
+ ind = find_sound(with_sound(:sample_type, type, :srate, 22050) do
fm_violin(0, 0.1, 440, 0.1)
fm_violin(10, 0.1, 440, 0.1)
fm_violin(100, 0.1, 440, 0.1)
- fm_violin(1000, 0.1, 440, 0.1)
+ fm_violin(250, 0.1, 440, 0.1)
end.output)
- snd_test_any_neq(maxamp(ind), 0.1, :ffequal?, "format %s", mus_data_format2string(type)) # okay
+ snd_test_any_neq(maxamp(ind), 0.1, :ffequal?,
+ "format %s", mus_sample_type2string(type))
end
3.times do |i|
with_sound(:srate, 22050) do
@@ -35127,31 +33140,10 @@ def test_23_02
snd_display("with_sound srate: %s (%s %s)?",
srate(ind), mus_srate, mus_sound_srate("test.snd"))
end
- if frames(ind) != 2205
- snd_display("with_sound frames (%s): %s?", i, frames(ind))
+ if framples(ind) != 2205
+ snd_display("with_sound framples (%s): %s?", i, framples(ind))
end
end
- with_sound(:continue_old_file, true) do
- fm_violin(0.2, 0.1, 440, 0.25)
- end
- ind = find_sound("test.snd")
- unless ind
- snd_display("with_sound continued: %s?", file_name(true))
- end
- if Snd.sounds.length != 1
- snd_display("with_sound continued: %s?", short_file_name(true))
- end
- if fneq(res = maxamp, 0.25)
- snd_display("with_sound continued max: %s?", res)
- end
- if srate(ind) != 22050
- snd_display("with_sound continued srate: %s (%s %s)?",
- srate(ind), mus_srate, mus_sound_srate("test.snd"))
- end
- if frames(ind) != 3 * 2205
- snd_display("with_sound continued frames: %s?", frames(ind))
- end
- close_sound(ind)
#
with_sound do
fm_violin(0, 0.1, 440, 0.1)
@@ -35163,7 +33155,7 @@ def test_23_02
if fneq(res = maxamp, 0.1)
snd_display("maxamp after continued sound: %s?", res)
end
- if fneq(res = frames(ind) / srate(ind).to_f, 0.3)
+ if fneq(res = framples(ind) / srate(ind).to_f, 0.3)
snd_display("duration after continued sound: %s?", res)
end
close_sound(ind)
@@ -35184,8 +33176,8 @@ def test_23_02
snd_display("with_sound srate (1): %s (%s %s)?",
srate(ind), mus_srate, mus_sound_srate("test1.snd"))
end
- if frames(ind) != 2205
- snd_display("with_sound frames (1): %s?", frames(ind))
+ if framples(ind) != 2205
+ snd_display("with_sound framples (1): %s?", framples(ind))
end
if chans(ind) != 2 or mus_sound_chans("test1.snd") != 2
snd_display("with_sound chans (1): %s?", chans(ind))
@@ -35196,7 +33188,7 @@ def test_23_02
with_sound(:srate, 48000,
:channels, 2,
:header_type, Mus_riff,
- :data_format, Mus_lshort,
+ :sample_type, Mus_lshort,
:output, "test1.snd") do
fm_violin(0, 0.1, 440, 0.1)
end
@@ -35219,7 +33211,7 @@ def test_23_02
with_sound(:srate, 48000,
:channels, 2,
:header_type, Mus_caff,
- :data_format, Mus_lshort,
+ :sample_type, Mus_lshort,
:output, "test1.snd") do
fm_violin(0, 0.1, 440, 0.1)
end
@@ -35319,31 +33311,14 @@ def test_23_02
fm_violin(0, 0.1, 440, 0.1, :degree, 45.0)
end
if sound?(ind = find_sound("test1.snd"))
- if frames(ind) != 22050 + 2205
- snd_display("with_sound reverbed frames (2): %s?", frames(ind))
+ if framples(ind) - (22050 + 2205) > 1
+ snd_display("with_sound reverbed framples (2): %s?", framples(ind))
end
close_sound(ind)
else
snd_display("with_sound (2): %s?", file_name(true))
end
#
- 3.times do
- with_sound(:srate, 22050,
- :output, "test1.snd",
- :reverb, :jc_reverb) do
- fm_violin(0, 0.1, 440, 0.1)
- end
- end
- ind = find_sound("test1.snd")
- unless ind
- snd_display("with_sound (3): %s?", file_name(true))
- end
- if frames(ind) != 22050 + 2205
- snd_display("with_sound reverbed frames (3): %s?", frames(ind))
- end
- close_sound(ind)
- delete_file("test1.snd")
- #
with_sound(:srate, 22050,
:comment, "Snd+Run!",
:scaled_to, 0.5) do
@@ -35364,7 +33339,7 @@ def test_23_02
with_sound(:srate, 22050,
:scaled_by, 0.5,
:header_type, Mus_aifc,
- :data_format, Mus_bfloat) do
+ :sample_type, Mus_bfloat) do
fm_violin(0, 0.1, 440, 0.1)
end
ind = find_sound("test.snd")
@@ -35377,8 +33352,8 @@ def test_23_02
if (res = header_type(ind)) != Mus_aifc
snd_display("with_sound type: %s (%s)?", res, mus_header_type_name(res))
end
- if (res = data_format(ind)) != Mus_bfloat
- snd_display("with_sound format: %s (%s)?", res, mus_data_format_name(res))
+ if (res = sample_type(ind)) != Mus_bfloat
+ snd_display("with_sound format: %s (%s)?", res, mus_sample_type_name(res))
end
close_sound(ind)
#
@@ -35393,8 +33368,10 @@ def test_23_02
if (res = header_type(ind)) != Mus_raw
snd_display("with_sound type raw: %s (%s)?", res, mus_header_type_name(res))
end
- if (res = data_format(ind)) != Mus_bshort and res != Mus_bfloat and res != Mus_lfloat
- snd_display("with_sound format raw: %s (%s)?", res, mus_data_format_name(res))
+ if (res = sample_type(ind)) != Mus_bshort and
+ res != Mus_bfloat and
+ res != Mus_lfloat
+ snd_display("with_sound format raw: %s (%s)?", res, mus_sample_type_name(res))
end
close_sound(ind)
#
@@ -35414,7 +33391,7 @@ def test_23_02
})
close_sound(ind)
#
- if File.exists?("ii.rb")
+ if File.exist?("ii.rb")
with_time("load(\"ii.rb\")") do load("ii.rb") end
Snd.sounds.apply(:close_sound)
delete_files("test.snd", "rest.reverb")
@@ -35423,16 +33400,17 @@ def test_23_02
set_default_output_srate(22050)
#
outer = with_sound do
- sound_let(Proc.new do fm_violin(0, 0.1, 440, 0.1) end) do |a|
- mus_mix(@output, a)
+ sound_let(Proc.new do fm_violin(0, 0.1, 440, 0.1) end) do |tmp|
+ clm_mix(tmp)
end
end.output
unless string?(outer)
snd_display("with_sound returns: %s?", outer)
end
ind = find_sound(outer)
- if (not sound?(ind)) or frames(ind) != (mus_srate * 0.1).floor
- snd_display("sound_let: %s %s?", frames(ind), (mus_srate * 0.1).floor)
+ if (not sound?(ind)) or
+ (framples(ind) - (res = (mus_srate * 0.1).floor)) > 1
+ snd_display("sound_let: %s %s?", framples(ind), res)
end
close_sound(ind)
delete_file("test.snd")
@@ -35440,10 +33418,10 @@ def test_23_02
outer = with_sound do
sound_let(Proc.new do fm_violin(0, 0.1, 440, 0.1) end,
100) do |a, b|
- mus_mix(@output, a, b)
+ clm_mix(a, b)
sound_let([:channels, 1, :output, "temp.snd",
Proc.new do fm_violin(0, 0.1, 110, 0.1) end]) do |c|
- mus_mix(@output, c)
+ clm_mix(c)
end
end
end.output
@@ -35451,10 +33429,11 @@ def test_23_02
snd_display("with_sound (2) returns: %s?", outer)
end
ind = find_sound(outer)
- if (not sound?(ind)) or frames(ind) != (res = 100 + (mus_srate * 0.1).floor)
- snd_display("sound_let (2): %s %s?", frames(ind), res)
+ if (not sound?(ind)) or
+ (framples(ind) - (res = 100 + (mus_srate * 0.1).floor)) > 1
+ snd_display("sound_let (2): %s %s?", framples(ind), res)
end
- if File.exists?("temp.snd")
+ if File.exist?("temp.snd")
snd_display("sound_let explicit output exists?")
end
close_sound(ind)
@@ -35465,74 +33444,91 @@ def test_23_03
set_default_output_srate(22050)
with_sound(:channels, 2) do
fullmix("pistol.snd")
- fullmix("oboe.snd", 1, 2, 0, [[0.1, make_env([0, 0, 1, 1], :duration, 2, :scaler, 0.5)]])
+ fullmix("oboe.snd", 1, 2, 0,
+ [[0.1, make_env([0, 0, 1, 1], :duration, 2, :scaler, 0.5)]])
end
if sound?(ind = find_sound("test.snd"))
close_sound(ind)
end
with_sound(:channels, 2) do
- fullmix("4.aiff", 0.0, 0.1, 36.4, [[0.0, 0.0], [0.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
+ fullmix("4.aiff", 0.0, 0.1, 36.4,
+ [[0.0, 0.0], [0.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
end
if sound?(ind = find_sound("test.snd"))
- snd_test_neq(maxamp(), 0.664947509765625, "4->2(0) fullmix")
+ snd_test_neq(maxamp(), 0.8865, "4->2(0) fullmix")
close_sound(ind)
end
with_sound(:channels, 1) do
- fullmix("4.aiff", 0.0, 0.1, 36.4, [[1.0], [0.0], [0.0], [0.0]])
+ fullmix("4.aiff", 0.0, 0.1, 36.4,
+ [[1.0], [0.0], [0.0], [0.0]])
end
if sound?(ind = find_sound("test.snd"))
snd_test_neq(maxamp(), 0.221649169921875, "4->1(0) fullmix")
close_sound(ind)
end
with_sound(:channels, 1) do
- fullmix("4.aiff", 0.0, 0.1, 36.4, [[0.0], [1.0], [0.0], [0.0]])
+ fullmix("4.aiff", 0.0, 0.1, 36.4,
+ [[0.0], [1.0], [0.0], [0.0]])
end
if sound?(ind = find_sound("test.snd"))
snd_test_neq(maxamp(), 0.44329833984375, "4->1(1) fullmix")
close_sound(ind)
end
with_sound(:channels, 1) do
- fullmix("4.aiff", 0.0, 0.1, 36.4, [[0.0], [0.0], [1.0], [0.0]])
+ fullmix("4.aiff", 0.0, 0.1, 36.4,
+ [[0.0], [0.0], [1.0], [0.0]])
end
if sound?(ind = find_sound("test.snd"))
snd_test_neq(maxamp(), 0.664947509765625, "4->1(2) fullmix")
close_sound(ind)
end
with_sound(:channels, 1) do
- fullmix("4.aiff", 0.0, 0.1, 36.4, [[0.0], [0.0], [0.0], [1.0]])
+ fullmix("4.aiff", 0.0, 0.1, 36.4,
+ [[0.0], [0.0], [0.0], [1.0]])
end
if sound?(ind = find_sound("test.snd"))
snd_test_neq(maxamp(), 0.8865966796875, "4->1(3) fullmix")
close_sound(ind)
end
with_sound(:channels, 2) do
- fullmix("4.aiff", 0.0, 0.1, 36.4, [[0.0, 0.0], [0.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
+ fullmix("4.aiff", 0.0, 0.1, 36.4,
+ [[0.0, 0.0], [0.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
end
if sound?(ind = find_sound("test.snd"))
mxs = maxamp(ind, true)
- snd_test_neq(mxs[0], 0.664947509765625, "4->2(1) fullmix")
- snd_test_neq(mxs[1], 0.8865966796875, "4->2(1) fullmix")
+ req1 = 0.664947509765625
+ req2 = 0.8865966796875
+ if fneq(mxs[0], req1) or fneq(mxs[1], req2)
+ snd_test_neq(mxs[0], req1, "4->2(1a) fullmix")
+ snd_test_neq(mxs[1], req2, "4->2(1b) fullmix")
+ end
close_sound(ind)
end
with_sound(:channels, 2) do
- fullmix("4.aiff", 0.0, 0.1, 36.4, [[0.0, 0.0], [0.0, 0.0], [0.0, 1.0], [1.0, 0.0]])
+ fullmix("4.aiff", 0.0, 0.1, 36.4,
+ [[0.0, 0.0], [0.0, 0.0], [0.0, 1.0], [1.0, 0.0]])
end
if sound?(ind = find_sound("test.snd"))
- req1 = 0.664947509765625
- req2 = 0.8865966796875
mxs = maxamp(ind, true)
- snd_test_neq(mxs[0], 0.8865966796875, "4->2(2) fullmix")
- snd_test_neq(mxs[1], 0.664947509765625, "4->2(2) fullmix")
+ req1 = 0.8865966796875
+ req2 = 0.664947509765625
+ if fneq(mxs[0], req1) or fneq(mxs[1], req2)
+ snd_test_neq(mxs[0], req2, "4->2(2a) fullmix")
+ snd_test_neq(mxs[1], req1, "4->2(2b) fullmix")
+ end
close_sound(ind)
end
with_sound(:channels, 2, :reverb, :nrev) do
- fullmix("pistol.snd", 0.0, 2.0, 0.25, nil, 2.0, 0.1)
+ fullmix("pistol.snd", 0.0, 2.0, 0.25, false, 2.0, 0.1)
fullmix("pistol.snd", 1.0, 2.0, 0.25, 0.2, 2.0, 0.1)
- fullmix("2a.snd", nil, nil, nil, [[0.5, 0.0], [0.0, 0.75]])
- fullmix("oboe.snd", nil, nil, nil, [[[0, 0, 1, 1, 2, 0], 0.5]])
- fullmix("oboe.snd", 3, 2, 0, [[0.1, make_env([0, 0, 1, 1], :duration, 2, :scaler, 0.5)]])
+ fullmix("2a.snd", false, false, false, [[0.5, 0.0], [0.0, 0.75]])
+ fullmix("oboe.snd", false, false, false, [[[0, 0, 1, 1, 2, 0], 0.5]])
+ fullmix("oboe.snd", 3, 2, 0,
+ [[0.1, make_env([0, 0, 1, 1], :duration, 2, :scaler, 0.5)]])
+ end
+ if sound?(ind = find_sound("test.snd"))
+ close_sound(ind)
end
- Snd.sounds.apply(:close_sound)
end
def test_23_04
@@ -35546,70 +33542,127 @@ def test_23_04
fm_violin(0, 2, 660, 0.1, :base, 32.0)
fm_violin(0.125, 0.5, 880, 0.1)
end) do |temp_1, temp_2|
- mus_mix(@output, temp_1, 0)
- mus_mix(@output, temp_2, 22050)
+ clm_mix(temp_1, 0)
+ clm_mix(temp_2, 22050)
end
end
if sound?(ind = find_sound("test.snd"))
unless maxamp(ind).between?(0.15, 0.2)
snd_display("with_sound+sound_lets maxamp: %s?", maxamp(ind))
end
- if fneq(res = frames(ind) / srate(ind).to_f, 3.0)
- snd_display("with_sound+sound_lets dur: res %s frms %s sr %s?", res, frames(ind), srate(ind))
+ if fneq(res = framples(ind) / srate(ind).to_f, 3.0)
+ snd_display("with_sound+sound_lets dur: res %s frms %s sr %s?",
+ res, framples(ind), srate(ind))
end
close_sound(ind)
else
snd_display("with_sound+sound_lets init: no test.snd?")
end
- #
+ #
with_sound(:srate, 44100) do
bigbird_2(0, 2.0, 60, 0, 0.5,
[0, 0, 1, 1],
[0, 0, 1, 1, 2, 1, 3, 0],
[1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1])
end
- ind = (find_sound("test.snd") or open_sound("test.snd"))
+ ind = (find_sound("test.snd") or open_sound("oboe.snd"))
mx = maxamp
- freqs = []
- 60.step(3000, 60) do |i| freqs.push(i) end
+ val = 0.0
+ freqs = Array.new(50) do |i| val += 60.0 end
notch_sound(freqs)
- snd_test_neq(mx, 0.5, "notch_sound 60 Hz 1a")
- snd_test_any_neq(maxamp(), 0.027, :ffequal?, "notch_sound 60 Hz 1b") # okay
+ snd_test_neq(mx, 0.5, "notch_sound 60 Hz (1a)")
+ snd_test_any_neq(maxamp(), 0.027, :ffequal?, "notch_sound 60 Hz (1b)")
undo_edit
notch_sound(freqs, false, ind, 0, 10)
- snd_test_neq(maxamp(), 0.004, "notch_sound 60 Hz 2")
+ snd_test_any_neq(maxamp(), 0.011, :ffequal?, "notch_sound 60 Hz 2")
undo_edit
notch_channel(freqs, false, false, false, ind, 0, false, false, 10)
snd_test_neq(maxamp(), 0.004, "notch_channel 60 Hz 2")
undo_edit
make_selection(10000, 11000)
- notch_selection(freqs, false)
- play_sound do |data| data.map!(0) do |val| val * 2.0 end end
+ notch_selection(freqs, false, 10)
close_sound(ind)
#
with_sound(:srate, 44100) do
- bigbird_2(0, 60.0, 60, 0, 0.5,
+ bigbird_2(0, 30, 60, 0, 0.5,
[0, 0, 1, 1],
[0, 0, 1, 1, 2, 1, 3, 0],
[1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1])
end
ind = find_sound("test.snd")
- freqs = []
- 60.step(3000, 60) do |i| freqs.push(i) end
notch_sound(freqs, false, ind, 0, 10)
- snd_test_neq(maxamp(), 0.036, "notch_sound 60 Hz 2 60")
+ snd_test_neq(maxamp(), 0.011, "notch_sound 60 Hz 2 60")
close_sound(ind)
#
+ # from play.rb
play_sine(440, 0.1)
- play_sines([[425, 0.05], [450, 0.01], [470, 0.01], [546, 0.02],
- [667, 0.01], [789, 0.034], [910, 0.032]])
+ play_sines([425, 0.05], [450, 0.01], [470, 0.01], [546, 0.02],
+ [667, 0.01], [789, 0.034], [910, 0.032])
+ # grani from clm-ins.rb
+ with_sound(:channels, 2,
+ :reverb, :jc_reverb,
+ :reverb_channels, 1) do
+ grani(0, 1, 0.5, "oboe.snd",
+ :grain_envelope, [0, 0, 0.2, 0.2, 0.5, 1, 0.8, 0.2, 1, 0])
+ grani(0, 4, 1, "oboe.snd")
+ grani(0, 4, 1, "oboe.snd", :grains, 10)
+ grani(0, 4, 1, "oboe.snd",
+ :grain_start, 0.11,
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 8,
+ :grain_envelope, [0, 0, 0.2, 0.2, 0.5, 1, 0.8, 0.2, 1, 0],
+ :grain_envelope_end, [0, 0, 0.01, 1, 0.99, 1, 1, 0],
+ :grain_envelope_transition, [0, 0, 0.4, 1, 0.8, 0, 1, 0])
+ grani(0, 3, 1, "oboe.snd",
+ :grain_start, 0.1,
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 20,
+ :grain_duration, [0, 0.003, 0.2, 0.01, 1, 0.3])
+ grani(0, 3, 1, "oboe.snd",
+ :grain_start, 0.1,
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 20,
+ :grain_duration, [0, 0.003, 0.2, 0.01, 1, 0.3],
+ :grain_duration_limit, 0.02)
+ grani(0, 2, 1, "oboe.snd",
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 40,
+ :grain_start, [0, 0.1, 0.3, 0.1, 1, 0.6])
+ grani(0, 2, 1, "oboe.snd",
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 40,
+ :grain_start, [0, 0.1, 0.3, 0.1, 1, 0.6],
+ :grain_start_spread, 0.01)
+ grani(0, 2.6, 1, "oboe.snd",
+ :grain_start, 0.1, :grain_start_spread, 0.01,
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 40,
+ :srate, [0, 0, 0.2, 0, 0.6, 5, 1, 5])
+ grani(0, 2.6, 1, "oboe.snd",
+ :grain_start, 0.1, :grain_start_spread, 0.01,
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 40,
+ :srate_base, 2,
+ :srate, [0, 0, 0.2, 0, 0.6, -1, 1, -1])
+ grani(0, 2.6, 1, "oboe.snd",
+ :grain_start, 0.1, :grain_start_spread, 0.01,
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 40,
+ :srate_linear, true,
+ :srate, [0, 0, 0.2, 1, 0.6, 2 ** (5.0 / 12.0), 1, 2 ** (5.0 / 12.0)])
+ grani(0, 2, 1, "oboe.snd",
+ :grain_start, 0.1, :grain_start_spread, 0.01,
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 40,
+ :grain_duration, [0, 0.02, 1, 0.1],
+ :grain_duration_spread, [0, 0, 0.5, 0.1, 1, 0],
+ :where_to, Grani_to_grain_duration,
+ :where_bins, vct(0, 0.05, 1))
+ grani(0, 2, 1, "oboe.snd",
+ :grain_start, 0.1, :grain_start_spread, 0.01,
+ :amp_envelope, [0, 1, 1, 1], :grain_density, 40,
+ :grain_degree, [0, 0, 1, 90],
+ :grain_degree_spread, 10)
+ end
#
ind = open_sound("oboe.snd")
with_sound(:output, "test1.snd") do
fm_violin(0, 0.1, 440, 0.1)
end
- set_samples(0, 2205, "test1.snd", ind, 0, false, "set_samples auto-delete test", 0, false, true)
- unless File.exists?("test1.snd")
+ set_samples(0, 2205, "test1.snd", ind, 0, false,
+ "set_samples auto-delete test", 0, false, true)
+ unless File.exist?("test1.snd")
snd_display("oops: auto-delete test1.snd?")
end
undo_edit(1, ind)
@@ -35617,7 +33670,7 @@ def test_23_04
fm_violin(0, 0.1, 440, 0.1)
end
insert_sound("test2.snd", 0, 0, ind, 0, false, true)
- if File.exists?("test1.snd")
+ if File.exist?("test1.snd")
snd_display("auto-delete set_samples?")
end
undo_edit(1, ind)
@@ -35625,7 +33678,7 @@ def test_23_04
fm_violin(0, 0.1, 440, 0.1)
end
insert_samples(0, 2205, "test3.snd", ind, 0, false, true)
- if File.exists?("test2.snd")
+ if File.exist?("test2.snd")
snd_display("auto-delete insert_sound?")
end
undo_edit(1, ind)
@@ -35633,12 +33686,12 @@ def test_23_04
fm_violin(0, 0.1, 440, 0.1)
end
mix("test4.snd", 0, 0, ind, 0, false, true)
- if File.exists?("test3.snd")
+ if File.exist?("test3.snd")
snd_display("auto-delete insert_samples?")
end
undo_edit(1, ind)
delete_sample(100, ind, 0)
- if File.exists?("test4.snd")
+ if File.exist?("test4.snd")
snd_display("auto-delete mix?")
end
with_sound(:output, "test5.snd") do
@@ -35647,7 +33700,7 @@ def test_23_04
mix("test5.snd", 0, 0, ind, 0, true, true)
revert_sound(ind)
close_sound(ind)
- if File.exists?("test5.snd")
+ if File.exist?("test5.snd")
snd_display("auto-delete mix (with-tag)?")
end
Snd.sounds.apply(:close_sound)
@@ -35699,20 +33752,19 @@ def test_23_04
end
#
if defined? variable_display
- wid1 = Snd.catch do make_variable_display("do-loop-1", "i*1", :text) end.first
- wid2 = Snd.catch do make_variable_display("do-loop-2", "i*2", :scale, [-1.0, 1.0]) end.first
- wid3 = Snd.catch do make_variable_display("do-loop-3", "i3", :spectrum) end.first
- wid4 = Snd.catch do make_variable_display("do-loop-4", "i4", :graph) end.first
+ wid1 = make_variable_display("do-loop-1", "i*1", :text)
+ wid2 = make_variable_display("do-loop-2", "i*2", :scale, [-1.0, 1.0])
+ wid3 = make_variable_display("do-loop-3", "i3", :spectrum)
+ wid4 = make_variable_display("do-loop-4", "i4", :graph)
if variable_display?(wid1) and
- variable_display?(wid2) and
- variable_display?(wid3) and
- variable_display?(wid4)
+ variable_display?(wid2) and
+ variable_display?(wid3) and
+ variable_display?(wid4)
1000.times do |i|
variable_display(wid4,
- variable_display(wid3,
- variable_display(wid2,
- sin(variable_display(wid1, 1) * 0.1)) * \
- 0.5))
+ variable_display(wid3,
+ variable_display(wid2,
+ sin(variable_display(wid1, 1) * 0.1)) * 0.5))
end
tag = Snd.catch do set_sample(0, 0.5, wid3.snd, 0) end
if (res = edit_position(wid3.snd, 0)) > 0
@@ -35736,7 +33788,7 @@ def test_23_04
[[:clm_srate, default_output_srate],
[:clm_channels, default_output_chans],
[:clm_header_type, default_output_header_type],
- [:clm_data_format, default_output_data_format],
+ [:clm_sample_type, default_output_sample_type],
[:clm_reverb_channels, 1],
[:clm_file_name, "test.snd"],
[:clm_play, false],
@@ -35754,7 +33806,7 @@ def test_23_04
$clm_verbose = false
$clm_statistics = false
$clm_play = false
- $clm_data_format = Mus_mulaw
+ $clm_sample_type = Mus_mulaw
$clm_header_type = Mus_riff
$clm_delete_reverb = true
$clm_reverb = :jc_reverb
@@ -35771,16 +33823,16 @@ def test_23_04
if (res = channels(ind)) != 2
snd_display("default channels in ws: %s %s?", res, $clm_channels)
end
- if (res = data_format(ind)) != Mus_mulaw
- snd_display("default format in ws: %s %s?", res, $clm_data_format)
+ if (res = sample_type(ind)) != Mus_mulaw
+ snd_display("default format in ws: %s %s?", res, $clm_sample_type)
end
if (res = header_type(ind)) != Mus_riff
snd_display("default type in ws: %s %s?", res, $clm_header_type)
end
- if (res = frames(ind)) != 88200
+ if (res = framples(ind)) != 88200
snd_display("reverb+1 sec out in ws: %s?", res)
end
- if File.exists?("test.reverb")
+ if File.exist?("test.reverb")
snd_display("perhaps reverb not deleted in ws?")
end
close_sound(ind)
@@ -35815,7 +33867,7 @@ def test_23_04
$clm_verbose = false
$clm_statistics = false
$clm_play = false
- $clm_data_format = Mus_lfloat
+ $clm_sample_type = Mus_lfloat
$clm_header_type = Mus_next
$clm_delete_reverb = false
$clm_reverb = nil
@@ -35860,7 +33912,7 @@ def test_23_04
# clm23.scm tests skipped
#
file = with_sound(:clipped, false,
- :data_format, Mus_bfloat,
+ :sample_type, Mus_bfloat,
:header_type, Mus_next) do
fm_violin(0, 0.1, 440, PI)
end.output
@@ -35870,7 +33922,7 @@ def test_23_04
end
close_sound(ind)
file = with_sound(:clipped, true,
- :data_format, Mus_bfloat,
+ :sample_type, Mus_bfloat,
:header_type, Mus_next) do
fm_violin(0, 0.1, 440, PI)
end.output
@@ -35880,7 +33932,7 @@ def test_23_04
end
close_sound(ind)
file = with_sound(:clipped, false,
- :data_format, Mus_bfloat,
+ :sample_type, Mus_bfloat,
:header_type, Mus_next,
:scaled_by, 0.1) do
fm_violin(0, 0.1, 440, PI)
@@ -35891,7 +33943,7 @@ def test_23_04
end
close_sound(ind)
file = with_sound(:clipped, false,
- :data_format, Mus_bfloat,
+ :sample_type, Mus_bfloat,
:header_type, Mus_next,
:scaled_to, 0.1) do
fm_violin(0, 0.1, 440, PI)
@@ -35911,7 +33963,7 @@ def test_23_04
tsize = 0
arrp = 0
mx = 0
- file = with_sound(:data_format, Mus_bfloat,
+ file = with_sound(:sample_type, Mus_bfloat,
:header_type, Mus_next) do
mx = mus_file_buffer_size
tsize = clm_table_size
@@ -35933,26 +33985,18 @@ def test_23_04
$clm_array_print_length = old_arrp
close_sound(ind)
#
- # FIXME
- # bug in ws.rb (with_sound)
- ind = find_sound(with_sound do
- fm_violin(0, 3, 440, 0.1)
- end.output)
- if $with_test_gui
- set_amp_control(0.5, ind)
- set_x_bounds([1.0, 2.0], ind, 0)
- end
- ind = find_sound(with_sound do
- fm_violin(0, 4, 440, 0.1)
- end.output)
- if $with_test_gui
- if fneq(res = amp_control(ind), 0.5)
- snd_display("update ws amp: %s?", res)
- end
- res = x_bounds(ind, 0)
- if (fneq(res[0], 1.0) or fneq(res[1], 2.0))
- snd_display("update ws bounds: %s?", res)
- end
+ file = with_sound() do fm_violin(0, 3.0, 440, 0.1) end.output
+ ind = find_sound(file)
+ set_amp_control(0.5, ind)
+ set_x_bounds([1.0, 2.0], ind, 0)
+ file = with_sound(:clm, false) do fm_violin(0, 4.0, 440, 0.1) end.output
+ ind = find_sound(file)
+ res = amp_control(ind)
+ snd_test_neq(res, 0.5, "update ws amp")
+ res = x_bounds(ind, 0)
+ req = [1.0, 2.0]
+ if fneq(res[0], req[0]) or fneq(res[1], req[1])
+ snd_format_neq(res, req, "update ws bounds")
end
close_sound(ind)
#
@@ -35962,7 +34006,7 @@ def test_23_04
ind = find_sound(file)
mx = maxamp(ind)
file = with_sound(:reverb, :jc_reverb,
- :reverb_data, [:volume, 12.0, :amp_env, [0, 0, 1, 1, 20, 1, 21, 0]]) do
+ :reverb_data, [:volume, 12.0, :amp_env, [0, 0, 1, 1, 20, 1, 21, 0]]) do
fm_violin(0, 4, 440, 0.1, :reverb_amount, 0.1)
end.output
ind = find_sound(file)
@@ -35973,8 +34017,8 @@ def test_23_04
#
ind = open_sound("oboe.snd")
step_src
- if (frames - 24602).abs > 100
- snd_display("step_src frames: %s (%s)?", frames, edits)
+ if (framples - 24602).abs > 100
+ snd_display("step_src framples: %s (%s)?", framples, edits)
end
close_sound(ind)
Snd.sounds.apply(:close_sound)
@@ -36018,267 +34062,326 @@ end
# ---------------- test 28: errors ----------------
def check_error_tag(expected_tag, &thunk)
- if (tag = Snd.catch do thunk.call end).first != expected_tag
- snd_display_prev_caller("%s %s: %s", get_func_name, expected_tag.inspect, tag.inspect)
- end
-end
-
-Procs = [:add_mark, :add_sound_file_extension, :add_source_file_extension, :sound_file_extensions,
- :sound_file?, :add_to_main_menu, :add_to_menu, :add_transform, :amp_control,
- :ask_about_unsaved_edits, :as_one_edit, :ask_before_overwrite,
- :audio_input_device, :audio_output_device, :auto_resize, :auto_update,
- :autocorrelate, :axis_color, :axis_info, :axis_label_font, :axis_numbers_font,
- :basic_color, :bind_key, :bomb, :apply_controls, :change_samples_with_origin,
- :channel_style, :channel_widgets, :channels, :chans, :peaks_font, :bold_peaks_font,
- :close_sound, :color_cutoff, :color_orientation_dialog, :colormap_ref, :add_colormap,
- :delete_colormap, :colormap_size, :colormap_name, :color_inverted, :color_scale,
- :color2list, :colormap, :color?, :comment, :contrast_control, :contrast_control_amp,
- :channel_properties, :channel_property, :controls2channel, :amp_control_bounds,
- :speed_control_bounds, :expand_control_bounds, :contrast_control_bounds,
- :sound_file_extensions, :reverb_control_length_bounds, :reverb_control_scale_bounds,
- :cursor_update_interval, :cursor_location_offset, :auto_update_interval,
- :count_matches, :current_font, :cursor, :cursor_color, :with_tracking_cursor,
- :cursor_size, :cursor_style, :tracking_cursor_style, :dac_combines_channels,
- :dac_size, :clipping, :data_color, :data_format, :data_location, :data_size,
- :default_output_chans, :default_output_data_format, :default_output_srate,
- :default_output_header_type, :insert_file_dialog, :file_write_date, :define_envelope,
- :delete_mark, :delete_marks, :forget_region, :delete_sample, :delete_samples,
- :delete_samples_and_smooth, :delete_selection, :delete_selection_and_smooth,
- :dialog_widgets, :display_edits, :dot_size, :draw_dot,
- :draw_dots, :draw_line, :draw_lines, :draw_string, :edit_header_dialog,
- :edit_fragment, :edit_list2function, :edit_position, :edit_tree, :edits,
- :env_selection, :env_sound, :enved_envelope, :enved_base, :enved_clip?,
- :enved_in_dB, :enved_dialog, :enved_style, :enved_power, :enved_target,
- :enved_waveform_color, :enved_wave?, :eps_file, :eps_left_margin, :eps_bottom_margin,
- :eps_size, :expand_control, :expand_control_hop, :expand_control_jitter,
- :expand_control_length, :expand_control_ramp, :expand_control?, :fft,
- :fft_window_beta, :fft_window_alpha, :fft_with_phases, :fft_log_frequency,
- :fft_log_magnitude, :transform_size, :disk_kspace, :transform_graph_type,
- :fft_window, :transform_graph?, :view_files_dialog, :mix_file_dialog, :file_name,
- :fill_polygon, :fill_rectangle, :filter_sound, :filter_control_in_dB,
- :filter_control_envelope, :enved_filter_order, :enved_filter, :filter_control_in_hz,
- :filter_control_order, :filter_selection, :filter_channel,
- :filter_control_waveform_color, :filter_control?, :find_channel, :find_mark,
- :find_sound, :finish_progress_report, :foreground_color, :frames, :free_sampler,
- :graph, :transform?, :delete_transform,
- :graph_color, :graph_cursor, :graph_data, :graph2ps, :gl_graph2ps, :graph_style,
- :lisp_graph?, :graphs_horizontal, :header_type, :help_dialog, :info_dialog,
- :highlight_color, :call_in, :insert_region, :insert_sample, :insert_samples,
- :insert_samples_with_origin, :insert_selection, :insert_silence, :insert_sound,
- :just_sounds, :key, :key_binding, :left_sample, :listener_color, :listener_font,
- :listener_prompt, :listener_selection, :listener_text_color, :main_widgets,
- :make_color, :make_graph_data, :make_mix_sampler, :make_player, :make_region,
- :make_region_sampler, :make_sampler, :map_chan, :mark_color, :mark_name,
- :mark_properties, :mark_property, :mark_sample, :mark_sync, :mark_sync_max,
- :mark_home, :marks, :mark?, :max_transform_peaks, :max_regions,
- :max_virtual_ptrees, :maxamp, :maxamp_position, :menu_widgets,
- :minibuffer_history_length, :min_dB, :log_freq_start, :mix, :mixes, :mix_amp,
- :mix_amp_env, :mix_color, :mix_length, :mix?, :view_mixes_dialog, :mix_position,
- :mix_dialog_mix, :mix_name, :mix_sync_max, :mix_sync, :mix_properties, :mix_property,
- :mix_region, :mix_sampler?, :mix_selection, :mix_home, :mix_speed, :mix_tag_height,
- :mix_tag_width, :mark_tag_height, :mark_tag_width, :mix_tag_y, :mix_vct,
- :mix_waveform_height, :time_graph_style, :lisp_graph_style, :transform_graph_style,
- :read_mix_sample, :next_sample, :read_region_sample,
- :show_full_duration, :initial_beg, :initial_dur, :transform_normalization,
- :open_file_dialog_directory, :open_raw_sound, :open_sound, :color_orientation_dialog,
- :previous_sample, :peaks, :player?, :players, :play_arrow_size, :position_color,
- :position2x, :position2y, :add_directory_to_view_files_list, :add_file_to_view_files_list,
- :view_files_amp, :view_files_speed, :view_files_files, :view_files_selected_files,
- :view_files_speed_style, :view_files_amp_env, :view_files_sort,
- :print_length, :progress_report, :prompt_in_minibuffer, :read_only,
- :redo_edit, :region_chans, :view_regions_dialog, :region_home,
- :region_graph_style, :region_frames, :region_position, :region_maxamp,
- :region_maxamp_position, :remember_sound_state, :selection_maxamp,
- :selection_maxamp_position, :region_sample, :region2vct, :region_srate, :regions, :region?,
- :remove_from_menu, :report_in_minibuffer, :reset_controls, :restore_controls,
- :restore_region, :reverb_control_decay, :reverb_control_feedback,
- :reverb_control_length, :reverb_control_lowpass, :reverb_control_scale,
- :reverb_control?, :reverse_sound, :reverse_selection, :revert_sound,
- :right_sample, :sample, :sampler_at_end?, :sampler?, :samples, :sampler_position,
- :sash_color, :save_controls, :ladspa_dir, :peak_env_dir, :save_dir,
- :save_edit_history, :save_envelopes, :save_listener, :save_marks, :save_region,
- :save_selection, :save_sound, :save_sound_as, :save_state, :save_state_file,
- :scale_by, :scale_selection_by, :scale_selection_to, :scale_to, :scan_chan,
- :search_procedure, :select_all, :select_channel, :select_sound, :selected_channel,
- :selected_data_color, :selected_graph_color, :selected_sound, :selection_position,
- :selection_color, :selection_creates_region, :selection_frames, :selection_member?,
- :selection?, :short_file_name, :show_axes, :show_controls, :show_transform_peaks,
- :show_indices, :show_listener, :show_selection, :unselect_all, :show_marks,
- :show_mix_waveforms, :show_selection_transform, :show_y_zero, :sinc_width, :show_grid,
- :show_sonogram_cursor, :grid_density, :smooth_sound, :smooth_selection, :snd_spectrum,
- :snd_tempnam, :snd_version, :sound_files_in_directory, :sound_loop_info, :sound_widgets,
- :soundfont_info, :sound?, :sounds, :spectrum_end, :spectro_hop, :spectrum_start,
- :spectro_x_angle, :spectro_x_scale, :spectro_y_angle, :spectro_y_scale, :spectro_z_angle,
- :spectro_z_scale, :speed_control, :speed_control_style, :speed_control_tones,
- :squelch_update, :srate, :src_sound, :src_selection, :start_progress_report,
- :stop_player, :stop_playing, :swap_channels, :syncd_marks, :sync, :sync_max,
- :sound_properties, :sound_property, :temp_dir, :text_focus_color, :tiny_font,
- :region_sampler?, :transform_dialog, :transform_sample, :transform2vct,
- :transform_frames, :transform_type, :trap_segfault, :with_file_monitor,
- :unbind_key, :update_transform_graph, :update_time_graph, :update_lisp_graph,
- :update_sound, :clm_table_size, :with_verbose_cursor, :view_sound, :wavelet_type,
- :with_inset_graph, :with_pointer_focus, :with_smpte_label, :with_toolbar, :with_tooltips,
- :with_menu_icons, :save_as_dialog_src, :save_as_dialog_auto_comment,
- :time_graph?, :time_graph_type, :wavo_hop,
- :wavo_trace, :window_height, :window_width, :window_x, :window_y, :with_mix_tags,
- :with_relative_panes, :with_gl, :x_axis_style, :beats_per_measure, :beats_per_minute,
- :x_bounds, :x_position_slider, :x2position, :x_zoom_slider, :mus_header_type2string,
- :mus_data_format2string, :y_bounds, :y_position_slider, :y2position, :y_zoom_slider,
- :zero_pad, :zoom_color, :zoom_focus_style, :sync_style,
- :mus_set_formant_radius_and_frequency, :mus_sound_samples, :mus_sound_frames,
- :mus_sound_duration, :mus_sound_datum_size, :mus_sound_data_location, :data_size,
- :mus_sound_chans, :mus_sound_srate, :mus_sound_header_type, :mus_sound_data_format,
- :mus_sound_length, :mus_sound_type_specifier, :mus_header_type_name,
- :mus_data_format_name, :mus_sound_comment, :mus_sound_write_date, :mus_bytes_per_sample,
- :mus_sound_loop_info, :mus_sound_mark_info, :mus_audio_describe,
- :mus_sound_maxamp, :mus_sound_maxamp_exists?, :mus_file_prescaler,
- :mus_prescaler, :mus_clipping, :mus_file_clipping, :mus_header_raw_defaults,
- :moving_average, :moving_average?, :make_moving_average, :mus_expand_filename,
- :make_sound_data, :sound_data_ref, :sound_data_set!, :sound_data_scale!,
- :sound_data_fill!, :sound_data?, :sound_data_length, :sound_data_multiply!,
- :sound_data_add!, :sound_data_offset!, :sound_data_copy, :sound_data_reverse!,
- :sound_data_maxamp, :sound_data_chans, :sound_data2vct, :vct2sound_data,
- :sound_data_peak, :all_pass, :all_pass?, :amplitude_modulate, :array2file,
- :array_interp, :mus_interpolate, :asymmetric_fm, :asymmetric_fm?,
- :sound_data2sound_data, :clear_array, :comb, :comb?, :filtered_comb,
- :filtered_comb?, :contrast_enhancement, :convolution, :convolve, :convolve?,
- :db2linear, :degrees2radians, :delay, :delay?, :dot_product, :env, :env_interp,
- :env?, :file2array, :file2frame, :file2frame?, :file2sample, :file2sample?,
- :filter, :filter?, :fir_filter, :fir_filter?, :formant, :formant_bank, :formant?,
- :frame_multiply, :frame_add, :frame2file, :clear_minibuffer, :frame2file?,
- :frame2frame, :frame2list, :frame2sample, :frame_ref, :frame_set!, :frame?,
- :granulate, :granulate?, :hz2radians, :iir_filter, :iir_filter?, :in_any, :ina, :inb,
- :linear2db, :locsig, :locsig_ref, :locsig_reverb_ref, :locsig_reverb_set!, :locsig_set!,
- :locsig?, :make_all_pass, :make_asymmetric_fm, :make_comb, :make_convolve, :make_delay,
- :make_env, :make_fft_window, :make_file2frame, :make_file2sample, :make_filter,
- :make_fir_filter, :make_formant, :make_frame, :make_frame2file, :make_granulate,
- :make_iir_filter, :make_locsig, :move_locsig, :make_mixer, :make_notch,
- :make_one_pole, :make_one_zero, :make_oscil, :make_pulse_train, :make_rand,
- :make_rand_interp, :make_readin, :make_sample2file, :make_sawtooth_wave,
- :make_square_wave, :make_src, :make_ssb_am, :make_table_lookup, :make_triangle_wave,
- :make_two_pole, :make_two_zero, :make_wave_train, :mixer_multiply, :mixer_ref,
- :mixer_set!, :mixer?, :mixer_add, :move_sound, :make_move_sound, :move_sound?,
- :mus_float_equal_fudge_factor, :multiply_arrays, :mus_array_print_length, :mus_channel,
- :mus_channels, :make_polyshape, :polyshape, :polyshape?, :mus_close, :mus_data,
- :mus_feedback, :mus_feedforward, :mus_fft, :mus_frequency, :mus_hop, :mus_increment,
- :mus_input?, :mus_file_name, :mus_length, :mus_location, :mus_mix, :mus_order,
- :mus_output?, :mus_phase, :mus_ramp, :mus_random, :mus_scaler, :mus_srate,
- :mus_xcoeffs, :mus_ycoeffs, :notch, :notch?, :one_pole, :one_pole?, :one_zero,
- :one_zero?, :oscil, :oscil?, :out_any, :outa, :outb, :outc, :outd, :partials2polynomial,
- :partials2wave, :phase_partials2wave, :polynomial, :pulse_train, :pulse_train?,
- :radians2degrees, :radians2hz, :rand, :rand_interp, :rand_interp?, :rand?, :readin,
- :readin?, :rectangular2polar, :rectangular2magnitudes, :ring_modulate, :sample2file,
- :sample2file?, :sample2frame, :sawtooth_wave, :sawtooth_wave?, :spectrum, :square_wave,
- :square_wave?, :src, :src?, :ssb_am, :ssb_am?, :table_lookup, :table_lookup?, :tap,
- :triangle_wave, :triangle_wave?, :two_pole, :two_pole?, :two_zero, :two_zero?,
- :wave_train, :wave_train?, :make_vct, :vct_add!, :vct_subtract!, :vct_copy,
- :vct_length, :vct_multiply!, :vct_offset!, :vct_ref, :vct_scale!, :vct_fill!,
- :vct_set!, :vct_peak, :vct?, :list2vct, :vct2list, :vector2vct, :vct2vector,
- :vct_move!, :vct_reverse!, :vct_subseq, :vct, :little_endian?, :vct2string,
- :clm_channel, :env_channel, :map_channel, :scan_channel, :reverse_channel,
- :seconds2samples, :samples2seconds, :vct2channel, :smooth_channel, :channel2vct,
- :src_channel, :scale_channel, :ramp_channel, :pad_channel, :normalize_channel,
- :cursor_position, :mus_sound_prune, :mus_sound_forget, :xramp_channel, :ptree_channel,
- :snd2sample, :snd2sample?, :make_snd2sample, :make_scalar_mixer, :beats_per_minute,
- :beats_per_measure, :channel_amp_envs, :convolve_files, :filter_control_coeffs,
- :locsig_type, :make_phase_vocoder, :mus_describe, :mus_error_type2string,
- :mus_file_buffer_size, :mus_name, :mus_offset, :mus_reset, :mus_rand_seed,
- :mus_width, :phase_vocoder?, :polar2rectangular, :phase_vocoder_amp_increments,
- :phase_vocoder_amps, :phase_vocoder_freqs, :phase_vocoder_phase_increments,
- :phase_vocoder_phases, :mus_generator?, :read_sample, :reset_listener_cursor,
- :goto_listener_end, :sampler_home, :selection_chans, :selection_srate, :snd_gcs,
- :snd_font, :snd_color, :snd_warning, :channel_data, :x_axis_label, :variable_graph?,
- :y_axis_label, :snd_url, :snd_urls, :free_player, :delay_tick, :playing, :draw_axes,
- :copy_sampler, :html_dir, :html_program, :make_fir_coeffs, :mus_interp_type, :mus_run,
- :phase_vocoder, :player_home, :redo_edit, :undo_edit, :widget_position, :widget_size,
- :focus_widget]
-
-Set_procs = [:amp_control, :ask_before_overwrite, :audio_input_device, :audio_output_device,
- :auto_resize, :sound_file_extensions, :auto_update, :axis_color, :axis_label_font,
- :axis_numbers_font, :channel_style, :peaks_font, :bold_peaks_font,
- :show_full_duration, :initial_beg, :initial_dur, :color_cutoff,
- :color_inverted, :color_scale, :contrast_control, :contrast_control_amp,
- :amp_control_bounds, :speed_control_bounds, :expand_control_bounds,
- :contrast_control_bounds, :reverb_control_length_bounds,
- :reverb_control_scale_bounds, :cursor_update_interval, :cursor_location_offset,
- :contrast_control?, :auto_update_interval, :current_font, :cursor, :cursor_color,
- :channel_properties, :channel_property, :with_tracking_cursor, :cursor_size,
- :cursor_style, :tracking_cursor_style, :dac_combines_channels, :dac_size,
- :clipping, :data_color, :default_output_chans, :default_output_data_format,
- :default_output_srate, :default_output_header_type, :dot_size, :enved_envelope,
- :enved_base, :enved_clip?, :enved_in_dB, :enved_style, :enved_power,
- :enved_target, :enved_waveform_color, :enved_wave?, :eps_file, :eps_left_margin,
- :eps_bottom_margin, :eps_size, :expand_control, :expand_control_hop,
- :expand_control_jitter, :expand_control_length, :expand_control_ramp,
- :expand_control?, :fft_window_beta, :fft_window_alpha, :fft_with_phases,
- :fft_log_frequency, :fft_log_magnitude, :transform_size, :transform_graph_type,
- :fft_window, :transform_graph?, :filter_control_in_dB, :filter_control_envelope,
- :axis_color, :enved_filter_order, :enved_filter, :filter_control_in_hz,
- :filter_control_order, :filter_control_waveform_color, :filter_control?,
- :foreground_color, :graph_color, :graph_cursor, :graph_style, :lisp_graph?,
- :graphs_horizontal, :highlight_color, :just_sounds, :left_sample, :listener_color,
- :listener_font, :listener_prompt, :listener_text_color, :mark_color, :mark_name,
- :mark_properties, :mark_property, :mark_sample, :mark_sync, :max_transform_peaks,
- :max_regions, :min_dB, :log_freq_start, :mix_amp, :mix_amp_env, :mix_color,
- :mix_name, :mix_position, :mix_sync, :mix_properties, :mix_property,
- :max_virtual_ptrees, :mix_speed, :mix_tag_height, :mix_tag_width, :mix_tag_y,
- :mark_tag_width, :mark_tag_height, :mix_waveform_height, :transform_normalization,
- :open_file_dialog_directory, :position_color, :view_files_sort, :print_length,
- :play_arrow_size, :region_graph_style, :reverb_control_decay, :reverb_control_feedback,
- :reverb_control_length, :reverb_control_lowpass, :reverb_control_scale,
- :time_graph_style, :lisp_graph_style, :transform_graph_style, :reverb_control?,
- :sash_color, :ladspa_dir, :peak_env_dir, :save_dir, :save_state_file,
- :selected_data_color, :selected_graph_color, :selection_color,
- :selection_creates_region, :show_axes, :show_controls, :show_transform_peaks,
- :show_indices, :show_marks, :show_mix_waveforms, :show_selection_transform,
- :show_listener, :show_y_zero, :show_grid, :show_sonogram_cursor, :sinc_width,
- :spectrum_end, :spectro_hop, :spectrum_start, :spectro_x_angle, :grid_density,
- :spectro_x_scale, :spectro_y_angle, :spectro_y_scale, :spectro_z_angle,
- :spectro_z_scale, :speed_control, :speed_control_style, :speed_control_tones,
- :squelch_update, :sync, :sound_properties, :sound_property, :temp_dir,
- :text_focus_color, :tiny_font, :y_bounds, :transform_type, :trap_segfault,
- :with_file_monitor, :with_verbose_cursor, :with_inset_graph, :with_pointer_focus,
- :wavelet_type, :x_bounds, :with_smpte_label, :with_toolbar, :with_tooltips,
- :with_menu_icons, :save_as_dialog_src, :save_as_dialog_auto_comment,
- :time_graph?, :wavo_hop, :wavo_trace, :with_gl, :with_mix_tags,
- :x_axis_style, :beats_per_minute, :zero_pad, :zoom_color, :zoom_focus_style,
- :sync_style, :with_relative_panes, :window_x, :window_y,
- :window_width, :window_height, :mix_dialog_mix, :beats_per_measure,
- :channels, :chans, :colormap, :comment, :data_format, :data_location,
- :data_size, :edit_position, :frames, :header_type, :maxamp,
- :minibuffer_history_length, :read_only, :right_sample, :sample, :samples,
- :selected_channel, :colormap_size, :selected_sound, :selection_position,
- :selection_frames, :selection_member?, :sound_loop_info, :srate, :time_graph_type,
- :x_position_slider, :x_zoom_slider, :y_position_slider, :y_zoom_slider,
- :sound_data_ref, :mus_array_print_length, :mus_float_equal_fudge_factor,
- :mus_data, :mus_feedback, :mus_feedforward, :mus_frequency, :mus_hop,
- :mus_increment, :mus_length, :mus_location, :mus_phase, :mus_ramp,
- :mus_scaler, :x_axis_label, :locsig_type, :mus_file_buffer_size,
- :mus_rand_seed, :mus_width, :clm_table_size, :mus_offset, :html_dir,
- :html_program, :widget_position, :widget_size, :mus_file_prescaler,
- :mus_clipping, :mus_prescaler, :mus_header_raw_defaults, :view_files_amp,
- :view_files_speed, :view_files_files, :view_files_selected_files,
- :view_files_speed_style, :view_files_amp_env]
-
-Make_procs = [:make_all_pass, :make_asymmetric_fm, :make_snd2sample, :make_moving_average,
- :make_comb, :make_filtered_comb, :make_convolve, :make_delay, :make_env,
- :make_fft_window, :make_file2frame, :make_file2sample, :make_filter,
- :make_fir_filter, :make_formant, :make_frame, :make_frame2file, :make_granulate,
- :make_iir_filter, :make_locsig, :make_mixer, :make_notch, :make_one_pole,
- :make_one_zero, :make_oscil, :make_pulse_train, :make_rand, :make_rand_interp,
- :make_readin, :make_sample2file, :make_sawtooth_wave, :make_square_wave,
- :make_src, :make_table_lookup, :make_triangle_wave, :make_two_pole,
- :make_two_zero, :make_wave_train, :make_phase_vocoder, :make_ssb_am,
- :make_polyshape, :make_color, :make_player, :make_region, :make_scalar_mixer]
-
-Keyargs = [:frequency, :initial_phase, :wave, :cosines, :amplitude, :ratio, :size,
- :a0, :a1, :a2, :b1, :b2, :input, :srate, :file, :channel, :start, :initial_contents,
- :initial_element, :scaler, :feedforward, :feedback, :max_size, :radius, :gain,
- :partials, :r, :a, :n, :fill_time, :order, :xcoeffs, :ycoeffs, :envelope, :base,
- :duration, :offset, :end, :direction, :degree, :distance, :reverb, :output, :fft_size,
- :expansion, :length, :hop, :ramp, :jitter, :type, :format, :comment, :channels, :filter,
- :revout, :width, :edit, :synthesize, :analyze, :interp, :overlap, :pitch, :distribution,
- :sines, :dur]
+ tag = Snd.catch do
+ thunk.call
+ end
+ if tag.first != expected_tag
+ snd_display_prev_caller("%s %s: %s",
+ get_func_name,
+ expected_tag.inspect,
+ tag.inspect)
+ end
+end
+
+Procs = [
+ :add_mark, :add_sound_file_extension, :add_source_file_extension,
+ :sound_file_extensions, :sound_file?, :add_to_main_menu,
+ :add_to_menu, :add_transform, :amp_control, :ask_about_unsaved_edits,
+ :as_one_edit, :ask_before_overwrite,
+ :auto_resize, :auto_update, :autocorrelate,
+ :axis_color, :axis_info, :axis_label_font, :axis_numbers_font,
+ :basic_color, :bind_key, :apply_controls,
+ :change_samples_with_origin, :channel_style, :channel_widgets,
+ :channels, :chans, :peaks_font, :bold_peaks_font, :close_sound,
+ :combined_data_color, :color_cutoff,
+ :color_orientation_dialog, :colormap_ref, :add_colormap,
+ :delete_colormap, :colormap_size, :colormap_name, :color_inverted,
+ :color_scale, :color2list, :colormap, :color?, :comment,
+ :contrast_control, :contrast_control_amp,
+ :channel_properties, :channel_property, :controls2channel,
+ :amp_control_bounds, :speed_control_bounds, :expand_control_bounds,
+ :contrast_control_bounds, :sound_file_extensions,
+ :reverb_control_length_bounds, :reverb_control_scale_bounds,
+ :cursor_update_interval, :cursor_location_offset,
+ :auto_update_interval,
+ :current_font, :cursor, :cursor_color, :with_tracking_cursor,
+ :cursor_size, :cursor_style, :tracking_cursor_style,
+ :dac_combines_channels, :dac_size, :clipping, :data_color,
+ :sample_type, :data_location, :data_size, :default_output_chans,
+ :default_output_sample_type, :default_output_srate,
+ :default_output_header_type, :insert_file_dialog, :file_write_date,
+ :define_envelope, :delete_mark, :delete_marks, :forget_region,
+ :delete_sample, :delete_samples, :delete_samples_and_smooth,
+ :delete_selection, :delete_selection_and_smooth,
+ :dialog_widgets, :display_edits, :dot_size, :draw_dot,
+ :draw_dots, :draw_line, :draw_lines, :draw_string, :edit_header_dialog,
+ :edit_fragment, :edit_list2function, :edit_position, :edit_tree,
+ :edits, :env_selection, :env_sound, :enved_envelope, :enved_base,
+ :enved_clip?, :enved_in_dB, :enved_dialog, :enved_style,
+ :enved_power, :enved_target, :enved_waveform_color, :enved_wave?,
+ :eps_file, :eps_left_margin, :eps_bottom_margin, :eps_size,
+ :expand_control, :expand_control_hop, :expand_control_jitter,
+ :expand_control_length, :expand_control_ramp, :expand_control?, :fft,
+ :fft_window_beta, :fft_window_alpha, :fft_with_phases,
+ :fft_log_frequency, :fft_log_magnitude, :transform_size,
+ :disk_kspace, :transform_graph_type, :fft_window,
+ :transform_graph?, :mix_file_dialog, :file_name, :fill_polygon,
+ :fill_rectangle, :filter_sound, :filter_control_in_dB,
+ :filter_control_envelope, :enved_filter_order, :enved_filter,
+ :filter_control_in_hz, :filter_control_order, :filter_selection,
+ :filter_channel, :filter_control_waveform_color, :filter_control?,
+ :find_mark, :find_sound, :finish_progress_report, :foreground_color,
+ :framples, :free_sampler, :graph, :transform?, :delete_transform,
+ :graph_color, :graph_cursor, :graph_data, :graph2ps, :gl_graph2ps,
+ :graph_style, :lisp_graph?, :graphs_horizontal, :header_type,
+ :help_dialog, :info_dialog, :highlight_color, :call_in,
+ :insert_region, :insert_sample, :insert_samples,
+ :insert_samples_with_origin, :insert_selection, :insert_silence,
+ :insert_sound, :just_sounds, :key, :key_binding, :left_sample,
+ :listener_color, :listener_font, :listener_prompt,
+ :listener_selection, :listener_text_color, :main_widgets,
+ :make_color, :make_graph_data, :make_mix_sampler, :make_player,
+ :make_region, :make_region_sampler, :make_sampler, :map_chan,
+ :mark_color, :mark_name, :mark_properties, :mark_property,
+ :mark_sample, :mark_sync, :mark_sync_max,
+ :mark_home, :marks, :mark?, :max_transform_peaks, :max_regions,
+ :maxamp, :maxamp_position, :menu_widgets,
+ :min_dB, :log_freq_start, :mix, :mixes, :mix_amp,
+ :mix_amp_env, :mix_color, :mix_length, :mix?, :view_mixes_dialog,
+ :mix_position, :mix_dialog_mix, :mix_name, :mix_sync_max,
+ :mix_sync, :mix_properties, :mix_property, :mix_region,
+ :mix_sampler?, :mix_selection, :mix_home, :mix_speed,
+ :mix_tag_height, :mix_tag_width, :mark_tag_height, :mark_tag_width,
+ :mix_tag_y, :mix_vct, :mix_waveform_height, :time_graph_style,
+ :lisp_graph_style, :transform_graph_style,
+ :read_mix_sample, :next_sample, :read_region_sample,
+ :show_full_duration, :show_full_range, :initial_beg, :initial_dur,
+ :transform_normalization, :open_file_dialog_directory,
+ :open_raw_sound, :open_sound, :color_orientation_dialog,
+ :previous_sample, :peaks, :player?, :players,
+ :play_arrow_size, :position_color,
+ :position2x, :position2y, :print_length, :progress_report, :read_only,
+ :redo_edit, :region_chans, :view_regions_dialog, :region_home,
+ :region_graph_style, :region_framples, :region_position, :region_maxamp,
+ :region_maxamp_position, :remember_sound_state, :selection_maxamp,
+ :selection_maxamp_position, :region_sample, :region2vct,
+ :region_srate, :regions, :region?, :remove_from_menu,
+ :reset_controls, :restore_controls, :restore_region,
+ :reverb_control_decay, :reverb_control_feedback,
+ :reverb_control_length, :reverb_control_lowpass,
+ :reverb_control_scale, :reverb_control?, :reverse_sound,
+ :reverse_selection, :revert_sound, :right_sample, :sample,
+ :sampler_at_end?, :sampler?, :samples, :sampler_position,
+ :sash_color, :save_controls, :ladspa_dir, :peak_env_dir,
+ :save_dir, :save_edit_history, :save_envelopes, :save_listener,
+ :save_marks, :save_region, :save_selection, :save_sound,
+ :save_sound_as, :save_state, :save_state_file,
+ :scale_by, :scale_selection_by, :scale_selection_to, :scale_to,
+ :search_procedure, :select_all, :select_channel,
+ :select_sound, :selected_channel, :selected_data_color,
+ :selected_graph_color, :selected_sound, :selection_position,
+ :selection_color, :selection_creates_region, :selection_framples,
+ :selection_member?, :selection?, :short_file_name,
+ :show_axes, :show_controls, :show_transform_peaks, :show_indices,
+ :show_listener, :show_selection, :unselect_all, :show_marks,
+ :show_mix_waveforms, :show_selection_transform, :show_y_zero,
+ :sinc_width, :show_grid, :show_sonogram_cursor, :grid_density,
+ :smooth_sound, :smooth_selection, :snd_spectrum, :snd_tempnam,
+ :snd_version, :sound_files_in_directory, :sound_loop_info,
+ :sound_widgets, :soundfont_info, :sound?, :sounds,
+ :spectrum_end, :spectro_hop, :spectrum_start, :spectro_x_angle,
+ :spectro_x_scale, :spectro_y_angle, :spectro_y_scale,
+ :spectro_z_angle, :spectro_z_scale, :speed_control,
+ :speed_control_style, :speed_control_tones, :squelch_update,
+ :srate, :src_sound, :src_selection, :start_progress_report,
+ :stop_player, :stop_playing, :swap_channels, :syncd_marks,
+ :sync, :sync_max, :sound_properties, :sound_property,
+ :temp_dir, :text_focus_color, :tiny_font,
+ :region_sampler?, :transform_dialog, :transform_sample, :transform2vct,
+ :transform_framples, :transform_type, :with_file_monitor,
+ :unbind_key, :update_transform_graph, :update_time_graph,
+ :update_lisp_graph, :update_sound, :clm_table_size,
+ :with_verbose_cursor, :view_sound, :wavelet_type,
+ :with_inset_graph, :with_interrupts, :with_pointer_focus,
+ :with_smpte_label, :with_toolbar, :with_tooltips,
+ :with_menu_icons, :save_as_dialog_src,
+ :save_as_dialog_auto_comment, :time_graph?, :time_graph_type,
+ :wavo_hop, :wavo_trace, :window_height, :window_width,
+ :window_x, :window_y, :with_mix_tags, :with_relative_panes,
+ :with_gl, :x_axis_style, :beats_per_measure, :beats_per_minute,
+ :x_bounds, :x_position_slider, :x2position, :x_zoom_slider,
+ :mus_header_type2string, :mus_sample_type2string, :y_bounds,
+ :y_position_slider, :y2position, :y_zoom_slider, :zero_pad,
+ :zoom_color, :zoom_focus_style, :sync_style,
+ :mus_set_formant_radius_and_frequency,
+ :mus_sound_samples, :mus_sound_framples, :mus_sound_duration,
+ :mus_sound_datum_size, :mus_sound_data_location, :data_size,
+ :mus_sound_chans, :mus_sound_srate, :mus_sound_header_type,
+ :mus_sound_sample_type, :mus_sound_length,
+ :mus_sound_type_specifier, :mus_header_type_name,
+ :mus_sample_type_name, :mus_sound_comment,
+ :mus_sound_write_date, :mus_bytes_per_sample,
+ :mus_sound_loop_info, :mus_sound_mark_info,
+ :mus_sound_maxamp, :mus_sound_maxamp_exists?,
+ :mus_clipping, :mus_file_clipping, :mus_header_raw_defaults,
+ :moving_average, :moving_average?, :make_moving_average,
+ :mus_expand_filename, :all_pass, :all_pass?,
+ :amplitude_modulate, :array2file, :array_interp,
+ :mus_interpolate, :asymmetric_fm, :asymmetric_fm?,
+ :comb, :comb?, :filtered_comb, :filtered_comb?,
+ :contrast_enhancement, :convolution, :convolve, :convolve?,
+ :db2linear, :degrees2radians, :delay, :delay?, :dot_product,
+ :env, :env_interp, :env?, :file2array, :file2frample,
+ :file2frample?, :file2sample, :file2sample?,
+ :filter, :filter?, :fir_filter, :fir_filter?, :formant,
+ :formant_bank, :formant_bank?, :formant?,
+ :frample2file, :frample2file?, :frample2frample,
+ :granulate, :granulate?, :hz2radians, :iir_filter, :iir_filter?,
+ :in_any, :ina, :inb, :linear2db, :locsig, :locsig_ref,
+ :locsig_reverb_ref, :locsig_reverb_set!, :locsig_set!,
+ :locsig?, :make_all_pass, :make_asymmetric_fm, :make_comb,
+ :make_convolve, :make_delay, :make_env, :make_fft_window,
+ :make_file2frample, :make_file2sample, :make_filter,
+ :make_fir_filter, :make_formant, :make_frample2file,
+ :make_granulate, :make_iir_filter, :make_locsig, :move_locsig,
+ :make_notch, :make_one_pole, :make_one_zero,
+ :make_oscil, :make_pulse_train, :make_rand, :make_rand_interp,
+ :make_readin, :make_sample2file, :make_sawtooth_wave,
+ :make_square_wave, :make_src, :make_ssb_am,
+ :make_table_lookup, :make_triangle_wave, :make_two_pole,
+ :make_two_zero, :make_wave_train, :move_sound,
+ :make_move_sound, :move_sound?, :mus_float_equal_fudge_factor,
+ :mus_array_print_length, :mus_channel, :mus_channels,
+ :make_polyshape, :polyshape, :polyshape?, :mus_close,
+ :mus_data, :mus_feedback, :mus_feedforward, :mus_fft,
+ :mus_frequency, :mus_hop, :mus_increment, :mus_input?,
+ :mus_file_name, :mus_length, :mus_location, :mus_order,
+ :mus_output?, :mus_phase, :mus_ramp, :mus_random,
+ :mus_scaler, :mus_srate, :mus_xcoeffs, :mus_ycoeffs,
+ :notch, :notch?, :one_pole, :one_pole?, :one_zero, :one_zero?,
+ :oscil, :oscil?, :out_any, :outa, :outb, :outc, :outd,
+ :partials2polynomial, :partials2wave, :phase_partials2wave,
+ :polynomial, :pulse_train, :pulse_train?, :radians2degrees,
+ :radians2hz, :rand, :rand_interp, :rand_interp?, :rand?, :readin,
+ :readin?, :rectangular2polar, :rectangular2magnitudes, :ring_modulate,
+ :sample2file, :sample2file?, :sawtooth_wave, :sawtooth_wave?,
+ :spectrum, :square_wave, :square_wave?, :src, :src?, :ssb_am,
+ :ssb_am?, :table_lookup, :table_lookup?, :tap, :triangle_wave,
+ :triangle_wave?, :two_pole, :two_pole?, :two_zero, :two_zero?,
+ :wave_train, :wave_train?, :make_vct, :vct_add!, :vct_subtract!,
+ :vct_copy, :vct_length, :vct_multiply!, :vct_offset!, :vct_ref,
+ :vct_scale!, :vct_set!, :vct_peak, :vct?, :list2vct, :vct2list,
+ :vector2vct, :vct2vector, :vct_move!, :vct_reverse!, :vct_subseq,
+ :vct, :little_endian?, :vct2string, :clm_channel, :env_channel,
+ :map_channel, :scan_channel, :reverse_channel, :seconds2samples,
+ :samples2seconds, :vct2channel, :smooth_channel, :channel2vct,
+ :src_channel, :scale_channel, :ramp_channel, :pad_channel,
+ :normalize_channel, :cursor_position, :mus_sound_prune,
+ :mus_sound_forget, :xramp_channel, :snd2sample, :snd2sample?,
+ :make_snd2sample, :beats_per_minute, :beats_per_measure,
+ :channel_amp_envs, :convolve_files, :filter_control_coeffs,
+ :locsig_type, :make_phase_vocoder, :mus_describe,
+ :mus_error_type2string, :mus_file_buffer_size, :mus_name,
+ :mus_offset, :mus_reset, :mus_rand_seed, :mus_width,
+ :phase_vocoder?, :polar2rectangular, :phase_vocoder_amp_increments,
+ :phase_vocoder_amps, :phase_vocoder_freqs, :phase_vocoder_phase_increments,
+ :phase_vocoder_phases, :mus_generator?, :read_sample,
+ :reset_listener_cursor, :goto_listener_end, :sampler_home,
+ :selection_chans, :selection_srate, :snd_gcs, :snd_font,
+ :snd_color, :snd_warning, :channel_data, :x_axis_label,
+ :variable_graph?, :y_axis_label, :snd_url, :snd_urls,
+ :free_player, :delay_tick, :playing, :draw_axes,
+ :copy_sampler, :html_dir, :html_program, :make_fir_coeffs,
+ :mus_interp_type, :mus_run, :phase_vocoder, :player_home,
+ :redo_edit, :undo_edit, :widget_position, :widget_size, :focus_widget]
+
+Set_procs = [
+ :amp_control, :ask_before_overwrite, :auto_resize, :sound_file_extensions,
+ :auto_update, :axis_color, :axis_label_font, :axis_numbers_font,
+ :channel_style, :peaks_font, :bold_peaks_font, :show_full_duration,
+ :show_full_range, :initial_beg, :initial_dur, :color_cutoff,
+ :color_inverted, :color_scale, :contrast_control, :contrast_control_amp,
+ :combined_data_color, :amp_control_bounds, :speed_control_bounds,
+ :expand_control_bounds, :contrast_control_bounds,
+ :reverb_control_length_bounds, :reverb_control_scale_bounds,
+ :cursor_update_interval, :cursor_location_offset, :contrast_control?,
+ :auto_update_interval, :current_font, :cursor, :cursor_color,
+ :channel_properties, :channel_property, :with_tracking_cursor, :cursor_size,
+ :cursor_style, :tracking_cursor_style, :dac_combines_channels, :dac_size,
+ :clipping, :data_color, :default_output_chans, :default_output_sample_type,
+ :default_output_srate, :default_output_header_type, :dot_size,
+ :enved_envelope, :enved_base, :enved_clip?, :enved_in_dB, :enved_style,
+ :enved_power, :enved_target, :enved_waveform_color, :enved_wave?, :eps_file,
+ :eps_left_margin,
+ :eps_bottom_margin, :eps_size, :expand_control, :expand_control_hop,
+ :expand_control_jitter, :expand_control_length, :expand_control_ramp,
+ :expand_control?, :fft_window_beta, :fft_window_alpha, :fft_with_phases,
+ :fft_log_frequency, :fft_log_magnitude, :transform_size,
+ :transform_graph_type, :fft_window, :transform_graph?,
+ :filter_control_in_dB, :filter_control_envelope, :axis_color,
+ :enved_filter_order, :enved_filter, :filter_control_in_hz,
+ :filter_control_order, :filter_control_waveform_color, :filter_control?,
+ :foreground_color, :graph_color, :graph_cursor, :graph_style, :lisp_graph?,
+ :graphs_horizontal, :highlight_color, :just_sounds, :left_sample,
+ :listener_color, :listener_font, :listener_prompt,
+ :listener_text_color, :mark_color, :mark_name, :mark_properties,
+ :mark_property, :mark_sample, :mark_sync, :max_transform_peaks,
+ :max_regions, :min_dB, :log_freq_start, :mix_amp,
+ :mix_amp_env, :mix_color, :mix_name, :mix_position, :mix_sync,
+ :mix_properties, :mix_property, :mix_speed, :mix_tag_height,
+ :mix_tag_width, :mix_tag_y, :mark_tag_width, :mark_tag_height,
+ :mix_waveform_height, :transform_normalization,
+ :open_file_dialog_directory, :position_color, :print_length,
+ :play_arrow_size, :region_graph_style, :reverb_control_decay,
+ :reverb_control_feedback, :reverb_control_length,
+ :reverb_control_lowpass, :reverb_control_scale, :time_graph_style,
+ :lisp_graph_style, :transform_graph_style, :reverb_control?,
+ :sash_color, :ladspa_dir, :peak_env_dir, :save_dir, :save_state_file,
+ :selected_data_color, :selected_graph_color, :selection_color,
+ :selection_creates_region, :show_axes, :show_controls, :show_transform_peaks,
+ :show_indices, :show_marks, :show_mix_waveforms, :show_selection_transform,
+ :show_listener, :show_y_zero, :show_grid, :show_sonogram_cursor, :sinc_width,
+ :spectrum_end, :spectro_hop, :spectrum_start, :spectro_x_angle, :grid_density,
+ :spectro_x_scale, :spectro_y_angle, :spectro_y_scale, :spectro_z_angle,
+ :spectro_z_scale, :speed_control, :speed_control_style, :speed_control_tones,
+ :squelch_update, :sync, :sound_properties, :sound_property, :temp_dir,
+ :text_focus_color, :tiny_font, :y_bounds, :transform_type,
+ :with_file_monitor, :with_verbose_cursor, :with_inset_graph, :with_interrupts,
+ :with_pointer_focus, :wavelet_type, :x_bounds, :with_smpte_label,
+ :with_toolbar, :with_tooltips, :with_menu_icons, :save_as_dialog_src,
+ :save_as_dialog_auto_comment, :time_graph?, :wavo_hop,
+ :wavo_trace, :with_gl, :with_mix_tags, :x_axis_style,
+ :beats_per_minute, :zero_pad, :zoom_color, :zoom_focus_style,
+ :sync_style, :with_relative_panes, :window_x, :window_y,
+ :window_width, :window_height, :mix_dialog_mix, :beats_per_measure,
+ :channels, :chans, :colormap, :comment, :sample_type, :data_location,
+ :data_size, :edit_position, :framples, :header_type, :maxamp,
+ :read_only, :right_sample, :sample, :samples,
+ :selected_channel, :colormap_size, :selected_sound, :selection_position,
+ :selection_framples, :selection_member?, :sound_loop_info, :srate,
+ :time_graph_type, :x_position_slider, :x_zoom_slider,
+ :y_position_slider, :y_zoom_slider,
+ :mus_array_print_length, :mus_float_equal_fudge_factor,
+ :mus_feedback, :mus_feedforward, :mus_frequency, :mus_hop,
+ :mus_increment, :mus_length, :mus_location, :mus_phase, :mus_ramp,
+ :mus_scaler, :x_axis_label, :locsig_type, :mus_file_buffer_size,
+ :mus_rand_seed, :mus_width, :clm_table_size, :mus_offset, :html_dir,
+ :html_program, :widget_position, :widget_size,
+ :mus_clipping, :mus_header_raw_defaults]
+
+Make_procs = [
+ :make_all_pass, :make_asymmetric_fm, :make_snd2sample, :make_moving_average,
+ :make_moving_max, :make_comb, :make_filtered_comb, :make_convolve,
+ :make_delay, :make_env, :make_fft_window, :make_file2frample,
+ :make_file2sample, :make_filter, :make_fir_filter, :make_formant,
+ :make_frample2file, :make_granulate, :make_iir_filter, :make_locsig,
+ :make_notch, :make_one_pole, :make_one_zero, :make_oscil,
+ :make_pulse_train, :make_rand, :make_rand_interp, :make_readin,
+ :make_sample2file, :make_sawtooth_wave, :make_square_wave, :make_src,
+ :make_table_lookup, :make_triangle_wave, :make_two_pole, :make_two_zero,
+ :make_wave_train, :make_phase_vocoder, :make_ssb_am, :make_polyshape,
+ :make_color, :make_player, :make_region]
+
+Keyargs = [
+ :frequency, :initial_phase, :wave, :cosines, :amplitude, :ratio, :size,
+ :a0, :a1, :a2, :b1, :b2, :input, :srate, :file, :channel, :start,
+ :initial_contents, :initial_element, :scaler, :feedforward, :feedback,
+ :max_size, :radius, :gain, :partials, :r, :a, :n, :fill_time, :order,
+ :xcoeffs, :ycoeffs, :envelope, :base, :duration, :offset, :end,
+ :direction, :degree, :distance, :reverb, :output, :fft_size, :expansion,
+ :length, :hop, :ramp, :jitter, :type, :format, :comment, :channels,
+ :filter, :revout, :width, :edit, :synthesize, :analyze, :interp,
+ :overlap, :pitch, :distribution, :sines, :dur]
class Array
# If body results in true, returns the rejected elements in a new
@@ -36298,44 +34401,80 @@ class Array
end
end
-Procs00 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 0) end
-Set_procs00 = Set_procs.remove_if! do |n| function?(n) and set_arity_ok(n, 1) end
-Procs01 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 1) end
-Set_procs01 = Set_procs.remove_if! do |n| function?(n) and set_arity_ok(n, 2) end
-Procs02 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 2) end
-Set_procs02 = Set_procs.remove_if! do |n| function?(n) and set_arity_ok(n, 3) end
-Procs03 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 3) end
-Set_procs03 = Set_procs.remove_if! do |n| function?(n) and set_arity_ok(n, 4) end
-Procs04 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 4) end
-Set_procs04 = Set_procs.remove_if! do |n| function?(n) and set_arity_ok(n, 5) end
-Procs05 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 5) end
-Procs06 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 6) end
-Procs07 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 7) end # not used
-Procs08 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 8) end
-Procs10 = Procs.remove_if! do |n| function?(n) and arity_ok(n, 10) end
+Procs00 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 0)
+end
+Set_procs00 = Set_procs.remove_if! do |n|
+ function?(n) and set_arity_ok(n, 1)
+end
+Procs01 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 1)
+end
+Set_procs01 = Set_procs.remove_if! do |n|
+ function?(n) and set_arity_ok(n, 2)
+end
+Procs02 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 2)
+end
+Set_procs02 = Set_procs.remove_if! do |n|
+ function?(n) and set_arity_ok(n, 3)
+end
+Procs03 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 3)
+end
+Set_procs03 = Set_procs.remove_if! do |n|
+ function?(n) and set_arity_ok(n, 4)
+end
+Procs04 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 4)
+end
+Set_procs04 = Set_procs.remove_if! do |n|
+ function?(n) and set_arity_ok(n, 5)
+end
+Procs05 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 5)
+end
+Procs06 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 6)
+end
+# Procs07 is not used
+Procs07 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 7)
+end
+Procs08 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 8)
+end
+Procs10 = Procs.remove_if! do |n|
+ function?(n) and arity_ok(n, 10)
+end
$delay_32 = make_oscil(440)
-$color_95 = [1, 2, 3]
+$color_95 = vector(1, 2, 3)
$vector_0 = make_comb(0.1, 3)
-$vct_3 = make_vct(3)
+$vct_3 = Vct.new(3)
def test_28_00
- procs1 =
- [:amp_control, :apply_controls, :comment,
- :contrast_control, :amp_control_bounds, :speed_control_bounds, :expand_control_bounds,
- :contrast_control_bounds, :reverb_control_length_bounds, :reverb_control_scale_bounds,
- :contrast_control_amp, :contrast_control?, :data_format, :data_location, :data_size,
- :expand_control, :expand_control_hop, :expand_control_jitter, :expand_control_length,
- :expand_control_ramp, :expand_control?, :filter_control_in_dB,
- :filter_control_in_hz, :filter_control_envelope, :filter_control_order, :filter_control?,
- :finish_progress_report, :frames, :header_type, :progress_report, :read_only,
- :reset_controls, :restore_controls, :reverb_control_decay, :reverb_control_feedback,
- :reverb_control_length, :reverb_control_lowpass, :reverb_control_scale, :reverb_control?,
- :save_controls, :select_sound, :short_file_name, :sound_loop_info, :soundfont_info,
- :speed_control, :speed_control_style, :speed_control_tones, :srate, :channel_style,
- :start_progress_report, :sync, :sound_properties, :sound_property, :swap_channels]
+ procs1 = [
+ :amp_control, :apply_controls, :comment, :contrast_control,
+ :amp_control_bounds, :speed_control_bounds, :expand_control_bounds,
+ :contrast_control_bounds, :reverb_control_length_bounds,
+ :reverb_control_scale_bounds, :contrast_control_amp,
+ :contrast_control?, :sample_type, :data_location, :data_size,
+ :expand_control, :expand_control_hop, :expand_control_jitter,
+ :expand_control_length, :expand_control_ramp, :expand_control?,
+ :filter_control_in_dB, :filter_control_in_hz, :filter_control_envelope,
+ :filter_control_order, :filter_control?, :finish_progress_report,
+ :framples, :header_type, :progress_report, :read_only, :reset_controls,
+ :restore_controls, :reverb_control_decay, :reverb_control_feedback,
+ :reverb_control_length, :reverb_control_lowpass, :reverb_control_scale,
+ :reverb_control?, :save_controls, :select_sound, :short_file_name,
+ :sound_loop_info, :soundfont_info, :speed_control,
+ :speed_control_style, :speed_control_tones, :srate, :channel_style,
+ :start_progress_report, :sync, :sound_properties, :sound_property,
+ :swap_channels]
procs1.each do |n|
- if (tag = Snd.catch do snd_func(n, integer2sound(123)) end).first != :no_such_sound
+ tag = Snd.catch do snd_func(n, integer2sound(123)) end
+ if tag.first != :no_such_sound
snd_display("snd :no_such_sound %s: %s", n, tag)
end
end
@@ -36350,24 +34489,26 @@ def test_28_00
end
end
end
- progs2 =
- [:amp_control, :channels, :chans, :comment,
- :contrast_control, :amp_control_bounds, :speed_control_bounds, :expand_control_bounds,
- :contrast_control_bounds, :reverb_control_length_bounds, :reverb_control_scale_bounds,
- :contrast_control_amp, :contrast_control?, :data_format, :data_location, :data_size,
- :expand_control, :expand_control_hop, :expand_control_jitter, :expand_control_length,
- :expand_control_ramp, :expand_control?, :filter_control_in_dB,
- :filter_control_in_hz, :filter_control_envelope, :filter_control_order, :filter_control?,
- :frames, :header_type, :read_only,
- :reverb_control_decay, :reverb_control_feedback,
- :reverb_control_length, :reverb_control_lowpass, :reverb_control_scale, :reverb_control?,
- :sound_loop_info,
- :speed_control, :speed_control_style, :speed_control_tones, :srate, :channel_style, :sync]
+ progs2 = [
+ :amp_control, :channels, :chans, :comment, :contrast_control,
+ :amp_control_bounds, :speed_control_bounds, :expand_control_bounds,
+ :contrast_control_bounds, :reverb_control_length_bounds,
+ :reverb_control_scale_bounds, :contrast_control_amp,
+ :contrast_control?, :sample_type, :data_location, :data_size,
+ :expand_control, :expand_control_hop, :expand_control_jitter,
+ :expand_control_length, :expand_control_ramp, :expand_control?,
+ :filter_control_in_dB, :filter_control_in_hz, :filter_control_envelope,
+ :filter_control_order, :filter_control?, :framples, :header_type,
+ :read_only, :reverb_control_decay, :reverb_control_feedback,
+ :reverb_control_length, :reverb_control_lowpass,
+ :reverb_control_scale, :reverb_control?, :sound_loop_info,
+ :speed_control, :speed_control_style, :speed_control_tones,
+ :srate, :channel_style, :sync]
[sqrt(-1.0), 1.5, "hiho"].each do |arg|
progs2.each_with_index do |n, i|
if (tag = Snd.catch do
case n
- when :channels, :chans, :data_format, :data_location, :data_size,
+ when :channels, :chans, :sample_type, :data_location, :data_size,
:header_type, :srate, :comment
# g_set_channels(snd, val)
set_snd_func(n, arg, 0)
@@ -36380,21 +34521,24 @@ def test_28_00
end
end
end
- progs3 =
- [:amp_control,
- :contrast_control, :amp_control_bounds, :speed_control_bounds, :expand_control_bounds,
- :contrast_control_bounds, :reverb_control_length_bounds, :reverb_control_scale_bounds,
- :contrast_control_amp, :contrast_control?,
- :expand_control, :expand_control_hop, :expand_control_jitter, :expand_control_length,
- :expand_control_ramp, :expand_control?, :filter_control_in_dB,
- :filter_control_in_hz, :filter_control_envelope, :filter_control_order, :filter_control?,
- :reverb_control_decay, :reverb_control_feedback,
- :reverb_control_length, :reverb_control_lowpass, :reverb_control_scale, :reverb_control?,
- :speed_control, :speed_control_style, :speed_control_tones, :channel_style, :sync]
+ progs3 = [
+ :amp_control, :contrast_control, :amp_control_bounds,
+ :speed_control_bounds, :expand_control_bounds, :contrast_control_bounds,
+ :reverb_control_length_bounds, :reverb_control_scale_bounds,
+ :contrast_control_amp, :contrast_control?, :expand_control,
+ :expand_control_hop, :expand_control_jitter,
+ :expand_control_length, :expand_control_ramp, :expand_control?,
+ :filter_control_in_dB, :filter_control_in_hz,
+ :filter_control_envelope, :filter_control_order, :filter_control?,
+ :reverb_control_decay, :reverb_control_feedback,
+ :reverb_control_length, :reverb_control_lowpass,
+ :reverb_control_scale, :reverb_control?, :speed_control,
+ :speed_control_style, :speed_control_tones, :channel_style, :sync]
index = open_sound("obtest.snd")
[sqrt(-1.0), "hiho"].each do |arg|
progs3.each_with_index do |n, i|
- if (tag = Snd.catch do set_snd_func(n, arg, index) end).first != :wrong_type_arg
+ tag = Snd.catch do set_snd_func(n, arg, index) end
+ if tag.first != :wrong_type_arg
snd_display("snd safe set :wrong_type_arg %s %s: %s %s", i, n, tag, arg)
end
end
@@ -36409,19 +34553,23 @@ def test_28_00
end
[Array.new(1), "hiho", sqrt(-1.0), 1.5, [1, 0], [0, 1]].each do |arg1|
["hiho", sqrt(-1.0), 1.5, [1, 0], [0, 1]].each do |arg2|
- [:vct_add!, :vct_subtract!, :vct_multiply!, :vct_ref, :vct_scale!, :vct_fill!].each do |n|
+ [:vct_add!, :vct_subtract!,
+ :vct_multiply!, :vct_ref, :vct_scale!].each do |n|
case tag = (res = Snd.catch do snd_func(n, arg1, arg2) end).first
when :wrong_type_arg, :wrong_number_of_args, :mus_error
nil
else
- snd_display("vct 1 :wrong_whatever %s: %s %s %s (%s)", n, tag, arg1, arg2, res)
+ snd_display("vct 1 :wrong_whatever %s: %s %s %s (%s)",
+ n, tag, arg1, arg2, res)
end
end
end
end
[Array.new(1), "hiho", sqrt(-1.0), [1, 0], [0, 1]].each do |arg|
- [:vct_add!, :vct_subtract!, :vct_multiply!, :vct_ref, :vct_scale!, :vct_fill!].each do |n|
- if (tag = Snd.catch do snd_func(n, $vct_3, arg) end).first != :wrong_type_arg
+ [:vct_add!, :vct_subtract!,
+ :vct_multiply!, :vct_ref, :vct_scale!].each do |n|
+ tag = Snd.catch do snd_func(n, $vct_3, arg) end
+ if tag.first != :wrong_type_arg
snd_display("vct 2 :wrong_type_arg %s: %s %s", n, tag, arg)
end
end
@@ -36439,16 +34587,17 @@ def test_28_00
if (tag = Snd.catch do v[12] end).first != :out_of_range
snd_display("v[12]: %s", tag)
end
- procs_p =
- [:all_pass?, :asymmetric_fm?, :comb?, :filtered_comb?, :convolve?, :delay?, :env?,
- :file2frame?, :file2sample?, :snd2sample?, :filter?, :fir_filter?, :formant?,
- :frame2file?, :frame?, :granulate?, :iir_filter?, :locsig?, :mixer?, :move_sound?, :mus_input?,
- :mus_output?, :notch?, :one_pole?, :one_zero?, :oscil?, :phase_vocoder?,
- :pulse_train?, :rand_interp?, :rand?, :readin?, :sample2file?, :sawtooth_wave?,
- :square_wave?, :src?,
- :table_lookup?, :triangle_wave?, :two_pole?, :two_zero?, :wave_train?,
- :color?, :mix_sampler?, :moving_average?, :ssb_am?, :sampler?,
- :region_sampler?, :vct?]
+ procs_p = [
+ :all_pass?, :asymmetric_fm?, :comb?, :filtered_comb?, :convolve?,
+ :delay?, :env?, :file2frample?, :file2sample?, :snd2sample?,
+ :filter?, :fir_filter?, :formant?, :frample2file?, :frame?,
+ :granulate?, :iir_filter?, :locsig?, :mixer?, :move_sound?,
+ :mus_input?, :mus_output?, :notch?, :one_pole?, :one_zero?,
+ :oscil?, :phase_vocoder?, :pulse_train?, :rand_interp?, :rand?,
+ :readin?, :sample2file?, :sawtooth_wave?, :square_wave?, :src?,
+ :table_lookup?, :triangle_wave?, :two_pole?, :two_zero?,
+ :wave_train?, :color?, :mix_sampler?, :moving_average?,
+ :ssb_am?, :sampler?, :region_sampler?, :vct?]
[Array.new(1), "hiho", sqrt(-1.0), 1.5, [1, 0], [0, 1]].each do |arg|
procs_p.each do |n|
if (tag = Snd.catch do snd_func(n, arg) end).first.kind_of?(TrueClass)
@@ -36458,131 +34607,169 @@ def test_28_00
end
procs_p.each do |n|
next if n == :oscil?
- if (tag = Snd.catch do snd_func(n, make_oscil(440)) end).first.kind_of?(TrueClass)
+ tag = Snd.catch do snd_func(n, make_oscil(440)) end
+ if tag.first.kind_of?(TrueClass)
snd_display("oscil?proc %s: %s", n, tag)
end
end
- [:reverse_selection, :selection_position, :selection_frames, :smooth_selection,
- :scale_selection_to, :insert_selection, :delete_selection, :delete_selection_and_smooth,
+ [:reverse_selection, :selection_position, :selection_framples,
+ :smooth_selection, :scale_selection_to, :insert_selection,
+ :delete_selection, :delete_selection_and_smooth,
:mix_selection].each do |n|
if (tag = Snd.catch do snd_func(n) end).first != :no_active_selection
snd_display("selection %s: %s", n, tag)
end
end
- # FIXME
- # Array.new(1): *partials_* functions return :bad_type (odd length partials list?)
- # We can't use arrays here like [:Pixel, ...] or [0, 1].
- [sqrt(-1.0)].each do |arg|
- [:all_pass, :asymmetric_fm, :clear_array, :comb, :filtered_comb, :convolve, :db2linear,
- :moving_average, :degrees2radians, :delay, :env, :formant, :frame2list, :granulate,
- :hz2radians, :linear2db, :make_all_pass, :make_asymmetric_fm, :make_comb, :make_filtered_comb,
- :make_convolve, :make_delay, :make_env, :make_file2frame, :make_file2sample,
- :make_filter, :make_fir_filter, :make_formant, :make_frame, :make_granulate,
- :make_iir_filter, :make_locsig, :make_notch, :make_one_pole, :make_one_zero,
- :make_oscil, :make_pulse_train, :make_rand, :make_rand_interp,
- :make_readin, :make_sawtooth_wave, :make_square_wave,
- :make_src, :make_table_lookup,
- :make_triangle_wave, :make_two_pole, :make_two_zero, :make_wave_train, :make_ssb_am,
- :mus_channel, :mus_channels, :make_polyshape,
- :mus_data, :mus_feedback, :mus_feedforward,
- :mus_frequency, :mus_hop, :mus_increment, :mus_length, :mus_file_name, :mus_location,
- :mus_order, :mus_phase, :mus_ramp, :mus_random, :mus_run, :mus_scaler, :mus_xcoeffs,
- :mus_ycoeffs, :notch, :one_pole, :one_zero, :make_moving_average, :seconds2samples,
- :samples2seconds, :oscil, :partials2polynomial, :partials2wave,
- :phase_partials2wave, :phase_vocoder, :pulse_train, :radians2degrees, :radians2hz,
- :rand, :rand_interp, :readin, :sawtooth_wave, :square_wave, :src,
- :table_lookup, :tap, :triangle_wave, :two_pole,
- :two_zero, :wave_train, :ssb_am].each_with_index do |n, i|
- case (tag = Snd.catch do snd_func(n, arg) end).first
- when :wrong_type_arg, :no_data, :bad_type, :arg_error
+ [:src_selection, :filter_selection, :env_selection].each do |n|
+ if (tag = Snd.catch do snd_func(n, 0.0) end).first != :no_active_selection
+ snd_display("selection %s: %s", n, tag)
+ end
+ end
+ [make_vector(1), $color_95, [1.0]].each do |arg|
+ [:all_pass, :asymmetric_fm, :comb, :filtered_comb,
+ :convolve, :db2linear, :moving_average, :degrees2radians, :delay,
+ :env, :formant, :granulate, :hz2radians, :linear2db,
+ :make_all_pass, :make_asymmetric_fm, :make_comb,
+ :make_filtered_comb, :make_convolve, :make_delay, :make_env,
+ :make_file2frample, :make_file2sample, :make_filter,
+ :make_fir_filter, :make_formant, :make_granulate,
+ :make_iir_filter, :make_locsig, :make_notch, :make_one_pole,
+ :make_one_zero, :make_oscil, :make_pulse_train, :make_rand,
+ :make_rand_interp, :make_readin, :make_sawtooth_wave,
+ :make_square_wave, :make_src, :make_table_lookup,
+ :make_triangle_wave, :make_two_pole, :make_two_zero,
+ :make_wave_train, :make_ssb_am, :mus_channel, :mus_channels,
+ :make_polyshape, :mus_data, :mus_feedback, :mus_feedforward,
+ :mus_frequency, :mus_hop, :mus_increment, :mus_length,
+ :mus_file_name, :mus_location, :mus_order, :mus_phase,
+ :mus_ramp, :mus_random, :mus_run, :mus_scaler, :mus_xcoeffs,
+ :mus_ycoeffs, :notch, :one_pole, :one_zero, :make_moving_average,
+ :seconds2samples, :samples2seconds, :oscil, :partials2polynomial,
+ :partials2wave, :phase_vocoder, :pulse_train,
+ :radians2degrees, :radians2hz, :rand, :rand_interp, :readin,
+ :sawtooth_wave, :square_wave, :src, :table_lookup, :tap,
+ :triangle_wave, :two_pole, :two_zero, :wave_train, :ssb_am].each do |n|
+ tag = Snd.catch do snd_func(n, arg) end
+ case tag.first
+ when :wrong_type_arg, :no_data, :no_such_method,
+ :bad_type, :error, :arg_error
next
else
- snd_display("clm %s: tag %s, arg %s [%s]", n, tag, arg, i)
+ snd_display("clm %s: tag %s, arg %s", n, tag, arg)
end
end
end
- [:all_pass, :array_interp, :asymmetric_fm, :comb, :filtered_comb, :contrast_enhancement,
- :convolution, :convolve, :moving_average, :convolve_files, :delay, :dot_product, :env_interp,
- :file2frame,
- :file2sample, :snd2sample, :filter, :fir_filter, :formant, :firmant, :formant_bank,
- :frame_multiply, :frame_add, :frame2frame, :frame_ref, :frame2sample, :granulate,
- :iir_filter, :ina, :inb, :locsig_ref, :locsig_reverb_ref, :make_all_pass,
- :make_asymmetric_fm, :make_comb, :make_filtered_comb, :make_delay, :make_env, :make_fft_window,
- :make_filter, :make_fir_filter, :make_formant, :make_firmant, :make_frame, :make_granulate,
+ # XXX: phase_partials2wave in clm (test 28)
+ # Original included in test above but Ruby's phase_partials2wave
+ # takes Arrays and Vecs as lists.
+ [make_vector(1), $color_95.to_a + [0], [1.0]].each do |arg|
+ n = :phase_partials2wave
+ tag = Snd.catch do snd_func(n, arg) end
+ case tag.first
+ when :wrong_type_arg, :no_data, :no_such_method,
+ :bad_type, :error, :arg_error
+ next
+ else
+ snd_display("clm %s: tag %s, arg %s", n, tag, arg)
+ end
+ end
+ [:all_pass, :array_interp, :asymmetric_fm, :comb, :filtered_comb,
+ :contrast_enhancement, :convolution, :convolve, :moving_average,
+ :moving_max, :convolve_files, :delay, :dot_product, :env_interp,
+ :file2frample, :file2sample, :snd2sample, :filter, :fir_filter,
+ :formant, :firmant, :formant_bank,
+ :granulate, :iir_filter, :ina, :inb, :locsig_ref,
+ :locsig_reverb_ref, :make_all_pass, :make_asymmetric_fm,
+ :make_comb, :make_filtered_comb, :make_delay, :make_env,
+ :make_fft_window, :make_filter, :make_fir_filter, :make_formant,
+ :make_firmant, :make_granulate,
:make_iir_filter, :make_locsig, :make_notch, :make_one_pole, :make_one_zero,
:make_oscil, :make_phase_vocoder, :make_pulse_train, :make_rand,
:make_rand_interp, :make_readin, :make_sawtooth_wave, :make_moving_average,
- :make_nrxysin, :make_nrxycos,
- :make_square_wave, :make_src, :make_ncos, :make_nsin,
- :make_table_lookup, :make_triangle_wave, :make_two_pole, :make_two_zero,
- :make_wave_train, :mixer_multiply, :mixer_add, :multiply_arrays, :notch, :one_pole, :one_zero,
- :oscil, :partials2polynomial, :partials2wave, :make_polyshape, :make_polywave,
- :phase_partials2wave, :phase_vocoder, :polynomial, :pulse_train, :rand, :rand_interp,
- :rectangular2polar, :rectangular2magnitudes,
- :ring_modulate, :sample2frame, :sawtooth_wave, :nrxysin, :nrxycos,
+ :make_nrxysin, :make_nrxycos, :make_square_wave, :make_src,
+ :make_ncos, :make_nsin, :make_table_lookup, :make_triangle_wave,
+ :make_two_pole, :make_two_zero, :make_wave_train,
+ :notch, :one_pole, :one_zero, :oscil, :partials2polynomial,
+ :partials2wave, :make_polyshape, :make_polywave,
+ :phase_partials2wave, :phase_vocoder, :polynomial, :pulse_train,
+ :rand, :rand_interp, :rectangular2polar, :rectangular2magnitudes,
+ :ring_modulate, :sawtooth_wave, :nrxysin, :nrxycos,
:square_wave, :src, :ncos, :nsin, :table_lookup, :tap, :triangle_wave,
:two_pole, :two_zero, :wave_train, :ssb_am, :make_ssb_am].each do |n|
- case tag = (res = Snd.catch do snd_func(n, make_oscil, $vct_3) end).first
- when :wrong_type_arg, :bad_arity, :mus_error
+ tag = Snd.catch do snd_func(n, make_oscil, $vct_3) end
+ case tag.first
+ when :wrong_type_arg, :bad_arity, :error, :mus_error
next
else
- snd_display("clm 1 %s: %s %s", n, tag, res)
+ snd_display("clm-1 %s: %s", n, tag)
end
end
[:mus_data, :mus_feedback, :mus_feedforward,
:mus_frequency, :mus_hop, :mus_increment, :mus_length, :mus_location,
:mus_phase, :mus_ramp, :mus_scaler].each do |n|
- if (tag = Snd.catch do set_snd_func(n, make_oscil, $vector_0) end).first != :wrong_type_arg
- snd_display("mus_gen %s: %s", n, tag)
- end
- end
- mus_procs = [:mus_sound_samples, :mus_sound_frames, :mus_sound_duration, :mus_sound_datum_size,
- :mus_sound_data_location, :mus_sound_chans, :mus_sound_srate, :mus_sound_header_type,
- :mus_sound_data_format, :mus_sound_length, :mus_sound_type_specifier,
- :mus_header_type_name, :mus_data_format_name, :mus_sound_comment,
- :mus_sound_write_date, :mus_bytes_per_sample, :mus_sound_loop_info,
- :mus_sound_mark_info, :mus_sound_maxamp, :mus_sound_maxamp_exists?,
- :mus_header_type2string, :mus_data_format2string]
+ tag = Snd.catch do set_snd_func(n, make_oscil, $vector_0) end
+ case tag.first
+ when :wrong_type_arg, :error
+ next
+ else
+ snd_display("mus-gen %s: %s", n, tag)
+ end
+ end
+ mus_procs = [
+ :mus_sound_samples, :mus_sound_framples, :mus_sound_duration,
+ :mus_sound_datum_size, :mus_sound_data_location, :mus_sound_chans,
+ :mus_sound_srate, :mus_sound_header_type, :mus_sound_sample_type,
+ :mus_sound_length, :mus_sound_type_specifier,
+ :mus_header_type_name, :mus_sample_type_name, :mus_sound_comment,
+ :mus_sound_write_date, :mus_bytes_per_sample, :mus_sound_loop_info,
+ :mus_sound_mark_info, :mus_sound_maxamp, :mus_sound_maxamp_exists?,
+ :mus_header_type2string, :mus_sample_type2string]
mus_procs.each do |n|
- if (tag = Snd.catch do snd_func(n, $vct_3) end).first != :wrong_type_arg
- snd_display("mus_sound %s: %s", n, tag)
+ tag = Snd.catch do snd_func(n, $vct_3) end
+ if tag.first != :wrong_type_arg
+ snd_display("mus-sound %s: %s", n, tag)
end
end
mus_procs.each do |n|
- if (tag = Snd.catch do snd_func(n) end).first != :wrong_number_of_args
- snd_display("no arg mus_sound %s: %s", n, tag)
+ tag = Snd.catch do snd_func(n) end
+ case tag.first
+ when :wrong_number_of_args, :error
+ next
+ else
+ snd_display("no arg mus-sound %s: %s", n, tag)
end
end
end
def test_28_01
- [:mus_sound_samples, :mus_sound_frames, :mus_sound_duration, :mus_sound_datum_size,
- :mus_sound_data_location, :mus_sound_chans, :mus_sound_srate, :mus_sound_header_type,
- :mus_sound_data_format, :mus_sound_length, :mus_sound_type_specifier,
- :mus_sound_comment, :mus_sound_write_date, :mus_sound_maxamp,
+ [:mus_sound_samples, :mus_sound_framples, :mus_sound_duration,
+ :mus_sound_datum_size, :mus_sound_data_location, :mus_sound_chans,
+ :mus_sound_srate, :mus_sound_header_type, :mus_sound_sample_type,
+ :mus_sound_length, :mus_sound_type_specifier, :mus_sound_comment,
+ :mus_sound_write_date, :mus_sound_maxamp,
:mus_sound_maxamp_exists?].each do |n|
- if (tag = Snd.catch do snd_func(n, "/bad/baddy") end).first != :mus_error
- snd_display("bad file mus_sound %s: %s", n, tag)
+ tag = Snd.catch do snd_func(n, "/bad/baddy") end
+ if tag.first != :mus_error
+ snd_display("bad file mus-sound %s: %s", n, tag)
end
end
mus_sound_forget("/bad/baddy")
- [:channel_widgets, :count_matches, :cursor, :channel_properties, :channel_property,
- :with_tracking_cursor,
+ [:channel_widgets, :cursor, :channel_properties, :channel_property,
:cursor_position, :cursor_size, :cursor_style, :tracking_cursor_style, :delete_sample,
:display_edits, :dot_size, :draw_dots, :draw_lines, :edit_fragment, :edit_list2function,
:edit_position, :edit_tree, :edits, :fft_window_alpha,
:fft_window_beta, :fft_log_frequency, :fft_log_magnitude, :fft_with_phases, :transform_size,
- :transform_graph_type, :fft_window, :transform_graph?, :find_channel, :graph, :graph_style,
+ :transform_graph_type, :fft_window, :transform_graph?, :graph, :graph_style,
:lisp_graph?, :insert_sound, :time_graph_style, :lisp_graph_style,
:transform_graph_style, :left_sample, :make_graph_data, :map_chan, :max_transform_peaks,
:maxamp_position, :min_dB, :mix_region, :transform_normalization,
:peaks, :play, :position2x, :position2y, :reverse_sound,
:revert_sound, :right_sample, :sample, :save_sound, :save_sound_as,
- :scan_chan, :select_channel, :show_axes, :show_transform_peaks, :show_marks,
+ :select_channel, :show_axes, :show_transform_peaks, :show_marks,
:show_mix_waveforms, :show_y_zero, :show_grid, :show_sonogram_cursor, :spectrum_end,
:spectro_hop, :spectrum_start, :spectro_x_angle, :spectro_x_scale, :spectro_y_angle,
:grid_density, :spectro_y_scale, :spectro_z_angle, :spectro_z_scale, :squelch_update,
- :transform_sample, :transform2vct, :transform_frames, :transform_type,
+ :transform_sample, :transform2vct, :transform_framples, :transform_type,
:update_transform_graph, :update_time_graph, :update_lisp_graph, :update_sound,
:wavelet_type, :time_graph?, :time_graph_type, :wavo_hop, :wavo_trace, :x_bounds,
:x_position_slider, :x_zoom_slider, :x_axis_label, :y_axis_label, :y_bounds,
@@ -36594,22 +34781,20 @@ def test_28_01
snd_display("%s: chn (no snd) procs %s: %s", i, n, tag)
end
end
- [:channel_widgets, :count_matches, :cursor, :channel_properties, :channel_property,
- :cursor_position,
- :cursor_size, :cursor_style, :tracking_cursor_style, :delete_sample, :display_edits, :dot_size,
- :draw_dots, :draw_lines, :edit_fragment, :edit_position, :edit_tree, :edits, :fft_window_beta,
- :fft_window_alpha, :fft_with_phases, :fft_log_frequency, :fft_log_magnitude, :transform_size,
- :transform_graph_type, :fft_window, :transform_graph?, :find_channel, :graph, :graph_style,
- :lisp_graph?, :insert_region,
+ [:channel_widgets, :cursor, :channel_properties, :channel_property,
+ :combined_data_color, :cursor_position, :cursor_size, :cursor_style, :tracking_cursor_style,
+ :delete_sample, :display_edits, :dot_size, :draw_dots, :draw_lines, :edit_fragment,
+ :edit_position, :edit_tree, :edits, :fft_window_beta, :fft_window_alpha, :fft_with_phases,
+ :fft_log_frequency, :fft_log_magnitude, :transform_size, :transform_graph_type, :fft_window,
+ :transform_graph?, :graph, :graph_style, :lisp_graph?, :insert_region,
:insert_sound, :left_sample, :time_graph_style, :lisp_graph_style, :transform_graph_style,
:make_graph_data, :map_chan, :max_transform_peaks, :maxamp, :maxamp_position, :min_dB,
- :mix_region, :transform_normalization, :peaks,
- :position2x, :position2y, :reverse_sound, :right_sample, :sample,
- :save_sound_as, :scan_chan, :show_axes, :show_transform_peaks, :show_marks,
- :show_mix_waveforms, :show_y_zero, :show_grid, :show_sonogram_cursor, :spectrum_end,
+ :mix_region, :transform_normalization, :peaks, :position2x, :position2y, :reverse_sound,
+ :right_sample, :sample, :save_sound_as, :show_axes, :show_transform_peaks,
+ :show_marks, :show_mix_waveforms, :show_y_zero, :show_grid, :show_sonogram_cursor, :spectrum_end,
:spectro_hop, :spectrum_start, :spectro_x_angle, :spectro_x_scale, :spectro_y_angle,
:spectro_y_scale, :spectro_z_angle, :spectro_z_scale, :squelch_update, :grid_density,
- :transform_sample, :transform2vct, :transform_frames, :transform_type,
+ :transform_sample, :transform2vct, :transform_framples, :transform_type,
:update_transform_graph, :update_time_graph, :update_lisp_graph, :wavelet_type,
:time_graph?, :time_graph_type, :wavo_hop, :wavo_trace, :x_bounds, :x_position_slider,
:x_zoom_slider, :x_axis_label, :y_axis_label, :y_bounds, :y_position_slider,
@@ -36618,29 +34803,37 @@ def test_28_01
snd_display("%s: chn (no chn) procs %s: %s", i, n, tag)
end
end
- [:channel_widgets, :cursor, :with_tracking_cursor, :channel_properties, :channel_property,
- :cursor_position,
- :cursor_size, :cursor_style, :tracking_cursor_style, :display_edits, :dot_size,
- :edit_position, :edit_tree, :edits, :env_sound, :fft_window_beta,
- :fft_window_alpha, :fft_log_frequency, :fft_with_phases,
- :fft_log_magnitude, :transform_size, :transform_graph_type, :fft_window, :transform_graph?,
- :filter_sound, :graph_data, :graph_style, :lisp_graph?, :left_sample,
- :time_graph_style, :lisp_graph_style, :transform_graph_style, :make_graph_data,
- :max_transform_peaks, :maxamp, :maxamp_position, :min_dB, :transform_normalization,
- :reverse_sound, :revert_sound, :right_sample, :save_sound, :scale_by,
- :scale_to, :show_axes, :show_transform_peaks, :show_marks, :show_mix_waveforms,
- :show_y_zero, :show_grid, :show_sonogram_cursor, :spectrum_end, :spectro_hop,
- :spectrum_start, :spectro_x_angle, :spectro_x_scale, :spectro_y_angle, :spectro_y_scale,
- :spectro_z_angle, :spectro_z_scale, :squelch_update, :grid_density, :src_sound,
- :transform2vct, :transform_frames, :transform_type,
- :update_transform_graph, :update_time_graph, :update_lisp_graph, :update_sound,
- :wavelet_type, :time_graph?, :time_graph_type, :wavo_hop, :wavo_trace, :x_bounds,
- :x_position_slider, :x_zoom_slider, :y_bounds, :y_position_slider, :x_axis_label,
- :y_axis_label, :y_zoom_slider, :zero_pad].each_with_index do |n, i|
- if (tag = Snd.catch do snd_func(n, integer2sound(1234)) end).first != :no_such_sound
+ idx = open_sound("oboe.snd")
+ [:delete_sample, :edit_fragment, :graph_data, :position2x, :position2y, :redo_edit, :scale_by,
+ :scale_to, :undo_edit, :x2position, :y2position].each_with_index do |n, i|
+ tag = Snd.catch do snd_func(n, 0, idx, 1234) end
+ if tag.first != :no_such_channel
+ snd_display("%s: snd(1 1234) chn procs %s: %s", i, n, tag)
+ end
+ end
+ close_sound(idx)
+ idx = open_sound("oboe.snd")
+ [:channel_widgets, :cursor, :cursor_position, :cursor_size, :cursor_style,
+ :tracking_cursor_style, :display_edits, :dot_size, :edit_position, :edit_tree, :edits,
+ :fft_window_alpha, :fft_window_beta, :fft_log_frequency, :fft_log_magnitude, :fft_with_phases,
+ :transform_size, :transform_graph_type, :fft_window, :transform_graph?, :graph_style,
+ :lisp_graph?, :left_sample, :time_graph_style, :lisp_graph_style, :transform_graph_style,
+ :combined_data_color, :make_graph_data, :max_transform_peaks, :maxamp, :maxamp_position,
+ :min_dB, :transform_normalization, :reverse_sound, :right_sample, :show_axes,
+ :show_transform_peaks, :show_marks, :show_mix_waveforms, :show_y_zero, :show_grid,
+ :show_sonogram_cursor, :grid_density, :spectrum_end, :spectro_hop, :spectrum_start,
+ :spectro_x_angle, :spectro_x_scale, :spectro_y_angle, :spectro_y_scale, :spectro_z_angle,
+ :spectro_z_scale, :squelch_update, :transform2vct, :transform_framples, :transform_type,
+ :update_transform_graph, :update_time_graph, :update_lisp_graph, :wavelet_type, :time_graph?,
+ :time_graph_type, :wavo_hop, :wavo_trace, :x_bounds, :x_position_slider, :x_axis_label,
+ :x_zoom_slider, :y_bounds, :y_position_slider, :y_zoom_slider, :zero_pad,
+ :channel_properties, :channel_property].each_with_index do |n, i|
+ tag = Snd.catch do snd_func(n, idx, 1234) end
+ if tag.first != :no_such_sound and tag.first != :no_such_channel
snd_display("%s: chn procs %s: %s", i, n, tag)
end
end
+ close_sound(idx)
[:delete_sample, :edit_fragment, :graph_data, :graph_style,
:position2x, :position2y, :redo_edit, :time_graph_style, :lisp_graph_style,
:transform_graph_style, :scale_by, :scale_to, :undo_edit, :x2position, :y2position,
@@ -36649,13 +34842,7 @@ def test_28_01
snd_display("%s: snd(1) chn procs %s: %s", i, n, tag)
end
end
- index = open_sound("oboe.snd")
- [:delete_sample, :edit_fragment, :graph_data, :position2x, :position2y, :redo_edit,
- :scale_by, :scale_to, :undo_edit, :x2position, :y2position].each_with_index do |n, i|
- if (tag = Snd.catch do snd_func(n, 0, index, 1234) end).first != :no_such_channel
- snd_display("%s: snd(1 1234) chn procs %s: %s", i, n, tag)
- end
- end
+ idx = open_sound("oboe.snd")
[:channel_widgets, :cursor, :cursor_position, :cursor_size, :cursor_style, :tracking_cursor_style,
:display_edits, :dot_size, :edit_position, :edit_tree, :edits, :fft_window_beta,
:fft_window_alpha, :fft_with_phases,
@@ -36667,13 +34854,13 @@ def test_28_01
:show_marks, :show_mix_waveforms, :show_y_zero, :show_grid, :show_sonogram_cursor,
:grid_density, :spectrum_end, :spectro_hop, :spectrum_start, :spectro_x_angle,
:spectro_x_scale, :spectro_y_angle, :spectro_y_scale, :spectro_z_angle,
- :spectro_z_scale, :squelch_update, :transform2vct, :transform_frames,
+ :spectro_z_scale, :squelch_update, :transform2vct, :transform_framples,
:transform_type, :update_transform_graph, :update_time_graph, :update_lisp_graph,
:wavelet_type, :time_graph?, :time_graph_type, :wavo_hop, :wavo_trace,
:x_bounds, :x_position_slider, :x_axis_label, :x_zoom_slider, :y_bounds,
:y_position_slider, :y_zoom_slider, :zero_pad,
:channel_properties, :channel_property].each_with_index do |n, i|
- case (tag = Snd.catch do snd_func(n, index, 1234) end).first
+ case (tag = Snd.catch do snd_func(n, idx, 1234) end).first
when :no_such_sound, :no_such_channel
next
else
@@ -36686,22 +34873,22 @@ def test_28_01
:transform_size, :transform_graph_type, :fft_window, :transform_graph?,
:graph_style, :lisp_graph?, :left_sample, :make_graph_data,
:max_transform_peaks, :maxamp, :maxamp_position, :time_graph_style,
- :lisp_graph_style, :transform_graph_style, :min_dB, :transform_normalization,
- :reverse_sound, :right_sample, :show_axes, :grid_density,
+ :lisp_graph_style, :transform_graph_style, :combined_data_color, :min_dB,
+ :transform_normalization, :reverse_sound, :right_sample, :show_axes, :grid_density,
:show_transform_peaks, :show_marks, :show_mix_waveforms, :show_y_zero,
:show_grid, :show_sonogram_cursor, :spectrum_end, :spectro_hop, :spectrum_start,
:spectro_x_angle, :spectro_x_scale, :spectro_y_angle, :spectro_y_scale,
:spectro_z_angle, :spectro_z_scale, :squelch_update, :transform2vct,
- :transform_frames, :transform_type, :update_transform_graph, :update_time_graph,
+ :transform_framples, :transform_type, :update_transform_graph, :update_time_graph,
:update_lisp_graph, :wavelet_type, :time_graph?, :time_graph_type, :wavo_hop,
:wavo_trace, :x_bounds, :x_position_slider, :x_zoom_slider, :y_bounds,
:y_position_slider, :y_zoom_slider, :zero_pad, :x_axis_label].each_with_index do |n, i|
- tag = Snd.catch do set_snd_func(n, $vct_3, index, 0) end
+ tag = Snd.catch do set_snd_func(n, $vct_3, idx, 0) end
if tag.first != :wrong_type_arg and tag.first != :no_method_error and tag.first != :name_error
snd_display("%s: set chn procs %s: %s", i, n, tag)
end
end
- close_sound(index)
+ close_sound(idx)
[:mix_amp, :mix_amp_env, :mix_length, :mix_name, :mix_position, :mix_home, :mix_speed,
:mix_tag_y].each_with_index do |n, i|
if (tag = Snd.catch do snd_func(n, $vct_3) end).first != :wrong_type_arg
@@ -36748,7 +34935,7 @@ def test_28_01
end
close_sound(index)
[[0, 1], sqrt(-1.0), "hiho", [0, 1]].each do |arg|
- [:region_chans, :region_home, :region_frames, :region_position,
+ [:region_chans, :region_home, :region_framples, :region_position,
:region_maxamp, :region_maxamp_position, :region_sample, :region2vct,
:region_srate, :forget_region].each_with_index do |n, i|
if (tag = Snd.catch do snd_func(n, arg) end).first != :wrong_type_arg
@@ -36756,7 +34943,7 @@ def test_28_01
end
end
end
- [:region_chans, :region_home, :region_frames, :region_position,
+ [:region_chans, :region_home, :region_framples, :region_position,
:region_maxamp, :region_maxamp_position, :region_srate,
:forget_region].each_with_index do |n, i|
if (tag = Snd.catch do snd_func(n, integer2region(1234)) end).first != :no_such_region
@@ -36765,26 +34952,26 @@ def test_28_01
end
[:enved_filter_order, :enved_filter, :filter_control_waveform_color,
:ask_before_overwrite, :auto_resize, :auto_update, :axis_label_font,
- :axis_numbers_font, :basic_color, :show_full_duration, :initial_beg, :initial_dur,
- :channel_style, :color_cutoff, :color_inverted, :color_scale, :cursor_color,
+ :axis_numbers_font, :basic_color, :show_full_duration, :show_full_range, :initial_beg,
+ :initial_dur, :channel_style, :color_cutoff, :color_inverted, :color_scale, :cursor_color,
:dac_combines_channels, :dac_size, :clipping, :data_color,
- :default_output_chans, :default_output_data_format, :default_output_srate,
+ :default_output_chans, :default_output_sample_type, :default_output_srate,
:default_output_header_type, :enved_envelope, :enved_base, :enved_clip?,
:enved_in_dB, :enved_style, :enved_power, :enved_target,
:enved_waveform_color, :enved_wave?, :eps_file, :eps_left_margin,
:eps_bottom_margin, :eps_size, :foreground_color, :graph_color, :graph_cursor,
:highlight_color, :just_sounds, :listener_color, :listener_font,
:listener_prompt, :listener_text_color, :max_regions,
- :minibuffer_history_length, :mix_waveform_height, :region_graph_style,
+ :mix_waveform_height, :region_graph_style,
:position_color, :time_graph_style, :lisp_graph_style, :transform_graph_style,
- :peaks_font, :bold_peaks_font, :view_files_sort, :print_length, :play_arrow_size,
+ :peaks_font, :bold_peaks_font, :print_length, :play_arrow_size,
:sash_color, :ladspa_dir, :peak_env_dir, :save_dir, :save_state_file, :selected_channel,
:selected_data_color, :selected_graph_color, :selected_sound,
:selection_creates_region, :show_controls, :show_indices,
:show_listener, :show_selection_transform, :sinc_width, :temp_dir,
- :text_focus_color, :tiny_font, :trap_segfault, :with_file_monitor,
- :with_verbose_cursor,
- :with_inset_graph, :with_pointer_focus, :window_height, :beats_per_measure, :with_smpte_label,
+ :text_focus_color, :tiny_font, :with_file_monitor,
+ :with_verbose_cursor, :with_inset_graph, :with_interrupts, :with_pointer_focus,
+ :window_height, :beats_per_measure, :with_smpte_label,
:with_toolbar, :with_tooltips, :with_menu_icons, :remember_sound_state,
:save_as_dialog_src, :save_as_dialog_auto_comment, :window_width, :window_x, :window_y, :with_gl,
:with_mix_tags, :x_axis_style, :beats_per_minute, :zoom_color, :mix_tag_height,
@@ -36799,67 +34986,76 @@ def test_28_01
:mix_release_hook, :save_hook, :before_save_as_hook, :after_save_as_hook,
:save_state_hook, :new_sound_hook, :mus_error_hook, :mouse_enter_graph_hook,
:mouse_leave_graph_hook, :open_raw_sound_hook, :select_channel_hook,
- :output_name_hook, :peak_env_hook, :after_open_hook, :close_hook, :draw_mark_hook,
+ :after_open_hook, :close_hook, :draw_mark_hook,
:draw_mix_hook, :mark_click_hook, :listener_click_hook, :mix_click_hook,
- :after_save_state_hook, :before_save_state_hook, :mark_hook, :mark_drag_hook,
- :mix_drag_hook, :name_click_hook, :after_apply_controls_hook,
- :open_hook, :output_comment_hook, :help_hook, :play_hook, :dac_hook,
- :new_widget_hook, :read_hook, :bad_header_hook, :snd_error_hook,
- :snd_warning_hook, :start_hook, :start_playing_hook, :stop_playing_hook,
- :mouse_enter_listener_hook, :mouse_leave_listener_hook,
- :select_sound_hook, :view_files_select_hook,
- :during_open_hook, :after_transform_hook, :mouse_enter_label_hook,
- :mouse_leave_label_hook, :initial_graph_hook, :graph_hook, :key_press_hook,
- :mouse_drag_hook, :mouse_press_hook, :mouse_click_hook, :enved_hook].each_with_index do |n, i|
+ :after_save_state_hook, :before_save_state_hook, :mark_hook,
+ :mark_drag_hook, :mix_drag_hook, :name_click_hook,
+ :after_apply_controls_hook, :open_hook, :output_comment_hook,
+ :help_hook, :play_hook, :new_widget_hook, :read_hook, :bad_header_hook,
+ :snd_error_hook, :snd_warning_hook, :start_playing_hook,
+ :stop_playing_hook, :mouse_enter_listener_hook, :mouse_leave_listener_hook,
+ :select_sound_hook, :during_open_hook, :after_transform_hook,
+ :mouse_enter_label_hook, :mouse_leave_label_hook, :initial_graph_hook,
+ :graph_hook, :key_press_hook, :mouse_drag_hook, :mouse_press_hook,
+ :mouse_click_hook, :enved_hook].each_with_index do |n, i|
hook = eval("$#{n}")
fnc = lambda do || 1 + 2 end
- if (tag = Snd.catch do hook.add_hook!("test28-1", &fnc) end).first != :wrong_type_arg
+ tag = Snd.catch do hook.add_hook!("test28-1", &fnc) end
+ if tag.first != :wrong_type_arg
snd_display("%s: hooks (1) %s: %s", i, n, tag)
end
end
- [:exit_hook, :stop_dac_hook, :stop_playing_selection_hook,
- :color_hook, :orientation_hook, :start_playing_selection_hook].each_with_index do |n, i|
+ [:exit_hook, :stop_playing_selection_hook, :color_hook,
+ :orientation_hook, :start_playing_selection_hook].each_with_index do |n, i|
hook = eval("$#{n}")
fnc = lambda do |a, b, c| a + b + c end
- if (tag = Snd.catch do hook.add_hook!("test28-2", &fnc) end).first != :wrong_type_arg
+ tag = Snd.catch do hook.add_hook!("test28-2", &fnc) end
+ if tag.first != :wrong_type_arg
snd_display("%s: hooks (2) %s: %s", i, n, tag)
end
end
end
def test_28_02
- not_an_env = nil # otherwise name_error: no such variable or function
+ # XXX: 'not_an_env = nil' otherwise name_error: no such variable or function
+ not_an_env = nil
check_error_tag(:no_such_envelope) do set_enved_envelope("not_an_env") end
check_error_tag(:cannot_save) do save_envelopes("/bad/baddy") end
- check_error_tag(:cannot_save) do save_macros("/bad/baddy") end
check_error_tag(:cannot_save) do mus_sound_report_cache("/bad/baddy") end
- check_error_tag(:bad_arity) do set_search_procedure(lambda do |a, b, c| a end) end
- check_error_tag(:no_such_sound) do set_search_procedure(1234, lambda do |a| a end) end
+ check_error_tag(:bad_arity) do
+ set_search_procedure(lambda do |a, b, c| a end)
+ end
check_error_tag(:no_such_channel) do make_sampler(0, "oboe.snd", 1) end
check_error_tag(:no_such_channel) do make_sampler(0, "oboe.snd", -1) end
check_error_tag(:bad_arity) do
bind_key(key_to_int(?p), 0, lambda do |a, b| play_often([1, a].max) end)
end
check_error_tag(:bad_arity) do set_zoom_focus_style(lambda do |a| 0 end) end
- check_error_tag(:wrong_type_arg) do
- mus_mix("oboe.snd", "pistol.snd", 0, 12, 0, make_mixer(1, 1.0), "a string")
- end
- check_error_tag(:bad_header) do mus_mix("oboe.snd", $sf_dir + "bad_chans.aifc") end
- check_error_tag(:mus_error) do mus_mix("oboe.snd", $sf_dir + "bad_length.aifc") end
- check_error_tag(:bad_header) do mus_mix($sf_dir + "bad_chans.aifc", "oboe.snd") end
check_error_tag(:no_such_sound) do set_sound_loop_info(123, [0, 0, 1, 1]) end
check_error_tag(:bad_header) do
- new_sound("fmv.snd", Mus_nist, Mus_bfloat, 22050, 2, "this is a comment")
+ new_sound("fmv.snd", 2, 22050, Mus_bfloat, Mus_nist, "this is a comment")
end
check_error_tag(:wrong_type_arg) do player_home(123) end
check_error_tag(:no_such_file) do set_temp_dir("/hiho") end
check_error_tag(:no_such_file) do set_save_dir("/hiho") end
- check_error_tag(:out_of_range) do snd_transform(integer2transform(20), make_vct(4)) end
- check_error_tag(:bad_header) do mus_sound_maxamp($sf_dir + "bad_chans.snd") end
- check_error_tag(:bad_header) do set_mus_sound_maxamp($sf_dir + "bad_chans.snd", [0.0, 0.0]) end
- check_error_tag(:mus_error) do make_iir_filter(:order, 32, :ycoeffs, make_vct(4)) end
- check_error_tag(:mus_error) do make_iir_filter(:coeffs, make_vct(4), :ycoeffs, make_vct(4)) end
- check_error_tag(:mus_error) do make_iir_filter(:coeffs, make_vct(4), :xcoeffs, make_vct(4)) end
+ check_error_tag(:out_of_range) do
+ snd_transform(integer2transform(20), make_vct(4))
+ end
+ check_error_tag(:bad_header) do
+ mus_sound_maxamp($sf_dir + "bad_chans.snd")
+ end
+ check_error_tag(:bad_header) do
+ set_mus_sound_maxamp($sf_dir + "bad_chans.snd", [0.0, 0.0])
+ end
+ check_error_tag(:mus_error) do
+ make_iir_filter(:order, 32, :ycoeffs, make_vct(4))
+ end
+ check_error_tag(:mus_error) do
+ make_iir_filter(:coeffs, make_vct(4), :ycoeffs, make_vct(4))
+ end
+ check_error_tag(:mus_error) do
+ make_iir_filter(:coeffs, make_vct(4), :xcoeffs, make_vct(4))
+ end
check_error_tag(:out_of_range) do make_table_lookup(:size, 123456789) end
check_error_tag(:out_of_range) do make_granulate(:ramp, -0.5) end
check_error_tag(:out_of_range) do make_granulate(:ramp, 1.5) end
@@ -36871,35 +35067,41 @@ def test_28_02
check_error_tag(:out_of_range) do make_readin("oboe.snd", :size, -1) end
check_error_tag(:out_of_range) do make_file2sample("oboe.snd", 0) end
check_error_tag(:out_of_range) do make_file2sample("oboe.snd", -1) end
- check_error_tag(:out_of_range) do make_file2frame("oboe.snd", 0) end
- check_error_tag(:out_of_range) do make_file2frame("oboe.snd", -1) end
- check_error_tag(:out_of_range) do set_default_output_data_format(-1) end
- check_error_tag(:out_of_range) do set_default_output_header_type(Mus_soundfont) end
- check_error_tag(:mus_error) do mus_sound_chans($sf_dir + "bad_location.nist") end
+ check_error_tag(:out_of_range) do make_file2frample("oboe.snd", 0) end
+ check_error_tag(:out_of_range) do make_file2frample("oboe.snd", -1) end
+ check_error_tag(:out_of_range) do set_default_output_sample_type(-1) end
+ check_error_tag(:out_of_range) do
+ set_default_output_header_type(Mus_soundfont)
+ end
+ check_error_tag(:mus_error) do
+ mus_sound_chans($sf_dir + "bad_location.nist")
+ end
check_error_tag(:mus_error) do mus_sound_chans($sf_dir + "bad_field.nist") end
if $with_test_motif
check_error_tag(:no_such_widget) do widget_position([:Widget, 0]) end
check_error_tag(:no_such_widget) do widget_size([:Widget, 0]) end
check_error_tag(:no_such_widget) do widget_text([:Widget, 0]) end
- check_error_tag(:no_such_widget) do set_widget_position([:Widget, 0], [0, 0]) end
- check_error_tag(:no_such_widget) do set_widget_size([:Widget, 0], [10, 10]) end
- check_error_tag(:no_such_widget) do set_widget_text([:Widget, 0], "hiho") end
+ check_error_tag(:no_such_widget) do
+ set_widget_position([:Widget, 0], [0, 0])
+ end
+ check_error_tag(:no_such_widget) do
+ set_widget_size([:Widget, 0], [10, 10])
+ end
+ check_error_tag(:no_such_widget) do
+ set_widget_text([:Widget, 0], "hiho")
+ end
end
check_error_tag(:no_such_menu) do main_menu(-1) end
check_error_tag(:no_such_menu) do main_menu(111) end
- check_error_tag(:out_of_range) do new_sound("hiho", 123) end
- check_error_tag(:out_of_range) do new_sound("hiho", Mus_nist, 123) end
- check_error_tag(:bad_header) do new_sound("hiho", Mus_nist, Mus_bfloat) end
- check_error_tag(:out_of_range) do make_sound_data(0, 1) end
- check_error_tag(:out_of_range) do make_sound_data(-2, 1) end
- check_error_tag(:out_of_range) do make_sound_data(1, -1) end
- check_error_tag(:out_of_range) do make_sound_data(1, 0) end
- check_error_tag(:out_of_range) do mus_sound_close_output(0, 1) end
- check_error_tag(:out_of_range) do mus_sound_close_output(1, 1) end
- check_error_tag(:out_of_range) do mus_sound_close_output(2, 1) end
- check_error_tag(:out_of_range) do mus_sound_close_input(0) end
- check_error_tag(:out_of_range) do mus_sound_close_input(1) end
- check_error_tag(:out_of_range) do mus_sound_close_input(2) end
+ check_error_tag(:out_of_range) do
+ new_sound("hiho", :header_type, 123)
+ end
+ check_error_tag(:out_of_range) do
+ new_sound("hiho", :header_type, Mus_nist, :sample_type, 123)
+ end
+ check_error_tag(:bad_header) do
+ new_sound("hiho", :header_type, Mus_nist, :sample_type, Mus_bfloat)
+ end
check_error_tag(:out_of_range) do set_mus_array_print_length(-1) end
check_error_tag(:out_of_range) do set_print_length(-1) end
check_error_tag(:out_of_range) do set_play_arrow_size(-1) end
@@ -36914,21 +35116,21 @@ def test_28_02
select_all
check_error_tag(:mus_error) do save_selection("sel0.snd", :not_a_key, 3) end
check_error_tag(:wrong_type_arg) do read_only([ind]) end
- check_error_tag(:wrong_type_arg) do frames(ind, [0]) end
+ check_error_tag(:wrong_type_arg) do framples(ind, [0]) end
check_error_tag(:wrong_type_arg) do smooth_sound(0, -10) end
check_error_tag(:no_such_channel) do mix_selection(0, ind, 123) end
check_error_tag(:no_such_channel) do insert_selection(0, ind, 123) end
check_error_tag(:out_of_range) do set_channels(ind, 0) end
- check_error_tag(:out_of_range) do set_channels(ind, -1) end
+ check_error_tag(:wrong_type_arg) do set_channels(ind, -1) end
check_error_tag(:out_of_range) do set_channels(ind, 12340) end
- check_error_tag(:out_of_range) do set_data_format(ind, 12340) end
+ check_error_tag(:out_of_range) do set_sample_type(ind, 12340) end
check_error_tag(:out_of_range) do set_header_type(ind, 12340) end
check_error_tag(:out_of_range) do set_srate(ind, 0) end
- check_error_tag(:out_of_range) do set_data_location(ind, -1) end
- check_error_tag(:out_of_range) do set_data_size(ind, -1) end
+ check_error_tag(:wrong_type_arg) do set_data_location(ind, -1) end
+ check_error_tag(:wrong_type_arg) do set_data_size(ind, -1) end
check_error_tag(:no_such_sample) do set_sample(-1, -1) end
check_error_tag(:no_such_sample) do sample(-1) end
- check_error_tag(:out_of_range) do set_frames(-10) end
+ check_error_tag(:out_of_range) do set_framples(-10) end
check_error_tag(:out_of_range) do set_min_dB(0.0) end
check_error_tag(:out_of_range) do set_min_dB(0.0, ind, 0) end
check_error_tag(:out_of_range) do start_playing(1, -22) end
@@ -36939,7 +35141,9 @@ def test_28_02
check_error_tag(:out_of_range) do
set_filter_control_envelope([0.0, 1.0, 0.1, 1.1, 1.0, 0.0], ind)
end
- check_error_tag(:env_error) do filter_sound([0, 0, 0.1, 0.1, 0.05, 0.1, 1, 1], 32) end
+ check_error_tag(:env_error) do
+ filter_sound([0, 0, 0.1, 0.1, 0.05, 0.1, 1, 1], 32)
+ end
check_error_tag(:out_of_range) do apply_controls(ind, 123) end
check_error_tag(:out_of_range) do set_speed_control_bounds([0.0, 2.0]) end
check_error_tag(:out_of_range) do set_expand_control_bounds([0.0, 2.0]) end
@@ -36947,33 +35151,72 @@ def test_28_02
check_error_tag(:out_of_range) do set_expand_control_bounds([2.0, 0.0]) end
check_error_tag(:bad_header) do insert_sound($sf_dir + "bad_chans.snd") end
check_error_tag(:io_error) do convolve_with($sf_dir + "bad_chans.snd") end
- check_error_tag(:cannot_save) do save_sound_as("hiho.snd", ind, -12) end
- check_error_tag(:cannot_save) do save_sound_as("hiho.snd", ind, Mus_next, -12) end
- check_error_tag(:cannot_save) do save_sound_as("test.snd", ind, Mus_nist, Mus_bdouble) end
- check_error_tag(:cannot_save) do save_sound_as("test.snd", ind, Mus_aifc, Mus_lfloat) end
- check_error_tag(:cannot_save) do save_sound_as("test.snd", ind, Mus_riff, Mus_bshort) end
- check_error_tag(:cannot_save) do save_sound_as("test.snd", ind, Mus_voc, Mus_bshort) end
- check_error_tag(:cannot_save) do save_selection("test.snd", Mus_riff, Mus_bshort) end
- check_error_tag(:cannot_save) do save_selection("test.snd", Mus_voc, Mus_bshort) end
- check_error_tag(:no_data) do draw_lines([]) end
- check_error_tag(:bad_length) do draw_lines([1, 2, 3]) end
- check_error_tag(:out_of_range) do src_channel(make_env([0, 0, 1, 1], :length, 11)) end
- check_error_tag(:out_of_range) do src_channel(make_env([0, 1, 1, 0], :length, 11)) end
- check_error_tag(:out_of_range) do src_channel(make_env([0, 1, 1, -1], :length, 11)) end
- check_error_tag(:out_of_range) do src_channel(make_env([0, -1, 1, 1], :length, 11)) end
- check_error_tag(:out_of_range) do src_sound(make_env([0, 0, 1, 1], :length, 11)) end
- check_error_tag(:out_of_range) do src_sound(make_env([0, 1, 1, 0], :length, 11)) end
- check_error_tag(:out_of_range) do src_sound(make_env([0, 1, 1, -1], :length, 11)) end
- check_error_tag(:out_of_range) do src_sound(make_env([0, -1, 1, 1], :length, 11)) end
- check_error_tag(:mus_error) do make_readin(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) end
+ check_error_tag(:cannot_save) do
+ save_sound_as("hiho.snd", ind, -12)
+ end
+ check_error_tag(:cannot_save) do
+ save_sound_as("hiho.snd", ind,
+ :header_type, Mus_next, :sample_type, -12)
+ end
+ check_error_tag(:cannot_save) do
+ save_sound_as("test.snd", ind,
+ :header_type, Mus_nist, :sample_type, Mus_bdouble)
+ end
+ check_error_tag(:cannot_save) do
+ save_sound_as("test.snd", ind,
+ :header_type, Mus_aifc, :sample_type, Mus_lfloat)
+ end
+ check_error_tag(:cannot_save) do
+ save_sound_as("test.snd", ind,
+ :header_type, Mus_riff, :sample_type, Mus_bshort)
+ end
+ check_error_tag(:cannot_save) do
+ save_sound_as("test.snd", ind,
+ :header_type, Mus_voc, :sample_type, Mus_bshort)
+ end
+ check_error_tag(:cannot_save) do
+ save_selection("test.snd", 22050, Mus_bshort, Mus_riff)
+ end
+ check_error_tag(:cannot_save) do
+ save_selection("test.snd", 22050, Mus_bshort, Mus_voc)
+ end
+ check_error_tag(:out_of_range) do
+ src_channel(make_env([0, 0, 1, 1], :length, 11))
+ end
+ check_error_tag(:out_of_range) do
+ src_channel(make_env([0, 1, 1, 0], :length, 11))
+ end
+ check_error_tag(:out_of_range) do
+ src_channel(make_env([0, 1, 1, -1], :length, 11))
+ end
+ check_error_tag(:out_of_range) do
+ src_channel(make_env([0, -1, 1, 1], :length, 11))
+ end
+ check_error_tag(:out_of_range) do
+ src_sound(make_env([0, 0, 1, 1], :length, 11))
+ end
+ check_error_tag(:out_of_range) do
+ src_sound(make_env([0, 1, 1, 0], :length, 11))
+ end
+ check_error_tag(:out_of_range) do
+ src_sound(make_env([0, 1, 1, -1], :length, 11))
+ end
+ check_error_tag(:out_of_range) do
+ src_sound(make_env([0, -1, 1, 1], :length, 11))
+ end
+ check_error_tag(:mus_error) do
+ make_readin(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
+ end
check_error_tag(:out_of_range) do filter_sound($vct_3, 32) end
check_error_tag(:out_of_range) do filter_sound([0, 0, 1, 1], 0) end
check_error_tag(:no_such_sound) do swap_channels(ind, 0, 12345, 0) end
- check_error_tag(:no_such_sample) do mix_vct(vct(0.1, 0.2, 0.3), -1, ind, 0, true) end
+ check_error_tag(:no_such_sample) do
+ mix_vct(vct(0.1, 0.2, 0.3), -1, ind, 0, true)
+ end
check_error_tag(:out_of_range) do snd_spectrum(Vct.new(8), 0, -123) end
check_error_tag(:out_of_range) do snd_spectrum(Vct.new(8), 0, 0) end
check_error_tag(:no_such_file) do play("/baddy/hiho") end
- check_error_tag(:bad_format) do play($sf_dir + "nist-shortpack.wav") end
+ check_error_tag(:bad_sample_type) do play($sf_dir + "nist-shortpack.wav") end
check_error_tag(:no_such_sound) do play(123, 0) end
check_error_tag(:no_such_channel) do make_player(ind, 123) end
check_error_tag(:no_such_file) do mix("/baddy/hiho") end
@@ -36982,17 +35225,23 @@ def test_28_02
check_error_tag(:no_such_file) do insert_sound("/baddy/hiho.snd") end
check_error_tag(:no_such_file) do insert_samples(0, 10, "/baddy/hiho.snd") end
check_error_tag(:no_data) do set_filter_control_envelope([], ind) end
- check_error_tag(:out_of_range) do set_data_format(ind, 123) end
+ check_error_tag(:out_of_range) do set_sample_type(ind, 123) end
check_error_tag(:out_of_range) do set_header_type(ind, 123) end
check_error_tag(:no_such_channel) do set_selected_channel(ind, 123) end
- check_error_tag(:bad_arity) do set_search_procedure(ind, lambda do |a, b, c| true end) end
+ check_error_tag(:bad_arity) do
+ set_search_procedure(lambda do |a, b, c| true end)
+ end
check_error_tag(:bad_arity) do map_chan(lambda do |a, b, c| 1.0 end) end
- check_error_tag(:bad_arity) do scan_chan(lambda do |a, b, c| 1.0 end) end
- check_error_tag(:bad_arity) do set_cursor_style(lambda do |a| 32 end, ind, 0) end
- check_error_tag(:bad_arity) do find_channel(lambda do | | 1.0 end) end
- check_error_tag(:bad_arity) do count_matches(lambda do | | 1.0 end) end
- check_error_tag(:no_such_graphics_context) do draw_line(0, 0, 1, 1, ind, 0, 1234) end
- check_error_tag(:no_such_graphics_context) do foreground_color(ind, 0, 1234) end
+ check_error_tag(:bad_arity) do scan_channel(lambda do |a, b, c| 1.0 end) end
+ check_error_tag(:bad_arity) do
+ set_cursor_style(lambda do |a| 32 end, ind, 0)
+ end
+ check_error_tag(:no_such_graphics_context) do
+ draw_line(0, 0, 1, 1, ind, 0, 1234)
+ end
+ check_error_tag(:no_such_graphics_context) do
+ foreground_color(ind, 0, 1234)
+ end
check_error_tag(:no_such_graphics_context) do current_font(ind, 0, 1234) end
check_error_tag(:no_such_graphics_context) do
graph_data([$vct_3, $vct_3], ind, 0, 1234, 0, 1, 0)
@@ -37003,10 +35252,12 @@ def test_28_02
check_error_tag(:no_such_axis) do y2position(100, ind, 0, 1234) end
check_error_tag(:no_such_axis) do axis_info(ind, 0, 1234) end
check_error_tag(:out_of_range) do
- draw_axes(channel_widgets.car, snd_gcs.car, "hiho", 0.0, 1.0, -1.0, 1.0, X_axis_in_seconds,1234)
+ draw_axes(channel_widgets.car, snd_gcs.car, "hiho",
+ 0.0, 1.0, -1.0, 1.0, X_axis_in_seconds,1234)
end
check_error_tag(:out_of_range) do
- draw_axes(channel_widgets.car, snd_gcs.car, "hiho", 0.0, 1.0, -1.0, 1.0, 1234)
+ draw_axes(channel_widgets.car, snd_gcs.car, "hiho",
+ 0.0, 1.0, -1.0, 1.0, 1234)
end
check_error_tag(:no_such_channel) do axis_info(ind, 1234) end
check_error_tag(:no_such_sound) do axis_info(1234) end
@@ -37014,25 +35265,35 @@ def test_28_02
check_error_tag(:out_of_range) do set_x_bounds([0.1, -0.1]) end
check_error_tag(:out_of_range) do make_region(100, 0) end
check_error_tag(:no_such_sample) do delete_sample(-1) end
- check_error_tag(:no_such_sample) do delete_sample(2 * frames(ind)) end
+ check_error_tag(:no_such_sample) do delete_sample(2 * framples(ind)) end
regions.empty? and make_region(0, 100)
check_error_tag(:no_such_channel) do region_sample(regions.car, 0, 1234) end
- check_error_tag(:no_such_channel) do region_frames(regions.car, 1234) end
+ check_error_tag(:no_such_channel) do region_framples(regions.car, 1234) end
check_error_tag(:no_such_channel) do region_position(regions.car, 1234) end
check_error_tag(:no_such_channel) do region2vct(regions.car, 0, 1, 1234) end
check_error_tag(:cannot_save) do save_sound_as("/bad/baddy.snd") end
check_error_tag(:no_such_sound) do transform_sample(0, 1, 1234) end
check_error_tag(:no_such_channel) do transform_sample(0, 1, ind, 1234) end
- check_error_tag(:no_such_sound) do graph(vct(0, 1), "hi", 0, 1, 0, 1, 1234) end
- check_error_tag(:no_such_channel) do graph(vct(0, 1), "hi", 0, 1, 0, 1, ind, 1234) end
+ check_error_tag(:no_such_sound) do
+ graph(vct(0, 1), "hi", 0, 1, 0, 1, 1234)
+ end
+ check_error_tag(:no_such_channel) do
+ graph(vct(0, 1), "hi", 0, 1, 0, 1, ind, 1234)
+ end
set_selection_member?(false, true)
- check_error_tag(:no_active_selection) do filter_selection(vct(0, 0, 1, 1), 4) end
+ check_error_tag(:no_active_selection) do
+ filter_selection(vct(0, 0, 1, 1), 4)
+ end
check_error_tag(:no_active_selection) do save_selection("/bad/baddy.snd") end
check_error_tag(:no_active_selection) do env_selection([0, 0, 1, 1]) end
- check_error_tag(:no_such_region) do save_region(integer2region(1234), "/bad/baddy.snd") end
+ check_error_tag(:no_such_region) do
+ save_region(integer2region(1234), "/bad/baddy.snd")
+ end
make_region(0, 100, ind, 0)
check_error_tag(:cannot_save) do save_selection("/bad/baddy.snd") end
- check_error_tag(:cannot_save) do save_region(regions.car, "/bad/baddy.snd") end
+ check_error_tag(:cannot_save) do
+ save_region(regions.car, "/bad/baddy.snd")
+ end
check_error_tag(:no_such_mix) do make_mix_sampler(integer2mix(1234)) end
check_error_tag(:no_such_sound) do make_region(0, 12, 1234, true) end
set_read_only(true, ind)
@@ -37042,16 +35303,15 @@ def test_28_02
check_error_tag(:no_such_direction) do make_sampler(0, ind, 0, -2) end
check_error_tag(:no_data) do scale_by([]) end
check_error_tag(:no_data) do scale_to([]) end
- check_error_tag(:bad_arity) do prompt_in_minibuffer("hi", lambda do |x, y| x + y end) end
check_error_tag(:no_such_sample) do set_selection_position(-999, ind, 0) end
- check_error_tag(:wrong_type_arg) do set_selection_frames(-999, ind, 0) end
- check_error_tag(:wrong_type_arg) do set_selection_frames(0, ind, 0) end
+ check_error_tag(:wrong_type_arg) do set_selection_framples(-999, ind, 0) end
+ check_error_tag(:wrong_type_arg) do set_selection_framples(0, ind, 0) end
check_error_tag(:no_such_edit) do edit_fragment(-1) end
check_error_tag(:no_such_edit) do edit_fragment(101, ind, 0) end
check_error_tag(:no_such_edit) do edit_tree(ind, 0, -2) end
check_error_tag(:no_such_edit) do edit_tree(ind, 0, 101) end
check_error_tag(:no_such_sample) do add_mark(-1) end
- check_error_tag(:no_such_sample) do add_mark(frames * 2) end
+ check_error_tag(:no_such_sample) do add_mark(framples * 2) end
check_error_tag(:no_such_file) do convolve_with("/bad/baddy") end
check_error_tag(:no_such_file) do mix("/bad/baddy") end
check_error_tag(:no_such_sound) do swap_channels(ind, 0, 123) end
@@ -37068,37 +35328,66 @@ def test_28_02
check_error_tag(:wrong_type_arg) do amp_control([0]) end
check_error_tag(:wrong_type_arg) do sound_loop_info([0]) end
check_error_tag(:wrong_type_arg) do add_mark(123, [0]) end
- check_error_tag(:no_such_sound) do filter_channel([0, 0, 1, 1], 100, false, false, 1234, 0) end
- check_error_tag(:no_such_channel) do filter_channel([0, 0, 1, 1], 100, false, false, ind, 1) end
- check_error_tag(:no_such_channel) do filter_channel(vct(0, 0, 1, 1), 4, false, false, ind, 1) end
+ check_error_tag(:no_such_sound) do
+ filter_channel([0, 0, 1, 1], 100, false, false, 1234, 0)
+ end
+ check_error_tag(:no_such_channel) do
+ filter_channel([0, 0, 1, 1], 100, false, false, ind, 1)
+ end
+ check_error_tag(:no_such_channel) do
+ filter_channel(vct(0, 0, 1, 1), 4, false, false, ind, 1)
+ end
check_error_tag(:out_of_range) do filter_sound(vct(0, 0, 1, 1), 0) end
check_error_tag(:out_of_range) do filter_sound(vct(0, 0, 1, 1), 10) end
- check_error_tag(:out_of_range) do set_reverb_control_length_bounds([0.1, 0.01], ind) end
- check_error_tag(:out_of_range) do set_reverb_control_scale_bounds([0.1, 0.01], ind) end
+ check_error_tag(:out_of_range) do
+ set_reverb_control_length_bounds([0.1, 0.01], ind)
+ end
+ check_error_tag(:out_of_range) do
+ set_reverb_control_scale_bounds([0.1, 0.01], ind)
+ end
check_error_tag(:wrong_type_arg) do scale_by(false) end
- check_error_tag(:wrong_type_arg) do scale_by(make_mixer(2, 0.1, 0.1, 0.2, 0.2)) end
check_error_tag(:wrong_type_arg) do src_sound(3.0, 1.0, true) end
check_error_tag(:wrong_type_arg) do src_sound(3.0, 1.0, ind, true) end
check_error_tag(:no_such_edit) do display_edits(ind, 0, 123) end
check_error_tag(:no_such_edit) do marks(ind, 0, 123) end
- check_error_tag(:no_such_edit) do save_sound_as("test.snd", :edit_position, 123) end
- check_error_tag(:no_such_auto_delete_choice) do insert_sound("1a.snd", 0, 0, ind, 0, 0, 123) end
+ check_error_tag(:no_such_edit) do
+ save_sound_as("test.snd", :edit_position, 123)
+ end
+ check_error_tag(:no_such_auto_delete_choice) do
+ insert_sound("1a.snd", 0, 0, ind, 0, 0, 123)
+ end
close_sound(ind)
- check_error_tag(:bad_arity) do add_transform("hiho", "time", 0, 1, lambda do | | 1.0 end) end
+ check_error_tag(:bad_arity) do
+ add_transform("hiho", "time", 0, 1, lambda do | | 1.0 end)
+ end
check_error_tag(:cannot_save) do save_state("/bad/baddy") end
- check_error_tag(:no_such_menu) do add_to_menu(1234, "hi", lambda do | | false end) end
- check_error_tag(:bad_arity) do add_to_main_menu("hi", lambda do |a, b| false end) end
- check_error_tag(:bad_arity) do add_to_menu(1, "hi", lambda do |a, b| false end) end
- check_error_tag(:wrong_type_arg) do set_transform_type(integer2transform(-1)) end
- check_error_tag(:out_of_range) do set_transform_type(integer2transform(123)) end
+ check_error_tag(:no_such_menu) do
+ add_to_menu(1234, "hi", lambda do | | false end)
+ end
+ check_error_tag(:bad_arity) do
+ add_to_main_menu("hi", lambda do |a, b| false end)
+ end
+ check_error_tag(:bad_arity) do
+ add_to_menu(1, "hi", lambda do |a, b| false end)
+ end
+ check_error_tag(:wrong_type_arg) do
+ set_transform_type(integer2transform(-1))
+ end
+ check_error_tag(:out_of_range) do
+ set_transform_type(integer2transform(123))
+ end
check_error_tag(:wrong_type_arg) do help_dialog([0, 1], "hiho") end
check_error_tag(:wrong_type_arg) do info_dialog([0, 1], "hiho") end
check_error_tag(:no_such_sound) do edit_header_dialog(1234) end
check_error_tag(:no_such_file) do open_sound("/bad/baddy.snd") end
- check_error_tag(:no_such_file) do open_raw_sound("/bad/baddy.snd", 1, 22050, Mus_lshort) end
+ check_error_tag(:no_such_file) do
+ open_raw_sound("/bad/baddy.snd", 1, 22050, Mus_lshort)
+ end
check_error_tag(:no_such_file) do view_sound("/bad/baddy.snd") end
check_error_tag(:no_such_file) do make_sampler(0, "/bad/baddy.snd") end
- check_error_tag(:no_such_region) do make_region_sampler(integer2region(1234567), 0) end
+ check_error_tag(:no_such_region) do
+ make_region_sampler(integer2region(1234567), 0)
+ end
check_error_tag(:no_such_key) do bind_key(12345678, 0, false) end
check_error_tag(:no_such_key) do bind_key(-1, 0, false) end
check_error_tag(:no_such_key) do bind_key(12, 17, false) end
@@ -37107,27 +35396,38 @@ def test_28_02
check_error_tag(:no_such_key) do key_binding(-1, 0) end
check_error_tag(:no_such_key) do key_binding(12, 17) end
check_error_tag(:no_such_key) do key_binding(12, -1) end
- check_error_tag(:bad_header) do file2array($sf_dir + "bad_chans.snd", 0, 0, 123, Vct.new(123)) end
+ check_error_tag(:bad_header) do
+ file2array($sf_dir + "bad_chans.snd", 0, 0, 123, Vct.new(123))
+ end
check_error_tag(:bad_header) do make_readin($sf_dir + "bad_chans.snd") end
check_error_tag(:mus_error) do make_iir_filter(30, Vct.new(3)) end
check_error_tag(:out_of_range) do make_wave_train(:size, 2 ** 30) end
check_error_tag(:out_of_range) do set_mus_srate(0.0) end
check_error_tag(:out_of_range) do set_mus_srate(-1000) end
check_error_tag(:out_of_range) do dot_product(Vct.new(3), Vct.new(3), -1) end
- check_error_tag(:out_of_range) do multiply_arrays(Vct.new(3), Vct.new(3), -1) end
check_error_tag(:out_of_range) do
make_delay(3, :initial_element, 0.0, :initial_contents, vct(0.1, 0.2, 0.3))
end
check_error_tag(:out_of_range) do
make_delay(3, :max_size, 100, :initial_contents, vct(0.1, 0.2, 0.3))
end
- check_error_tag(:out_of_range) do make_table_lookup(:size, 100, :wave, Vct.new(3)) end
- check_error_tag(:out_of_range) do make_wave_train(:size, 100, :wave, Vct.new(3)) end
+ check_error_tag(:out_of_range) do
+ make_table_lookup(:size, 100, :wave, Vct.new(3))
+ end
+ check_error_tag(:out_of_range) do
+ make_wave_train(:size, 100, :wave, Vct.new(3))
+ end
check_error_tag(:out_of_range) do make_ssb_am(100, 12345678) end
- check_error_tag(:mus_error) do make_rand(:envelope, [0, 0, 1, 1], :distribution, Vct.new(10)) end
+ check_error_tag(:mus_error) do
+ make_rand(:envelope, [0, 0, 1, 1], :distribution, Vct.new(10))
+ end
check_error_tag(:mus_error) do make_rand(:envelope, [0, 0, 1]) end
- check_error_tag(:out_of_range) do make_rand(:envelope, [0, 0, 1, 1], :size, -2) end
- check_error_tag(:out_of_range) do make_rand(:envelope, [0, 0, 1, 1], :size, 1234567890) end
+ check_error_tag(:out_of_range) do
+ make_rand(:envelope, [0, 0, 1, 1], :size, -2)
+ end
+ check_error_tag(:out_of_range) do
+ make_rand(:envelope, [0, 0, 1, 1], :size, 1234567890)
+ end
check_error_tag(:bad_arity) do
grn = make_granulate
granulate(grn, false, lambda do |a, s, d| false end)
@@ -37160,35 +35460,37 @@ def test_28_02
f = make_filter(3, :xcoeffs, $vct_3, :ycoeffs, $vct_3)
set_mus_ycoeff(f, 4, 1.0)
end
- check_error_tag(:mus_error) do make_filter(:ycoeffs, Vct.new(4), :order, 12) end
+ check_error_tag(:mus_error) do
+ make_filter(:ycoeffs, Vct.new(4), :order, 12)
+ end
check_error_tag(:mus_error) do
hi = make_oscil
set_mus_offset(hi, 1)
end
check_error_tag(:out_of_range) do make_locsig(:channels, 2 ** 30) end
check_error_tag(:out_of_range) do make_src(:width, 3000) end
- check_error_tag(:out_of_range) do make_frame(-1) end
- check_error_tag(:mus_error) do
- hi = make_frame(2, 0.1, 0.2)
- frame_ref(hi, 3)
+ check_error_tag(:bad_arity) do
+ add_colormap("baddy", lambda do | | false end)
end
- check_error_tag(:out_of_range) do make_scalar_mixer(0, 0.1) end
- check_error_tag(:mus_error) do
- m = make_mixer(2)
- mixer_ref(m, 3, 4)
+ check_error_tag(:bad_arity) do
+ add_colormap("baddy", lambda do |a, b, c| false end)
end
- check_error_tag(:bad_arity) do add_colormap("baddy", lambda do | | false end) end
- check_error_tag(:bad_arity) do add_colormap("baddy", lambda do |a, b, c| false end) end
check_error_tag(:out_of_range) do
sr = make_src(:input, lambda do |dir| 1.0 end)
src(sr, 2000000.0)
end
check_error_tag(:out_of_range) do partials2polynomial([1, 1], -1) end
check_error_tag(:out_of_range) do partials2polynomial([1, 1], 3) end
- check_error_tag(:out_of_range) do make_polyshape(440.0, :partials, [1, 1], :kind, -1) end
- check_error_tag(:out_of_range) do make_polyshape(440.0, :partials, [1, 1], :kind, 3) end
+ check_error_tag(:out_of_range) do
+ make_polyshape(440.0, :partials, [1, 1], :kind, -1)
+ end
+ check_error_tag(:out_of_range) do
+ make_polyshape(440.0, :partials, [1, 1], :kind, 3)
+ end
check_error_tag(:wrong_type_arg) do set_mus_header_raw_defaults(1234) end
- check_error_tag(:wrong_type_arg) do set_mus_header_raw_defaults([44100, 2.123, "hi"]) end
+ check_error_tag(:wrong_type_arg) do
+ set_mus_header_raw_defaults([44100, 2.123, "hi"])
+ end
check_error_tag(:wrong_type_arg) do set_with_toolbar(123) end
check_error_tag(:wrong_type_arg) do set_with_tooltips(123) end
check_error_tag(:wrong_type_arg) do set_with_menu_icons(123) end
@@ -37196,13 +35498,18 @@ def test_28_02
check_error_tag(:wrong_type_arg) do set_save_as_dialog_auto_comment(123) end
check_error_tag(:wrong_type_arg) do set_with_smpte_label(123) end
check_error_tag(:wrong_type_arg) do set_ask_about_unsaved_edits(123) end
- check_error_tag(:no_such_mix) do mix_properties(integer2mix(mix_sync_max + 1)) end
- check_error_tag(:no_such_mix) do set_mix_properties(integer2mix(mix_sync_max + 1), 1) end
+ check_error_tag(:no_such_mix) do
+ mix_properties(integer2mix(mix_sync_max + 1))
+ end
+ check_error_tag(:no_such_mix) do
+ set_mix_properties(integer2mix(mix_sync_max + 1), 1)
+ end
#
if $with_test_motif
[:widget_position, :widget_size, :widget_text,
:hide_widget, :show_widget, :focus_widget].each do |n|
- if (tag = Snd.catch do snd_func(n, [:Widget, 0]) end).first != :no_such_widget
+ tag = Snd.catch do snd_func(n, [:Widget, 0]) end
+ if tag.first != :no_such_widget
snd_display("%s of null widget: %s", n, tag)
end
end
@@ -37229,8 +35536,9 @@ def test_28_03
:make_sawtooth_wave,
:make_rand,
:make_rand_interp].each do |g|
- if (res = Snd.catch do snd_func(g, :frequency, 440.0) end).first != :out_of_range
- snd_display("srate %s: %s -> %s", n, g, res.inspect)
+ tag = Snd.catch do snd_func(g, :frequency, 440.0) end
+ if tag.first != :out_of_range
+ snd_display("srate %s: %s -> %s", n, g, tag.inspect)
end
end
end
@@ -37494,7 +35802,6 @@ def test_28_03
end
end
end
- clear_sincs
stop_playing
dismiss_all_dialogs
end
@@ -37522,7 +35829,6 @@ def test_28_03
end
end
end
- clear_sincs
dismiss_all_dialogs
end
#
@@ -37620,16 +35926,13 @@ def test_28_03
end
end
end
- clear_sincs
dismiss_all_dialogs
end
+ set_ask_about_unsaved_edits(false)
end
def test_28_04
- if defined? mus_audio_reinitialize
- mus_audio_reinitialize
- end
- File.exists?("test.snd") and File.chmod(0644, "test.snd") and File.unlink("test.snd")
+ File.exist?("test.snd") and File.chmod(0644, "test.snd") and File.unlink("test.snd")
file_copy("oboe.snd", "test.snd")
ind = open_sound("test.snd")
delete_file("test.snd")
@@ -37709,18 +36012,16 @@ def test_28
test_28_01
test_28_02
end
- # FIXME
- # with snd-gtk test_28_04 should come before test_28_03 because of:
- # (snd-ruby-xg:2371): Gdk-WARNING **: GdkWindow 0x160015b unexpectedly destroyed
- # ...
- test_28_04
test_28_03
+ test_28_04
end
# ---------------- test all done
def test_30
- test_04_08
+ # $bigtest_08 = true
+ # test_08_24
+ test_28_00
end
main_test