I’ve been working through Introduction to DSP Tutorial and was trying to figure out how to do the exercise for creating a triangle, square and noise waveform.

In the tutorial it goes through mapping a sine wave into a sawtooth, which is not too difficult as its just two discrete points. However, I assume you would need at least 3 discrete points for a triangle, but the jmap function doesn’t work with that.

Is there any documentation I can look into to figure out how to make those waveforms? I don’t need the answers, just some resources so I can figure out how to do it. Thanks!

Any function would do. For a triangle you can use a piecewise defined function:

osc.initialise ([] (Type x)
{
return (x < 0) ?
juce::jmap (x,
Type (-juce::MathConstants<double>::pi),
Type (0),
Type (-1),
Type (1));
}, 2) :
juce::jmap (x,
Type (0),
Type (juce::MathConstants<double>::pi),
Type (1),
Type (-1));
}, 2);

there are lots of cool alternative ways to come up with waveforms for wavetables and stuff.
one tool that you should be using for that is desmos. there you can try a lot of stuff, even conditionals, so that you can immediatly visualize your ideas without testing it in the code already. for example here i made an analog sawtooth wave from a sum of sine waves:

another way to make waveforms is to read up on their wikipedia pages and choose one of the dozen of functions there to generate the waveform. for example this triangle wave wikipedia article. cool thing about that is you can add more parameters to those functions and usually find some interesting twists that can especially become useful when you make multidimensional wavetables:

Is there a typo somewhere in your piecewise defined function? I spent ages fiddling about with it before it would compile. I managed to get this to work.