[linux-audio-user] 2 SAOL questions answered :-)

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-user] 2 SAOL questions answered :-)
From: John Lazzaro (lazzaro_AT_CS.Berkeley.EDU)
Date: Tue Jan 22 2002 - 22:59:45 EET


> Paul Winkler <pw_lists_AT_slinkp.com> writes
>
> f 1 0 2049 -12 20
>
> This draws an unscaled ln(I0(x)) from 0 to 20.
>
> How to generate that in SAOL? There's no equivalent to gen 12 that I
> can see.

Here's an approximation for Io(x), in C code -- the constants are
derived from a series approximation. Should be straightforward to
convert it into a SAOL user-defined opcode; note that since SAOL is
computing using "32-bit floating-point" (the standard ducked the
IEEE-compliance issue to appease the DSP manufacturers ...), you can
probably delete the last few terms.

 double modbessel(double x)
 {
   double sum,a;
   sum = a = 1.0;
   a *= x*x; sum += a*2.5e-1;
   a *= x*x; sum += a*1.5625e-2;
   a *= x*x; sum += a*4.340278e-4;
   a *= x*x; sum += a*6.781684e-6;
   a *= x*x; sum += a*6.781684e-8;
   a *= x*x; sum += a*4.709503e-10;
   a *= x*x; sum += a*2.402808e-12;
   a *= x*x; sum += a*9.385967e-15;
   a *= x*x; sum += a*2.896903e-17;
   a *= x*x; sum += a*7.242258e-20;
   return sum;
 }

> I see hints that it's possible to define your own table generators,

Not exactly, but you can get pretty close; define an empty table, whose
size can be a function of an instr's pfields (and other things known at
instr initiation), and then call a user-defined opcode to fill the table.
For example:

SASL file:
---------

0.25 blast 1 1024
4.50 end

SAOL file:
---------

global {
srate 44100;
}

// fills table with noise

iopcode fill_with_noize(table t, ivar amp, ivar len)

{
  ivar i;

  while (i < len)
    {
      tablewrite(t, i, irand(amp));
      i = i + 1;
    }
}

instr blast(len) {

  table t(empty, len);
  

  // i-rate, generator replacement

  fill_with_noize(t, 0.1, len);

  // loops noise to output

  output(oscil(t, 100));
}

> 2. There's no dcblock opcode. So I figure I'll just use a hipass
> filter with a cutoff freq of 15 Hz. Anybody got a better idea?

If you're intending to stay normative, I'd suggest designing your
own DC blocking filter using (perhaps cascaded) iir(), iirt(),
or biquad() blocks; the hipass() call isn't totally normative
(i.e. different decoders can implement different filter functions,
its one of a handful of "convenience" opcodes that aren't strictly
normative), although the "conformance" document does put some limits
on the filter function shape now, so its not as bad as it sounds ...

> 3. Any idea why the attached saol/sasl compiles but segfaults with a
> coredump when I run it?

I'll take a closer look and report back ...

-------------------------------------------------------------------------
John Lazzaro -- Research Specialist -- CS Division -- EECS -- UC Berkeley
lazzaro [at] cs [dot] berkeley [dot] edu www.cs.berkeley.edu/~lazzaro
-------------------------------------------------------------------------


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Tue Jan 22 2002 - 22:52:56 EET