|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
[sc-dev] question about sc_loop in PlayBufHi
As you probably noticed from my last question I'm trying to build a version of PlayBuf that crossfades both on a trigger and when reaching the end of the buffer. I have it crossfading on trigger, correctly both with positive rate (moving foward) and negative rate (moving back). Now I'm trying to make it crossfade when getting to then end of the buffer, and for that i will need to change my version of the sc_loop function used in PlayBuf. On analysing the function*, i was woundering why it was written like this. For instance, when phase is bigger than the buffer, why doesn't PlayBuf just set the phase to 0 ? Now if i studied the code correctly, the only way that phase can be out of bounds is if the startPos was out of bounds. So if the sc_loop function goes to the trouble of not making a division when possible, why not go even more simple and just set phase to 0 if phase > loopMax and phase = loopMax if phase < 0, and then check the startpos to see if it is out of bounds, in which case set phase to 0. Maybe there is some extra functionality that is enabled in this way that I'm not grasping in the moment. thanks Miguel Negrão * inline double sc_loop(Unit *unit, double in, double hi, int loop) { // avoid the divide if possible if (in >= hi) { if (!loop) { unit->mDone = true; return hi; } in -= hi; if (in < hi) return in; } else if (in < 0.) { if (!loop) { unit->mDone = true; return 0.; } in += hi; if (in >= 0.) return in; } else return in; return in - hi * floor(in/hi); } _______________________________________________ sc-dev mailing list sc-dev@... archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: [sc-dev] question about sc_loop in PlayBufyou could be going backwards for one... the other is that you may not
want the sample 0 (perhaps, if the rate is 2, you need sample 1 when the buffer loops!). josh On Jun 20, 2008, at 5:53 PM, Miguel Negrao wrote: > Hi > > As you probably noticed from my last question I'm trying to build a > version of PlayBuf that crossfades both on a trigger and when > reaching the end of the buffer. > > I have it crossfading on trigger, correctly both with positive rate > (moving foward) and negative rate (moving back). Now I'm trying to > make it crossfade when getting to then end of the buffer, and for > that i will need to change my version of the sc_loop function used > in PlayBuf. > > On analysing the function*, i was woundering why it was written like > this. For instance, when phase is bigger than the buffer, why > doesn't PlayBuf just set the phase to 0 ? Now if i studied the code > correctly, the only way that phase can be out of bounds is if the > startPos was out of bounds. So if the sc_loop function goes to the > trouble of not making a division when possible, why not go even more > simple and just set phase to 0 if phase > loopMax and phase = > loopMax if phase < 0, and then check the startpos to see if it is > out of bounds, in which case set phase to 0. > Maybe there is some extra functionality that is enabled in this way > that I'm not grasping in the moment. > > thanks > > Miguel Negrão > > * > inline double sc_loop(Unit *unit, double in, double hi, int loop) > { > // avoid the divide if possible > if (in >= hi) { > if (!loop) { > unit->mDone = true; > return hi; > } > in -= hi; > if (in < hi) return in; > } else if (in < 0.) { > if (!loop) { > unit->mDone = true; > return 0.; > } > in += hi; > if (in >= 0.) return in; > } else return in; > > return in - hi * floor(in/hi); > } > > _______________________________________________ > sc-dev mailing list > > sc-dev@... > archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ > search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ ****************************************** /* Joshua D. Parmenter http://www.realizedsound.net/josh/ “Every composer – at all times and in all cases – gives his own interpretation of how modern society is structured: whether actively or passively, consciously or unconsciously, he makes choices in this regard. He may be conservative or he may subject himself to continual renewal; or he may strive for a revolutionary, historical or social palingenesis." - Luigi Nono */ _______________________________________________ sc-dev mailing list sc-dev@... archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: [sc-dev] question about sc_loop in PlayBufAh, yes that's right, didn't saw that one.
Miguel Josh Parmenter escreveu: > you could be going backwards for one... the other is that you may not > want the sample 0 (perhaps, if the rate is 2, you need sample 1 when the > buffer loops!). > > josh > > On Jun 20, 2008, at 5:53 PM, Miguel Negrao wrote: > >> Hi >> >> As you probably noticed from my last question I'm trying to build a >> version of PlayBuf that crossfades both on a trigger and when reaching >> the end of the buffer. >> >> I have it crossfading on trigger, correctly both with positive rate >> (moving foward) and negative rate (moving back). Now I'm trying to >> make it crossfade when getting to then end of the buffer, and for that >> i will need to change my version of the sc_loop function used in PlayBuf. >> >> On analysing the function*, i was woundering why it was written like >> this. For instance, when phase is bigger than the buffer, why doesn't >> PlayBuf just set the phase to 0 ? Now if i studied the code correctly, >> the only way that phase can be out of bounds is if the startPos was >> out of bounds. So if the sc_loop function goes to the trouble of not >> making a division when possible, why not go even more simple and just >> set phase to 0 if phase > loopMax and phase = loopMax if phase < 0, >> and then check the startpos to see if it is out of bounds, in which >> case set phase to 0. >> Maybe there is some extra functionality that is enabled in this way >> that I'm not grasping in the moment. >> >> thanks >> >> Miguel Negrão >> >> * >> inline double sc_loop(Unit *unit, double in, double hi, int loop) >> { >> // avoid the divide if possible >> if (in >= hi) { >> if (!loop) { >> unit->mDone = true; >> return hi; >> } >> in -= hi; >> if (in < hi) return in; >> } else if (in < 0.) { >> if (!loop) { >> unit->mDone = true; >> return 0.; >> } >> in += hi; >> if (in >= 0.) return in; >> } else return in; >> >> return in - hi * floor(in/hi); >> } >> >> _______________________________________________ >> sc-dev mailing list >> >> sc-dev@... >> archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ >> search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ > > ****************************************** > /* Joshua D. Parmenter > http://www.realizedsound.net/josh/ > > “Every composer – at all times and in all cases – gives his own > interpretation of how modern society is structured: whether actively or > passively, consciously or unconsciously, he makes choices in this > regard. He may be conservative or he may subject himself to continual > renewal; or he may strive for a revolutionary, historical or social > palingenesis." - Luigi Nono > */ > > > _______________________________________________ > sc-dev mailing list > > sc-dev@... > archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ > search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ > > _______________________________________________ sc-dev mailing list sc-dev@... archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: [sc-dev] question about sc_loop in PlayBufOne more question: how does one handle error messages. Let's say some
parameter is out of bounds, what should a ugen do in that case ? Does he quit with some message (and how is that done) ? What is the usual approach to this ? Miguel Josh Parmenter escreveu: > you could be going backwards for one... the other is that you may not > want the sample 0 (perhaps, if the rate is 2, you need sample 1 when the > buffer loops!). > > josh > > On Jun 20, 2008, at 5:53 PM, Miguel Negrao wrote: > >> Hi >> >> As you probably noticed from my last question I'm trying to build a >> version of PlayBuf that crossfades both on a trigger and when reaching >> the end of the buffer. >> >> I have it crossfading on trigger, correctly both with positive rate >> (moving foward) and negative rate (moving back). Now I'm trying to >> make it crossfade when getting to then end of the buffer, and for that >> i will need to change my version of the sc_loop function used in PlayBuf. >> >> On analysing the function*, i was woundering why it was written like >> this. For instance, when phase is bigger than the buffer, why doesn't >> PlayBuf just set the phase to 0 ? Now if i studied the code correctly, >> the only way that phase can be out of bounds is if the startPos was >> out of bounds. So if the sc_loop function goes to the trouble of not >> making a division when possible, why not go even more simple and just >> set phase to 0 if phase > loopMax and phase = loopMax if phase < 0, >> and then check the startpos to see if it is out of bounds, in which >> case set phase to 0. >> Maybe there is some extra functionality that is enabled in this way >> that I'm not grasping in the moment. >> >> thanks >> >> Miguel Negrão >> >> * >> inline double sc_loop(Unit *unit, double in, double hi, int loop) >> { >> // avoid the divide if possible >> if (in >= hi) { >> if (!loop) { >> unit->mDone = true; >> return hi; >> } >> in -= hi; >> if (in < hi) return in; >> } else if (in < 0.) { >> if (!loop) { >> unit->mDone = true; >> return 0.; >> } >> in += hi; >> if (in >= 0.) return in; >> } else return in; >> >> return in - hi * floor(in/hi); >> } >> >> _______________________________________________ >> sc-dev mailing list >> >> sc-dev@... >> archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ >> search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ > > ****************************************** > /* Joshua D. Parmenter > http://www.realizedsound.net/josh/ > > “Every composer – at all times and in all cases – gives his own > interpretation of how modern society is structured: whether actively or > passively, consciously or unconsciously, he makes choices in this > regard. He may be conservative or he may subject himself to continual > renewal; or he may strive for a revolutionary, historical or social > palingenesis." - Luigi Nono > */ > > > _______________________________________________ > sc-dev mailing list > > sc-dev@... > archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ > search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ > > _______________________________________________ sc-dev mailing list sc-dev@... archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: [sc-dev] question about sc_loop in PlayBufhmm
really? you are aware you are coding ugens right? no baby sitting - have words wrap, no go? tuff luck, look harder. Miguel, isolate the idea in question. flood it with post / printf look deep. good luck, x On Sat, Jun 21, 2008 at 9:31 AM, Miguel Negrao <miguel.negrao@...> wrote: > One more question: how does one handle error messages. Let's say some > parameter is out of bounds, what should a ugen do in that case ? Does he > quit with some message (and how is that done) ? What is the usual approach > to this ? > > Miguel > > Josh Parmenter escreveu: >> >> you could be going backwards for one... the other is that you may not want >> the sample 0 (perhaps, if the rate is 2, you need sample 1 when the buffer >> loops!). >> >> josh >> >> On Jun 20, 2008, at 5:53 PM, Miguel Negrao wrote: >> >>> Hi >>> >>> As you probably noticed from my last question I'm trying to build a >>> version of PlayBuf that crossfades both on a trigger and when reaching the >>> end of the buffer. >>> >>> I have it crossfading on trigger, correctly both with positive rate >>> (moving foward) and negative rate (moving back). Now I'm trying to make it >>> crossfade when getting to then end of the buffer, and for that i will need >>> to change my version of the sc_loop function used in PlayBuf. >>> >>> On analysing the function*, i was woundering why it was written like >>> this. For instance, when phase is bigger than the buffer, why doesn't >>> PlayBuf just set the phase to 0 ? Now if i studied the code correctly, the >>> only way that phase can be out of bounds is if the startPos was out of >>> bounds. So if the sc_loop function goes to the trouble of not making a >>> division when possible, why not go even more simple and just set phase to 0 >>> if phase > loopMax and phase = loopMax if phase < 0, and then check the >>> startpos to see if it is out of bounds, in which case set phase to 0. >>> Maybe there is some extra functionality that is enabled in this way that >>> I'm not grasping in the moment. >>> >>> thanks >>> >>> Miguel Negrão >>> >>> * >>> inline double sc_loop(Unit *unit, double in, double hi, int loop) >>> { >>> // avoid the divide if possible >>> if (in >= hi) { >>> if (!loop) { >>> unit->mDone = true; >>> return hi; >>> } >>> in -= hi; >>> if (in < hi) return in; >>> } else if (in < 0.) { >>> if (!loop) { >>> unit->mDone = true; >>> return 0.; >>> } >>> in += hi; >>> if (in >= 0.) return in; >>> } else return in; >>> return in - hi * floor(in/hi); >>> } >>> >>> _______________________________________________ >>> sc-dev mailing list >>> >>> sc-dev@... >>> archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ >>> search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ >> >> ****************************************** >> /* Joshua D. Parmenter >> http://www.realizedsound.net/josh/ >> >> "Every composer – at all times and in all cases – gives his own >> interpretation of how modern society is structured: whether actively or >> passively, consciously or unconsciously, he makes choices in this regard. He >> may be conservative or he may subject himself to continual renewal; or he >> may strive for a revolutionary, historical or social palingenesis." - Luigi >> Nono >> */ >> >> >> _______________________________________________ >> sc-dev mailing list >> >> sc-dev@... >> archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ >> search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ >> >> > > > _______________________________________________ > sc-dev mailing list > > sc-dev@... > archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ > search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ > _______________________________________________ sc-dev mailing list sc-dev@... archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: [sc-dev] question about sc_loop in PlayBufIt's up to you.
(1) Often, for efficiency's sake, a UGen will not test at all. For example, try using LPF with a cutoff of exactly zero - it'll blow up, rather than handling it gracefully. It's a good idea not to fill up your UGen's calculation function with too many checks, since they'll be run very often. (2) Often a UGen will print a warning and then stop. (FFT and IFFT do this in their ctor, for example, if the supplied buffer is not a usable size.) There's a couple of ways to do this. One way for a UGen to "stop" is to do this: SETCALC(*ClearUnitOutputs); This means that from now onwards, the unit will do nothing but output zeroes (_instead_ of calling your calculation function). (3) If a parameter is out of range (like you mention), often UGens will clip it to the desired range. This is quite user-friendly I guess. Dan 2008/6/21 Miguel Negrao <miguel.negrao@...>: > One more question: how does one handle error messages. Let's say some > parameter is out of bounds, what should a ugen do in that case ? Does he > quit with some message (and how is that done) ? What is the usual approach > to this ? > > Miguel > > Josh Parmenter escreveu: >> >> you could be going backwards for one... the other is that you may not want >> the sample 0 (perhaps, if the rate is 2, you need sample 1 when the buffer >> loops!). >> >> josh >> >> On Jun 20, 2008, at 5:53 PM, Miguel Negrao wrote: >> >>> Hi >>> >>> As you probably noticed from my last question I'm trying to build a >>> version of PlayBuf that crossfades both on a trigger and when reaching the >>> end of the buffer. >>> >>> I have it crossfading on trigger, correctly both with positive rate >>> (moving foward) and negative rate (moving back). Now I'm trying to make it >>> crossfade when getting to then end of the buffer, and for that i will need >>> to change my version of the sc_loop function used in PlayBuf. >>> >>> On analysing the function*, i was woundering why it was written like >>> this. For instance, when phase is bigger than the buffer, why doesn't >>> PlayBuf just set the phase to 0 ? Now if i studied the code correctly, the >>> only way that phase can be out of bounds is if the startPos was out of >>> bounds. So if the sc_loop function goes to the trouble of not making a >>> division when possible, why not go even more simple and just set phase to 0 >>> if phase > loopMax and phase = loopMax if phase < 0, and then check the >>> startpos to see if it is out of bounds, in which case set phase to 0. >>> Maybe there is some extra functionality that is enabled in this way that >>> I'm not grasping in the moment. >>> >>> thanks >>> >>> Miguel Negrão >>> >>> * >>> inline double sc_loop(Unit *unit, double in, double hi, int loop) >>> { >>> // avoid the divide if possible >>> if (in >= hi) { >>> if (!loop) { >>> unit->mDone = true; >>> return hi; >>> } >>> in -= hi; >>> if (in < hi) return in; >>> } else if (in < 0.) { >>> if (!loop) { >>> unit->mDone = true; >>> return 0.; >>> } >>> in += hi; >>> if (in >= 0.) return in; >>> } else return in; >>> return in - hi * floor(in/hi); >>> } >>> >>> _______________________________________________ >>> sc-dev mailing list >>> >>> sc-dev@... >>> archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ >>> search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ >> >> ****************************************** >> /* Joshua D. Parmenter >> http://www.realizedsound.net/josh/ >> >> "Every composer – at all times and in all cases – gives his own >> interpretation of how modern society is structured: whether actively or >> passively, consciously or unconsciously, he makes choices in this regard. He >> may be conservative or he may subject himself to continual renewal; or he >> may strive for a revolutionary, historical or social palingenesis." - Luigi >> Nono >> */ >> >> >> _______________________________________________ >> sc-dev mailing list >> >> sc-dev@... >> archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ >> search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ >> >> > > > _______________________________________________ > sc-dev mailing list > > sc-dev@... > archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ > search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ > -- http://www.mcld.co.uk _______________________________________________ sc-dev mailing list sc-dev@... archive: http://www.listarc.bham.ac.uk/lists/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
| Free Forum Powered by Nabble | Forum Help |