back to list

Re: Smoothing end-points (was re: Sad symmetric septimal minor tune)

🔗Robert Walker <robertwalker@ntlworld.com>

5/29/2004 5:54:53 PM

Hi Kurt,

> Ah, I see, you are doing it by smoothing the end result, not by adjusting
> the spliced-in section to achieve the desired continuity?

Yes, I think it is probably easier to smooth out the result than to
splice in a spline with all the infinitely many correct derivatives
at the joins.

What you want is a function which has all its derivatives zero at the origin.
You might think that impossible because its taylor series would be
identically zero so it would surely just be a constant function
- indeed you can't have a function which can be given by a taylor series
within any finite radius of convergence - but
such functions do exist, it is just that the taylor series only converges
to the function at a single point.

Here is one:

http://www.shu.edu/projects/reals/cont/fp_cinf.html

g(x) = e^-1/x^2 if x!= 0
= 0 at origin

Then by the product rule if we take
g(x)*h(x) for any function h bounded at the
origin then its derivative
g(x)*h'(x)+g'(x)*h(x)
is zero, and indeed all its derivatives are zero
at the origin once more.

So if our function is f(x) we want to smooth out
f(x) at the origin and let K*x be a line
at the intermediate slope between the two gradients
for F for 0- and 0+

Just use
k*x + g(x)*(f(x)-k*x)

Then it's derivative at the origin is k
and all its other derivatives are 0.

I used that for the quarter waves
as it was easy to do with the
average slope for the two curves
as 0 there.

Could do it for the complete
waveform too, but you would have to
add in a cubic or something and multiply
two copies of this function with the infinitely
many zero derivatives together with it,
(2 copies, one with shifted x values) - or something like
that - in order to get both ends working.

But actually I was lazy there and did
another method for the complete wave
It just smooths out the first derivative
and probably not the others, but it gives decent
results which is the main thing in a practical
situation like this.

A couple of screen shots:

http://www.robertinventor.com/waveform_before_smoothing.png
http://www.robertinventor.com/waveform_after_smoothing.png

> Maybe we should talk about getting FTS ported to the Mac? How much of the
> code is user-interface and how much of it is sythesis and other
> implementation, and how well are these aspects separated out? If there was
> a quick-and-dirty way to do it it might be worth it. Just a thought. Not
> that I have any time for it at the moment or in the next year! ;)

Thanks for the thought.

Some parts are well separated out. The code for generating the waveforms
just calls a number of routines to fill a buffer with waveform audio
data. So that could be ported to any platform. Ditto for
the equation parsing e.g. for the heavyside functions etc.
Indeed one could make that part of the code into
a console app version that did all that fairly easiily
and it would be multi-platfrom code surely, only
standard c routines. Maybe output in .RAW format
(just the waveform data) and input all the user
variables from a file or something. Not saying that
I plan to do that, but it could be done.

The GUI, writing the waveform to file in the .WAV riff format,
and playing the audio are all coded using many Windows routines and the
Windows architectures, and I'd be surprised if it could
be ported easily. So anyone contemplating the port would
need to code for all that.

Easiest though is to use FTS with Virtual PC.
Several users now use FTS on Macs like that
and report that it works fine.

Unfortunately though I don't know if one
can get a trial version of Virtual PC any more
now that it has been taken over by Windows - one
may have to purchase it to try it out.

The best way to write a platform indpendent app is
set out to do that from the start and write it using
one of the tools for that such as GtK as Manuel does.
I may give that a go some time in the future with some
small program to see how it goes (probably not this year
yet).

Thanks,

Robert

🔗Kurt Bigler <kkb@breathsense.com>

5/29/2004 8:08:06 PM

on 5/29/04 5:54 PM, Robert Walker <robertwalker@ntlworld.com> wrote:

> Hi Kurt,
>
>> Ah, I see, you are doing it by smoothing the end result, not by adjusting
>> the spliced-in section to achieve the desired continuity?
>
> Yes, I think it is probably easier to smooth

Easier, I'm sure. But you're doing the work so I don't need it to be easy.
;)

But more to the point the result is just different. Smoothing the entire
result rather directly reduces the higher harmonic content, less so to the
degree the smoothing method has some inherent nonlinearity. My curiousity
was what if you take the curve the user specified *unmodified* and join it
to itself by some splicing curve. Change the duty cycle (whatever you want
to call it) and listen to the result. I used to do this with electronics
using waveforms that mostly had square edges and it gives effects akin to
filter sweeps but much more interesting. It need not necessarily be dynamic
(e.g. shaped by an envelope or by a modulation input) but if it can be, all
the better.

> out the result than to
> splice in a spline with all the infinitely many correct derivatives
> at the joins.

Don't need infinitely many correct derivatives, just a specified limited
number, with possibly special solution cases offered for particular lower
limits.

Hey, we're probably OT, but unfortunately I'm not on tuning-math.

> What you want is a function which has all its derivatives zero at the origin.

