i´ve got a question about robert hencke’s samp~:

http://www.cycling74.com/twiki/bin/view/Share/Monolake

can anybody explain how the inner part (between unpack and pack) of the

p_samp polyobject works?

why sending a zero to mtof and devide 1 by the result?

why multiplying the semitones by -1. ?

thanks, yohannes

]]>If you check the result of sending 0 to mtof you see the frequency is 8.1751799 (or so). This establishes a reference point for pitch ratios. Taking this and dividing 1 by it is simply inverting it so that it can then be multiplied by something else to get a division(multiplication is less expensive on your CPU than division so it was better for him to set any division up in the loadbang initialization and then use a multiplication the rest of the time rather than actually dividing every incoming value by 8.1751799). Using this efficient method of dividing every incoming value by the base value, he then multiplies this ratio by the length of playback in order to adjust the playback speed accordingly.

In order to translate a ratio of pitch bend in MIDI or Hz to a time-length in milliseconds, he also needs to multiply the input MIDI value by -1 because although when speaking of pitch, an increase in value is a pitch up, when speaking of playback speed, an increase in value means an increase in the length of time taken to play back the sample(effectively causing it to pitch down). So by multiplying it by -1, he is making sure that a MIDI-pitch-bend up translates properly into shortening the playback length in milliseconds by the appropriate fractional amount.

This is a way of utilizing pitch-bend that translates from a MIDI pitch ratio, to a length-of-time ratio. Unfortunately, I’m not that familiar with the particular algorithm or where he got it. I’m just amazed with how slick and efficient it is so I figured I’d try my best to explain it. Basically, it’s all about maintaining the proper ratio between two values in two different formats(pitch and time). ]]>

> Well, until someone else answers who is less clumsy than I am with words and knowledge, i’ll give it a shot:

> If you check the result of sending 0 to mtof you see the frequency is 8.1751799 (or so). This establishes a reference point for pitch ratios. Taking this and dividing 1 by it is simply inverting it so that it can then be multiplied by something else to get a division(multiplication is less expensive on your CPU than division so it was better for him to set any division up in the loadbang initialization and then use a multiplication the rest of the time rather than actually dividing every incoming value by 8.1751799). Using this efficient method of dividing every incoming value by the base value, he then multiplies this ratio by the length of playback in order to adjust the playback speed accordingly.

> In order to translate a ratio of pitch bend in MIDI or Hz to a time-length in milliseconds, he also needs to multiply the input MIDI value by -1 because although when speaking of pitch, an increase in value is a pitch up, when speaking of playback speed, an increase in value means an increase in the length of time taken to play back the sample(effectively causing it to pitch down). So by multiplying it by -1, he is making sure that a MIDI-pitch-bend up translates properly into shortening the playback length in milliseconds by the appropriate fractional amount.

> This is a way of utilizing pitch-bend that translates from a MIDI pitch ratio, to a length-of-time ratio. Unfortunately, I’m not that familiar with the particular algorithm or where he got it. I’m just amazed with how slick and efficient it is so I figured I’d try my best to explain it. Basically, it’s all about maintaining the proper ratio between two values in two different formats(pitch and time).

>

>

thanks raja, that helps alot. j ]]>