Audio-rate signal to float/int (snapshot~) within gen~?
Hi,
Working on a patch that uses the phase (derived from an fft~ and cartopol~) of one cycle~ to flip the phase (using *~) of another cycle~ at audio-rate.
Since I want to do this at audio-rate, I encapsulated part of my max patch (one that was using snapshot~) within a gen and attempted to take the cartopol~ output, scale it, and send it into a multiplier being fed by a cycle (the one that needs to have it's phase flipped) within gen~.
This doesn't work because it's multiplying it by the actual signal, similar to syncing two oscillators (I think.)
If I feed in the result of my snapshot~ from max into gen~, the phase flip routine works fine.
It appears to me that I need to convert the signal from cartopol~ or scale~ into an int/float somewhere (gen~'s i and f made no difference when I tried it).
I attached my patch currently set up with snapshot~ functionally working (albeit at 1ms, not audio-rate). Basically I want gen~ in 1 to work like this attached to the multiplier, not in 2 as it's currently set up.
Another thing: does everything within gen~ run at audio-rate by default?
are you trying to do phase modulation ?
right now, your patch seems to be a weird mix of things that don't really work together that way
Nope, I actually want to click the phase reversal off (1) and on (-1) at audio-rate (speeds faster than 1ms).
This is the first time I've used gen~ so I'm unfamiliar with the commands.
I did also try setting up (within gen~) two constants/ints (1 and -1) going into gates/switches that are opened and closed by the signal from gen~ in1 but had no luck.
I suspect that IS actually one way of doing it if i had a little more knowledge of gen~ (sending int 1/-1 to * at audio-rate using gates)
what do you mean by "click" the "phase reversal" ? really, it's hard to understand... do you want that each 1 out of 2 sample gets multiplied by -1 ? that's really a weird thing to do... complicated and the output doesn't have an audible result.
snapshot~ is expressely designed to get out of the signal-rate domain and into the control-rate speed, so this is probably not the object you are looking for.
That's more or less what I want to do, yes. If -1 is 180 degrees, then I want to alternate ('clicking') between that and 0 degrees.
I just have snapshot~ there as a working example of what I want to do, as I said in the first post it I know it only goes as low as 1ms. Really I'm trying to replicate snapshot~ in gen.
You are correct that I want to do 1 out of 2 samples at maximum speed.
edit: If you check out the patch, I have another cycle running against the phase reversed one, maybe this is where I wasn't clear.
snapshot~ is just outputting an audio sample value, at control rate. So, any patchord in audio rate domain will output sample at audio rate... "replicating" snapshot~ in audio domain would mean : to connect two objects together.
That said, you can do that in gen. But i suppose you will be disappointed. I suppose it is not what you wnat to obtain. I think what you want to obtain and your conceptual idea of how to patch it are disconnected.
Having 1 out of 2 samples at maximum speed reversed would mean : a sinewave at maximum amplitude, and at maximum rate.
It does the thing (double clic on capture~ to see the output) but makes no sound.
and i saw that other cycle, and it is even less clear...
Also, a note in fft~ : i'm not sure you understood it very well - it doesn't give you in real time, all the phase values for one sine ; but it gives you at each signal vector ; the phase value for 128 sinewaves at the beginning of the signal vector.
Let me try to simplify what I'm asking for:
Lets say I'm using snapshot~ at 1ms. This means it's outputting information every 44.1 samples, right? Forget everything else I've been doing-- what If I want a version of snapshot~ that updates at 0.5ms, or every 22 samples?
I simply want a 'faster' version of snapshot~, and I think the best way to do that is making a custom apparatus in gen~.
"and I think the best way to do that is making a custom apparatus in gen~"
sorry to say, but you did not understood what Vichug said.
i will just correct your words:
and I think the best way to do that is making a custom external.
but still you end up as fast as vector size.
I guess I don't understand.. gen~ can not do audio-rate processing? I understand that there are obvious limitations but refresh rates faster than MSP's 1000hz/44 samples are possible right?
Presuming I am using my hardware's smallest vector size, how can I make a gate or switch in gen~ that will alternate between feeding int 1/-1 to a multiplier that is controlled by the signal from cartopol~ (or even just a plain cycle)?
edit: Perhaps I'm adding to the confusion by seemingly stating two different goals, so here are the two options I have in mind:
a. Hard code a device in gen~ that outputs alternating ints (1/-1) at speeds above MSP control rate (faster than 1ms/1000hz/44 samples).
b. Design an audio-rate version of snapshot~ (more challenging but also potentially more useful).
Hello,
1:
2: 2 makes no sense, its like Vichug said snapshot at control rate would simply be connecting two msp-objects together
Luvulongtime!
(1 is quite ugly but its late here and it does what you want)
Much better
like vishug said, you could that with any oscillator as modulator. a cosine at 22 khz, then truncate to whole numbers or measure 0/1 transitions. or maybe even train msp.
no idea inside gen.
Thank you luvulongtime! This patch is working great for me. I can put delays or multiple history objects between history and accum to slow it down or speed it up.
The truncation idea is nice as well. Thanks!
"I understand that there are obvious limitations but refresh rates faster than MSP’s 1000hz/44 samples are possible right?"
-> Yes, gen~ processes and outputs at sample rate. (Or faster, via codebox code or by embedding in a poly~ with @up > 1)
"does everything within gen~ run at audio-rate by default?"
-> Yes. Vector size does not matter in gen~, every object is effectively running at a vector size of 1 sample. (Efficiently!)
"What If I want a version of snapshot~ that updates at 0.5ms, or every 22 samples?"
-> Use [latch], which is the simplest form of sample & hold in gen~, and trigger it (via the 2nd inlet) with a [counter 22] via a [== 0]. That will 'snapshot' the input (latch left inlet) every 22 samples, and hold that value in between.
Not the only way, but perhaps the simplest for this simple example.
"Hard code a device in gen~ that outputs alternating ints (1/-1) at speeds above MSP control rate"
-> frequency -> [phasor] -> [> 0.5] -> [scale 0 1 -1 1] (you can do that in MSP too).
Not the only way, but perhaps the simplest for this simple example.