<div><br></div><div>Template specialisation. I never know really how to write them.</div><div><br></div><div>For example, I'm writing the template class for fixed point that works like</div><div><br></div><div><div>typedef FixedFP<int32,28> sample_t ;</div>
</div><div><br></div><div>where the first argument is the 'container type' (how we're going to store the fixed point) and the second is the number of bits used for the fractional part</div><div><br></div><div>
When you do a multiply, you need a 'temporary' container that is twice the number of bits from the original container so that if it is int32 it uses int64 if it is int8 uses int16 and so on. </div><div><br></div><div>
There are several ways of doing: on is to re-implement the operator* for each supported type with the typename explicitely stated or to have a mechanism that for one type, gives you the type of the 'expanded containter' type. Both need template specialisation which is fine in theory but, since i'm not 100% template HxC, I can't type it right the first time and need countless iteration before the compiler accepts it :(</div>
<div><br></div><div>At least, now that's sorted, I got my basic class working. I'll need to polish it a bit and add support for operations between FP with variable fractional parts but it's not really though. Then in a few years, I can get Tony to fiddle with multiply dithering.</div>
<div><br></div><div>Now to change every reference of sample_t in my framework and pray it still works :)</div><div><br></div><div>/M</div><div>PS: There's a (overly) extensive description of a FP class here <a href="http://www.codeproject.com/KB/cpp/fp_math.aspx">http://www.codeproject.com/KB/cpp/fp_math.aspx</a> for any one that is willing to scratch it's head very deeply</div>
<div><br></div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
"Thanks" to you I'm going for a template based mechanism.<div><br></div><div>Boy I HATE c++ template syntax :)</div></blockquote></div><div><br><font color="#888888"><br>- Peter <br></font></div></div><br>
<br>_______________________________________________<br>
music-bar mailing list<br>
<a href="mailto:music-bar@lists.music-bar.org">music-bar@lists.music-bar.org</a><br>
<a href="http://lists.music-bar.org/cgi-bin/mailman/listinfo/music-bar" target="_blank">http://lists.music-bar.org/cgi-bin/mailman/listinfo/music-bar</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="http://nostromo.noisepages.com">http://nostromo.noisepages.com</a><br>