Browse Source

Added Synthdef Example, Readme.

akshaycadambi 5 years ago
parent
commit
c0a6b612fb
4 changed files with 93 additions and 23 deletions
  1. 37 0
      README.md
  2. 11 11
      examples/01-BareMinimum.ino
  3. 9 12
      examples/02-SineOscillator.ino
  4. 36 0
      examples/03-SynthDefs.ino

+ 37 - 0
README.md

@@ -0,0 +1,37 @@
+MSynth
+======
+#####A modular synthesis library for Arduino. 
+Author: Akshay Cadambi
+
+MSynth was designed to make modular synthesis on the arduino simple and easy to use. It tries to combine the idea of SynthDefs, like in [SuperCollider](http://supercollider.sourceforge.net/) with [Gamma](http://mat.ucsb.edu/gamma/)'s simple syntax that is a result of it's per-sample processing architecture. 
+
+The intent of this project was to make the sketch code as decluttered as possible, and yet, have the ability to work with powerful modular-synthesis tools. 
+
+Therefore, the design of the syntax focuses on ease of programming and ease of use: connect modules together, create synths, and have fun with it. 
+
+Please see examples for a step-by-step instructions of how to use MSynth. 
+
+######Hardware Specs:
+* Tested on `Arduino Uno`. 
+* Uses `Pin 9` as `audio output` pin (PWM based).
+
+######Features (at the moment)
+* Wavetable based oscillators: Sine, Triangle, Saw, Reverse-Saw, Square
+* Amplitude and Frequency modulation. 
+* Custom synth definitions to connect oscillators in any manner. 
+* Per-sample processing at 16kHz.
+* 8-bit audio. 
+* Uses the `TimerOne` library (included in the source). 
+
+######Features (future)
+* Control Rate / Audio Rate ISR system. 
+* Envelopes: Linear, exponential. 
+* Control Rate Amplitude and frequency modulation.
+* Filters, effects, etc.
+
+######Caveats:
+* Uses Timer1. You can no longer use the `Servo Library` or any other library that makes use of Timer1.
+
+------
+This project was conceived as a part of the *240B: Audio Synthesis and Processing* course at the Media, Arts and Technology Program, UC Santa Barbara.
+Contact: akshay19.92@gmail.com

+ 11 - 11
examples/01-BareMinimum.ino

@@ -9,17 +9,6 @@ Author: Akshay Cadambi (akshay19.92@gmail.com)
 
 #include "MSynth.h"
 
-// Different from traditional 'loop' function in arduino sketches. 
-sample audioLoop(void)
-{	
-	sample out; 			// To hold the output. Pass all audio to this variable.
-
-	// This is where the audio code goes. 
-
-	return out;
-}
-
-
 void setup()
 {
 	// Setup code
@@ -30,3 +19,14 @@ void loop()
 {
 	// Regular loop code. 
 }
+
+// This is another loop where you put only the audio stuff.
+ 
+sample audioLoop(void)
+{	
+	sample out; 			// To hold the output. Pass all audio to this variable.
+
+	// This is where the audio code goes. 
+
+	return out;
+}

+ 9 - 12
examples/02-SineOscillator.ino

@@ -3,22 +3,10 @@ Example 2: Sine Oscillator
 --------------------------
 This example shows you how to output a Sine-wave. 
 
-
 MSynth: A modular-synthesis library for Arduino
 Author: Akshay Cadambi (akshay19.92@gmail.com)
 */
 
-sample audioLoop(void)
-{	
-	sample out;			
-
-	Sine osc(440.0);	// Sine-oscillator of frequency 440Hz
-
-	out = osc();		// Send the sine-wave to the output
-    return out;
-}
-
-
 void setup()
 {
     MSynth.init();
@@ -29,4 +17,13 @@ void loop()
 
 }
 
+sample audioLoop(void)
+{	
+	sample out;			
+
+	static Sine osc(440.0);	// Sine-oscillator of frequency 440Hz (Make sure all declarations are 'static')
+
+	out = osc();			// Send the sine-wave to the output
+    return out;
+}
 

+ 36 - 0
examples/03-SynthDefs.ino

@@ -0,0 +1,36 @@
+/* 
+Example 3: Synth-Definitions
+--------------------------
+This example shows you how to define a synth and use it in your audioLoop
+
+
+MSynth: A modular-synthesis library for Arduino
+Author: Akshay Cadambi (akshay19.92@gmail.com)
+*/
+
+void setup()
+{
+    MSynth.init();
+}
+
+void loop()
+{
+
+}
+
+// This is how you define a synth.
+sample mySynth() 
+{
+	sample out;
+
+	static Sine osc(440.0);	
+
+	out = osc();				// Connect osc to the mySynth's output
+}
+
+sample audioLoop(void)
+{	
+	sample out;			
+	out = mySynth();			// Connect 'mySynth' to the audioLoop's output
+    return out;
+}