<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Hi Joel, I love your idea about a general waveform ugen. Of course there is SndBuf which has rate control and could be looped arbitrarily short.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">The benefit of a dedicated waveform player is that smoothing algorithms could be applied. But after smoothing and filtering the algorithm &nbsp;could be less efficient
 than the trig function. I&#8217;m more of an audio engineer than a programmer, but I would speculate that the reason that a trig function is currently performed on every sample is because the SinOsc is intended to sound good over a wide frequency range. And the
 current chuck SinOsc implementation sounds great from 20Hz to 20Khz. If you were to implement a table look up with a simple interpolation, it will degrade in fidelity if you stray too far from the original sample rate. Complex waveforms are even more critical.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">I don&#8217;t know where the optimal playback smoothing occurs but from experience, the Creative Labs Audigy board used a hardware 8 point interpolation (4 points
 to the left and 4 points to the right) and after buying one some 20 years ago, that was the first time that I thought some of my looped samples with sharp edges played back without that annoying swooshing sound. Some modern software samplers sound good too,
 but I don&#8217;t know what they have internally.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Nat<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;color:windowtext">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;color:windowtext"> chuck-dev-bounces@lists.cs.princeton.edu [mailto:chuck-dev-bounces@lists.cs.princeton.edu]
<b>On Behalf Of </b>Joel Matthys<br>
<b>Sent:</b> Friday, September 18, 2015 8:35 AM<br>
<b>To:</b> chuck-dev@lists.cs.princeton.edu<br>
<b>Subject:</b> EXTERNAL: Re: [chuck-dev] SinOsc calculations<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Spencer.<br>
<br>
I think I would like to work on making a wavetable sine.<br>
<br>
Actually, I think a general wavetable instrument which takes an array might be very useful. Chuck ought to be able to read a user array just as quickly as an internal one, right? So it could be something like:<br>
<br>
Wavetable w =&gt; dac;<br>
w.table(&quot;sine&quot;, 1027); // shape, number of points in array<br>
440 =&gt; w.freq;<br>
week =&gt; now; // sit back and enjoy<br>
<br>
[-1,0,1] @=&gt; float[] mytable;<br>
w.set(mytable);<br>
2::weeks =&gt; now; //even better<br>
<br>
I'll see what I can glean from the RTcmix code (which I think does it really well, and IIRC is pretty close to MusicN wavetable code) and make a Chugin, and then do some tests to compare for efficiency.<br>
<br>
Joel<o:p></o:p></p>
<div>
<p class="MsoNormal">On 09/18/2015 01:20 AM, Spencer Salazar wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">Hi Joel, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Thats correct- SinOsc is just a naive implementation of a sine wave. I don't know that there is a reason for this other than simplicity.&nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">In performance-sensitive situations I have recommended using either MagicSine (if it is not necessary to change the freq/phase rapidly) or Gen9/Gen10, which are sinusoid wavetables.&nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">I have been interested in developing a chugin that is just a really fast/mathematically accurate wavetable sine. If you'd be interested in making something like that, or collaborating on it, that'd be very cool. If we got that in good shape
 we could replace the default sine, if there is no other reason to keep it the way it is.&nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">spencer<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">On Thu, Sep 17, 2015 at 6:52 PM, Joel Matthys &lt;<a href="mailto:jwmatthys@gmail.com" target="_blank">jwmatthys@gmail.com</a>&gt; wrote:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hello! I was looking through the source recently, and I was a little surprised to find that the SinOsc UGen performs a trig function every sample. I was under the impression that most osc implementations use
 a lookup table with interpolation because it's considerably more efficient.<br>
<br>
Was this a specific design decision? Would there be support for revising SinOsc for efficiency if the audible result was indistinguishable?<br>
<br>
Thanks,<br>
Joel<br>
_______________________________________________<br>
chuck-dev mailing list<br>
<a href="mailto:chuck-dev@lists.cs.princeton.edu" target="_blank">chuck-dev@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev</a><br>
<br>
<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Spencer Salazar<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Doctoral Candidate<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Center for Computer Research in Music and Acoustics<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Stanford University<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><a href="mailto:spencer@ccrma.stanford.edu" target="_blank">spencer@ccrma.stanford.edu</a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">&#43;1 831.277.4654<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><a href="https://ccrma.stanford.edu/%7Espencer/" target="_blank"><span style="color:#1155CC">https://ccrma.stanford.edu/~spencer/</span></a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><br>
<br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>chuck-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:chuck-dev@lists.cs.princeton.edu">chuck-dev@lists.cs.princeton.edu</a><o:p></o:p></pre>
<pre><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev">https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>