[Cs-dev] f Statement manual page
Date | 2012-02-21 11:14 |
From | peiman khosravi |
Subject | [Cs-dev] f Statement manual page |
Attachments | None None |
Hello, This is really confusing me! Is it saying that when table size is a power of two then an additional index is automatically added to provide the guard point? So table size is always going to be power of two + 1? One confusion is that the first sentence starts with "For arrays whose length is a power of 2" and the second sentence contains "if size is an exact power of 2". So what is the difference between power of two and an exact power of two? Why is 'size' italicised here? Also what is meant by extending the contour of the function? As in continuing in the same direction beyond index N-1? Thanks Peiman
|
Date | 2012-02-21 11:21 |
From | Adam Puckett |
Subject | Re: [Cs-dev] f Statement manual page |
Peiman, Size means the number you write as the fourth argument of the f statement. For example: f1 0 4096 10 1 is a table whose size is an exact power of two. Replacing 4096 with 4097 will make the table have a size of a power of two plus one. I'm not sure, however, what "contour" is. I'll have a look at fgens.c and get back to you if you like. Hope this helps, Adam On 2/21/12, peiman khosravi |
Date | 2012-02-21 11:36 |
From | peiman khosravi |
Subject | Re: [Cs-dev] f Statement manual page |
Attachments | None None |
Hi Adam, On 21 February 2012 11:21, Adam Puckett <adotsdothmusic@gmail.com> wrote: Peiman, Yes understand this but why is it italicised in the manual? (just nitpicking here!)
But my question is, is this done automatically? (replacing the table size with power of two + 1 that is). That's what the manual seems to suggest. Thanks Peiman I'm not sure, however, what "contour" is. I'll have a look at fgens.c |
Date | 2012-02-21 12:08 |
From | Richard Dobson |
Subject | Re: [Cs-dev] f Statement manual page |
Actually, you have pretty much got it. On 21/02/2012 11:14, peiman khosravi wrote: > Hello, > > This is really confusing me! Is it saying that when table size is a > power of two then an additional index is automatically added to provide > the guard point? So table size is always going to be power of two + 1? > Yes. Or rather, now that we have arbitrary-sized tables too, the cases of a power of two size or power of two plus 1 are "special" (unless they have themselves been subverted by the changes). > One confusion is that the first sentence starts with "For arrays whose > length is a power of 2" This should perhaps more precisely (but more verbosely) say: "For arrays whose length is specified as a power of two or a power of two plus 1..." and the second sentence contains "if /size/ is > an exact power of 2". So what is the difference between power of two and > an exact power of two? Why is 'size' /italicised/ here? > Because there it is referring to the GEN "size" argument name, rather than its ordinary semantic meaning. > Also what is meant by extending the contour of the function? As in > continuing in the same direction beyond index N-1? > Yes. For the sake of (a) further interest and (b) more sales(!): I put a standalone example of the Csound ftable oscili code in the Audio Programming Book (DVD Chapter 3); but only considering the periodic waveform lookup with interpolation, not the single-shot usage, which I guess you could say was left as the proverbial exercise. The "guard point" idea is by no means confined to Csound, and in one form or another is very widely used in audio dsp, especially in hardware dsp systems. For higher-order interpolation (cubic, etc), multiple guard points are used, and there are even situations where a lookup table is basically drawn twice, so the number of guard points is the same as the nominal size of the table. It is all in the cause of speed, avoiding lots of conditional tests per sample. With a single oscillator you will not notice the difference, but with 512 of them you will! Richard Dobson ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2012-02-21 12:24 |
From | peiman khosravi |
Subject | Re: [Cs-dev] f Statement manual page |
Attachments | None None |
Thanks Richard, On 21 February 2012 12:08, Richard Dobson <richarddobson@blueyonder.co.uk> wrote: Actually, you have pretty much got it. So just to be really clear if one defines table size as a power-of-two then it will be automatically extended by one guard point? In this case returning the table size in the orchestra would still return the defined power-of-two size but internally the table is processed as power-of-two+1? Then using tab_i with ixmode 1 and a table size of power-of-two should not return an error because of that internally added guard point. I'm sure I'm missing something here!
Yes I see. I hadn't noticed that!
I have the book and it's going to be my summer read! Really looking forward to it. Best, Peiman Richard Dobson |
Date | 2012-02-21 13:02 |
From | Richard Dobson |
Subject | Re: [Cs-dev] f Statement manual page |
On 21/02/2012 12:24, peiman khosravi wrote: .. > So just to be really clear if one defines table size as a power-of-two > then it will be automatically extended by one guard point? In this case > returning the table size in the orchestra would still return the defined > power-of-two size but internally the table is processed as power-of-two+1? > Yes. But we do have to be careful - the guard-point is (I think) strictly an internal construct (e.g. assumes oscili rather than oscil, etc), rather than sometning that should or could be directly addressed by an instrument. > Then using tab_i with ixmode 1 and a table size of power-of-two should > not return an error because of that internally added guard point. I'm > sure I'm missing something here! > I would have to look at the code to see exactly what is done, but I would expect it to return an error, as that extra position is really internal; and even more so with arbitrary-length tables, the behaviour needs to be consietent across all cases. From my recollection, the orchestra itself does not know in what mode the table has been constructed (it just assumes the table has been appropriately specified). In any situation where the table is intended to be periodic (guard point is a copy of the first point), asking for it explicitly is logically/strategically equivalent to asking for the first point. This is a case where we are, for better or worse, exposed to the underlying implementation perhaps a little too generously! The only globally safe default position is, in the orchestra, to treat all tables (etc) as indexed from 0 to size-1, and then just leave Csound to do its clever thing behind the scenes. Anything else is arguably a "hack" with, in the usual way of such things, "undefined' results. Richard Dobson ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2012-02-21 19:22 |
From | peiman khosravi |
Subject | Re: [Cs-dev] f Statement manual page |
Attachments | None None |
Thanks for the explanation Richard. It all makes sense now. It may be a good idea for us to put some of these points in the manual. Best, Peiman On 21 February 2012 13:02, Richard Dobson <richarddobson@blueyonder.co.uk> wrote:
|