Is there truly no way to cast from a dur to a float? I'm writing a sketch of a TapTempo object. It measures the duration between events to estimate a tempo (in my case, expressed in Hz), which of necessity means *somewhere* I need to convert from a dur to a float. But I haven't figured out how to do that. Suggestions? - r
Hi Robert,
I usually do something like this
1::second => dur sampled;
1::ms => dur timing_rate;
sampled / timing_rate => float ratio;
<<< ratio >>>; // gives a float
I'm not sure if there's a way to do an explicit cast, though.
Rogan
On Fri, Feb 27, 2009 at 11:49 PM, Robert Poor
Is there truly no way to cast from a dur to a float?
I'm writing a sketch of a TapTempo object. It measures the duration between events to estimate a tempo (in my case, expressed in Hz), which of necessity means *somewhere* I need to convert from a dur to a float.
But I haven't figured out how to do that. Suggestions?
- r
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
2009/2/28 Robert Poor
Is there truly no way to cast from a dur to a float?
In addition to Rogan's notes; Dividing any dur by another dur will give you a float so; second / ms => float thousand; This is, BTW, a 100% proper; in physics, if I divide a meter into bits that are a centimetre long then the result will be a 100, a amount without a unit. If I'd divede the same meter into a hundred(without unit) bits the result will be a centimetre (or 0.01 metre) so definitely with a unit. Duration inherently expresses time and so it will have a unit, unlike floats.
I'm writing a sketch of a TapTempo object. It measures the duration between events to estimate a tempo (in my case, expressed in Hz), which of necessity means *somewhere* I need to convert from a dur to a float.
You may also be interested in .period( dur ), a member function of many oscillators that sets the period of the wave shape and which is just a alternative way of expressing the frequency. This can be quite useful for setting LFO speeds relative to a piece's BPM. Hope that helps, Kas.
participants (3)
-
Kassen
-
Robert Poor
-
Rogan Carr