Mmc-august-2012/Lab1: Difference between revisions
Created page with '= Lab 1 - "Vel-Oscilla-raptor" = In this lab, we will experiment with a variety of oscillators, both by themselves and in combination as FM operators. == Part 1 ==' |
No edit summary |
||
Line 1: | Line 1: | ||
= Lab 1 - | = Lab 1 - Oscillators = | ||
In this lab, we will experiment with a variety of oscillators, both by themselves and in combination as FM operators. | In this lab, we will experiment with a variety of oscillators, both by themselves and in combination as FM operators. | ||
== | == Audio Bootup == | ||
Make sure you are up-to-date with your Xcode install, and that you are able to load code onto your iOS device. Create a new project ("single-view application"), and add MoAudio as described in the audioStuff download (found here: [https://github.com/downloads/markcerqueira/mobile-music/audioStuff.zip audioStuff.zip]). To test everything out, write an audio callback that generates a sine wave at a fixed frequency, making sure that it runs in both the simulator and your device. | |||
== Basic Oscillators == | |||
Implement sine wave, triangle wave, sawtooth, and square wave oscillators using the phase-increment method shown in class. For each of these, structure the oscillator as a function that accepts a phase between [0,1] and returns the value at that phase, like this: | |||
float exampleOsc(float p) | |||
{ | |||
return ???; // <-- fancy math goes here to figure out value for phase | |||
} | |||
Call this function from your callback, incrementing the phase after each frame. Software engineers may recognize this basic design pattern as '''modularity''': the structuring of code into reusable blocks. As we will see later, we can and will reuse these oscillators for more than simple waveform generation. |
Revision as of 09:50, 12 August 2012
Lab 1 - Oscillators
In this lab, we will experiment with a variety of oscillators, both by themselves and in combination as FM operators.
Audio Bootup
Make sure you are up-to-date with your Xcode install, and that you are able to load code onto your iOS device. Create a new project ("single-view application"), and add MoAudio as described in the audioStuff download (found here: audioStuff.zip). To test everything out, write an audio callback that generates a sine wave at a fixed frequency, making sure that it runs in both the simulator and your device.
Basic Oscillators
Implement sine wave, triangle wave, sawtooth, and square wave oscillators using the phase-increment method shown in class. For each of these, structure the oscillator as a function that accepts a phase between [0,1] and returns the value at that phase, like this:
float exampleOsc(float p) { return ???; // <-- fancy math goes here to figure out value for phase }
Call this function from your callback, incrementing the phase after each frame. Software engineers may recognize this basic design pattern as modularity: the structuring of code into reusable blocks. As we will see later, we can and will reuse these oscillators for more than simple waveform generation.