The Oscillator patch generates sound signals in specific waveforms or tones. Oscillators are the fundamental component or sound source of synthesizers. One way you can use this patch in Spark AR Studio is to create your own musical instrument (synthesizer).
Name | Description |
---|---|
Pitch | The Oscillator frequency, from 0-20kHz. The default value of 440 Hz is A4. |
Waveform | The Oscillator waveform type. Noise is white noise. |
Pulse width | The amount of pulse width modulation applied when the “Square” waveform is selected. A 0.5 value will produce a pure square wave, and increasing or decreasing the value will add harmonics which change the timbre of the sound. |
Name | Description |
---|---|
Audio | Connect to a speaker patch, an audio effect or another patch that has an audio input. |
In the example above, we’ve used the Oscillator patch to build a basic synthesizer. Press play to hear what it sounds like.
To see how we built the synthesizer, download the example project and take a look at the finished project.
Inside the project, you’ll see we used the following patch graph to create the effect:
The graph starts with a Screen Tap patch. Each tap on the screen:
This means that instead of just generating a constant flat tone, we create an effect where a different musical note is played for a brief period of time. We’ll explain this in more detail below.
Each vertical tap on the screen changes the pitch generated by the Oscillator patch. There are three key operations we need to perform in the Patch Editor to do this:
The first two operations (point 1 and 2) are performed by the patches in the Screen Tap Position → MIDI Note Value box:
First, the Screen Tap patch outputs the 2D Position of the finger on the screen. Then the patches connected to this output:
The rounded value is then connected to the MIDI to Pitch patch group in the MIDI Note Value → Pitch (Hz) box. You can download this patch group from AR library to use in your own projects.
The MIDI to Pitch patch group contains the math patches that carry out point 3 — transforming the MIDI note values into a frequency. This provides the frequency value that’s used as the Pitch input of the Oscillator patch.
At this point, connecting the output of the Oscillator patch to a speaker would generate different continuous notes, changing each time the user taps. For our synthesizer we want to emulate individual musical notes that start at volume zero, transition to an audible volume for a short period of time, then return to volume zero. This transition is called a volume envelope.
The patches in the Screen Tap Event > Gain Amount box shape this volume envelope:
When the screen is tapped:
The final part of the graph — the patches in the Audio Generation & Processing box —outputs the pitch and volume defined by the earlier parts of the graph. The Oscillator handles the pitch and the Gain applies the volume.
With the synthesizer set up, it’s easy to experiment with different synth sounds. The Oscillator patch has five different waveforms to choose from, each with its own distinctive waveshape and sound. Select an option from the dropdown to listen to each one:
You could also connect the audio output of the Oscillator through any of Spark AR's audio processing patches to further shape the sound. For example, try adjusting the tone of your synth by adding an effect like the Ring Modulator patch between the Oscillator and the Gain as in the example below:
Alternatively, add a time-based effect like Reverb or Delay between the Gain and the Speaker to add a sense of space or depth to each note played.