[beast/bug-433531] Added test signal generator.



commit 29feac1539769f258b0eaf0f509082c5b08cf0ad
Author: Stefan Westerfeld <stefan space twc de>
Date:   Wed Mar 3 15:06:58 2010 +0100

    Added test signal generator.

 tools/scripts/Makefile.am |    2 +
 tools/scripts/blip.py     |   76 +++++++++++++++++++++++++++++++++++++++++++++
 tools/scripts/blip.sh     |   44 ++++++++++++++++++++++++++
 3 files changed, 122 insertions(+), 0 deletions(-)
---
diff --git a/tools/scripts/Makefile.am b/tools/scripts/Makefile.am
index c925a44..122728b 100644
--- a/tools/scripts/Makefile.am
+++ b/tools/scripts/Makefile.am
@@ -7,4 +7,6 @@ EXTRA_DIST += $(strip \
 	waveloadtest.scm \
 	noteplaytest.scm \
 	retrokit.sh \
+        blip.py \
+        blip.sh \
 )
diff --git a/tools/scripts/blip.py b/tools/scripts/blip.py
new file mode 100755
index 0000000..5b47459
--- /dev/null
+++ b/tools/scripts/blip.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2010 Stefan Westerfeld, stefan space twc de
+#
+# This software is provided "as is"; redistribution and modification
+# is permitted, provided that the following disclaimer is retained.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# In no event shall the authors or contributors be liable for any
+# direct, indirect, incidental, special, exemplary, or consequential
+# damages (including, but not limited to, procurement of substitute
+# goods or services; loss of use, data, or profits; or business
+# interruption) however caused and on any theory of liability, whether
+# in contract, strict liability, or tort (including negligence or
+# otherwise) arising in any way out of the use of this software, even
+# if advised of the possibility of such damage.
+#
+
+#
+# a test signal generator for beast
+#
+import array
+from math import sin, pi, atan
+
+def pseudo_square (sample_rate, freq):
+  out = array.array ('f')
+  samples = int (sample_rate / freq)
+  for i in range (samples):
+    x = sin (i * pi * 2.0 / samples)
+    x = atan (x * 10) / (pi / 2)
+    out.append (x)
+  print sample_rate * 1.0 / samples
+  return out
+
+def pseudo_saw (sample_rate, freq):
+  out = array.array ('f')
+  samples = int (sample_rate / freq)
+  for i in range (samples):
+    phase = i * 1.0 / samples
+    if phase < 0.9:     # ramp up
+      x = phase / 0.9   # range from  0.0 .. 1.0
+      x = 2 * x - 1     # range from -1.0 .. 1.0
+    else:
+      x = phase - 0.9   # range from 0.0 .. 0.1
+      x = x / 0.1       # range from 0.0 .. 1.0
+      x = -2 * x + 1    # range from 1.0 .. -1.0
+    out.append (x)
+  return out
+
+def interleave (left, right):
+  assert len (left) == len (right)
+
+  out = array.array ('f')
+  for i in range (len (left)):
+    out.append (left[i])
+    out.append (right[i])
+  return out
+
+def repeat (block, n):
+  out = array.array ('f')
+  for i in range (n):
+    for j in range (len (block)):
+      out.append (block[j])
+  return out
+
+out_psq = pseudo_square (48000, 440)
+out_psq.tofile (open ("pseudo_square_440", "w"))
+
+out_psaw = pseudo_saw (48000, 440)
+out_psaw.tofile (open ("pseudo_saw_440", "w"))
+
+#out_psq_psaw = repeat (interleave (out_psq, out_psaw), 50)
+out_psq_psaw = interleave (out_psq, out_psaw)
+out_psq_psaw.tofile (open ("pseudo_stereo_440", "w"))
diff --git a/tools/scripts/blip.sh b/tools/scripts/blip.sh
new file mode 100755
index 0000000..48ed535
--- /dev/null
+++ b/tools/scripts/blip.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Copyright (C) 2010 Stefan Westerfeld, stefan space twc de
+#
+# This software is provided "as is"; redistribution and modification
+# is permitted, provided that the following disclaimer is retained.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# In no event shall the authors or contributors be liable for any
+# direct, indirect, incidental, special, exemplary, or consequential
+# damages (including, but not limited to, procurement of substitute
+# goods or services; loss of use, data, or profits; or business
+# interruption) however caused and on any theory of liability, whether
+# in contract, strict liability, or tort (including negligence or
+# otherwise) arising in any way out of the use of this software, even
+# if advised of the possibility of such damage.
+#
+
+#
+# a test signal generator for beast
+#
+# shell script to convert the output of blip.py to .bsewave files
+#
+blip.py || { echo "creation failed" ; exit 1; }
+rm pseudo_square.bsewave
+bsewavetool create pseudo_square.bsewave 1
+bsewavetool add-raw-chunk pseudo_square.bsewave -f 440.366972477 -F float -R 48000 pseudo_square_440
+LOOP_END=108
+bsewavetool xinfo pseudo_square.bsewave -f440.36 loop-type=jump loop-start=0 loop-end=$LOOP_END loop-count=1000000
+
+rm pseudo_saw.bsewave
+bsewavetool create pseudo_saw.bsewave 1
+bsewavetool add-raw-chunk pseudo_saw.bsewave -f 440.366972477 -F float -R 48000 pseudo_saw_440
+LOOP_END=108
+bsewavetool xinfo pseudo_saw.bsewave -f440.36 loop-type=jump loop-start=0 loop-end=$LOOP_END loop-count=1000000
+
+rm pseudo_stereo.bsewave
+bsewavetool create pseudo_stereo.bsewave 2
+bsewavetool add-raw-chunk pseudo_stereo.bsewave -f 440.366972477 -F float -R 48000 pseudo_stereo_440
+LOOP_END=216
+bsewavetool xinfo pseudo_stereo.bsewave -f440.36 loop-type=jump loop-start=0 loop-end=$LOOP_END loop-count=1000000
+bsewavetool xinfo pseudo_stereo.bsewave --wave play-type=adsr-wave-2



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]