[ANSWERED] Reverse Direction of a Wave Generator?
-
Is there any way to reverse the direction of a wave generator? I have a patch where I'm reversing the playback of some videos on demand, and it would be helpful to also be able to reverse some of the modulation I'm doing at the same time. This might be more of a feature request, but I wanted to pick the community's brain and see if it was possible through some combination of actors first. Thanks in advance!
JP
-
i've done this before like this:
the issue is when the direction changes, the value jumps, unless you change direction exactly at '50'.
-
@dbini Thank you for the response! That's what I've landed on for now as well, but ran into that same issue. I'm trying to have it be more of a smooth rewind and avoid the jumping effect. I feel like there has to be some combination of math and storing previous values that can do it but I can't wrap my brain around it. I appreciate the help anyway.
-
Hi,
You can use the "Limit-Scale Value" actor by changing the output (out min- out max). I hope this helps.
Best -
@jandraka Thank you for the response! I believe this has the same issue with the value jump that I'm running into with my other methods. What I want is for the direction of the wave generated to reverse. Think of it like the wave is on a timeline and I'm trying to hit the rewind button. So if I have a sine wave going 80 - 90 - 100 and I hit my reverse trigger it should start from the same value that I hit the trigger on and go 100 - 90 - 80 from there. Let me know if I can clarify further!
-
@jpg-wav possibly use the Envelope Generator ++ Actor with trig mode set to one/ind, in conjunction with a Trigger Value Actor you can control when each segment of the wave shape progress forward and hence changes the playback speed of the movie. This way you can design your wave / timeline. What do you think?
Best wishes, Simon
-
This post is deleted! -
@Paz Thank you for your response!
I really appreciate everyone's help and patience, I feel like I might be causing confusion by overexplaining myself while attempting to clarify what I want. Reversing video already works fine in my patch, just using a selector and some math. What I'm looking for is a way to smoothly reverse the values coming from, say, a sine wave generator. So that if I have, for example, a sine wave generator hooked up to translate a shape along the X axis, I can reverse that motion at an arbitrary point in time and have not have that object jump across the stage. I'm visualizing it like the playback head on the wave generator actor moving in the opposite direction, but from what I understand that functionality doesn't exist in the actor as it stands.
I'll make another reply in a moment with a gif to help visualize what I mean. Again I appreciate everyone's suggestions and creativity, the community support for this program is one of the things I really love and value about Isadora.
-
@jpg-wav Alright I made a quick animation in Blender to hopefully clarify what I'm looking for
pretend the wave on the left is controlling the X translation of the cube on the right. at frame 40 there would be a trigger, and the wave generator reverses direction, and as a result the cube changes the direction in which it's oscillating.
I understand what I'm looking for might not be currently possible, if this is the case I'll make a feature request for it in the appropriate section.
-
this works as you want. If you need finer values take the Float counter actor.
best regards
Jean-François
-
@jfg Thank you for your reply, this is certainly the closest! The patch you've provided only produces a ramping value, but I feel like I should be able to use this principle to create at least a triangle wave as well. Not quite a sine but it will do for now. Thank you to everyone for all of your input and patience. I'll update this thread with my reversible triangle wave patch once it's complete.
-
I asked ChatGPT for some Javascript Math to help and it gave me this:
function invertWave(time, frequency, waveType) { // Calculate the current phase of the wave const phase = 2 * Math.PI * frequency * time; // Generate the wave based on the selected type let currentVal; if (waveType === 'sine') { currentVal = 50 * (1 + Math.sin(phase)); } else if (waveType === 'sawtooth') { currentVal = 50 * (1 - 2 * (phase % (2 * Math.PI)) / (2 * Math.PI)); } else if (waveType === 'square') { currentVal = 50 * (Math.sin(phase) > 0 ? 1 : -1); } else { throw new Error('Invalid wave type. Choose "sine", "sawtooth", or "square"'); } // Determine when to invert the wave const invertedVal = currentVal >= 50 ? 100 - currentVal : currentVal; return invertedVal; } // Example usage const frequency = 1; // 1Hz frequency const time = 0.25; // Example time value (between 0 and 1) // Invert the values for a sine wave const invertedSineValue = invertWave(time, frequency, 'sine'); console.log('Inverted Sine Value:', invertedSineValue); // Invert the values for a sawtooth wave const invertedSawtoothValue = invertWave(time, frequency, 'sawtooth'); console.log('Inverted Sawtooth Value:', invertedSawtoothValue); // Invert the values for a square wave const invertedSquareValue = invertWave(time, frequency, 'square'); console.log('Inverted Square Value:', invertedSquareValue);
Haven't had time to test it yet, but my gut feeling that it wouldn't be as simple as just inverting the direction of the Wave Generator seems to be correct.
E.g. If you're using a sawtooth wave and you get to 25% of the way through a phase, you'll be outputting 25 (25% of the way from 0 to 100). If you then inverted the wave with a switch on the Wave Generator actor (if there was one) you'd be switched to 25% of the way through the inverse wave, which would mean you'd immediately be outputting the value 75 (25% of the way from 100 to 0). This is why all these methods are creating jumps; you need to do more than just invert the direction of the Wave Generator.
-
@woland said:
This is why all these methods are creating jumps; you need to do more than just invert the direction of the Wave Generator.
For sure! It's more of a matter of reversing the stream of values coming from the wave generator. I have no idea how they work under the hood in Isadora, but since they all have predictable behavior (excluding the random of course) it seems like it would be something that could be done as an addition to the actor. Of course I'm also no software engineer, and I know that things that often seem quite simple to the end user can be quite an undertaking to implement. But I won't take up any more of this forum's time with this topic, my feature request was logged so I'm happy :). I appreciate everyone humoring my request and hearing me out.
-
Maybe some unorthodox workaround:
instead of going with the Hz self generating timer in the wave generator, you can push the 'phase'. Set the 'hz' to 0 and let some other generator move the phase to generate the output value.
I just tried it with a movie player and some simple video.To get the value output from 0 to 100, you need to set the min / max properties of the 'phase' value at 22.1 and 72 (maybe it needs to be something around these numbers +/- to be absolute accurate), or use a limit scale value actor. I actually don't know the reason for it, to be like that. The length of the video will determine the wave speed (in combination with the movie playback speed). To change the speed easily, you can change the play length in combination with the limit scale value actor. With putting the loop mode to palindrome, you'll get an endless waveform and switching playback speed from 1 to -1 will reverse the sine/sawtooth/triangle etc. at any point.
-
Brilliant!
-
Your solution gave me this idea:
Gif: http://recordit.co/ucyw5nXFK0
File: invertable-wave-generator-2024-01-08-3.2.6.izz
@jpg-wav This solution works for all the wave types. The main limitation is that to have a smooth output, you want a low increment amount and a high increment rate, but the increment rate maxes out at 999Hz, so you can't use this for simulating a Wave Generator actor with a high frequency without making the increment amount larger and losing some granularity (though perhaps this could be solved with a Smoother actor).
-
@woland Amazing! I would have never been able to put this all together!
Thank you so much!
And thank you to @DillTheKraut too for inspiring the mad genius. This community never ceases to amaze me.
-
@jpg-wav said:
I would have never been able to put this all together!
I needed help from chatGPT to find the right equation ;)