Difference between revisions of "Mmc-august-2012/Lab1"

From CCRMA Wiki
Jump to: navigation, search
Line 4: Line 4:
  
 
== Audio Bootup ==
 
== 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.  
+
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 <tt>MoAudio</tt> 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 ==
 
== Basic Oscillators ==
Line 17: Line 17:
 
* a widget to turn your oscillator on and off
 
* a widget to turn your oscillator on and off
 
* a widget/widgets to select which type of oscillator is used
 
* a widget/widgets to select which type of oscillator is used
* a widget/widgets to pick different notes and/or frequencies (you might find {{mtof.h}} in audioStuff useful for this -- {{mtof}} converts a '''MIDI note''' to a frequency)
+
* a widget/widgets to pick different notes and/or frequencies (you might find <tt>mtof.h</tt> in audioStuff useful for this -- <tt>mtof</tt> converts a '''MIDI note''' to a frequency)
  
 
For each of these, take a second to think about what kind of UI widget works best for the task at hand.  
 
For each of these, take a second to think about what kind of UI widget works best for the task at hand.  
  
 
== FM ==
 
== FM ==

Revision as of 03:03, 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.

Add some basic UI to your app:

  • a widget to turn your oscillator on and off
  • a widget/widgets to select which type of oscillator is used
  • a widget/widgets to pick different notes and/or frequencies (you might find mtof.h in audioStuff useful for this -- mtof converts a MIDI note to a frequency)

For each of these, take a second to think about what kind of UI widget works best for the task at hand.

FM