Klang C++ 0.7.15
Language Reference (draft)
Loading...
Searching...
No Matches
copysign

Language Guide / Functions ยท Generated namespace reference

copysign

klang::copysign

Magnitude of the first operand with the sign of the second.

Combines the magnitude of one value with the sign of another. Copying the sign of a sine onto a magnitude of 0.707 produces a square wave with abrupt edges that can alias.

-1-0.707-0.5-0.353000.50.35410.707ResultInput x
copysign(0.707, x)

Based on std::copysign.

Declare Sine sine; as a member. Both examples read one sample from it in process().

Direct call

const signal square = copysign(0.707, sine(440));

Signal flow

Route the result directly to out. The oscillator supplies the sign and the first argument supplies the magnitude.

copysign(0.707, sine(440)) >> out;