From 8342ab77f5be792054a9168ef3c0494dbee99ce5 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 2 Nov 2006 00:27:23 +0000 Subject: use branch hints small fixes update for new flext callback naming updated docs svn path=/trunk/; revision=6211 --- externals/grill/xsample/source/groove.cpp | 68 +++++++++++++++---------------- externals/grill/xsample/source/inter.cpp | 2 +- externals/grill/xsample/source/inter.h | 32 +++++++-------- externals/grill/xsample/source/main.cpp | 20 ++++----- externals/grill/xsample/source/main.h | 2 +- externals/grill/xsample/source/play.cpp | 4 +- externals/grill/xsample/source/record.cpp | 14 +++---- 7 files changed, 71 insertions(+), 71 deletions(-) (limited to 'externals/grill/xsample/source') diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp index 2a7cbeec..fd899275 100644 --- a/externals/grill/xsample/source/groove.cpp +++ b/externals/grill/xsample/source/groove.cpp @@ -1,7 +1,7 @@ /* xsample - extended sample objects for Max/MSP and pd (pure data) -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) +Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. */ @@ -36,11 +36,11 @@ public: void m_pos(float pos) { - setpos(s2u?pos/s2u:0); + setpos(LIKELY(s2u)?pos/s2u:0); Update(xsc_pos,true); } - inline void m_posmod(float pos) { setposmod(pos?pos/s2u:0); } // motivated by Tim Blechmann + inline void m_posmod(float pos) { setposmod(LIKELY(pos)?pos/s2u:0); } // motivated by Tim Blechmann inline void mg_pos(float &v) const { v = curpos*s2u; } @@ -87,8 +87,8 @@ protected: inline void setpos(double pos) { - if(pos < znsmin) curpos = znsmin; - else if(pos > znsmax) curpos = znsmax; + if(UNLIKELY(pos < znsmin)) curpos = znsmin; + else if(UNLIKELY(pos > znsmax)) curpos = znsmax; else curpos = pos; } @@ -208,7 +208,7 @@ xgroove::xgroove(int argc,const t_atom *argv): #if FLEXT_SYS == FLEXT_SYS_MAX // old-style command line? - if(argi == 1 && argc == 2 && CanbeInt(argv[argi])) { + if(UNLIKELY(argi == 1 && argc == 2 && CanbeInt(argv[argi]))) { outchns = GetAInt(argv[argi]); argi++; post("%s: old style command line detected - please change to '%s [channels] [buffer]'",thisName(),thisName()); @@ -259,13 +259,13 @@ void xgroove::ms_xzone(float xz) { ChkBuffer(true); - _xzone = (xz < 0 || !s2u)?0:xz/s2u; + _xzone = (UNLIKELY(xz < 0) || UNLIKELY(!s2u))?0:xz/s2u; Update(xsc_fade,true); } void xgroove::ms_xshape(int sh) { - if(sh < 0 || sh > xss_hsine) sh = xss_lin; + if(UNLIKELY(sh < 0) || UNLIKELY(sh > xss_hsine)) sh = xss_lin; xshape = (xs_shape)sh; switch(xshape) { @@ -300,14 +300,14 @@ void xgroove::s_pos_once(int n,t_sample *const *invecs,t_sample *const *outvecs) const double smin = curmin,smax = curmax,plen = smax-smin; - if(plen > 0) { + if(LIKELY(plen > 0)) { register double o = curpos; for(int i = 0; i < n; ++i) { const t_sample spd = speed[i]; // must be first because the vector is reused for output! - if(!(o < smax)) { o = smax; lpbang = true; } - else if(o < smin) { o = smin; lpbang = true; } + if(UNLIKELY(!(o < smax))) { o = smax; lpbang = true; } + else if(UNLIKELY(o < smin)) { o = smin; lpbang = true; } pos[i] = o; o += spd; @@ -322,7 +322,7 @@ void xgroove::s_pos_once(int n,t_sample *const *invecs,t_sample *const *outvecs) else s_pos_off(n,invecs,outvecs); - if(lpbang) ToOutBang(outchns+3); + if(UNLIKELY(lpbang)) ToOutBang(outchns+3); } void xgroove::s_pos_loop(int n,t_sample *const *invecs,t_sample *const *outvecs) @@ -338,19 +338,19 @@ void xgroove::s_pos_loop(int n,t_sample *const *invecs,t_sample *const *outvecs) const double smin = curmin,smax = curmax,plen = smax-smin; - if(plen > 0) { + if(LIKELY(plen > 0)) { register double o = curpos; - if(wrap && smin < 0 && smax >= buf.Frames()) { + if(wrap && UNLIKELY(smin < 0) && UNLIKELY(smax >= buf.Frames())) { for(int i = 0; i < n; ++i) { const t_sample spd = speed[i]; // must be first because the vector is reused for output! // normalize offset - if(!(o < smax)) { // faster than o >= smax + if(UNLIKELY(!(o < smax))) { // faster than o >= smax o = fmod(o-smin,plen)+smin; lpbang = true; } - else if(o < smin) { + else if(UNLIKELY(o < smin)) { o = fmod(o-smin,plen)+smax; lpbang = true; } @@ -365,11 +365,11 @@ void xgroove::s_pos_loop(int n,t_sample *const *invecs,t_sample *const *outvecs) const t_sample spd = speed[i]; // must be first because the vector is reused for output! // normalize offset - if(!(o < smax)) { // faster than o >= smax + if(UNLIKELY(!(o < smax))) { // faster than o >= smax o = fmod(o-smin,plen)+smin; lpbang = true; } - else if(o < smin) { + else if(UNLIKELY(o < smin)) { o = fmod(o-smin,plen)+smax; lpbang = true; } @@ -393,7 +393,7 @@ void xgroove::s_pos_loop(int n,t_sample *const *invecs,t_sample *const *outvecs) vec_dss(0); #endif - if(lpbang) ToOutBang(outchns+3); + if(UNLIKELY(lpbang)) ToOutBang(outchns+3); } void xgroove::s_pos_loopzn(int n,t_sample *const *invecs,t_sample *const *outvecs) @@ -414,7 +414,7 @@ void xgroove::s_pos_loopzn(int n,t_sample *const *invecs,t_sample *const *outvec // hack -> set curmin/curmax to loop extremes so that sampling functions (playfun) don't get confused curmin = smin,curmax = smax; - if(plen > 0) { + if(LIKELY(plen > 0)) { bool inzn = false; register double o = curpos; @@ -424,16 +424,16 @@ void xgroove::s_pos_loopzn(int n,t_sample *const *invecs,t_sample *const *outvec for(int i = 0; i < n; ++i) { // normalize offset - if(o < smin) { + if(UNLIKELY(o < smin)) { o = fmod(o-smin,plen)+smax; lpbang = true; } - else if(!(o < smax)) { + else if(UNLIKELY(!(o < smax))) { o = fmod(o-smin,plen)+smin; lpbang = true; } - if(o < lmin) { + if(UNLIKELY(o < lmin)) { register float inp; if(o < lmin2) { // in first half of early cross-fade zone @@ -456,7 +456,7 @@ void xgroove::s_pos_loopzn(int n,t_sample *const *invecs,t_sample *const *outvec znidx[i] = inp*xf; inzn = true; } - else if(!(o < lmax)) { + else if(UNLIKELY(!(o < lmax))) { register float inp; if(!(o < lmax2)) { // in second half of late cross-fade zone @@ -494,7 +494,7 @@ void xgroove::s_pos_loopzn(int n,t_sample *const *invecs,t_sample *const *outvec // rescale position vector arrscale(n,pos,pos); - if(inzn) { + if(UNLIKELY(inzn)) { // only if we have touched the cross-fade zone // calculate samples in loop zone (2nd voice) @@ -520,7 +520,7 @@ void xgroove::s_pos_loopzn(int n,t_sample *const *invecs,t_sample *const *outvec curmin = cmin,curmax = cmax; - if(lpbang) ToOutBang(outchns+3); + if(UNLIKELY(lpbang)) ToOutBang(outchns+3); } void xgroove::s_pos_bidir(int n,t_sample *const *invecs,t_sample *const *outvecs) @@ -531,7 +531,7 @@ void xgroove::s_pos_bidir(int n,t_sample *const *invecs,t_sample *const *outvecs const int smin = curmin,smax = curmax,plen = smax-smin; - if(plen > 0) { + if(LIKELY(plen > 0)) { register double o = curpos; register float bd = bidir; @@ -540,12 +540,12 @@ void xgroove::s_pos_bidir(int n,t_sample *const *invecs,t_sample *const *outvecs // normalize offset // \todo at the moment fmod doesn't take bidirectionality into account!! - if(!(o < smax)) { + if(UNLIKELY(!(o < smax))) { o = smax-fmod(o-smax,plen); // mirror the position at smax bd = -bd; lpbang = true; } - else if(o < smin) { + else if(UNLIKELY(o < smin)) { o = smin+fmod(smin-o,plen); // mirror the position at smin bd = -bd; lpbang = true; @@ -565,14 +565,14 @@ void xgroove::s_pos_bidir(int n,t_sample *const *invecs,t_sample *const *outvecs else s_pos_off(n,invecs,outvecs); - if(lpbang) ToOutBang(outchns+3); + if(UNLIKELY(lpbang)) ToOutBang(outchns+3); } void xgroove::CbSignal() { int ret = ChkBuffer(true); - if(ret) { + if(LIKELY(ret)) { FLEXT_ASSERT(buf.Valid()); const lock_t l = Lock(); @@ -655,10 +655,10 @@ void xgroove::DoUpdate(unsigned int flags) bool xgroove::do_xzone() { // \todo do we really need this? - if(!s2u) return false; // this can happen if DSP is off + if(UNLIKELY(!s2u)) return false; // this can happen if DSP is off const long frames = buf.Frames(); - if(!frames) return false; + if(UNLIKELY(!frames)) return false; xzone = _xzone; // make a copy for changing it @@ -756,7 +756,7 @@ bool xgroove::do_xzone() void xgroove::m_help() { post("%s - part of xsample objects, version " XSAMPLE_VERSION,thisName()); - post("(C) Thomas Grill, 2001-2005"); + post("(C) Thomas Grill, 2001-2006"); #if FLEXT_SYS == FLEXT_SYS_MAX post("Arguments: %s [channels=1] [buffer]",thisName()); #else diff --git a/externals/grill/xsample/source/inter.cpp b/externals/grill/xsample/source/inter.cpp index 418726fc..1f70b79f 100644 --- a/externals/grill/xsample/source/inter.cpp +++ b/externals/grill/xsample/source/inter.cpp @@ -1,7 +1,7 @@ /* xsample - extended sample objects for Max/MSP and pd (pure data) -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) +Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. */ diff --git a/externals/grill/xsample/source/inter.h b/externals/grill/xsample/source/inter.h index d0ab3994..5ee87b90 100755 --- a/externals/grill/xsample/source/inter.h +++ b/externals/grill/xsample/source/inter.h @@ -1,7 +1,7 @@ /* xsample - extended sample objects for Max/MSP and pd (pure data) -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) +Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. */ @@ -26,7 +26,7 @@ TMPLDEF void xinter::st_play1(const t_sample *bdt,const int smin,const int smax, // no interpolation // ---------------- - if(smin == smax) { + if(UNLIKELY(smin == smax)) { // zero loop length -> assume that smin is a valid sample position... int ci; @@ -40,8 +40,8 @@ TMPLDEF void xinter::st_play1(const t_sample *bdt,const int smin,const int smax, register long oint = CASTINT(*(pos++)); // for xplay oint can be out of bounds -> check - if(oint >= smin) - if(oint < smax) { + if(LIKELY(oint >= smin)) + if(LIKELY(oint < smax)) { // normal *(sig0++) = bdt[oint*BCHNS]; } @@ -61,8 +61,8 @@ TMPLDEF void xinter::st_play1(const t_sample *bdt,const int smin,const int smax, register const t_sample *fp; // for xplay oint can be out of bounds -> check - if(oint >= smin) - if(oint < smax) { + if(LIKELY(oint >= smin)) + if(LIKELY(oint < smax)) { // normal fp = bdt+oint*BCHNS; } @@ -87,7 +87,7 @@ TMPLDEF void xinter::st_play1(const t_sample *bdt,const int smin,const int smax, TMPLDEF void xinter::st_play2(const t_sample *bdt,const int smin,const int smax,const int n,const int inchns,const int outchns,t_sample *const *invecs,t_sample *const *outvecs,bool looped) { const int plen = smax-smin; - if(plen < 2) { + if(UNLIKELY(plen < 2)) { st_play1 TMPLCALL (bdt,smin,smax,n,inchns,outchns,invecs,outvecs,looped); return; } @@ -111,8 +111,8 @@ TMPLDEF void xinter::st_play2(const t_sample *bdt,const int smin,const int smax, const float frac = o-oint; t_sample fp0,fp1; - if(oint >= smin) - if(oint < maxo) { + if(LIKELY(oint >= smin)) + if(LIKELY(oint < maxo)) { // normal interpolation fp0 = bdt[oint*BCHNS]; fp1 = bdt[(oint+1)*BCHNS]; @@ -148,8 +148,8 @@ TMPLDEF void xinter::st_play2(const t_sample *bdt,const int smin,const int smax, const t_sample *fp0,*fp1; const float frac = o-oint; - if(oint >= smin) - if(oint < maxo) { + if(LIKELY(oint >= smin)) + if(LIKELY(oint < maxo)) { // normal interpolation fp0 = bdt+oint*BCHNS; fp1 = fp0+BCHNS; @@ -187,7 +187,7 @@ TMPLDEF void xinter::st_play2(const t_sample *bdt,const int smin,const int smax, TMPLDEF void xinter::st_play4(const t_sample *bdt,const int smin,const int smax,const int n,const int inchns,const int outchns,t_sample *const *invecs,t_sample *const *outvecs,bool looped) { const int plen = smax-smin; //curlen; - if(plen < 4) { + if(UNLIKELY(plen < 4)) { if(plen < 2) st_play1 TMPLCALL (bdt,smin,smax,n,inchns,outchns,invecs,outvecs,looped); else st_play2 TMPLCALL (bdt,smin,smax,n,inchns,outchns,invecs,outvecs,looped); return; @@ -212,8 +212,8 @@ TMPLDEF void xinter::st_play4(const t_sample *bdt,const int smin,const int smax, const float frac = o-oint; register const t_sample *ptr = bdt+oint*BCHNS; - if(oint > smin) { - if(oint < maxo-2) { + if(LIKELY(oint > smin)) { + if(LIKELY(oint < maxo-2)) { // normal case fa = ptr[-BCHNS]; fb = ptr[0]; @@ -306,8 +306,8 @@ looped1: register const t_sample *ptr = bdt+oint*BCHNS; register const t_sample *fa,*fb,*fc,*fd; - if(oint > smin) - if(oint < maxo-2) { + if(LIKELY(oint > smin)) + if(LIKELY(oint < maxo-2)) { // normal case fb = ptr; fa = fb-BCHNS; diff --git a/externals/grill/xsample/source/main.cpp b/externals/grill/xsample/source/main.cpp index c62df461..7c8bd9d2 100644 --- a/externals/grill/xsample/source/main.cpp +++ b/externals/grill/xsample/source/main.cpp @@ -1,7 +1,7 @@ /* xsample - extended sample objects for Max/MSP and pd (pure data) -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) +Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. */ @@ -16,7 +16,7 @@ static void xsample_main() flext::post("xsample objects, version " XSAMPLE_VERSION); flext::post(""); flext::post(" xrecord~, xplay~, xgroove~ "); - flext::post(" (C)2001-2005 Thomas Grill "); + flext::post(" (C)2001-2006 Thomas Grill "); #ifdef FLEXT_DEBUG flext::post(""); flext::post("DEBUG BUILD - " __DATE__ " " __TIME__); @@ -74,7 +74,7 @@ int xsample::ChkBuffer(bool refresh) { if(!buf.Ok()) return 0; - if(buf.Update()) { + if(UNLIKELY(buf.Update())) { #ifdef FLEXT_DEBUG post("%s - buffer update!",thisName()); #endif @@ -100,7 +100,7 @@ void xsample::m_set(int argc,const t_atom *argv) { const t_symbol *sym = argc >= 1?GetASymbol(argv[0]):NULL; int r = buf.Set(sym); - if(sym && r < 0) + if(LIKELY(sym) && UNLIKELY(r < 0)) post("%s - can't find buffer %s",thisName(),GetString(sym)); Update(xsc_buffer,true); } @@ -109,12 +109,12 @@ void xsample::m_min(float mn) { int ret = ChkBuffer(true); - if(ret && s2u) { + if(LIKELY(ret) && LIKELY(s2u)) { long cmn = CASTINT(mn/s2u+0.5f); // conversion to samples - if(cmn < 0) + if(UNLIKELY(cmn < 0)) curmin = 0; - else if(cmn > curmax) + else if(UNLIKELY(cmn > curmax)) curmin = curmax; else curmin = cmn; @@ -127,12 +127,12 @@ void xsample::m_max(float mx) { int ret = ChkBuffer(true); - if(ret && s2u) { + if(LIKELY(ret) && LIKELY(s2u)) { long cmx = CASTINT(mx/s2u+0.5f); // conversion to samples - if(cmx > buf.Frames()) + if(UNLIKELY(cmx > buf.Frames())) curmax = buf.Frames(); - else if(cmx < curmin) + else if(UNLIKELY(cmx < curmin)) curmax = curmin; else curmax = cmx; diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h index 9d9f94b8..ec2218d3 100644 --- a/externals/grill/xsample/source/main.h +++ b/externals/grill/xsample/source/main.h @@ -1,7 +1,7 @@ /* xsample - extended sample objects for Max/MSP and pd (pure data) -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) +Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. */ diff --git a/externals/grill/xsample/source/play.cpp b/externals/grill/xsample/source/play.cpp index 69f37cc3..f3fdaab1 100644 --- a/externals/grill/xsample/source/play.cpp +++ b/externals/grill/xsample/source/play.cpp @@ -1,7 +1,7 @@ /* xsample - extended sample objects for Max/MSP and pd (pure data) -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) +Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. */ @@ -117,7 +117,7 @@ void xplay::m_help() #ifdef FLEXT_DEBUG post("compiled on " __DATE__ " " __TIME__); #endif - post("(C) Thomas Grill, 2001-2005"); + post("(C) Thomas Grill, 2001-2006"); #if FLEXT_SYS == FLEXT_SYS_MAX post("Arguments: %s [channels=1] [buffer]",thisName()); #else diff --git a/externals/grill/xsample/source/record.cpp b/externals/grill/xsample/source/record.cpp index 92738a2e..b8c8a9b0 100644 --- a/externals/grill/xsample/source/record.cpp +++ b/externals/grill/xsample/source/record.cpp @@ -1,7 +1,7 @@ /* xsample - extended sample objects for Max/MSP and pd (pure data) -Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org) +Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. */ @@ -25,7 +25,7 @@ public: void m_pos(float pos) { - curpos = pos?CASTINT(pos/s2u+.5):0; + curpos = LIKELY(pos)?CASTINT(pos/s2u+.5):0; Update(xsc_pos); Refresh(); } @@ -210,11 +210,11 @@ TMPLDEF void xrecord::s_rec(int n,t_sample *const *invecs,t_sample *const *outve if(o < curmin) o = curmin; - if(dorec && curmax > curmin) { + if(dorec && LIKELY(curmax > curmin)) { while(n) { long ncur = curmax-o; // at max to buffer or recording end - if(ncur <= 0) { // end of buffer + if(UNLIKELY(ncur <= 0)) { // end of buffer if(doloop) { ncur = curmax-(o = curmin); } @@ -227,9 +227,9 @@ TMPLDEF void xrecord::s_rec(int n,t_sample *const *invecs,t_sample *const *outve lpbang = true; } - if(!dorec) break; + if(UNLIKELY(!dorec)) break; - if(ncur > n) ncur = n; + if(UNLIKELY(ncur > n)) ncur = n; register int i; register t_sample *bf = buf.Data()+o*BCHNS; @@ -452,7 +452,7 @@ void xrecord::m_help() #ifdef FLEXT_DEBUG post("compiled on " __DATE__ " " __TIME__); #endif - post("(C) Thomas Grill, 2001-2005"); + post("(C) Thomas Grill, 2001-2006"); #if FLEXT_SYS == FLEXT_SYS_MAX post("Arguments: %s [channels=1] [buffer]",thisName()); #else -- cgit v1.2.1