# Generating waves other than sine using the oscillators namespace

Hello.

I’m making a simple AM and RM plug-in, and I need to generate different modulator waves.
Generating a sine way was simple enough, as this was built into the soul::oscillators namespace, so I could simply use the following line:
`let oscSine = soul::oscillators::Sine (float, 10.0f);`

However the namespace doesn’t allow for easy generation of other waves, and after having seemingly tried everything I can not get it to even recognize any other object, so I hope you can help.

Code is below (sorry about the shotty formatting, couldn’t figure out how to properly attach it):
/**

``````This is an auto-generated SOUL patch template.

This example code simply performs a simple gain between its input

and output. Now it's your turn to build this up into a real effect!
``````

*/

graph TopLevelGraph [[main]]

{

``````//Declare input and output

input stream float audioInDry;

input stream float sineIn;

input stream float sawIn;

output stream float audioOut;

//Overall Dry/Wet

input event float onDryWetChange [[name: "Dry/Wet", min: 0.0f, max: 100.0f,

init: 0.0f, step: 1, unit: "%"]];

//Sine wave freq (modulation)

input event float sineFrequency [[name: "Sine Frequency", min: 5.0f, max: 500.0f,

init: 10.0f, step: 0.01, unit: "Hz"]];

//Saw wave freq (modulation)

input event float sawFrequency [[name: "Saw Frequency", min: 5.0f, max: 500.0f,

init: 10.0f, step: 0.01, unit: "Hz"]];

//We want an instance of our effect

let dryWetMixer = Tremolo;

//SOULs built in oscillator for Sine

let oscSine = soul::oscillators::Sine (float, 10.0f);

//let oscSaw  = soul::oscillators; //This is the one I can't find a solution for

connection

{

//Various input sources

audioInDry -> dryWetMixer.audioInDry;

sawIn -> dryWetMixer.sawIn;

sineFrequency -> oscSine.frequencyIn;

//sawFrequency -> oscSaw.frequencyIn;

oscSine -> dryWetMixer.sineIn;

//Output

dryWetMixer.audioOut -> audioOut;

//User input

onDryWetChange -> dryWetMixer.onDryWetChange;

sineFrequency -> dryWetMixer.sineFrequency;

}
``````

}

processor Tremolo

{

``````//Declare inputs and outputs

input stream float audioInDry;

input stream float audioInWet;

input stream float sineIn;

input stream float sawIn;

output stream float audioOut;

//Declare events

input event float onDryWetChange;

input event float sineFrequency;

input event float sineInFrequency;

//Notes (lowest octave)

float c = 16.35f;

float cSharp = 17.32f;

float d = 18.35f;

float dSharp = 19.45f;

float e = 20.60f;

float f = 21.83f;

float fSharp = 23.12f;

float g = 24.50f;

float gSharp = 25.96f;

float a = 27.50f;

float aSharp = 29.14f;

float b = 30.87f;

//Initialize variables

//Dry/wet

float dryWetValue = 0.0f;

//Carrier frequency "hack"

//float carrierFrequency = f * 2.0^5.0; //should be f5, but exponents doesn't work like this

float carrierFrequency = 698.46f;

//Sine wave

float modFrequency = 10.0f;

let fs = processor.frequency;

//Output values

float outDry = 0.0f;

float outAm = 0.0f;

float outRm = 0.0f;

//Change to dry/wet slider

event onDryWetChange(float incomingValue)

{

dryWetValue = incomingValue / 100.0f;

}

//Change to frequency slider (Sine wave mod)

event sineFrequency(float incomingValue)

{

modFrequency = incomingValue;

}

void run()

{

loop

{

//Set the dry signal

outDry = (1-dryWetValue) * audioInDry;

//Set the AM/Tremolo signal

//AM

outAm = sineIn * cos(carrierFrequency) * cos(modFrequency) * audioInDry;

outAm = outAm * dryWetValue;

//Tremolo

//outAm = audioInDry * (sineValue * dryWetValue);

//Set the RM Signal

outRm = sineIn * cos(carrierFrequency) * cos(modFrequency);

outRm = outRm * dryWetValue;

//Output

audioOut << outDry + outAm ;

}

}
``````

}

I found a solution for this!
Although it seems that this might get a lot easier with the next update, I’ll post the answer here anyway just in case someone needs it in the future.

In order to use the poly_blep oscillator, first a dummy variable has to be created, because it needs an input at two points in the namespace. So in order to get the oscillator working you need these lines:

``````namespace poly_blep = soul::oscillators::poly_blep(float);
let oscPoly = poly_blep::Processor(0,10.0f);
``````

First you need to create a dummy namespace, in order to tell it what you want the variable type to be. And after that you can create an instance of that namespace using the starting shape and frequency as inputs.

I hope this can help someone in the future!