![]() |
![]() ![]() ![]() ![]() ![]()
|
next newest topic | next oldest topic |
Author | Topic: Updating a variable (constant) |
sarth Member |
![]() ![]() ![]() Hello, anyone know how I can update the value of a "constant" or a "soundtoglobalcontroller" so that the new value = old value + input amount? that doesn't read clearly. hmm, I know how to do it in Perl or Javascipt. j = j + 1; I want to update a notenumber value so that each time I press a key, I get the pitch which is the old pitch plus the amount above (or below) middle C the new key I've pressed is. The existing pitch is shifted by the interval amount above or below middle C my current key press is. Am I making sense? Anyone know how to do this? -- Sarth IP: Logged |
SSC Administrator |
![]() ![]() ![]() If you repeatedly press the same key, should the pitch continue to increment by that amount each time? IP: Logged |
sarth Member |
![]() ![]() ![]() yes. That's what would make this so cool. I actually did a soundtoglobalcontroller with the code !mypitch + !keynumber nn that outputs !mypitch but I am not sure if it was working at all, and if it was, It was infinitely adding the current !keynumber to itself creating an ever upwardly spiraling value. IP: Logged |
sarth Member |
![]() ![]() ![]() yes. That's what would make this so cool. I actually did a soundtoglobalcontroller with the code !mypitch + !keynumber nn that outputs !mypitch but I am not sure if it was working at all, and if it was, It was infinitely adding the current !keynumber to itself creating an ever upwardly spiraling value. IP: Logged |
SSC Administrator |
![]() ![]() ![]() You're right, that should create a loop where the new value of !myPitch is used to compute the *next* new value. You should be able to implement something similar using a MemoryWriter and a Sample. The only tricky part is that Sound inputs and outputs have to lie between -1 and 1, but you can do this easily by dividing and multiplying. For example, your Constant's value parameter could be [theSample] L + (!KeyNumber - 60/ 128) and you would feed the Constant into a MemoryWriter. In the MemoryWriter click Cyclic, and name its memory something, e.g. 'fdbk'. Then edit the Sample and make sure its memory has the same name--fdbk--and check the box called FromMemoryWriter. This sets up the feedback loop. Use a TriggeredSsampleAndHold on the Sample and trigger that with your !KeyDown (to avoid the endless spiralling). Finally, paste the MemoryWriter into the frequency field of the Sound you want to control with the incrementing pitches and multiply it back up into the right range for notenumbers, eg. [theMemWriter] L * 128 nn + 60 nn (This is just off the top of my head, so there may be some details that are missing, but maybe this is enough to get you started) IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() ![]() |
This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.