I can't figure out why you would want that.

> You might think that impossible because its taylor series would be
> identically zero so it would surely just be a constant function
> - indeed you can't have a function which can be given by a taylor series
> within any finite radius of convergence - but
> such functions do exist, it is just that the taylor series only converges
> to the function at a single point.
>
> Here is one:
>
> http://www.shu.edu/projects/reals/cont/fp_cinf.html

That's a very interesting one. All the movement is hiding away from 0, you
might say.

> But actually I was lazy there and did
> another method for the complete wave
> It just smooths out the first derivative
> and probably not the others, but it gives decent
> results which is the main thing in a practical
> situation like this.

There you go.

> A couple of screen shots:
>
> http://www.robertinventor.com/waveform_before_smoothing.png
> http://www.robertinventor.com/waveform_after_smoothing.png

Well there you probably haven't lost too many harmonics for that particular
case.

>> Maybe we should talk about getting FTS ported to the Mac? How much of the
>> code is user-interface and how much of it is sythesis and other
>> implementation, and how well are these aspects separated out? If there was
>> a quick-and-dirty way to do it it might be worth it. Just a thought. Not
>> that I have any time for it at the moment or in the next year! ;)
>
> Thanks for the thought.
>
> Some parts are well separated out. The code for generating the waveforms
> just calls a number of routines to fill a buffer with waveform audio
> data. So that could be ported to any platform. Ditto for
> the equation parsing e.g. for the heavyside functions etc.
> Indeed one could make that part of the code into
> a console app version that did all that fairly easiily
> and it would be multi-platfrom code surely, only
> standard c routines. Maybe output in .RAW format
> (just the waveform data) and input all the user
> variables from a file or something. Not saying that
> I plan to do that, but it could be done.

Well tell me how many customer's you have and multiply by a market-share
factor for Mac, and we'll see whether its worth it. ;)

> The GUI, writing the waveform to file in the .WAV riff format,
> and playing the audio are all coded using many Windows routines and the
> Windows architectures, and I'd be surprised if it could
> be ported easily.

Nah, I've cleaned up and ported all kinds of junk. I often take the
strategy of simulating the original platform and that's less hard than you'd
imagine in many cases.

> So anyone contemplating the port would
> need to code for all that.
>
> Easiest though is to use FTS with Virtual PC.
> Several users now use FTS on Macs like that
> and report that it works fine.

Ah, that's interesting. I don't have Virtual PC yet.

> Unfortunately though I don't know if one
> can get a trial version of Virtual PC any more
> now that it has been taken over by Windows - one
> may have to purchase it to try it out.

I could probably acquire a trial version one way or the other, so to speak.
I'd want it to be able to use my non-built-in audio output devices.
Presumably Virtual PC would let you select your output device, though.

> The best way to write a platform indpendent app is
> set out to do that from the start and write it using
> one of the tools for that such as GtK as Manuel does.

Well, unfortunately gtk currently gets ported to MacOS X via the X-Windows
platform which is a slightly ugly result, although better than nothing. A
native OSX gtk target is planned but is probably years off.

> I may give that a go some time in the future with some
> small program to see how it goes (probably not this year
> yet).

Yea, you might want to wait for the OSX-native gtk. There is an OSX native
tcl/tk, recently finished, FWIW:

http://tcltkaqua.sourceforge.net

But I don't know what can and can't be done with tcl/tk.

-Kurt

>
> Thanks,
>
> Robert

🔗Robert Walker <robertwalker@ntlworld.com>

5/30/2004 8:56:36 AM

Hi Kurt,

I let the user set the amount of the smoothing.
So if it is say 1% then only a little bit of the
curve at the ends gets smoothed very strongly.
So it still looks like a pretty sharp corner at
the join. If it is say 80% then much of the curve
gets smoothed and e.g. in sin(1/x^2) the ripples
will all get so small as to be invisible.

The reason for wanting the derivatives all zero
at the origin is because then when you multiply
it by any other function, the result has all
its derivatives zero there too, whatever the
slope of the other function (if bounded)
even if the other function has discontinuous
derivatives, so the result is going to be smooth.

> Well tell me how many customer's you have and multiply by a market-share
> factor for Mac, and we'll see whether its worth it. ;)

Not worth it financially. Only because one wants
to do it out of ones own enthusiasm for the work.

If I were to write a synth of soft synth based
on these waveform ideas for Windows as a separate
program I'd feel very happy indeed if I got
as much as $200 a year for it. (unless it was
so really excellent that it became one of the
three or four top soft synths
in the market). So for the Mac, guestimate,
maybe $20 a year. Very rough estimate.

Sorry, I don't happen to know whether you
can select your output device in Virtual PC
but would be surprised if you can't.

Yes one thing about native written programs
for a platform is that they tend to have a
more polished GUI.

But GtK is looking pretty good for
Windows now indeed, with some neat features
you don't have in Windows programs even
- particularly the way it handles
window resizing logic.

thanks,

Robert